Repository navigation
fix(reconcile): re-run waiting reviews on a late tick once their checks finish - #18692
Conversation
…ks finish A full pass that finds a stopped hosted review on a head whose checks run is still going only waits, and every later tick of the same token window skips because a full pass already ran. On 2026-11-24 the reviews of #18671 and #18646, deferred at 03:13Z, waited about an hour for the next window's pass. The full pass now queues each such review ({checksRunId, reviewRunId, pr, head, path}) as waiting_reviews in its reconcile-settled-runs artifact, leaving out any it selected itself. reset-tick names the window start on a not-due tick too, and recent-pass, on a scheduled same-window hit, downloads that artifact by the id its listing gave and writes a non-empty queue for the follow-up. That tick goes through the existing budget kill switch into a review-only plan (followup.mjs): one run listing per queued head, and for a head whose newest checks run finished red only on the review stop, the full pass's own stoppedReviews (lane switch, re-run window, defer reset, upstream gate), limited to the queued reviews and to the DEFER_MAX band. A kill-switch stop needs a MAX_IN_FLIGHT place, which only a full pass counts, so it waits for that pass. The items go through recordOutputs, the record uploads and the existing act step on the workflow GITHUB_TOKEN. The queue is never rewritten. A review a tick re-ran is at attempt 2 on the next tick, and the attempt-1 predicate (isUnreviewed) skips it in the plan and again in act's re-read before the POST. Together with the workflow concurrency group, that keeps a follow-up from doubling the hub's forced review re-run. A follow-up uploads no settled runs and never marks a clean pass, so the full-pass marker and the pacer see only full passes. Missing or invalid state queues nothing. Co-Authored-By: Claude Opus 5.5 <[email protected]>
…p-tick # Conflicts: # .github/scripts/maintenance-reconcile-lost-runs/reconcile.mjs
…ence Review findings on the follow-up tick: - The queued checks run must still be the head's newest and be complete. A newer checks run on the same head leaves the reviews to the next full pass. - The live pull request must pass the full pass's own filter (open, not a draft, into main, from this repository, at the queued head), now shared as reconciledPull. - A head with a CI run the full pass recovers first (a lost CI run, a CI re-run in flight, or another CI run's failed first attempt) is left to the full pass, through the shared classify. - The head's whole stopped-review set is judged before the queue filter. The follow-up re-runs only when every stopped review is queued and deferred and they fit the band; a mixed set goes to a full pass. - Each follow-up tick writes a "reconcile follow-up tick: N queued, M re-run" notice, so a run shows it took this path. The recent-pass ingestion tests now read fixtures/settled-waiting.json, the full pass's writer output captured from the reconcile harness, and derive each malformed variant from it. reconcile.test.mjs pins the writer to that fixture, so the two cannot drift apart. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Codex Review Summary: ✅ CompletedThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
|
claude-security-review reviewed Security review: PR #18692 (reconcile follow-up tick)I found no security issues. I read every hunk of all 9 changed files. The workflow file and the reconciler scripts are trusted paths, so I also read the code the change depends on. What I checked
Spend (not a finding): each late scheduled tick now makes about 3-5 extra critical-findings: 0 The register at |
|
claude-review reviewed Code review: PR #18692, reconcile follow-up tickNo findings. I read every hunk of all 9 changed files. What changed. A full reconciler pass now records each hosted review it leaves waiting on a running checks run. It writes that list as
What I checked against unchanged code:
Tests. The assertions changed in Closing issue. The PR body says Spend (not a hold, not a finding). Each late scheduled tick now runs recent-pass: 1 run listing, 1-3 artifact listings and 1 archive GET. A follow-up adds about 14 GitHub API calls for one head with two deferred reviews, up to 3 times per window. The PR estimates about 240 extra calls a day on ticks with an empty queue. These draw on the Loosened checks. I found no loosening: no test skipped, no assertion weakened, no gate made to accept more without a gate in its place. Path-scoped rules. No Verifier dropped 0 of 0 candidates. |
Post-merge mutation testingKilled 4, survived 3, timeout 0, no coverage 0, invalid 0, not run 0.
Surviving mutants
The run's summary has the full report. |
Refs: #17460
A defect fix inside #17460's reconciler contract (hub decisions D435 and D528).
Summary
A full reconciler pass that finds a hosted review stopped by a kill switch (most often the budget defer gate) on a head whose checks run is still going only waits. Every later tick in the same token window then skips, because a full pass already ran in it. The review is re-run only by the first full pass of the next window.
Before (measured 2026-11-24): reviews deferred at 03:13Z (#18671 runs 45317976800 and 45317976924, #18646 run 45318004446) waited about 1 h. The 03:16Z full pass (run 45318335382) logged
#18671: review run 45317976800 (.github/workflows/pr-review-hosted.yml) was stopped by a kill switch; waiting for checks run 45318132512 (.github/workflows/pr-require-checks.yml) to finish. The defer notice on that run names reset 03:13:57Z, so the reset was not what held it. The later ticks (45318361967, 45319736659) skipped, and the re-run came with the first full pass after the 04:13:57Z reset. The schedule ticks 4 times per 3600 s window (cron: "4,19,34,49 * * * *"), and only one of those ticks runs a full pass.After: a later tick in the same window re-runs exactly those queued reviews once their checks run has finished.
Fix
reconcile.mjs):plan()collects{checksRunId, reviewRunId, pr, head, path}for each review it leaves waiting on a running checks run, and drops any review the pass selected itself.mainwrites the queue into the existingreconcile-settled-runsartifact as optionalwaiting_reviews.parseSettled()validates it, and a missing array reads as empty. NoSETTLED_VERSIONbump: no settle rule changed.reset-tick.mjs,recent-pass.mjs, the workflow):tickPlan()names the window start on a not-due tick too. On a scheduled hit in the same window,recentPass()returns the matched artifact id.maindownloads that artifact by id (ghDownloadArtifact, therotation.mjs:126pattern) and writes a non-empty queue toFOLLOWUP_PATHwithfollowup=true. The recent-pass step now runs before the kill switch, so the existingbudget: "true"kill-switch step gates the follow-up as well. The plan and act conditions are the full-pass condition, unchanged,|| steps.recent.outputs.followup == 'true'.followup.mjs, loaded fromreconcile.mjsplan mode whenFOLLOWUP=true):classify;reconciledPull: open, not a draft, into main, from this repository, at the queued head.stoppedReviews(), which this PR extracts unchanged fromplan(). That covers the lane switch, the re-run window, the defer reset and grace, and the upstream gate. It judges the head's whole stopped-review set and re-runs only when every review in it is queued and deferred and the set fits theDEFER_MAXband. Any other set goes to the next full pass.::notice title=reconcile::reconcile follow-up tick: N queued, M re-runannotation, so a run shows that it took this path. M counts the planned re-runs; act's own lines name each POST.recordOutputs(), the record uploads and the existingact(), which re-checks attempt 1 and the open, non-draft PR head before the POST.clean, so the full-pass marker and the pacer see only full passes. Missing or invalid state means no follow-up work. There is no new write kind, token, permission, threshold, cron or pacing change.Known scope: a kill-switch stop with no defer is not re-run by a follow-up tick. It waits for the next full pass, because follow-ups take only
DEFER_MAXplaces and only a full pass can countMAX_IN_FLIGHTplaces.Why it cannot double the hub's
review_reopen_kick: the queue is never rewritten. A review re-run by anyone is at attempt 2, and the attempt-1 predicateisUnreviewed(reconcile.mjs:727on the base, now in the exportedstoppedReviews) skips it in the plan.act()'slostNowre-read skips it again before the POST. The workflow'sconcurrency: maintenance-reconcile-lost-runsgroup (workflow line 83) runs one reconciler tick at a time. A test pins the attempt-2 skip.Verification
node --test --test-concurrency=4overreconcile.test.mjs,recent-pass.test.mjsandreset-tick.test.mjs: 279 pass, 0 fail. The new cases are:fixtures/settled-waiting.json, the full pass's writer output captured from the reconcile harness, and every malformed variant is derived from it.reconcile.test.mjspins the writer to that fixture;jobs-batch.test.mjs,guard-coverage.test.mjs,pr-review-main/workflow.test.mjs): 55 pass.actionlint: clean.zizmor --offline: no findings (2 ignored, both pre-existing).scripts/check-affected.sh --no-fetch: 18 passed, 6 skipped, over 9 changed files.3c1ec6704band found 4 medium and 1 low finding (superseded checks run, retargeted PR, CI-recovery precedence, mixed review set, hand-built fixture). All five are fixed atb5e09e58fcand covered by the tests above.GitHub API calls per follow-up tick, as built (not yet measured on a real run):
GET /rate_limit, which no pool countsGET /rate_limit, only when the queue is non-emptyact)The pinned test case, one head with two deferred reviews, makes 14 calls: 8 in the plan and 6 in act.
The worst case is 3 follow-up ticks per window. A not-due tick now also runs recent-pass, so even with an empty queue each late tick costs a run listing, 1-3 artifact listings and 1 archive GET.
Measured after merge: ~240 calls/day on empty-queue ticks (estimate). No cheaper guard ships here. The cheaper option would be a separate artifact, uploaded only when the queue is non-empty and found with one name-filtered
/actions/artifacts?name=listing. That artifact needs a new family row in.github/artifact-retention.json, whichscripts/check-artifact-retention.shrequires for every upload and which is outside this PR's scope. Verifying the listed artifact's run as a trusted main run of this workflow also takes one run GET, because the artifact'sworkflow_runobject carries no path or event. An empty-queue tick would then cost 1 call instead of 3-5.Revert criteria after merge: revert if, over the next 2 windows in which a follow-up actually ran, any follow-up tick makes more than ~20 calls, or the window's added calls in
gh-job-calls.jsonlbreach the budget.Deviation from the brief's figure: the brief listed 1 status GET per distinct checks run. This PR adds 3 reads per finished-red head (the PR, the checks jobs, the ci-status notes) and 2 reads per queued review. Without them the follow-up would re-run reviews on heads the full pass would hold: a checks run that failed on more than the review stop, or a review whose defer reset has not passed. The real-run measurement can only come after merge, since this workflow runs from main on its schedule; the revert criteria above apply to it.
Related
🤖 Generated with Claude Code