Skip to content

fix(coalescer): treat CoalescingRefused as the documented safe no-op in main() - #1822

Merged
seonghobae merged 2 commits into
mainfrom
fix/coalescer-refused-graceful-exit
Sep 4, 2026
Merged

seonghobae merged 2 commits into
mainfrom
fix/coalescer-refused-graceful-exit

Conversation

@seonghobae

Copy link
Copy Markdown
Contributor

Summary

  • current-head-run-coalescer.yml's own design comment states that CoalescingRefused (a queued run's remembered head no longer matching the PR's live head) is "a safe no-op." coalesce()'s top-level live-PR-state check raises exactly that exception before any per-candidate cancellation loop even starts — but main() only ever called coalesce() directly with no handling for that exception, so it propagated uncaught and crashed the required coalesce check with exit code 1, instead of the intended graceful no-op.
  • Live evidence of the real breakage: ContextualWisdomLab/.github#1503, run 33766056421, job coalesce — a queued run drained from the org-wide Actions capacity backlog against an already-superseded head failed with CoalescingRefused: pull request head moved before duplicate classification.
  • Fix: main() now catches CoalescingRefused specifically and exits 0 with an informational message, matching the treatment the per-candidate loop inside coalesce() already gives the same exception type. Any other exception (malformed repository/PR identity, an unavailable GitHub API) still fails closed — this is a narrow, intentional carve-out, not a general fail-open.

Changes

  • scripts/ci/current_head_run_coalescer.py: wrap the coalesce() call in main() in a try/except CoalescingRefused.
  • tests/test_current_head_run_coalescer.py: new regression test test_main_treats_coalescing_refused_as_a_safe_no_op, confirmed failing (uncaught exception propagating) against the pre-fix main() before the fix landed.
  • CHANGELOG.md: ## [Unreleased] entry describing the fix and the live incident it responds to.

Verification

coverage run -m pytest tests && coverage report --show-missing
# 2762 passed, 1 skipped, 21 subtests passed
# (the 1 skip is 2 pre-existing files incompatible with local Python 3.11 vs. this repo's pinned 3.12+/3.14 CI target — unrelated to this change)
# TOTAL coverage (scripts/ci/*): 100%

interrogate scripts/ci/current_head_run_coalescer.py
# RESULT: PASSED (minimum: 100.0%, actual: 100.0%)

git diff --check
# clean

RED confirmed: the new test fails against the pre-fix main() with the CoalescingRefused exception propagating uncaught. GREEN confirmed after the fix.

Notes for reviewers

  • This is a .github-central-repo-only change (no workflow YAML edits) to a script the trusted current-head-run-coalescer.yml pull_request_target workflow already calls. No bypass-merge request — normal review is fine.
  • Scope is intentionally narrow: only the specific, already-documented-as-safe CoalescingRefused signal is caught. Malformed-input RuntimeErrors from coalesce()'s own validation still propagate and fail closed, unchanged.

Generated by Claude Code

…in main()

current-head-run-coalescer.yml's own design comment states that
CoalescingRefused (a queued run's remembered head no longer matching the
live head) is "a safe no-op". coalesce()'s top-level live-PR-state check
raises exactly that exception before any per-candidate loop starts, but
main() only called coalesce() directly with no handling for it, so the
exception propagated uncaught and crashed the required coalesce check with
exit code 1 instead of the intended graceful no-op.

Reproduced live on #1503 (run 33766056421, job
100684095620): a stale queued run drained from the org-wide Actions
capacity backlog against an already-superseded head failed with
"CoalescingRefused: pull request head moved before duplicate
classification".

main() now catches CoalescingRefused specifically and exits 0 with an
informational message, matching the per-candidate loop's existing
treatment of the same exception type. Any other exception (malformed
identity, an unavailable GitHub API) still fails closed.

Verification:
- RED: new regression test fails against pre-fix main() with the
  uncaught CoalescingRefused propagating.
- GREEN: coverage run -m pytest tests -- 2762 passed, 1 skipped
  (2 pre-existing Python 3.11-vs-3.12+ sandbox-incompatible files),
  21 subtests passed.
- coverage report --include='scripts/ci/*' -- 100%.
- interrogate scripts/ci/current_head_run_coalescer.py -- 100%.
- git diff --check -- clean.

Co-Authored-By: Claude Sonnet 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01KPmJErfkcHer4UVEgrQxUX
@coderabbitai

coderabbitai Bot commented Sep 4, 2026

Copy link
Copy Markdown
Contributor

Important

Draft PR not reviewed

Draft PRs are not automatically reviewed by default.

  • Trigger a manual review

To automatically review draft PRs, update your CodeRabbit configuration:

reviews:
  auto_review:
    drafts: true

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@seonghobae
seonghobae marked this pull request as ready for review September 4, 2026 05:14
@seonghobae
seonghobae merged commit dafb1e6 into main Sep 4, 2026
4 of 23 checks passed
@seonghobae
seonghobae deleted the fix/coalescer-refused-graceful-exit branch September 4, 2026 05:14
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