Skip to content

fix(source-control): stop counting infra merge-queue removals toward the ejection cap - #17451

Merged
kyle-sexton merged 8 commits into
mainfrom
fix/pr-merge-infra-ejections
Nov 19, 2026
Merged

kyle-sexton merged 8 commits into
mainfrom
fix/pr-merge-infra-ejections

Conversation

@kyle-sexton

@kyle-sexton kyle-sexton commented Nov 19, 2026 •

Copy link
Copy Markdown
Member

Closes #17489

Gate defect found by the hub sweep. Five rated, verify-passing lanes PRs (#17253, #17325, #17340, #17359, #17417) sit at the ejection cap with a failing pr-merge/unarmed status, and every removal that put them there was infra.

Summary

merge.max-queue-ejections stopped pr-merge from re-arming or enqueuing a head after 2 failed-check removals. The only removals it did not count were runs where CI Status was the sole failing job and failed on a rate limit alone (babysit_merge.py _run_rate_limit_reset, removed here). The removals of the five PRs were verify:unreadable read-floor refusals, kill-switch stops, and rate limits in Check Plugins and Check Managed Files. All of them counted, and only a push reset the count. A push also voids the merge-risk rating and the pr-verify result.

Owner decisions for this loosening of merge.max-queue-ejections, recorded on #17489:

Why the cap keeps its safety: the cap still counts every real check failure, including a real failure beside an infra line, a lane that fails on its exit line alone, and any read that fails. An infra-caused removal is excused only once the pool's named reset has passed, or an hour after the removal when none is named, so the rate-budget safety the cap provides stays. What the cap stops counting is removals that a re-queue cannot repeat once the reset has passed.

Fix

  • infra_removals / _infra_removal (babysit_merge.py) excuse a removal only when every failed job of its merge-group run passes one of two tests:
    • Its failure annotations name an infra cause: rate-limit, read-floor, verify-unreadable, kill-switch or lost-runner. Each line of an annotation is judged alone (a hygiene check's quoted tail is split), its other lines must be generic lines or lines that only report that cause, and outside CI Status a cause line must start as its producer writes it (a gh error, a guard's request line, a runner message) or with the cause, so a test's output quoting a cause phrase counts.
    • It is not CI Status, and it also failed on main's run of the same workflow at the time on every line it failed with beyond the exit line (main-red). A job failing on its exit line alone, or on lines main's job did not fail with (another shard's test), counts.
  • These removals still count:
    • a real check failure beside an infra line, in its own annotation or quoted in the same one;
    • a lane that fails with only an exit-code line;
    • pr-verify has not passed with no unreadable line, whether main is red or not;
    • any run, job or annotation read that fails.
  • The cap still protects the API budget. Every cause, kill-switch and lost-runner included, excuses a removal only once its own named reset has passed, or an hour after the removal when it names none; the wait is the latest of them.
  • New config list merge.queue-ejection-infra-causes in pr-pipeline.yaml (schema, policy reader, cache check). Absent means every cause. An unknown name is dropped with a note, so removals for it count. stricter_config keeps only the causes both the base and main name.
  • Each excused removal is logged so it can be measured:
    • ::notice title=queue-ejection::#N removal at T not counted ... infra (causes), from the gate and from enable-auto-merge.mjs;
    • excludedRemovals in evidence --lane-queue and in the enqueue step JSON.
  • The failed merge_group listing now reads up to 5 pages back to the head's oldest removal. Before, it read only the newest 100, and other PRs' failures pushed older removals out of reach.
  • The run-cache sections are renamed, so cached reset: null answers from the old classifier are not reused.

Verification

  • Tests written first, from the real annotation lines of runs 44492175156, 44481851116, 44479392429 and 44474968812, in test_babysit_merge_async.py InfraQueueRemovalsAreNotCounted. Covered: the negative cases listed under Fix, a real failure quoted beside an infra line in one annotation, a lane assertion quoting a cause phrase, a stamped rate limit beside the unstamped verify-unreadable gate (counted at 08:00, excused at 09:00), the gate's own pr-verify refusal while main is red, main failing the same job on other lines, main red versus green at the time, a main run too old to count, the config leaving a cause out, and paging past the first 100. Each review-fix test fails on the code before its fix. The policy read and stricter_config intersection tests are in test_babysit_merge_policy.py, and the notice test is in enable-auto-merge.test.mjs.
  • The babysit-prs Python suite passes locally after merging main, and so does enable-auto-merge.test.mjs (234 tests).
  • Checked against live data before the review fixes: the branch's queue_ejection_hold on the five PRs left all five with no refusal.

Related

  • #17401 (D418) fixed the read-floor cause of most of these ejections. #17382, #17411 and #17433 are in flight on the same causes.
  • Re-arming: plugins/source-control is part of enable-auto-merge's skip key (SKIP_MAIN_PATHS), so the first pr-merge sweep after merge reads every lanes PR again. The sweep runs on cron 11,41, or by workflow_dispatch. It arms the five and writes success over their pr-merge/unarmed status.

🤖 Generated with Claude Code

https://claude.ai/code/session_01KeBVgbERyakZ33T4AetfRj

…the ejection cap

pr-merge stopped re-arming a head after merge.max-queue-ejections
failed-check removals, and only excused a run whose CI Status alone failed
on a rate limit. The verify:unreadable read-floor refusals, kill-switch
stops and rate limits in Check Plugins and Check Managed Files that
ejected #17253, #17325, #17340, #17359 and #17417 all counted, so each
sat at the cap with a failing pr-merge/unarmed status until a push.

A removal is now excused when every failed job of its merge-group run
names an infra cause (rate-limit, read-floor, verify-unreadable,
kill-switch, lost-runner) apart from lines that only report it, or the
job also failed on main's run at the time (main-red). A real check
failure beside an infra line still counts, as does any unread run. The
budget causes and main-red wait for their reset, or an hour, so the cap
still protects the API budget. merge.queue-ejection-infra-causes names
the causes (default all; base and main must both name one). Each excused
removal gets a queue-ejection notice, and the failed-run listing pages
back to the head's oldest removal.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01KeBVgbERyakZ33T4AetfRj
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 19, 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-19T15:20:56.511320Z 065dab4 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.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 065dab43fe

ℹ️ 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".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@github-actions

github-actions Bot commented Nov 19, 2026 •

Copy link
Copy Markdown
Contributor

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

Security review: PR #17451, incremental (08877d1 → 565bb96)

No security issues found. This lane already reviewed an earlier head (blocking only: yes), so this review reports only CRITICAL and IMPORTANT findings.

What I read: the scope has one listed file, plugins/source-control/skills/babysit-prs/scripts/babysit_merge.py, which is a trusted path and part of the merge-hold control. I read every hunk of its incremental diff and the whole of _infra_removal at head (babysit_merge.py#L4629-L4686).

What changed: the WAITING_CAUSES set is gone. _infra_removal now waits for a reset on every cause it found, not just the causes that were in that set.

  • The old set held all five infra causes plus main-red. That is the whole of QUEUE_EJECTION_INFRA_CAUSES (babysit_merge_policy.py#L808) plus main-red, so today's behaviour is unchanged.
  • Any cause added later now has to wait for its reset by default. Before, a new cause left out of the set would have been excused at once.
  • Merge hold: this makes the merge.max-queue-ejections hold slightly stricter. It widens nothing.

Possible crash checked: the resets and guard was dropped, so I checked whether max(resets) can now run on an empty list and raise. It cannot. if not found: return None at L4678 returns first, and resets has one entry per key of found, so it is never empty there.

Settled threads: the three resolved threads (quoted infra line, the gate's own refusal while main-red, mixed-cause reset timing) are not raised again. This change only extends the fix for the third one.

Spend (not a finding): none beyond what the earlier review named.

critical-findings: 0

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

claude-review: 2 inline finding(s) on 065dab43fe5bc086996be79f3037134b283bdd5f; the summary is in this lane's pull request comment.

claude-lane: claude-review

@github-actions

github-actions Bot commented Nov 19, 2026 •

Copy link
Copy Markdown
Contributor

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

Code review: incremental, 08877d1573..565bb96a59 (blocking only)

This lane has reviewed earlier heads of this PR, so this pass reports blocking findings only. I read the whole incremental change: one file, plugins/source-control/skills/babysit-prs/scripts/babysit_merge.py. I ran no tests, because this lane has no shell. The PR's test results are the author's claims, and I have not verified them.

No blocking findings at this head.

What changed: the commit drops WAITING_CAUSES. _infra_removal now takes one reset per cause in found and no longer filters them against that set (babysit_merge.py#L4680-L4685).

  • Behaviour is unchanged. At the previous head, the set already held every cause the function can put in found: rate-limit, read-floor, verify-unreadable, kill-switch, lost-runner and main-red. So the filter removed nothing.
  • The removed resets and guard is safe. The if not found: return None check just above (L4678) means resets is never empty, so max(resets) cannot raise ValueError.
  • No references are left behind. A search of the repository finds no other use of WAITING_CAUSES.
  • The docstring matches the code: every cause waits for its named reset, or DEFAULT_RESET after the removal when it names none. This is the closing issue pr-merge: stop counting infra-caused merge-queue removals toward the ejection cap #17489's decision ("once the named reset has passed, or one hour after the removal when none is named").

Settled threads: the three earlier threads stay fixed, and nothing in this change reopens them. They covered quoted infra lines, the gate under main-red, and the per-cause wait for mixed causes.

Loosened-check verdict: fail. This is the default, because the prompt had no loosened_check_verdict: or loosened_check_patterns: line, so the patterns are 0 consumer entries. The prompt had no loosened_check_decision_record: line either, so I did not check the citation requirement. This change loosens nothing: it removes a set that had no effect.

Verifier dropped 0 of 0 candidates.

@github-actions

github-actions Bot commented Nov 19, 2026 •

Copy link
Copy Markdown
Contributor

The pr-verify verifier failed head 4f9d8a94a42ec38411741a65078ca313047299cc. What it wrote, as data:

What it wrote (26 lines)
Summary: The verdict is fail, on two defects. PR #17451 refs #17489, an owner decision record whose
  only done-when item is "#17451 merges". The record carries the required owner-decisions line links
  (L233, L234) and verbatim quotes for loosening the `merge.max-queue-ejections` cap. The diff
  mostly delivers that decision. An infra removal is excused only when every failed job failed on
  those causes alone. Real failures still count: one quoted in the same annotation, a lane failing
  on its exit line alone, and the gate's own pr-verify refusal while main is red. So does any read
  that fails. Tests cover all of these, plus the config list and the `stricter_config` intersection.
  Defect 1: the decision excuses a removal "once the named reset has passed, or one hour after the
  removal when none is named". `WAITING_CAUSES` leaves out `kill-switch` and `lost-runner`, so those
  removals are excused at once, a looser cap than the owner recorded. Defect 2: the PR body links
  #17489 with `Refs:` but names no remaining work, and the diff delivers the whole decision record.
  The pr-require-checks run on the head is no test evidence either way: `Select Tests` was skipped,
  which marks a label or body-edit re-run. There is no capture to weigh.
- plugins/source-control/skills/babysit-prs/scripts/babysit_merge.py: `WAITING_CAUSES` leaves out
  `kill-switch` and `lost-runner`, so `_infra_removal` excuses those removals at once. The owner
  decision on #17489 excuses a removal only "once the named reset has passed, or one hour after the
  removal when none is named". Add both causes to `WAITING_CAUSES` so they wait `DEFAULT_RESET`, or
  get the decision record changed first.
- plugins/source-control/skills/babysit-prs/scripts/tests/test_babysit_merge_async.py:
  `test_a_kill_switch_stop_does_not_wait_an_hour` asserts that a kill-switch removal is excused 4
  minutes after it happened, which goes against the owner decision. Change it to assert the removal
  is counted before the one-hour default passes and excused after, and add the same pair for
  `lost-runner`.
- PR body: `Refs: #17489` names no remaining work, yet the diff delivers the whole decision record,
  whose done-when is "#17451 merges". Change the line to `Closes #17489`, or name the part of #17489
  left for later work.

This pull request leaves the merge queue, and ci-status holds it out while it carries pr-verify-failed. A pr-verify pass removes the label, at a new commit or at this same head: once a trusted person edits the body, and only trusted people have edited it since the fail, this head is judged again, so a fail on the body or the issues it links needs only the body fixed, no new commit.

@github-actions github-actions Bot added the pr-verify-failed pr-verify failed this head; a pass at a new commit, or after a trusted body edit, removes it. label Nov 19, 2026
kyle-sexton and others added 2 commits November 19, 2026 11:35
…and never excuse the gate as main-red

- Split a failure annotation into its lines (dropping the hygiene headline,
  ::error:: and path prefixes) so a real failure quoted beside an infra
  line counts the removal.
- Wait for each waiting cause's own reset: a cause whose lines name none
  waits an hour after the removal, beside another cause's named reset.
- Never put CI Status through the main-red test: on main it fails whenever
  any job does, so its own refusal would be excused while main is red.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01KeBVgbERyakZ33T4AetfRj
kyle-sexton and others added 2 commits November 19, 2026 12:41
…cer's own shape

- Outside CI Status, a cause line must start as its producer writes it (a
  gh error, a guard's request, a runner message) or with the cause, so a
  test's output quoting a cause phrase counts the removal.
- main-red needs main's job of the same name to have failed on every line
  the merge-group job failed with beyond the exit line, so a shard failing
  on main for another test does not excuse it.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01KeBVgbERyakZ33T4AetfRj
kyle-sexton and others added 3 commits November 19, 2026 15:01
…unner removals

The owner decision excuses an infra merge-queue removal only once its named
reset has passed, or one hour after the removal when none is named. The
kill-switch and lost-runner causes were excused at once; they now wait
DEFAULT_RESET like the other causes. Tests pair a counted-before and an
excused-after case for each, and the docs, schema and changesets say every
cause waits its reset.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01KeBVgbERyakZ33T4AetfRj
Every infra cause waits its named reset or DEFAULT_RESET, so the set and
its always-true membership check in _infra_removal are removed. Behaviour
is unchanged.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01KeBVgbERyakZ33T4AetfRj
@github-actions github-actions Bot removed the pr-verify-failed pr-verify failed this head; a pass at a new commit, or after a trusted body edit, removes it. label Nov 19, 2026
@kyle-sexton
kyle-sexton added this pull request to the merge queue Nov 19, 2026
Merged via the queue into main with commit 63fc187 Nov 19, 2026
52 checks passed
@kyle-sexton
kyle-sexton deleted the fix/pr-merge-infra-ejections branch November 19, 2026 20:50
@github-actions github-actions Bot added the merge-path: owner-agent Post-merge accounting record (README.md, Merge paths) label Nov 19, 2026
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.

pr-merge: stop counting infra-caused merge-queue removals toward the ejection cap

1 participant