Repository navigation
fix(hygiene): never condemn the checked-out branch - #298
Merged
Merged
Conversation
… root Two guard bugs found by a full hygiene run. **tidy condemned the branch being worked on.** Both the counting leg (prescan_tidy) and the plan leg (enumerate_condemn_candidates) filtered only the literal names main/master/HEAD and the default branch, never the branch HEAD actually points at. A freshly cut branch is an ancestor of origin/<default> until its first commit, so it always read merged=yes and was reported as "recommend straight delete" — on a real run this recommended deleting the session's own working branch in all 9 scanned repos. Since the tidy path files condemned entries async with no per-item gate, that is a bad thing to get wrong. Both legs now skip HEAD's branch; the guard is narrow, so a merged branch that is not checked out is still condemned as before. **refs crashed on a missing scan root.** Resolver.__init__ called root.iterdir() unguarded, raising FileNotFoundError when PYAUTO_ROOT does not point at a real directory — and in the default all-mode scan the traceback printed twice, burying the rest of the worklist. It now degrades to a "not scannable here" row, matching what the extras and config modes already do. Regression tests cover both, including the narrowness of the tidy guard and the all-mode scan that produced the double traceback. Full suite: 209 passed. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01HySLvBY16YnStJKHdDCCbU
Keeps the checked-out-branch guard (hygiene.sh + its three regression tests):
main's enumerate_condemn_candidates still skips only main|master|HEAD|$def, so
the conductor can propose condemning the branch the session is working on.
Drops this branch's _hygiene_refs.py missing-root guard as SUPERSEDED: it
returned status=clean ("nothing to say") for an unscannable root, which main
now deliberately reports as an error row -- a clean status there is a false
green on the Brain board's cloud render.
Conflict in tests/test_hygiene_conductor.py resolved by keeping BOTH sides:
this branch's checked-out-branch regressions and main's body-map coverage.
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01QsDakzvrNxSAH1cfvW6nQm
test_refs_reports_not_scannable_for_a_missing_root and test_default_scan_survives_a_missing_root are branch-only (neither exists on main) and assert the status=clean behaviour this merge dropped. main's test_json_stays_parseable_when_a_helper_crashes asserts the opposite contract -- a missing root is an error row, not a clean one -- and that is the one the Brain board's cloud render depends on. Full PyAutoBrain suite: 557 passed. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01QsDakzvrNxSAH1cfvW6nQm
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.
enumerate_condemn_candidatesandprescan_tidyboth skip onlymain|master|HEAD|$def. A freshly cut agent branch is an ancestor of thedefault branch until its first commit, so it reads
merged=yes— and theconductor recommends straight-deleting the branch the session is actively
working on. This adds a HEAD guard to both legs so the ranked worklist and
the condemn plan cannot disagree about what is debris.
Three regression tests cover it: the condemn leg, the counting leg, and a
narrowness check that a merged branch which is not checked out is still
condemned.
Provenance
Recovered during a
/repo_cleanupsweep — the branch had no PR and was 147commits behind
main, so it was on the delete list until the diff was read.One hunk from the original branch was deliberately dropped. It added a
row_forguard returningstatus: "clean"("nothing to say") for a missingscan root.
mainhas since settled the opposite contract — a missing root isan
errorrow (test_json_stays_parseable_when_a_helper_crashes), becausethe Brain board's cloud render parses that document and bare helper failures
emitted empty rows. A
cleanstatus on an unscannable root is a false green,so
_hygiene_refs.pyis left exactly asmainhas it, and the two branch-onlytests asserting the dropped behaviour were removed with it.
The
tests/test_hygiene_conductor.pymerge conflict was resolved by keepingboth sides: these regressions plus
main's body-map-derived coverage.Testing
Full PyAutoBrain suite: 557 passed.
Note for reviewers running locally: several hygiene tests anchor on a
PyAutoMindsibling of the repo root, so they fail in a bare worktree untilthe sibling is linked — pristine
mainfails the same five there.🤖 Generated with Claude Code
https://claude.ai/code/session_01QsDakzvrNxSAH1cfvW6nQm