Repository navigation
fix(cleanup): reclaim squash-merged lanes by default; add gx agents start --cleanup-only - #816
Merged
Conversation
…start --cleanup-only` `gx cleanup` judged "merged" by git ancestry unless --include-pr-merged was passed. In squash/rebase-merge repos the branch tip never lands on the base, so every merged lane looked unmerged and its worktree was kept forever — on one KFB station repo 21 merged worktrees (~2.5 GB each) filled the disk. - cleanup: --include-pr-merged is now the default; --no-include-pr-merged restores ancestry-only. A missing or failing `gh` still disables the lookup (fail-closed: nothing is treated as merged). - agents start --cleanup-only: run just the cleanup bot, without the token-spending review bot. The bot inherits the new default. Tests: parse defaults + opt-out, the cleanup->prune path queries merged PRs (fake GUARDEX_GH_BIN) and skips it on opt-out, --cleanup-only bot lifecycle. Full suite: 1452/1458 pass, the one failure is identical on origin/main. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Review follow-up (#816): with --include-pr-merged on by default, a name-only match would let cleanup delete a reused branch name, or a lane with commits pushed after its PR merged. The merged-PR lookup now records each PR's headRefOid; a lane counts as merged only when its tip equals that SHA or is contained in it. Unknown/unrelated SHAs fail closed. Also: `agents start --cleanup-only` no longer claims the review bot was not started when one is already running — it says it was left as is. Tests: tip == PR head → reclaimed; commits after merge → kept; unrelated SHA for a reused name → kept. The existing squash-merge cleanup test's fake gh now reports name + head SHA like the real one. Full suite: 1453/1459, the one failure identical on origin/main. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Review follow-up (#816): only the local tip was checked, with origin as a fallback. A stale local branch at the merged PR head while origin carries newer work read as merged, and cleanup (keepRemote defaults to false) would delete the remote work. Every visible tip — local and origin — must now equal or be contained in a merged PR head. Test: local at PR head + origin past it → kept. Full suite 1453/1459, the one failure identical on origin/main. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
… review bot Review follow-up (#816, LOW): the Logs line now matches the state file. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Why
gx cleanupjudged "merged" by git ancestry unless--include-pr-mergedwas passed. In squash/rebase-merge repos the branch tip never lands on the base, so every merged lane looked unmerged and its worktree was kept forever. On a KFB station repo 21 merged worktrees (~2.5 GB each) filled the disk to 100%. The cleanup bot (gx agents start) never passed the flag either, and could only be started together with the token-spending review bot.What
cleanup:--include-pr-mergedis now the default;--no-include-pr-mergedrestores ancestry-only. A missing/failingghstill disables the lookup — fail-closed, nothing is treated as merged.agents start --cleanup-only: start just the cleanup bot. It inherits the new default.Tests
--cleanup-onlyparsegx cleanup→ prune queriesgh pr list --state mergedby default (fakeGUARDEX_GH_BIN) and not under--no-include-pr-mergedagents start --cleanup-onlylifecycle: cleanup bot alive, no review pid/log, second start is a no-op, stop worksgx pr-review writes markdown artifact when GitHub auth is unavailable);commof failing sets: no new failures. biome lint clean.Not in scope
Merged-PR lookup still filters on the single resolved
--base; multi-base repos (station branches) miss PRs merged into other bases.🤖 Generated with Claude Code