fix(branch_sweep): stop reporting origin/HEAD as an unmerged branch - #279
Merged
Conversation
The first live run listed a branch named `origin` under KEEP with verdict UNKNOWN. No such branch exists: `refs/remotes/origin/HEAD` is a symbolic ref, and git renders its `%(refname:short)` as bare `origin` — which survives both the `origin/` strip and the `!= HEAD` guard, so it fell through to branch_contribution as `origin/origin`, came back UNKNOWN, and was filed as outstanding work. Nothing was ever at risk: UNKNOWN is fail-safe and never enters the delete set. The cost is honesty. It reported PyAutoBrain as having 3 unmerged branches when it has 2, and invited a reader to go looking for work that does not exist — a null result dressed as a finding, which is the D1 mistake docs/agent_failure_modes.md already names. Iterating full refnames and stripping the real prefix removes the ambiguity at the source rather than special-casing the rendered string. The regression test was checked the only way worth trusting: it fails against the old iteration and passes against the new one. It also pins the count, so a future phantom entry fails the assertion rather than quietly inflating a total nobody re-derives. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01KwqicJpMqmcT5RVbyNwdKq
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.
What the first live run showed
The sweep's first real dispatch (run 32856131614) worked — 55 contained, 2 protected — but listed a branch named
originunder KEEP with verdictUNKNOWN:No such branch exists.
refs/remotes/origin/HEADis a symbolic ref, and git renders its%(refname:short)as bareorigin— which survives both theorigin/strip and the!= HEADguard, so it reachedbranch_contributionasorigin/origin, came backUNKNOWN, and was filed as outstanding work.Why it matters even though nothing was at risk
UNKNOWNis fail-safe and never enters the delete set, so no branch was ever endangered. The cost is honesty: it reported this repo as having 3 unmerged branches when it has 2, and invited a reader to go looking for work that does not exist.That is a null result dressed as a finding — the D1 mistake
docs/agent_failure_modes.mdalready names, reappearing in the very tool written to avoid it.The fix
Iterate full refnames and strip the real prefix, so the ambiguity is gone at the source rather than special-cased downstream after it has already been rendered.
Checks
pytest tests/→ 500 passed.The regression test was checked the only way worth trusting: it fails against the old iteration and passes against the new one. It also pins the count, so a future phantom fails the assertion rather than quietly inflating a total nobody re-derives.
🤖 Generated with Claude Code
https://claude.ai/code/session_01KwqicJpMqmcT5RVbyNwdKq
Generated by Claude Code