Skip to content

fix(hygiene): never condemn the checked-out branch - #298

Merged
Jammy2211 merged 3 commits into
mainfrom
claude/hygiene-agent-run-n9qtd5
Aug 26, 2026
Merged

Jammy2211 merged 3 commits into
mainfrom
claude/hygiene-agent-run-n9qtd5

Conversation

@Jammy2211

Copy link
Copy Markdown
Contributor

enumerate_condemn_candidates and prescan_tidy both skip only
main|master|HEAD|$def. A freshly cut agent branch is an ancestor of the
default branch until its first commit, so it reads merged=yes — and the
conductor 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_cleanup sweep — the branch had no PR and was 147
commits 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_for guard returning status: "clean" ("nothing to say") for a missing
scan root. main has since settled the opposite contract — a missing root is
an error row (test_json_stays_parseable_when_a_helper_crashes), because
the Brain board's cloud render parses that document and bare helper failures
emitted empty rows. A clean status on an unscannable root is a false green,
so _hygiene_refs.py is left exactly as main has it, and the two branch-only
tests asserting the dropped behaviour were removed with it.

The tests/test_hygiene_conductor.py merge conflict was resolved by keeping
both 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
PyAutoMind sibling of the repo root, so they fail in a bare worktree until
the sibling is linked — pristine main fails the same five there.

🤖 Generated with Claude Code

https://claude.ai/code/session_01QsDakzvrNxSAH1cfvW6nQm

claude and others added 3 commits August 5, 2026 10:22
… 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
@Jammy2211
Jammy2211 merged commit 30c04a8 into main Aug 26, 2026
2 checks passed
@Jammy2211
Jammy2211 deleted the claude/hygiene-agent-run-n9qtd5 branch August 26, 2026 21:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants