Skip to content

fix(branch_sweep): stop reporting origin/HEAD as an unmerged branch - #279

Merged
Jammy2211 merged 1 commit into
mainfrom
claude/repo-cleanup-82k6kh
Aug 25, 2026
Merged

fix(branch_sweep): stop reporting origin/HEAD as an unmerged branch#279
Jammy2211 merged 1 commit into
mainfrom
claude/repo-cleanup-82k6kh

Conversation

@Jammy2211

Copy link
Copy Markdown
Contributor

What the first live run showed

The sweep's first real dispatch (run 32856131614) worked — 55 contained, 2 protected — but listed a branch named origin under KEEP with verdict UNKNOWN:

KEEP (unique content)
  origin	UNKNOWN
  claude/hygiene-agent-run-n9qtd5	unmerged
  claude/pyauto-cti-ci-phase-5-n4idom	unmerged

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 reached branch_contribution as origin/origin, came back UNKNOWN, and was filed as outstanding work.

Why it matters even though nothing was at risk

UNKNOWN is 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.md already 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

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
@Jammy2211
Jammy2211 merged commit 29771bb into main Aug 25, 2026
2 checks passed
@github-actions
github-actions Bot deleted the claude/repo-cleanup-82k6kh branch August 25, 2026 14: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