Skip to content

perf(pr-pipeline): re-run ci-status once per head after both review lanes finish - #12797

Merged
kyle-sexton merged 1 commit into
mainfrom
perf/rerun-ci-status-once-per-head
Nov 3, 2026
Merged

kyle-sexton merged 1 commit into
mainfrom
perf/rerun-ci-status-once-per-head

Conversation

@kyle-sexton

Copy link
Copy Markdown
Member

No related issue: run-volume cut 4 from the 2026-11-03 volume analysis (breaker trips from API volume)

Summary

rerun-ci-status in pr-feedback-dispatch.yml runs once per review-lane completion. In one measured hour it made 89 runs over 47 heads and 371 API calls, plus 34 extra ci-status attempts, each of which fires pr-verify, pr-review-main and post-verify-notes again. The token's API volume trips the rate breaker every hour.

Two kinds of run are redundant:

  • The earlier lane's run reads the other lane as finished when both lanes finish close together, or when the run waits in the per-head queue until both have finished. It then goes on to read the pr-require-checks runs and jobs (3 calls), or it re-runs ci-status itself.
  • When the earlier lane's run re-runs ci-status and the later lane's run reads that re-run as started inside the 60 s margin, the later run re-runs ci-status again, as attempt 3. The test added here reproduces that against the current file.

With this change only the lane that finished last acts, so each head gets one re-run, and the other lane's run stops after its one read.

Measurement plan: take the same 1 h window shape as the baseline (89 runs / 47 heads / 371 calls) after merge and compare:

  • rerun-ci-status runs per reviewed head;
  • the calls-per-run histogram (baseline 1:15, 3:33, 4:5, 6:26, 7:7, 8:1, 12:2). The 3-call runs from earlier lanes should become 1-call runs;
  • ci-status attempts above 1 per head, and how many heads reach attempt 3 (baseline 6).

No savings figure is claimed before that measurement.

Fix

  • In the find step's other-lane loop, a lane's run exits after its one read when the other lane's newest run finished later (equal times: the higher run id wins). It only does this when that run will itself re-run ci-status and record the re-run: its conclusion is not skipped (the job's if: starts no run for a skipped completion) and it is at attempt 1.
  • A later lane that was skipped, or re-run past attempt 1, does not hold this lane, so a PR that runs one lane never waits.
  • The approval relay (pr-review-approved.yml) is unchanged.
  • ci-status's own rule is untouched. Its Require both review lanes on this head step (pr-require-checks.yml, lanes at :6683-6684, newest-run choice in lane_at at :6911-6918) still fails while a lane is unfinished. This job already mirrors that newest-run choice in newest().
  • Concurrency: unchanged. The workflow-level group is already per head SHA, with cancel-in-progress: false and queue: max (pr-feedback-dispatch.yml:103-116). It queues rather than cancels so that a newer pending run can never drop the later lane's run. Because the actor is now picked by finish order, there is exactly one actor whichever order the queue runs them in, so no job-level group is added.
  • The dispatch job for review completions is left alone. It passes only lane-branch (work-resolve-issue/issue-*) completions (:303-329), and its dispatch record skips a head that was already handled before any read (:88-91).

Verification

  • bash scripts/ci-rerun-ci-status.test.sh: PASS=257 FAIL=0. New cases:
    • both lanes finished: the earlier lane's run re-runs nothing after 1 read and the last lane's run re-runs, so a pair of completions makes exactly one re-run;
    • an earlier lane's run held in the queue past a re-run that started inside the 60 s margin makes no third attempt (1 read);
    • a tie in finish time re-runs exactly once;
    • a later lane that was skipped by design, or re-run at attempt 2, lets this lane re-run;
    • a later lane that was cancelled or failed is left to its own completion (1 read).
    • The existing "other lane still going: one read" and "no other-lane run: re-run on this lane alone" cases still pass.
  • The same test against the current main workflow: 13 failures, including "re-runs over both completions: 2" and "as attempt 3".
  • shellcheck and shfmt are clean on the test. Local actionlint reports only the existing queue: key on line 116, which this local actionlint version does not know.
  • workflow-gates.test.mjs, reconcile.test.mjs and dispatcher-current.test.sh pass. One feedback-dispatch.test.mjs case (ownerAdoption) fails locally in code this PR does not touch.

Related

  • Volume analysis 2026-11-03, section 5 (rerun-ci-status) and Top 5 rank 4. The structural alternatives there (one review workflow, or a separate review check) were not taken; the review workflows stay separate, as agreed with Automation Lanes.

🤖 Generated with Claude Code

https://claude.ai/code/session_01Vcupom3BKF6QuC5U3sRJPj

…anes finish

rerun-ci-status ran once per review-lane completion. When the earlier
lane's run read the other lane as already finished (both lanes done
close together, or the run held in the per-head queue), it re-ran
ci-status too, and the later lane's run could re-run it again as
attempt 3 when the first re-run started inside the 60 s margin. Each
extra attempt fires pr-verify, pr-review-main and post-verify-notes.

Only the lane that finished last now acts: the other lane's run exits
after its one read when the other lane finished later (ties go to the
higher run id), that run starts this job (not skipped) and its re-run
is recorded (attempt 1). A later lane that was skipped, or re-run past
attempt 1, does not hold this lane. The approval relay is unchanged.

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

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

Copy link
Copy Markdown

Codex Review Summary

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

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-03T08:55:02.403389Z 2638cd6 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

github-actions Bot commented Nov 3, 2026

Copy link
Copy Markdown
Contributor

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

Security review: PR #12797 (head 2638cd6)

No security issues found.

What changed. The rerun-ci-status job's find step in .github/workflows/pr-feedback-dispatch.yml now stops early when the other review lane's newest run finished after this one (a tie goes to the higher run id). It defers only when that later run is not skipped and is at run_attempt == 1, so that run's own completion handles the ci-status re-run. The rest of the PR is test changes in scripts/ci-rerun-ci-status.test.sh.

What I checked

  • Injection: none. The new jq filter gets LANE_DONE_AT and REVIEW_RUN_ID through --arg, not string interpolation. Both come into run: through step env: (L639, L645), not ${{ }} inside the script. LANE_DONE_AT is checked against a strict UTC regex before this code runs (L686). The whole filter sits in try … catch false, so bad input makes the job re-run ci-status rather than skip it.
  • Trust controls and merge holds: nothing widened or weakened. The change only cuts how often ci-status gets re-run. The rule that decides ci-status (the "Require both review lanes on this head" step in pr-require-checks.yml) is untouched. A skipped deferral can leave ci-status stale or red. It can never turn it green. The approval-relay path ($LANE_PATH == $approved) is left out of the new branch, so the trusted-human check before it (L671) works as before. The kill-switch step and the GH_TOKEN: ${{ github.token }} scope are unchanged.
  • Tokens, secrets, permissions: no change to permissions:, token requests or secrets.
  • Instruction surface and plugin manifests: none touched.

Spend: this lowers prepaid Actions/API use (fewer rerun-ci-status API calls and fewer extra ci-status attempts, so fewer pr-verify and pr-review-main runs). It is not a hold.

Prior findings: none (round 0 of 3). No settled-threads file was given. The PR context has no embedded directives.

critical-findings: 0

@github-actions

github-actions Bot commented Nov 3, 2026

Copy link
Copy Markdown
Contributor

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

Code review: PR #12797, no findings

Scope: I read every hunk of both changed files: .github/workflows/pr-feedback-dispatch.yml and scripts/ci-rerun-ci-status.test.sh. I also read the surrounding rerun-ci-status job (its if:, the other-lane loop, the 60 s margin and the last read before the re-run) and the workflow-level per-head concurrency group (cancel-in-progress: false, queue: max).

What changed: In the other-lane loop of the find step, a review lane's run now stops after one read when the other lane's newest run finished later. Equal finish times go to the higher run id. It only stops when that run will act on its own completion: its conclusion is not skipped, so the job's if: runs it, and it is at run_attempt == 1, so its re-run is recorded.

Correctness checks (by reading the code, not by running it):

  • Exactly one lane acts. The comparison is symmetric, so for two finished lanes exactly one of them acts, whichever order the per-head queue runs their jobs in. A tie is broken by run id, which both runs see the same way. An unreadable timestamp or run id ends in catch false, so that run re-runs instead of waiting on the other lane.

  • A later run of the same lane. The other lane's run may still be going, or skipped. Going, it stops with "has not finished". Skipped, it is not deferred to (conclusion != "skipped"). So a skipped newest run never leaves a head with nobody to re-run.

  • Same filters on both sides. newest() already filters by pull_request event and same-repository head. Those match the job's if:, so a run this lane defers to does start this job.

  • The approval relay is untouched. pr-review-approved.yml is excluded from deferring by [[ $LANE_PATH != "$approved" ]], as the PR describes.

  • Tests. The new cases cover:

    • the earlier and the later lane of a pair;
    • an earlier lane's run held in the queue past a re-run inside the 60 s margin;
    • a tie in finish time;
    • a later lane that was skipped, or is at attempt 2;
    • a later lane that was cancelled or failed.

    The test runs with set -uo pipefail and no -e, so pair=$(reran) does not abort when grep -c counts 0. Changing the fixture default to DONE for the other lane and LATER for this lane keeps the earlier cases' meaning.

  • Not verified. The PR's results (PASS=257 FAIL=0, 13 failures against main, clean shellcheck and shfmt) are the author's claims. This lane had no shell and ran nothing.

PR context: The PR has no closing issue, so there are no acceptance criteria to check. The PR body contains no embedded instructions to the lane.

Prior findings: This is round 0 of 3 and the cap does not apply. There were no prior posts to carry over.

Spend: The change reduces rerun-ci-status runs and ci-status re-run attempts per head, which saves Actions minutes and API calls. It adds no billed resource, so there is no cost hold.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant