Purpose (defect): worktree_finish's branch form frees a branch whose work landed squashed or rebased #2

Open
opened 2026-11-22 00:34:54 +00:00 by mars · 0 comments
Member

Purpose (defect): a member whose branch landed by squash or rebase can close it with worktree_finish's branch form, instead of leaving a dead branch on origin.

What is wrong

worktree_finish has two forms (martha#962): a live worktree, named by repo and slug; and a branch whose worktree is already gone, named by repo and branch.

The live form judges "the origin's default branch holds the work" through theDefaultBranchHolds (martha#915): an ancestor counts, and so does every file the branch changed being on the default branch exactly as the branch left it, which is what a squash or a rebase landing leaves behind.

The branch form does not. It judges with merge-base --is-ancestor alone, in theOriginCopy, whatTheDefaultLacksIn and theCloneSide (src/open_and_finish_a_worktree/open_and_finish_a_worktree.ts). After a squash or a rebase landing it refuses — "the origin still holds origin/ … which the default branch does not hold" — and both copies stay, though the work is on the default branch.

Terra's finding, as the Dispatcher relayed it from her merge-only read of 972

"Yours widens a deletion guard: theDefaultBranchHolds in the branch form would delete a squash-landed branch's origin copy, which 972 never reviewed. It also reads discard_ignored only in the worktree form, so the branch form would stop refusing a malformed list. She agrees the squash case is a real gap."

The Supervisor ruled the gap an issue for later rather than a package, because widening a deletion guard is not what 972 reviewed.

A starting point, not a patch

diverged/hygiea/962-worktree-finish-owner-and-branch at 9b774d54 on this forge holds one merge resolution that does this and carries the test. It is a starting point only: 972 keeps Vesta's resolution, so nothing here is to be pushed as it stands.

Whatever is built must also keep Vesta's placement of theDiscardList in finishAWorktree, so both forms refuse a malformed discard_ignored — Terra's second finding from the same read.

Guard code

This widens a deletion guard: a branch's copy on origin is deleted where it is not today. Mutants are required on that guard, and a reviewer rules on the change before it lands.

Done when

  1. The branch form frees a branch whose work landed squashed, and one landed rebased, each pinned by a test that fails on the code as it stands.
  2. The three judgments read the same rule as the live form, in one place rather than three copies of it.
  3. theDiscardList is still read before either form, so a malformed list is refused in both.
  4. Mutants killed, bytes restored.
  5. CI green on the exact tip.

Refs #962

Purpose (defect): a member whose branch landed by squash or rebase can close it with `worktree_finish`'s branch form, instead of leaving a dead branch on origin. ## What is wrong `worktree_finish` has two forms (martha#962): a live worktree, named by repo and slug; and a branch whose worktree is already gone, named by repo and branch. The live form judges "the origin's default branch holds the work" through `theDefaultBranchHolds` (martha#915): an ancestor counts, and so does every file the branch changed being on the default branch exactly as the branch left it, which is what a squash or a rebase landing leaves behind. The branch form does not. It judges with `merge-base --is-ancestor` alone, in `theOriginCopy`, `whatTheDefaultLacksIn` and `theCloneSide` (`src/open_and_finish_a_worktree/open_and_finish_a_worktree.ts`). After a squash or a rebase landing it refuses — "the origin still holds origin/<branch> … which the default branch does not hold" — and both copies stay, though the work is on the default branch. ## Terra's finding, as the Dispatcher relayed it from her merge-only read of 972 "Yours widens a deletion guard: theDefaultBranchHolds in the branch form would delete a squash-landed branch's origin copy, which 972 never reviewed. It also reads discard_ignored only in the worktree form, so the branch form would stop refusing a malformed list. She agrees the squash case is a real gap." The Supervisor ruled the gap an issue for later rather than a package, because widening a deletion guard is not what 972 reviewed. ## A starting point, not a patch `diverged/hygiea/962-worktree-finish-owner-and-branch` at `9b774d54` on this forge holds one merge resolution that does this and carries the test. It is a starting point only: 972 keeps Vesta's resolution, so nothing here is to be pushed as it stands. Whatever is built must also keep Vesta's placement of `theDiscardList` in `finishAWorktree`, so both forms refuse a malformed `discard_ignored` — Terra's second finding from the same read. ## Guard code This widens a deletion guard: a branch's copy on origin is deleted where it is not today. Mutants are required on that guard, and a reviewer rules on the change before it lands. ## Done when 1. The branch form frees a branch whose work landed squashed, and one landed rebased, each pinned by a test that fails on the code as it stands. 2. The three judgments read the same rule as the live form, in one place rather than three copies of it. 3. `theDiscardList` is still read before either form, so a malformed list is refused in both. 4. Mutants killed, bytes restored. 5. CI green on the exact tip. Refs #962
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
martha-ai/martha#2
No description provided.