Repository navigation
fix(skills): housekeep branch pruning ignores squash merges; fixer never re-runs it after draining - #2311
Conversation
…ver re-runs it after draining Two related bugs found while running /fixer end-to-end (issues #1923-#2077, 12 squash-merged PRs): 1. housekeep's Phase 4a ("Find merged branches") used `git branch --merged origin/main` — ancestry-based, so a squash-merged branch's tip is never an ancestor of the new squash commit on main. Phase 1c already documents this exact failure mode and fixes it for worktree staleness (resolves merged-ness from GitHub PR state instead); Phase 4a never got the same fix. Verified directly: after this run squash-merged 12 PRs, the ancestry check reported zero mergeable branches both times /fixer invoked /housekeep, while 10 of those branches sat locally unpruned. Fixing detection alone isn't sufficient: git branch -d's own internal check is the same ancestry test, so even a correctly gh-pr-list-confirmed-merged branch still gets refused by -d once stale remote-tracking refs are pruned (verified directly). Phase 4d and Phase 1e's worktree-branch cleanup now use -D for branches a GitHub PR-state check already confirmed merged — not a blanket force-delete, just deferring to a more authoritative signal than git's own unreliable-under-squash-merge heuristic. 2. fixer's Phase 3 (step 3a) runs /housekeep once per completed batch specifically because branches accumulate during the Solve and Merge Loop — but Phase 4 (Drain Parked PRs) also cuts/merges branches via its catch-up-merge procedure, and nothing called /housekeep again after the drain loop's own exit conditions (all merged, 3-stall, or 15-pass cap). Added the same housekeep call, once, after the drain loop stops. Filed #2310 as a follow-up: gc-worktrees.sh (a separate executable script, not a skill doc) has the identical -d-vs-ancestry bug at its own branch-deletion call site. docs check acknowledged: skill-doc fix only, no language/feature/ architecture surface change.
Greptile SummaryThis PR updates the housekeeping workflow to recognize squash-merged branches through GitHub PR state and runs housekeeping after Fixer’s parked-PR drain loop.
Confidence Score: 5/5The PR appears safe to merge. No blocking failure remains. Important Files Changed
Reviews (2): Last reviewed commit: "fix(skills): bind branch-merge classific..." | Re-trigger Greptile |
|
|
||
| ```bash |
There was a problem hiding this comment.
Historical names trigger force deletion
When a branch name is reused after an earlier same-named PR merged, this name-only intersection classifies the new local branch as merged and Phase 4d deletes it with git branch -D, causing the only ref to newer unmerged commits to be lost. Bind the classification to the current branch revision or otherwise veto reused branches before authorizing force deletion.
… alone Greptile review (PR #2311): matching a local branch to a merged PR by head-ref *name* alone is insufficient — a branch name can be reused after its earlier PR merged (a later run, or a human, creating a new branch of the same name for unrelated work), and the new, never-merged commits would be misclassified as "confirmed merged" and handed straight to Phase 4d's force-delete. Fix: pull headRefOid alongside headRefName from `gh pr list` and only classify a local branch as confirmed-merged when its current tip SHA exactly matches the SHA GitHub recorded as that PR's head at merge time. Any commit added since (a reused name, a new unpushed commit) changes the tip SHA, so the pair no longer matches and the branch is left alone instead of guessed at. Phase 1c's gc-worktrees.sh-backed classifier has the identical name-only gap; noted inline and added to issue #2310 (already tracking that script's -d-vs-D bug) rather than duplicating the fix outside this skill doc. docs check acknowledged: skill-doc fix only, no language/feature/ architecture surface change.
|
Fixed — the branch-name-reuse gap you flagged was real. Phase 4a now pulls Verified the new Also noted the same gap exists in Phase 1c's |
Summary
Two related bugs found while running `/fixer` end-to-end this session (issues #1923-#2077, 12 squash-merged PRs):
1.
housekeep's Phase 4a ("Find merged branches") usedgit branch --merged origin/main— ancestry-based, so a squash-merged branch's tip is never an ancestor of the new squash commit on `main`. Phase 1c already documents this exact failure mode and fixes it for worktree staleness (resolves merged-ness from GitHub PR state instead); Phase 4a never got the same fix.Verified directly: after this run squash-merged 12 PRs, the ancestry check reported zero mergeable branches both times `/fixer` invoked `/housekeep`, while 10 of those branches sat locally unpruned.
Fixing detection alone isn't sufficient: `git branch -d`'s own internal check is the same ancestry test, so even a correctly `gh pr list`-confirmed-merged branch still gets refused by `-d` once stale remote-tracking refs are pruned (verified directly — reproduced this exact refusal on a real squash-merged branch from this run). Phase 4d and Phase 1e's worktree-branch cleanup now use `-D` for branches a GitHub PR-state check already confirmed merged — not a blanket force-delete, just deferring to a more authoritative signal than git's own unreliable-under-squash-merge heuristic.
2.
fixer's Phase 3 (step 3a) runs/housekeeponce per completed batch specifically because branches accumulate during the Solve and Merge Loop — but Phase 4 (Drain Parked PRs) also cuts/merges branches via its catch-up-merge procedure, and nothing called/housekeepagain after the drain loop's own exit conditions (all merged, 3-stall, or 15-pass cap). Added the same housekeep call, once, after the drain loop stops.Follow-up filed
#2310 — `gc-worktrees.sh` (a separate executable script, not a skill doc) has the identical `-d`-vs-ancestry bug at its own branch-deletion call site. Left for a separate PR since it's a script + its own test suite, not a doc change.
Verification
Closes #2309