Skip to content

fix(ci): count merge-queue removals, not failed groups, in signal 4 - #16899

Merged
kyle-sexton merged 2 commits into
mainfrom
fix/merge-queue-ejection-signal
Nov 17, 2026
Merged

kyle-sexton merged 2 commits into
mainfrom
fix/merge-queue-ejection-signal

Conversation

@kyle-sexton

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

Copy link
Copy Markdown
Member

No related issue: #14293 is filed by the monitor itself, so it carries no human-written spec

Summary

The monitoring lane's signal 4 (merge-queue-ejections) counted failed merge-group runs and called them ejections. A failed group is not always a removal. The merge queue rebuilds a group that sits behind an entry that left, and that rebuild removes nothing. The signal now counts pull requests the merge queue actually removed for failed checks. It leaves out removals caused by a hold applied after the PR was queued, which the loop-lane contract intends.

A read-only classification of the 147 failed or cancelled merge-group runs from 2026-11-10 to 2026-11-17 (90 PRs, 1,411 merge-group runs listed) found:

  • In a 15-PR sample, 33 failed runs produced 18 removals by the queue that were not merges.
  • #15464, #15505 and #16458 had 7 failed runs between them and were never removed. Each group was rebuilt.
  • 54 runs (36.7%) were holds working as designed:
  • 71 runs (48.3%) failed on the exhausted GITHUB_TOKEN core pool, for example 42978333308 and 43149751867.
  • 11 runs (7.5%) were real test or staleness failures, for example 42958876607.

Fix

  • collect.mjs, source merge-queue ejections:
    • After the existing failed-run listing, one GraphQL query per 25 pull requests (at most 50) reads each PR's ADDED_TO_MERGE_QUEUE_EVENT, REMOVED_FROM_MERGE_QUEUE_EVENT and LABELED_EVENT items. The query covers the last 24 hours plus a 6-hour lookback, so each removal can find its enqueue.
    • queueRemovals keeps removals with reason failed_checks and drops manual and merged, the same reason babysit_merge.py counts. Each kept removal carries its enqueue and the labels added between the enqueue and the removal.
    • For the newest 10 failed groups, the failed jobs whose queue-hold step failed get their annotations read. The group is marked when one is switchHold's kill-switch line.
    • The listing goes from 50 to 100 runs per call. More than 100 failed runs, more than 50 PRs, or a PR whose timeline has more than 100 items in the window (pageInfo.hasPreviousPage), is a gap that leaves the signal unread.
  • signals.mjs, ejectionFindings:
    • Counts removals, not groups.
    • Leaves out a removal when a label that merge-holds.mjs labelHolds holds on was added while queued (do-not-merge, needs-human, pr-verify-failed, security: outside-actor), or when a failed group of that enqueue hit the kill switch.
    • The title and summary carry the counted number. The facts list each counted removal with its newest failed group's steps and link, and each removal not counted with the reason.
    • The fingerprint is the newest counted removal.
  • The signal field "4 merge-queue ejections" is the signal's id, as in "2 ceiling" and "13 lane holds". It is not a hardcoded count, and it is unchanged: issues.mjs keys on it.
  • The signal-4 row in docs/conventions/pr-pipeline/README.md is updated, plus a pr-pipeline patch fragment.
  • No workflow edit. The monitor job already has pull-requests: read.
  • API cost per monitor run:

Verification

Related

Remaining

  • The kill switch is read only for the newest 10 failed groups (LIMITS.mergeGroupRuns), and only from the queue-hold step annotations. A kill-switch removal whose group falls past those 10 is still counted.
  • A removal is matched to its failed group by PR and time, between the enqueue and the removal. A removal whose enqueue is more than 30 hours back gets neither the hold-label check nor the kill-switch check, and is counted.
  • pr-verify-failed added while queued is treated as a hold applied after queueing and is not counted (test(prototype): wait for the frame's Esc to reach the host #16692). The gap behind it remains: a head enqueued before pr-verify judged it. Counting it again is a one-line change to isHoldLabel.
  • A removal with no failed merge-group run in the 24-hour listing (a cancelled or timed-out group) is not read, because candidate PRs come from status=failure runs.
  • The rate-limit failures, 48% of failed runs, still eject PRs. They count here as intended, and their cause is The workflow token reaches its rate-limit floor each hour and its steps fail instead of waiting #16642's.

🤖 Generated with Claude Code

The monitoring lane's merge-queue-ejections signal fired on the count of
failed merge-group runs. A failed group is not always a removal: the queue
rebuilds a group behind an entry that left, and in a 15-PR sample 33 failed
runs were 18 removals.

The collector now reads, in one GraphQL query per 25 pull requests (at most
50), the merge-queue timeline of each pull request whose merge group failed
in the last 24 hours, reaching 6 hours further back for each removal's
enqueue. The signal counts RemovedFromMergeQueueEvent items with reason
failed_checks (the reason babysit_merge.py counts; manual dequeues and
merges carry manual and merged). It leaves out a removal a hold caused after
the enqueue: a label merge-holds.mjs labelHolds holds on, added between the
enqueue and the removal, or a failed group of that enqueue whose queue-hold
step failed with switchHold's kill-switch line (read from the annotations of
that step's job, for the newest 10 groups only). The kill-switch match needs
the removal's enqueue on the page read, as the label rule does, so a group
from an earlier enqueue never excludes a later removal. A test pins the two
step names to pr-require-checks.yml.

Failed runs still fold into one group per gh-readonly-queue branch, since one
merge group can fail in more than one workflow; the comment that said so
called the group an ejection and is gone.

The title and summary carry the counted removals. The fingerprint is the
newest counted removal, so an old one leaving the 24-hour window writes
nothing. The listing goes from 50 to 100 runs a call, and a listing past it
or more than 50 pull requests is a gap that leaves the signal unread.

Calls a monitor run adds: 1 GraphQL query per 25 pull requests with a failed
group (2 at most), and for the newest 10 groups the annotations of each
failed queue-hold job (one GraphQL batch, or one REST read each).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@kyle-sexton
kyle-sexton marked this pull request as ready for review November 17, 2026 18:02
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 17, 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-17T18:05:16.104433Z 9e5680e Draft marked ready
ℹ️ 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: 9e5680eb43

ℹ️ 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 17, 2026 •

Copy link
Copy Markdown
Contributor

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

Security review (incremental): PR #16899, from 9e5680e to ba07ee0

No security issues found. This lane already reviewed an earlier head of this pull request, so this pass reported only CRITICAL and IMPORTANT findings. There were none.

Scope. I read every hunk of all 4 files in this push's diff:

  • .changes/pr-pipeline/fix-merge-queue-ejection-signal-a994a232.md
  • .github/scripts/maintenance-monitor-signals/collect.mjs
  • .github/scripts/maintenance-monitor-signals/collect.test.mjs
  • docs/conventions/pr-pipeline/README.md

None of these files matches a trusted path.

What changed. The monitoring collector's merge-queue timeline query now also asks for pageInfo { hasPreviousPage }. In collect.mjs#L612-L616 it handles the answer in two ways:

  • If the answer has no boolean hasPreviousPage, it treats the timeline as not read and throws.
  • If the timeline was cut at 100 items, it records a gap, so signal 4 is left unread instead of counting part of the set.

What I checked:

  • Query building. The fixed QUEUE_FIELDS string adds no interpolated value. Each PR number in the query still comes from a \d+ capture.
  • Failure handling. This narrows what the signal accepts: a missing or truncated read now becomes a gap. It widens nothing.
  • Controls touched. None: no workflow, permissions: block, token request, merge hold, kill switch or trusted-actor list.
  • Other changes. The test and doc edits only describe or pin the new behavior.

API spend. The same query now reads one more small field. That uses existing token quota, not a billed resource.

There is no manifest change, no standing-instruction deletion and no prior finding to repeat.

critical-findings: 0

@github-actions

github-actions Bot commented Nov 17, 2026 •

Copy link
Copy Markdown
Contributor

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

Code review (incremental, blocking only): no blocking findings

I reviewed only what changed since 9e5680eb, in 4 files. I read every hunk in all of them. Because this lane already reviewed an earlier head, I looked only for blocking findings.

The new commit adds a check for a cut-off timeline read. The timeline query now asks for pageInfo { hasPreviousPage }. When that comes back true for a pull request, the read records a merge-queue ejections: gap, so signal 4 is left unread for that run. When an answer has no boolean page info, the read throws "did not read", and source() turns that into a gap. This answers the settled codex thread on collect.mjs:610, which the owner marked fixed.

What I checked:

  • Gap wiring. gaps is the same array that records the listing-past-100 gap (collect.mjs#L573). The new gap message has the same merge-queue ejections: prefix, so unreadSignals maps it to signal 4. The new test checks that. The partial removals are still collected, the same way as on the existing listing-cut path.
  • Strict page-info check. typeof cut !== "boolean" treats a missing pageInfo as a failed read. It does not treat it as "not cut". That is the safe direction.
  • Test fake. fakeApi wraps an array fixture with hasPreviousPage: false. It passes a non-array answer (a cut object, or a null route) through unchanged. So the existing fixtures keep their behaviour, and the two new tests cover the true case and the missing-page-info case. The query assertion also pins pageInfo { hasPreviousPage } in the query that is sent.
  • Docs. The README signal-4 row and the changelog fragment describe the new over-100-items gap in the same words as the code.

I did not run any tests. The PR description says the truncated-timeline test was red before the fix and green after it. That is the author's claim, and I have not verified it.

API spend: this adds one field to the GraphQL query that already runs and adds no new calls. It spends only API rate quota. Nothing is billed.

Loosened-check verdict: fail (default, because the prompt had no loosened_check_verdict: or loosened_check_patterns: lines); patterns: 0. I found no loosening: the change adds assertions and removes none.

Verifier dropped 0 of 0 candidates.

The timeline read takes each pull request's newest 100 merge-queue and
label items in the window. A pull request with more lost its older
removals with no gap, so signal 4 could read clear on a partial count and
close its incident.

The query now asks for pageInfo.hasPreviousPage. When it is true for any
pull request, the source records a gap, which leaves signal 4 unread for
that run, as the failed-run listing past its 100 does. An answer without
page info is a failed read. It does not page further: the read stays at
one GraphQL query per 25 pull requests, and 100 such items for one pull
request in 30 hours is far past the busiest timelines read for this
change.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@kyle-sexton
kyle-sexton added this pull request to the merge queue Nov 17, 2026
Merged via the queue into main with commit b87a2bb Nov 17, 2026
128 of 132 checks passed
@kyle-sexton
kyle-sexton deleted the fix/merge-queue-ejection-signal branch November 17, 2026 19:18
@github-actions github-actions Bot added the merge-path: owner-agent Post-merge accounting record (README.md, Merge paths) label Nov 17, 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.

1 participant