You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Resume local branch cleanup after merge removes the worktree #1116
A merged task can lose its worktree and keep its local branch. loopzero start creates both in one step. Merge verifies the PR head, removes the worktree, then runs a separate branch deletion. An interruption or ref-lock failure in that gap leaves the branch behind. The existing regression test expects a manual deletion hint when an error is caught. If the process is interrupted, the hint can be lost too. Rerunning merge from the task path is impossible because merge discovers the task from the current checkout.
On miki, 16 local lz/* branches had no worktree and still pointed exactly at the head of a merged PR with the same branch name. Examples are #375 and #409. The snapshot confirms the residue that recovery needs to handle. It cannot distinguish interrupted merges from manual worktree removal.
Acceptance
Interrupt cleanup after worktree removal and before local ref deletion. Rerun the existing merge command from a surviving checkout of the same repository and finish the recorded cleanup without recreating the task worktree. A further retry is harmless.
Persist the existing merged PR and head proof in the owning Git metadata before removing the worktree. Retry only recorded cleanup. Preserve any branch that moved, is checked out, or lacks matching proof. Remove the recovery record when the retry reaches a terminal result.
Keep normal merge and dirty-worktree behavior. Use the existing merge command and add no flags or gates.
Lean178 scope ruling (26 Nov): the "persist proof in Git metadata / recovery record" acceptance conflicts with the owner rule to add no new state, so it is replaced.
Close the gap by reordering, not by recording. In merge cleanup, detach the task worktree's HEAD, delete the local branch (still only when its tip equals the verified merged PR head), then remove the worktree. An interruption then leaves at most a detached, clean worktree. The next run or the existing cleanup removes it, and no branch survives without its worktree.
Residue proof is derived, not stored. A local branch with no worktree whose tip equals the head of a merged PR with the same head ref can be deleted. This is checkable at any time via GitHub (commits/<sha>/pulls). Branches that moved, are checked out, or do not match keep the current behaviour (kept, with the manual hint).
Keep normal merge and dirty-worktree behaviour; no flags, gates or state files.
One-off: clean up the 16 existing lz/* residue branches on miki that match rule 2, and list them in the PR description.
Activity
eowca commentedon Nov 26, 2026
Lean178 scope ruling (26 Nov): the "persist proof in Git metadata / recovery record" acceptance conflicts with the owner rule to add no new state, so it is replaced.
commits/<sha>/pulls). Branches that moved, are checked out, or do not match keep the current behaviour (kept, with the manual hint).lz/*residue branches on miki that match rule 2, and list them in the PR description.eowca commentedon Nov 26, 2026
#1192 was closed because the current main conflicts and both review rounds were used. This issue remains open for a fresh PR.
eowca commentedon Nov 26, 2026
Not planned for now: its PR #1760 was closed on cost (#575 (comment)). Reopen with new evidence of a material, measured saving or failure.