finish branch= and worktree remove can act on another session's branch #874

Open
opened 2026-10-22 17:32:49 +00:00 by hexajon · 0 comments
Owner

The gap

Two operations act on another worktree's branch with no owner check in the same repo:

  • madt_finish branch=<name> pushes, opens a PR for, and merges any local branch, including one checked out in another linked worktree. Its parameter doc says that is the intent (internal/opspec/paramdocs.go:215).
  • madt_worktrees action=remove refuses only a dirty or locked tree, or one whose branch is not on the forge default branch.

So one session can merge another session's half-done committed branch, and then remove that session's clean worktree. For a foreign repo, the "created by this session" test is a path convention (a .worktrees path on a non-default branch, internal/mcp/foreignrepo.go:383), so it does not prove ownership either.

I found this while designing the madt_switch refusal for a branch that another worktree holds (#867). That refusal now names no step that acts on the holder.

What I want

  • A decision record that states who may finish or remove a branch or worktree that another session owns.
  • A guard that holds that rule on every surface.

Acceptance criteria

  • A decision record in docs/decisions/ states the ownership rule for madt_finish branch= and madt_worktrees action=remove.
  • The guard that the record names is built, and a test covers each case it refuses.
  • A test covers the case that the record allows, so a session can still finish and remove its own work.
## The gap Two operations act on another worktree's branch with no owner check in the same repo: - `madt_finish branch=<name>` pushes, opens a PR for, and merges any local branch, including one checked out in another linked worktree. Its parameter doc says that is the intent (`internal/opspec/paramdocs.go:215`). - `madt_worktrees action=remove` refuses only a dirty or locked tree, or one whose branch is not on the forge default branch. So one session can merge another session's half-done committed branch, and then remove that session's clean worktree. For a foreign repo, the "created by this session" test is a path convention (a `.worktrees` path on a non-default branch, `internal/mcp/foreignrepo.go:383`), so it does not prove ownership either. I found this while designing the `madt_switch` refusal for a branch that another worktree holds (#867). That refusal now names no step that acts on the holder. ## What I want - A decision record that states who may finish or remove a branch or worktree that another session owns. - A guard that holds that rule on every surface. ## Acceptance criteria - [ ] A decision record in `docs/decisions/` states the ownership rule for `madt_finish branch=` and `madt_worktrees action=remove`. - [ ] The guard that the record names is built, and a test covers each case it refuses. - [ ] A test covers the case that the record allows, so a session can still finish and remove its own work.
Sign in to join this conversation.
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
sixfold-space/madtea#874
No description provided.