Skip to content

fix(census): ignore stale merged-remote-only branch in in_flight detection (#158)#168

Merged
robercano-ghbot merged 1 commit into
mainfrom
feat/issue-158-census-stale-merged-remote
Jul 21, 2026
Merged

fix(census): ignore stale merged-remote-only branch in in_flight detection (#158)#168
robercano-ghbot merged 1 commit into
mainfrom
feat/issue-158-census-stale-merged-remote

Conversation

@robercano-ghbot

Copy link
Copy Markdown
Collaborator

Closes #158

Problem

loop-census.sh's in-flight detection matched git branch -a --list "*feat/issue-N-*", which includes stale remotes/origin/... refs. After a PR merged, the local remote-tracking ref in the main checkout could survive (until pruned), so a still-open issue whose partial PR already merged kept matching that stale ref and was reported in_flight forever — wedging advance_ready and triggering false stall/escalation.

Fix (fix #2, minimal, single-file)

In loop-census.sh only: when the matched branch for an issue is REMOTE-ONLY (no local branch, only a remotes/... ref), it is treated as in_flight ONLY IF no MERGED PR exists for that bare head branch (bot-gh pr list --state merged --head <branch>). If a merged PR exists, the stale ref is ignored (branch=none) so the issue neither counts as in_flight nor blocks advance. A local branch match keeps prior behavior unchanged; the extra gh call is made only on the remote-only path and is || true-guarded so a transient failure degrades to prior behavior.

Tests

Extended .claude/scripts/loop-census.test.sh (real git repo + stubbed bot-gh): new issue-44 scenario (remote-only ref with a stubbed merged PR → branch=none, not in_flight); issue-42 retained as the no-merged-PR control (stays in_flight), proving the fix doesn't blanket-drop remote-only refs.

Gates

build / lint / test all green (GATES_FILE=.claude/self/gates.json); loop-census.test.sh 45/45.

Review

correctness (opus) APPROVE, tests (sonnet) APPROVE — consensus=all. Non-blocking note: transient-gh-failure fallback is code-inspection-covered, not fixture-covered.

🤖 Generated with Claude Code

…#158)

git branch -a --list matches both local branches and remote-tracking refs;
after a PR merges the main checkout's local remotes/origin/... ref for it
can survive until pruned, so a still-open issue whose branch was already
merged kept matching that stale ref forever and was reported in_flight
forever, wedging advance_ready. Now a remote-only match (no local branch of
the same name) is only counted as existing when no merged PR exists for its
bare branch name; a genuine local branch match is unaffected.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
@robercano-ghbot

Copy link
Copy Markdown
Collaborator Author

fix(census): ignore stale merged-remote-only branch in in_flight detection (#158) (not yet reviewed)

@robercano-ghbot
robercano-ghbot merged commit ac5da06 into main Jul 21, 2026
9 checks passed
@robercano-ghbot
robercano-ghbot deleted the feat/issue-158-census-stale-merged-remote branch July 21, 2026 08:42
Repository owner deleted a comment from robercano-ghbot Jul 23, 2026
Repository owner deleted a comment from robercano-ghbot Jul 23, 2026
Repository owner deleted a comment from robercano-ghbot Jul 23, 2026
Repository owner deleted a comment from robercano-ghbot Jul 23, 2026
Repository owner deleted a comment from robercano-ghbot Jul 23, 2026
Repository owner deleted a comment from robercano-ghbot Jul 23, 2026
Repository owner deleted a comment from robercano-ghbot Jul 23, 2026
Repository owner deleted a comment from robercano-ghbot Jul 23, 2026
Repository owner deleted a comment from robercano-ghbot Jul 23, 2026
Repository owner deleted a comment from robercano-ghbot Jul 23, 2026
Repository owner deleted a comment from robercano-ghbot Jul 23, 2026
Repository owner deleted a comment from robercano-ghbot Jul 23, 2026
Repository owner deleted a comment from robercano-ghbot Jul 23, 2026
Repository owner deleted a comment from robercano-ghbot Jul 23, 2026
Repository owner deleted a comment from robercano-ghbot Jul 23, 2026
Repository owner deleted a comment from robercano-ghbot Jul 23, 2026
Repository owner deleted a comment from robercano-ghbot Jul 23, 2026
Repository owner deleted a comment from robercano-ghbot Jul 23, 2026
Repository owner deleted a comment from robercano-ghbot Jul 23, 2026
Repository owner deleted a comment from robercano-ghbot Jul 23, 2026
Repository owner deleted a comment from robercano-ghbot Jul 23, 2026
Repository owner deleted a comment from robercano-ghbot Jul 23, 2026
Repository owner deleted a comment from robercano-ghbot Jul 23, 2026
Repository owner deleted a comment from robercano-ghbot Jul 23, 2026
Repository owner deleted a comment from robercano-ghbot Jul 23, 2026
Repository owner deleted a comment from robercano-ghbot Jul 23, 2026
Repository owner deleted a comment from robercano-ghbot Jul 23, 2026
Repository owner deleted a comment from robercano-ghbot Jul 23, 2026
Repository owner deleted a comment from robercano-ghbot Jul 23, 2026
Repository owner deleted a comment from robercano-ghbot Jul 23, 2026
Repository owner deleted a comment from robercano-ghbot Jul 23, 2026
Repository owner deleted a comment from robercano-ghbot Jul 23, 2026
Repository owner deleted a comment from robercano-ghbot Jul 23, 2026
Repository owner deleted a comment from robercano-ghbot Jul 23, 2026
Repository owner deleted a comment from robercano-ghbot Jul 23, 2026
Repository owner deleted a comment from robercano-ghbot Jul 23, 2026
Repository owner deleted a comment from robercano-ghbot Jul 23, 2026
Repository owner deleted a comment from robercano-ghbot Jul 23, 2026
Repository owner deleted a comment from robercano-ghbot Jul 23, 2026
Repository owner deleted a comment from robercano-ghbot Jul 23, 2026
Repository owner deleted a comment from robercano-ghbot Jul 23, 2026
Repository owner deleted a comment from robercano-ghbot Jul 23, 2026
Repository owner deleted a comment from robercano-ghbot Jul 23, 2026
Repository owner deleted a comment from robercano-ghbot Jul 23, 2026
Repository owner deleted a comment from robercano-ghbot Jul 23, 2026
Repository owner deleted a comment from robercano-ghbot Jul 23, 2026
Repository owner deleted a comment from robercano-ghbot Jul 23, 2026
Repository owner deleted a comment from robercano-ghbot Jul 23, 2026
Repository owner deleted a comment from robercano-ghbot Jul 23, 2026
Repository owner deleted a comment from robercano-ghbot Jul 23, 2026
Repository owner deleted a comment from robercano-ghbot Jul 23, 2026
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.

Census: stale merged remote branch counts as in_flight — wedges advance and re-triggers stall/escalation

2 participants