@@ -23,6 +23,24 @@ deleted), and any `gh` failure fails safe to the legacy cherry-only behavior (KE
2323Config: ` monitoring.agentWorktreeReaper.githubMergeCheck ` (default ` true ` ; set ` false ` to
2424disable the GitHub call). The reaper still ships OFF + dry-run by default.
2525
26+ ## Evidence
27+
28+ ** Reproduction / observed before:** On the affected machine, ` git worktree list ` showed
29+ ~ 290 worktrees totalling ~ 118GB. The 28730 diagnostic session manually verified ~ 30 of
30+ the worktrees the reaper was KEEPING against GitHub and found their branches had MERGED
31+ PRs (e.g. #1041 , #577 , #1209 ) — i.e. the content was already in ` main ` — yet ` git cherry `
32+ reported them unmerged (multi-commit branches squash-merged into one commit have
33+ different SHAs/patch-ids), so the reaper's verdict was ` unmerged ` → KEEP, forever. It
34+ manually reclaimed 27 of them (~ 5GB freed) only by checking GitHub by hand.
35+
36+ ** Observed after (this fix):** ` isMerged ` now returns ` true ` for exactly that case — a
37+ multi-commit squash-merged branch whose merged-PR head OID matches the worktree HEAD —
38+ so the reaper classifies them ` reap-eligible ` instead of keeping them. Unit tests pin
39+ both sides: the squash-merge-via-PR-map case returns merged; a branch advanced past its
40+ merge (OID mismatch) is still KEPT; gh-unavailable falls back to cherry-only (KEEP). The
41+ real-git end-to-end test ("reaps merged+clean, keeps dirty+unmerged") exercises the live
42+ deps and degrades safely when gh can't resolve the test repo.
43+
2644## What to Tell Your User
2745
2846If a user asks "why is my disk full of merged worktrees that never get cleaned?" — the
0 commit comments