Guard a member clone that is on a feature branch #147

Open
opened 2026-10-19 17:22:33 +02:00 by motoko · 0 comments
Collaborator

Seen at d7036ed199.

Location

.agents/hooks/main-checkout-guard.sh, lines 9–10 (the header's
exemption for "a main worktree on another branch, as an adoption works")
and lines 89–90 ([[ -n $main && $branch == "$main" ]] || return 0).

Evidence

The guard refuses an edit only while the main worktree is on its main
branch. The exemption is there so an adoption, which runs in the main
checkout on a branch of its own, can edit. A member clone in an umbrella
falls under the same exemption, although AGENTS.md § Members says "the
member's clone stays as it was". Member work happens in
.worktrees/<name>/<branch>.

Reproduction: in an umbrella whose member clone members/app is on the
user's branch feature/x, feed the guard an Edit event for
members/app/README.md. It exits 0. The same event with the clone on
main exits 2.

Scenario

An agent slips and edits the member clone instead of opening the
member's worktree. The edit lands in the user's own feature branch,
mixed with the user's work, and nothing warns either of them.

Smallest fix

The narrower option: refuse on any branch when the main worktree is
nested inside another repository's working tree, since an adoption never
runs in one. The alternative is to state the exemption in § Members.

Seen at d7036ed199ca23491159479231c377c3e17de02d. ## Location `.agents/hooks/main-checkout-guard.sh`, lines 9–10 (the header's exemption for "a main worktree on another branch, as an adoption works") and lines 89–90 (`[[ -n $main && $branch == "$main" ]] || return 0`). ## Evidence The guard refuses an edit only while the main worktree is on its main branch. The exemption is there so an adoption, which runs in the main checkout on a branch of its own, can edit. A member clone in an umbrella falls under the same exemption, although `AGENTS.md` § Members says "the member's clone stays as it was". Member work happens in `.worktrees/<name>/<branch>`. Reproduction: in an umbrella whose member clone `members/app` is on the user's branch `feature/x`, feed the guard an `Edit` event for `members/app/README.md`. It exits 0. The same event with the clone on `main` exits 2. ## Scenario An agent slips and edits the member clone instead of opening the member's worktree. The edit lands in the user's own feature branch, mixed with the user's work, and nothing warns either of them. ## Smallest fix The narrower option: refuse on any branch when the main worktree is nested inside another repository's working tree, since an adoption never runs in one. The alternative is to state the exemption in § Members.
Sign in to join this conversation.
No labels
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
claudiomaradonna/agent-foundry#147
No description provided.