Skip to content

fix(pr-merge): let a passed newer commit clear an unattributed red run - #17003

Merged
kyle-sexton merged 3 commits into
mainfrom
fix/postmerge-unattributed-superseded
Nov 18, 2026
Merged

kyle-sexton merged 3 commits into
mainfrom
fix/postmerge-unattributed-superseded

Conversation

@kyle-sexton

Copy link
Copy Markdown
Member

No related issue: hub finding L770, measured in .work token-spend report

Summary

pr-merge's PR-scoped wake (pr-merge: arm #N, job Enable Auto Merge) armed nothing in 16 of 16 runs on 2026-11-17 between 20:00Z and 23:50Z. Eight of those runs spent 103-107 GITHUB_TOKEN calls each, 44 of them paging actions/workflows/{x}/runs, to build a fresh post-merge report. settle --idle-tick --fresh then refused that report as idle tick unattributed. Example: run 44214235479.

That report's unattributed list held four red main full runs from 2026-11-17 07:47Z-11:18Z: 44041416405, 44050918457, 44067913362 and 44072876681. They failed on flaky tests that were later fixed, and main has passed since.

Root cause: an unattributed red run never ages out.

  • A full run reads RED only on its attempt-2 paths in _Context._outcome: the identity's re-run was red again, or someone else re-ran it.
  • Supersession by a newer green run (_Context.superseded) is read only when there is no attempt 2.
  • RED also sets final = False in _judge, so the merge never settles and every later check judges it again.
  • Once a re-run was red, the run stayed in unattributed for good. idle_report_refusal refuses any report with an unattributed entry, so the wake could never arm.

Fix

  • babysit_postmerge.py. _judge stops counting a red run charged to no merge once _Context.superseded finds a full run that passed after it on a newer commit of the default branch (_recovered).
    • The run keeps counting while no such run exists.
    • A pass on the same commit does not clear it.
    • A spent compare budget (SETTLE_COMPARE_BUDGET) leaves it counting, which is the conservative direction.
    • A run with a newly failing check is still a failure: the change sits only in the no-regressions branch.
    • The merge stays unsettled (final = False), as before.
  • babysit_verify_evidence.py settle --idle-tick --probe-unmoved. With the new flag, a report whose only refusal is its unattributed runs gets the rest of the idle rule: verifying runs, the lane room's rule, quarantine issues and pins. If all of those pass, it is refused as idle tick unattributed-unmoved.
    • Nothing that could clear the run has moved since the report was made. A fresh check would list the same runs again and be refused the same way.
    • When anything moved, the plain idle tick unattributed refusal stands.
    • Without the flag, the refusal reads nothing, as before. dispatch-post-merge-runs's own idle tick runs the full check after any refusal anyway, so it does not pay for the probe.
    • The flag needs --idle-tick and rejects --fresh.
  • pr-merge.yml, step "Keep the last sweep's report only while nothing it read has moved". The wake's settle of the last sweep's report passes --probe-unmoved. On unattributed-unmoved the wake ends without the fresh check, as the existing post-merge answer code-changed branch already does. The next sweep decides.
    • A source-control patch changelog fragment records both changes.
    • The step comment above still says every other refused report gets a fresh check. The repository's comment lint rejected each edit to that comment, so the notice line printed on this path carries the behavior instead.

Verification

  • python3 -m unittest discover -s plugins/source-control/skills/babysit-prs/scripts/tests -p "test_babysit_postmerge*.py": 587 tests OK.
  • ... -p test_babysit_lane_room.py: 93 tests OK.
  • ... -p "test_babysit_verify_evidence*.py": 453 tests OK.
  • node --test .github/scripts/pr-merge/*.test.mjs: 984 pass, 0 fail.
  • scripts/run-ruff.sh check on the changed Python files: clean.
  • New tests:
    • Baseline.test_a_pre_existing_red_run_stops_counting_once_a_newer_commit_passes: the report's unattributed is empty, and idle_report_refusal returns None.
    • Baseline.test_a_pre_existing_red_run_counts_while_no_newer_commit_passed: with only a same-commit pass, the refusal is still unattributed.
    • Baseline.test_a_newer_passing_commit_does_not_excuse_a_newly_failing_check.
    • SettleCommand unattributed-unmoved cases:
      • the refusal when nothing else moved;
      • the plain refusal when runs or pins moved;
      • no read at all without --probe-unmoved, --fresh included;
      • the flag's argument rules.
    • workflow.test.mjs: unattributed-unmoved runs no fresh check, while unattributed still does. The wake's first settle call carries --probe-unmoved.
  • Fail-first:
    • With _judge restored to the old else, the superseded case fails.
    • With the newer-head condition dropped, the same-commit case fails.

Related

  • Measured in the operator's token-spend report for 2026-11-17 (brakes on this repository's GITHUB_TOKEN rate limit).
  • #10475 introduced the idle-tick reuse and the unattributed refusal.

🤖 Generated with Claude Code

kyle-sexton and others added 3 commits November 17, 2026 20:41
A red full run charged to no merge (red again on its re-run, failing only
checks already failing before the merge) stayed in the post-merge report's
`unattributed` list for good: supersession is read only for a run with no
attempt 2, and the red run keeps its merge unsettled, so every check
judged it again. `idle_report_refusal` refuses any report with an
unattributed run, so pr-merge's PR-scoped wake never armed and paid about
80 GITHUB_TOKEN calls a run for a fresh check settle then refused.

- `_judge` stops counting such a run once `_Context.superseded` finds a
  full run that passed after it on a newer commit of the branch
  (`_recovered`). A pass on the same commit, or a spent compare budget,
  leaves it counting; a newly failing check is still a failure.
- `settle --idle-tick` refuses a report that stands but for its
  unattributed runs, with nothing else moved, as `unattributed-unmoved`.
  pr-merge.yml's wake then runs no fresh check, as it already does for
  `code-changed`.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
dispatch-post-merge-runs's own idle tick runs the full check after any
refusal, so the unattributed-unmoved probe's reads (verifying runs, the
lane room's rule, quarantine issues and pins) bought it nothing. The probe
now runs only under `settle --probe-unmoved`, which only the PR-scoped
wake's settle of the last sweep's report passes; without it an
unattributed report is refused with no read, as before.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 18, 2026 •

Copy link
Copy Markdown
Codex Review Summary: ✅ Completed

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-18T01:51:26.803383Z d139597 PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@github-actions

Copy link
Copy Markdown
Contributor

claude-security-review reviewed d139597613e9fd8e4e58dd625dd73f5a9515de1e: read 7 of 7 changed file(s); 0 finding(s), 0 as inline comments.

Security review: no security issues found

I read all 7 changed files in full. Three of them are trusted-path files and need extra scrutiny: .github/workflows/pr-merge.yml, babysit_postmerge.py and babysit_verify_evidence.py. All three sit on the merge-hold path.

Merge-hold path checked. I looked at both changes for a merge hold that could let through something the base code stopped.

  • _recovered / _judge in babysit_postmerge.py. The new branch runs only when no checks are newly failing. Before this change, those runs were already listed as unattributed, and the merge already treated them as green. The change only affects whether idle_report_refusal turns down a reused idle report. A run is cleared only when the existing _Context.superseded control approves a newer run. That control is unchanged (babysit_postmerge.py#L1707-L1747). It requires all of the following:

    • The newer run passed on attempt 1, after the red run.
    • The newer run is a schedule run, the lane identity's own run, or a dispatch confirmed by a lane record. _own turns away a dispatch made by a person.
    • Its head descends from the red run's commit and is on the branch.
    • A failed read or a spent compare budget returns None, so the run keeps counting.

    An outside actor has no way to produce a qualifying run. A newly failing check still counts as a failure.

  • babysit_verify_evidence.py --probe-unmoved. The probe re-runs _settle_reason on a copy of the report with unattributed cleared. It only picks which refusal to return (unattributed-unmoved or plain unattributed). Both are refusals, and an error falls back to the plain one, so a report that the base code refused is never accepted now. The argument rules require --idle-tick and reject --fresh.

  • pr-merge.yml. On idle tick unattributed-unmoved, the new elif deletes the cached report and ends the wake. It runs no fresh check and arms nothing, the same way the existing code-changed branch already works. This holds back more than before, never less. No new expression reaches a run: block: last_reason is compared as a quoted shell variable.

No token scope, trusted actor, untrusted-text path or kill switch is touched, and none of the changed files is a plugin manifest.

Spend: this lowers GITHUB_TOKEN API use, because the PR-scoped wake skips the roughly 100-call fresh post-merge check when nothing has moved. It costs no money.

critical-findings: 0

@github-actions

Copy link
Copy Markdown
Contributor

claude-review reviewed d139597613e9fd8e4e58dd625dd73f5a9515de1e: read 7 of 7 changed file(s); 1 finding(s), 0 as inline comments.

Code review: #17003 at d139597

One advisory finding. Nothing blocks the merge. I read every hunk of all 7 changed files, the code the changed lines call and the related tests.

What I checked, and found correct:

  • _recovered in _judge. The new check sits only in the no-regressions branch of the RED case, so a newly failing check is still a failure. It uses _Context.superseded, which already counts only schedule runs and the identity's or lane's dispatches, so a person re-running until green can't clear the run. A spent compare budget or a failed read returns None, which leaves the run counting.
  • The --probe-unmoved recursion in _settle_reason. It re-runs the whole idle rule on a copy of the report with unattributed emptied: verifying runs, settle_shared, marks, then idle_report_refusal again. Any other refusal still wins. A read error inside the probe falls back to the plain idle tick unattributed. The argparse rules match the tests. Only pr-merge.yml's wake passes the flag, and no other code reads the new reason string.
  • Reports made by the old code. A report from before this change is refused first as post-merge answer code-changed, so the probe never declares one of them "unmoved".

Finding (advisory):

  • The step's own comment now contradicts the step. It still says "A report refused as code-changed ends the wake with no fresh check … Any other report that does not stand is never reused: the step removes it and runs the sweep's post-merge check fresh."
    • pr-merge.yml#L2724-L2728
    • The new idle tick unattributed-unmoved branch at pr-merge.yml#L2783-L2785 also ends the wake with no fresh check.
    • The PR body says the repository's comment lint rejected edits to this comment, and that the ::notice:: line carries the behavior instead. Still, someone reading the step from its header will expect a fresh check on every refusal except code-changed.
    • Suggested fix: name both refusals in the existing sentence ("A report refused as code-changed, or as unattributed-unmoved (settle --probe-unmoved), ends the wake…"), or ask a maintainer to waive the lint for this comment.

Not findings:

  • No loosened check. _recovered shrinks the report's unattributed list. Unattributed runs already pass the post-merge check, and the sweep arms with no idle rule, so the check's verdict accepts nothing new. The list only feeds the wake's idle-reuse refusal, a staleness rule.
  • API spend. This is GITHUB_TOKEN rate budget, not billing. On the wake's path, a report refused as unattributed now costs up to 2 run listings, and when those are unchanged also settle_shared plus the quarantine and pin reads, before any fresh check. An unattributed-unmoved report saves the roughly 105-call fresh check.

Review settings:

  • Closing issues: none. The PR says "No related issue", so there are no acceptance criteria to check.
  • Path-scoped rules matched: cost-claims.md, skill-bodies-state-current-rules.md and ruff-pin.md. The change breaks none of them.
  • Security is out of scope here: the repository runs a separate security lane.
  • I took the author's test runs in the PR body on trust; I could not run the tests myself.
  • Loosened-check verdict: fail (default; the prompt had no loosened_check_verdict: line); patterns: 0

Verifier dropped 0 of 1 candidates.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

merge-path: owner-agent Post-merge accounting record (README.md, Merge paths)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant