Skip to content

fix(reconcile): re-run stopped reviews only when ci-status failed on review stops alone - #18763

Merged
kyle-sexton merged 5 commits into
mainfrom
fix/reconcile-full-pass-mixed-ci-status
Nov 24, 2026
Merged

kyle-sexton merged 5 commits into
mainfrom
fix/reconcile-full-pass-mixed-ci-status

Conversation

@kyle-sexton

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

Copy link
Copy Markdown
Member

Refs: #17460

Summary

The reconciler's full pass reads the head's ci-status annotations. When they show a review stop (an API budget defer or a kill switch) or a rate hold, it re-runs the head's stopped reviews. On main the check is reviewStopNoted(notes) || rateHeldNoted(notes), and both predicates match when any one failure annotation matches. So a head whose ci-status also failed on a real failure, such as an upstream outage on the other review lane or a local read error, still had its stopped reviews re-run. That re-run is wasted: ci-status stays red on the other failure, so the re-run cannot turn the head green.

#18757 closed the same gap in the follow-up tick with onlyReviewStopsNoted(). Codex found the full-pass copy of the gap on that PR.

Rule: the full pass is never stricter than main, except where a real failure is present.

Fix

  • reconcile.mjs: the full pass gates the stopped-review re-run on reviewStopsAmidGateNotes(notes). The head needs at least one review stop or rate hold, and every other failure note, past GitHub's Process completed with exit code N. (EXIT_NOTE), must be a gate note:

    • a kill-switch note (killSwitchNoted);
    • a pending or missing review-lane note (PENDING_REVIEW_NOTE, MISSING_REVIEW_NOTE);
    • a rate-limit floor note (FLOOR_NOTE);
    • a could not companion tied to a floor note's call.
  • The tie: each target a ci-status read_api description names is matched to the path of the call in a floor note:

    • #N matches /pulls/N or /issues/N;
    • run N matches /actions/runs/N;
    • job N matches /check-runs/N or /actions/jobs/N;
    • a commit SHA matches a /SHA or =SHA target;
    • the push history of BRANCH matches ref=refs/heads/BRANCH, encoded as jq's @uri encodes it, up to the end of the parameter.

    Each match stops at the end of the id, so #1 does not match /pulls/12, and feat/floor does not match feat/floor-tie. Every GitHub API read that ci-status describes (pr-require-checks.yml:7500-8030) names one of these targets.

  • Residual, by design: a could not error from a local read names no API call. Examples are the pr-pipeline.yaml keys in the hold config and the trusted-actor list from a checkout. Such an error counts as a real failure, so a head with one gets no stopped-review re-run.

  • onlyReviewStopsNoted() moved from followup.mjs into reconcile.mjs, next to the predicates it is built from. followup.mjs imports it through its existing static import of reconcile.mjs, so there is no dynamic import and no new import edge. The follow-up tick keeps this narrower rule. On main it already hands a head with other gate notes to the full pass ("failed on more than a review stop"), and the full pass counts the re-run places such a head may need.

  • A ci-status that fails on a real failure alone takes the same fall-through as before (kill switch, rate-limit floor, pending review).

  • It costs no extra API calls: the annotations are already read.

Verification

Each case is a subtest of "the full pass re-runs a head's stopped reviews only when every other ci-status failure is a gate note, past GitHub's exit-code note" in reconcile.test.mjs. The notes come from their producers: switchHold() from merge-holds.mjs, ci-status's echo lines with the current check names PR Review / Status and PR Review Security / Status, and read_api's could not read <description>; re-run this run. beside gh_read's 'gh api <call>' was not sent: GitHub's core API rate limit holds until .... Every case also ends with GitHub's exit-code note. The table lists the stopped reviews each check re-runs; review 201 is the stopped one.

Case Main This PR
defer + outage on the other lane [201] (wasted) []
defer alone [201] [201]
outage alone [] []
lanes App PR: kill switch + stop [201] [201]
floor + its companion (the files of #1) + stop [201] [201]
floor + its companion + unrelated local error (could not read docs/conventions/pr-pipeline.yaml ...) + stop [201] (wasted) []
stop + pending (other lane still running) [201] [201]
stop + missing (other lane has no run yet) [201] [201]
floor on actions/runs/301/jobs + could not read the jobs of run 301 + stop [201] [201]
floor on actions/runs/301 + could not read run 301 + stop [201] [201]
floor on check-runs/9001/annotations + could not read the annotations of job 9001 + stop [201] [201]
floor on actions/runs?head_sha=SHA + could not read the pull_request runs on SHA + stop [201] [201]
floor on workflows/pr-review-security-hosted.yml/runs?head_sha=SHA + could not read the pr-review-security-hosted.yml runs on SHA + stop [201] [201]
floor on pulls/1 + could not read #1 + stop [201] [201]
floor on pulls/1/reviews + could not read the reviews of #1 + stop [201] [201]
floor on issues/1/comments + could not read the comments of #1 + stop [201] [201]
floor on activity?ref=refs%2Fheads%2Ffeat%2Ffloor-tie + could not read the push history of feat/floor-tie + stop [201] [201]
mismatched id: floor on run 301 + could not read the jobs of run 302 + stop [201] (wasted) []
mismatched branch: floor on feat/floor-tie + could not read the push history of feat/floor + stop [201] (wasted) []

Main's column was measured by restoring main's any-one check in the same tests. This PR differs from main only on the four "(wasted)" rows. Each of those carries a real failure.

Mutation proofs (each one was reverted after it ran):

  • With main's any-one check restored, the defer + outage, local-error, mismatched-id and mismatched-branch cases fail (actual [201], expected []).
  • With the review-stops-only check (onlyReviewStopsNoted) in the full pass, these cases fail: kill switch + stop (which also re-runs ci-status run 101), floor + companion + stop, stop + pending, and stop + missing.
  • With the EXIT_NOTE skip removed, "defer alone" fails in both the full-pass and follow-up tests (actual [], expected [201]).
  • With the review-stop requirement (causes.some(stopCause)) removed, the direct predicate test fails. It checks that a kill-switch, floor, pending or missing note alone is not a review stop.
  • With the companion tie replaced by "any could not beside a floor note", the local-error case fails.
  • With the run N and job N forms removed, the three run and job companion cases fail.
  • With the branch form removed, the push-history case fails. With the end-of-parameter check removed, the mismatched-branch case fails.

Suites:

  • node --test --test-concurrency=4 over the reconciler suites (reconcile.test.mjs, recent-pass.test.mjs, reset-tick.test.mjs, followup-main.test.mjs, the child-process e2e test) and the importer suites (jobs-batch.test.mjs, guard-coverage.test.mjs, pr-review-main/workflow.test.mjs, component-status.test.mjs, infra-failure.test.mjs): 387 pass, 0 fail.
  • scripts/check-affected.sh --no-fetch: 17 passed, 7 skipped over 3 changed files.

Related

  • #18757: added onlyReviewStopsNoted() for the follow-up tick.

🤖 Generated with Claude Code

kyle-sexton and others added 3 commits November 24, 2026 04:01
…review stops alone

The full pass re-ran a head's stopped reviews when any one ci-status
failure annotation was a review stop or rate hold, so a head whose
ci-status also failed on an unrelated real failure got a wasted re-run.
It now uses onlyReviewStopsNoted(), the follow-up tick's predicate,
moved into reconcile.mjs beside the notes it reads and imported
statically by followup.mjs.

Refs: #17460

Co-Authored-By: Claude Opus 5.5 <[email protected]>
…d floor notes

The strict check sent a head whose ci-status notes paired a review stop
with a kill-switch or rate-limit floor note to the switch or floor
branch, so a PR outside the lanes App got no re-run at all. The full
pass now allows any gate note beside the review stop
(reviewStopsAmidGateNotes) and still excludes a job or upstream
failure. The follow-up tick keeps onlyReviewStopsNoted: on main it
hands such a head to the full pass, which counts the re-run places.

Refs: #17460

Co-Authored-By: Claude Opus 5.5 <[email protected]>
…r companions to their call

The full pass's gate-note rule rejected ci-status's pending and missing
review-lane notes, so a deferred lane beside a lane still running, or
with no run yet, no longer re-ran as it did on main. Both are gate
notes now.

floorNoted's /^could not / companion let any local failure pass beside
a floor note, such as the missing pr-pipeline.yaml error. For this
decision a "could not" error counts only when the pull request number
or commit it names is a path or query target of a floor note's call.

The tests build their notes from the producers: switchHold's text and
ci-status's echo lines with the current check names, with no consumer
match constant in the fixture text. A direct predicate test pins that
a switch, floor, pending or missing note alone is not a review stop.

Refs: #17460

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@kyle-sexton
kyle-sexton marked this pull request as ready for review November 24, 2026 09:15
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 24, 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-24T09:17:14.834981Z 51059d1 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: 51059d1feb

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

Copy link
Copy Markdown
Contributor

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

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

This review covers only the push since 1236d251. It touches reconcile.mjs and reconcile.test.mjs. This lane already reviewed an earlier head, so I posted blocking findings only.

What changed. TARGET_FORMS now has a fifth form: could not read the push history of BRANCH; re-run this run.. It ties to a floor note whose call has ref=<jq @uri of refs/heads/BRANCH>, and the match must end at &, ', a space or the end of the text (reconcile.mjs#L594-L603). Each form now carries its own end-of-id lookahead: (?![0-9]) for numeric ids and (?![0-9a-f]) for SHAs. Before, namedCalls added one shared lookahead to every form.

How I checked it.

  • Producer. pr-require-checks.yml builds the ref with jq -rn --arg r "refs/heads/$HEAD_REF" '$r | @uri' and calls read_api "the push history of $HEAD_REF" "$next" -i (pr-require-checks.yml#L7703-L7723).
    • jqUri gives the same output as jq's @uri. jq leaves only A-Za-z0-9-_.~ unencoded and writes uppercase hex. encodeURIComponent plus percent-encoding !'()* gives the same result.
    • literal escapes the . that encoding keeps, so it is not a regex wildcard.
  • Later pages. Page 2 and later call repositories/<id>/activity?..., not repos/.... The step only follows a next link that has &ref=$ref& (L7742). So the [?&]ref= form also matches a floor note on a cursor page, with the same encoding.
  • End of the parameter. In the floor note the call is followed by -i', so the (?=[&' ]|$) lookahead accepts the real call. feat/floor cannot tie to feat/floor-tie, because the next character, - (%2D is never produced), fails the lookahead.
  • Tests. One new case ties the push-history companion to its own floor note. Another case names a different branch and must count as a real failure. I did not run the tests; the 387-pass result in the PR body is the author's claim and unverified.

Other checks.

  • There is no closing issue: the PR only refs perf(ci): pace GITHUB_TOKEN spend so busy hours stop tripping the kill switch #17460, so I checked no acceptance criteria.
  • The prompt had no loosened-check verdict or pattern lines, so I used fail with no consumer entries. This change loosens no check.
  • The prompt had no decision-record line, so I did not check the citation requirement.
  • Loosened checks would be marked: not applicable, since no loosened check was found.
  • There are no settled threads. The only prior entry is last round's summary comment, which raised no findings.
  • The change spends nothing: the annotations are already read.

Verifier dropped 0 of 0 candidates.

@github-actions

github-actions Bot commented Nov 24, 2026 •

Copy link
Copy Markdown
Contributor

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

Security review: PR #18763 (incremental, blocking only)

I found no security issues in this push.

Scope. This review covers only the change since 1236d251, which touched .github/scripts/maintenance-reconcile-lost-runs/reconcile.mjs and reconcile.test.mjs. I read every hunk of both files.

  • Neither file matches a trusted-path glob.
  • Neither file is a trust control, a merge hold or an instruction surface.
  • This lane already reviewed an earlier head, so this review reports only CRITICAL and IMPORTANT findings.

What changed. Two things changed in how a could not note is tied to a floor note's call:

  • Each id form now carries its own end-of-id lookahead. Before, a single (?![0-9a-f]) was applied to every form in namedCalls.
  • A new form ties could not read the push history of BRANCH; re-run this run. to [?&]ref=<jq @uri of refs/heads/BRANCH>, which must end at &, ', a space or the end of the text.

What I checked.

  • Regex built at runtime from annotation text (reconcile.mjs, the new branch form): the captured branch text runs through jqUri and then through literal before it goes into new RegExp.
    • encodeURIComponent plus jqUri's extra !'()* escapes leave only ., ~, - and _ unencoded, along with %-hex and alphanumerics.
    • literal then escapes every regex metacharacter, . included.
    • So crafted text in an annotation cannot change the structure of the built pattern. The added lookaheads are fixed template text.
  • ReDoS: the matching pattern ^could not read the push history of (.+); re-run this run\.$ is anchored, with one .+ before a literal suffix. The built pattern is an escaped literal followed by a one-character lookahead. Neither can backtrack catastrophically.
  • Effect: the predicate only decides whether the reconciler re-runs a head's stopped reviews. It sets no merge hold, gate, token scope or trust decision. The new form and the tighter lookaheads can only narrow which companions count as gate notes, so the worst a crafted note can do is skip a review re-run.
  • Test file: the only additions are new test cases (a push-history companion and a mismatched branch). It has no security-relevant surface.

Spend: whether a stopped review re-runs draws only on prepaid API and Actions usage. This is not a hold.

critical-findings: 0

kyle-sexton and others added 2 commits November 24, 2026 04:24
A stopped review beside a floor-held read of the other lane's jobs
writes read_api's "could not read the jobs of run N; re-run this run."
next to a floor note naming /actions/runs/N/jobs. The tie read only
#N and commit SHAs, so it rejected that companion, and nothing re-ran
the head. Each id a ci-status read_api description names now maps to
its call's path: #N to pulls/N or issues/N, run N to actions/runs/N,
job N to check-runs/N or actions/jobs/N, and a SHA to a /SHA or =SHA
target. Every read_api companion shape in ci-status is pinned beside
the floor note for its call, plus one naming another run.

Refs: #17460

Co-Authored-By: Claude Opus 5.5 <[email protected]>
…ranch

ci-status's read_api writes "could not read the push history of BRANCH;
re-run this run." for the activity read, whose call carries the branch
as ref=refs/heads/BRANCH, URI-encoded by jq's @uri. That companion
named no id, so a floor-held push-history read beside a review stop
re-ran nothing where main re-ran the stopped review. The companion's
branch is now encoded the same way and matched against the call's ref
parameter up to its end, so a different branch, or one that only
shares a prefix, stays a real failure.

Refs: #17460

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@kyle-sexton
kyle-sexton added this pull request to the merge queue Nov 24, 2026
Merged via the queue into main with commit 82d777f Nov 24, 2026
61 checks passed
@kyle-sexton
kyle-sexton deleted the fix/reconcile-full-pass-mixed-ci-status branch November 24, 2026 09:47
@github-actions github-actions Bot added the merge-path: owner-agent Post-merge accounting record (README.md, Merge paths) label Nov 24, 2026
@github-actions

Copy link
Copy Markdown
Contributor

Post-merge mutation testing

Killed 6, survived 1, timeout 0, no coverage 0, invalid 0, not run 0.
Covered-code score 86%; mutation score 86%.

File Killed Survived Timeout No coverage Invalid Not run
.github/scripts/maintenance-reconcile-lost-runs/reconcile.mjs 6 1 0 0 0 0

Surviving mutants

Location Operator Disposition Cause
.github/scripts/maintenance-reconcile-lost-runs/reconcile.mjs:570 ROR productive input-gap

The run's summary has the full report.

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