Skip to content

perf(ci): wait out a reset up to 12 minutes in rerun-ci-status - #17517

Merged
kyle-sexton merged 4 commits into
mainfrom
perf/rerun-ci-status-rate-wait
Nov 19, 2026
Merged

kyle-sexton merged 4 commits into
mainfrom
perf/rerun-ci-status-rate-wait

Conversation

@kyle-sexton

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

Copy link
Copy Markdown
Member

Refs: #17460

Summary

When the repository token's hourly pool runs out, pr-dispatch-feedback's Rerun CI Status job fails red if the reset is past its 600 s cap: 231 times in the 7 days to 2026-11-19. Sampled resets were 9-25 min away, and the brake holds the pool a median 12 min. Most of those resets fit inside the job's existing 15-minute timeout.

Fix

  • Rate-limit waits take RATE_WAIT_SECONDS: '720', counted with the poll's waits. They used to share the poll's 600 s. A reset up to 12 min away is now waited out, and the job re-runs ci-status itself.
  • A longer reset still fails red and names the reset, as before.
  • Unchanged: timeout-minutes (15), POLL_LIMIT_SECONDS (600), the reconciler's PENDING_BACKOFF_MINUTES (20), and the brake, kill switch and floor. No merge or recovery waits longer than today.
  • WAIT_BUDGET_SECONDS.rerunCiStatusRate (rate-guard.mjs) holds the value. rate-guard.test.mjs pins the workflow's value and requires the timeout to cover it plus 2 min.
  • Earlier revisions:
    • v1 used an 1800 s wait and a 45 min reconciler backoff. Withdrawn because it would delay lanes App PRs during trips.
    • v2 handed past-the-cap cases to the reconciler. Withdrawn because the reconciler misses approval relays and attempt-2 ci-status runs (claude-review finding).

Verification

Before (hub lane_causes_daily.json, 7 days): 231 red jobs with "past this job's 600s cap".

Run Time to reset Covered by 720 s
44420081821 24m49s no
44179747581 16m02s no
43969060891 11m59s yes
44480780714 11m25s yes
44403219434 9m02s yes

Expected after: about 60% fewer red jobs of this cause (3 of 5 sampled), each recovered right after the reset instead of by a person. Calls are unchanged. Measured from the same file 7 days after merge.

Local:

  • bash scripts/ci-rerun-ci-status.test.sh: 310 pass. New case: a reset 701 s away waits and re-runs. A reset past 720 s still fails and names the reset.
  • node --test over rate-guard and reconcile: 435 pass.
  • actionlint: clean.

Related

🤖 Generated with Claude Code

https://claude.ai/code/session_01KeBVgdbwavfuWZGmKnMhWX

Rerun CI Status shared one 600 s budget between its poll and its
rate-limit waits, so a job held 9-25 minutes from the reset failed at
once and left ci-status stale on that head. That happened 231 times in
the 7 days to 2026-11-19. The rate waits now take RATE_WAIT_SECONDS
(1800), apart from the poll. That outlasts the brake's longest hold (28
minutes). A wait sleeps and sends no calls.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01KeBVgdbwavfuWZGmKnMhWX
@kyle-sexton
kyle-sexton marked this pull request as ready for review November 19, 2026 20:24
@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-19T20:28:13.170806Z 6aaaf98 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.

@github-actions

github-actions Bot commented Nov 19, 2026 •

Copy link
Copy Markdown
Contributor

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

Security review: PR #17517, changes since 746429d4

No security issues found. I read every hunk of the four files in scope: .github/actions/log-api-budget/rate-guard.mjs, .github/actions/log-api-budget/rate-guard.test.mjs, .github/workflows/pr-dispatch-feedback.yml and scripts/ci-rerun-ci-status.test.sh. The lane already reviewed an earlier head, so this review reported only CRITICAL and IMPORTANT findings.

What changed

  • The Rerun CI Status job's find step has a new setting, RATE_WAIT_SECONDS: '720'. Waits for a rate-limit reset now count against 720 s instead of the poll's 600 s POLL_LIMIT_SECONDS.
  • When a reset is further away than that, the job now posts an error and fails (::error and exit 1) instead of posting a notice and passing (::notice and exit 0). See pr-dispatch-feedback.yml#L920-L923.
  • rate-guard.mjs gains a WAIT_BUDGET_SECONDS.rerunCiStatusRate: 720 entry. It is only a number the tests compare against. A new test in rate-guard.test.mjs pins the workflow's value and checks that timeout-minutes × 60 is at least 720 + 120. The other test changes only update expected exit codes and messages, and add a case where a reset 701 s away is waited out.

Trust-boundary checks

  • Failing the step approves nothing. exit 1 stops the find step before it writes its job-id or record outputs. Both are written after every read_api call, as the previous review of this lane confirmed. A failed step also skips the later re-run and record steps, so nothing is re-run or recorded. This is stricter than the exit 0 it replaces: the stale ci-status stays red and keeps blocking the merge.
  • No control is widened. The push changes no permissions: block, token request, trusted-actor check, kill-switch read, merge-hold script or merge-gate setting.
  • rate-guard.mjs is on a trusted path. I read its whole change. It adds one entry to a frozen constant and some comment text. Nothing else in the diff changes how the rate guard decides whether to stop a call.
  • No steering text. The PR description has no text that tries to steer the review.

Spend (not a finding, not a hold)

In the worst case, a rate-limited job now holds an Actions runner up to about 2 minutes longer (720 s instead of 600 s), still inside the existing 15-minute timeout-minutes. API calls are unchanged.

critical-findings: 0

@github-actions

github-actions Bot commented Nov 19, 2026 •

Copy link
Copy Markdown
Contributor

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

Code review (incremental): PR #17517, perf(ci): wait out a reset up to 12 minutes in rerun-ci-status

No blocking findings. This review covers what changed since 746429d, in four files: rate-guard.mjs, rate-guard.test.mjs, pr-dispatch-feedback.yml and ci-rerun-ci-status.test.sh. I read every hunk of all four. The prior-findings file says blocking only: yes, so this review reports blocking findings only.

The earlier finding is resolved. The earlier finding (the ::notice / exit 0 hand-off stranded approval relays and attempt-2 ci-status runs) is fixed. A reset past the cap now gives ::error / exit 1 again (pr-dispatch-feedback.yml:920-923), so both of those paths fail red and ask for a re-run, as they did on base. The thread is settled by the owner's reply, and I'm not raising it again.

What this push does.

  • Rate-limit waits now check waited + wait against a new RATE_WAIT_SECONDS: '720'. They used to check against POLL_LIMIT_SECONDS.
  • waited is still shared with the poll. The poll loop still stops at waited >= POLL_LIMIT_SECONDS (600), at L1031.
  • Total sleep stays bounded by about max(720, 600 + POLL_SECONDS), which fits the unchanged 15-minute job timeout (L724). Retry backoffs and API time are the rest.
  • WAIT_BUDGET_SECONDS.rerunCiStatusRate = 720 pins the value. The new test asserts that the job's first timeout-minutes match (the job-level 15) covers 720 s plus 120 s.
  • I checked that setting() (rate-guard.test.mjs:1009) matches the job-level timeout-minutes: 15 line.

Tests.

  • The 701 s case and the 801 s case match the stub's reset arithmetic: 701 s waits and re-runs, 801 s fails with ::error.
  • The per-file-read case moves to STUB_RESET=1800 and expects rc 1.
  • "The reset wait counts toward the poll cap" still expects the 600 s poll error. That is right, because rate waits still add to waited.

Verification: I ran nothing; this lane has no shell. The test counts (310, 435) and the clean actionlint in the PR body come from the author and are unverified.

Closing issue: the PR context has no closing-issue section (Refs: #17460 only), so there were no acceptance criteria to check.

Spend (not a hold): a rate-limited Rerun CI Status job can now sleep up to 12 minutes instead of 10, inside the same 15-minute timeout. That is slightly more runner time per such job. It adds no API calls.

Trusted paths: .github/actions/log-api-budget/rate-guard.mjs and .github/workflows/pr-dispatch-feedback.yml match trusted-path globs. I read their whole change and what it gates: the find step's rate-limit wait, its poll loop, and the ci-status re-run after it.

Loosened-check verdict: fail (default: the prompt has no loosened_check_verdict: or loosened_check_patterns: line, so no consumer entries apply); patterns: 0. The test edits put back the ::error / rc 1 expectations for a reset past the cap. They also add a positive case for a reset inside the new budget, and a new pin test. No assertion that guards kept behavior was relaxed. The prompt has no loosened_check_decision_record: line, so the citation requirement was not checked.

Verifier dropped 0 of 0 candidates.

The reconciler's Pending kind must wait at least rerun-ci-status's
timeout, so it does not race a late re-run. The timeout is now 45
minutes, so PENDING_BACKOFF_MINUTES rises from 20 to 45. The review-run
fixture now derives its age from the backoff instead of a fixed time.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01KeBVgdbwavfuWZGmKnMhWX
@kyle-sexton kyle-sexton added the do-not-merge Hard merge gate: do not merge while applied. label Nov 19, 2026
Replace the separate 1800 s rate wait with a hand-off. A rate limit
whose reset is past rerun-ci-status's 600 s cap now ends the job with a
notice, instead of failing. The reconciler's Pending kind already
re-runs that ci-status: the same hand-off the job makes for a lanes App
PR while the kill switch is on. The job's timeout and the reconciler's
backoff stay at 15 and 20 minutes, so no merge waits longer, and the
red job (231 in 7 days) goes away.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01KeBVgdbwavfuWZGmKnMhWX
@kyle-sexton kyle-sexton changed the title perf(ci): give rerun-ci-status its own rate-limit wait perf(ci): hand a rate-limited rerun-ci-status to the reconciler Nov 19, 2026
@kyle-sexton kyle-sexton removed the do-not-merge Hard merge gate: do not merge while applied. label Nov 19, 2026

@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: 1 inline finding(s) on 746429d41fe891a8b2788b89cdda8a9a9aa8185b; the summary is in this lane's pull request comment.

claude-lane: claude-review

@kyle-sexton kyle-sexton added the do-not-merge Hard merge gate: do not merge while applied. label Nov 19, 2026
Replace the hand-off with a longer wait. The reconciler's Pending kind
takes only an attempt-1 ci-status red on a pending review, so it misses
approval relays and a ci-status already at attempt 2, which the second
review lane's re-run makes common. Those heads would have gone
unrecovered with no flag (claude-review finding on #17517).

Rate-limit waits now take RATE_WAIT_SECONDS (720), counted with the
poll's waits, up from the poll's 600. That waits out resets up to 12
minutes away and re-runs ci-status itself. A longer reset still fails
red and names the reset, as before. The 15-minute timeout and the
reconciler's 20-minute backoff are unchanged.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01KeBVgdbwavfuWZGmKnMhWX
@kyle-sexton kyle-sexton changed the title perf(ci): hand a rate-limited rerun-ci-status to the reconciler perf(ci): wait out a reset up to 12 minutes in rerun-ci-status Nov 19, 2026
@kyle-sexton kyle-sexton removed the do-not-merge Hard merge gate: do not merge while applied. 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 b1d6186 Nov 19, 2026
115 of 118 checks passed
@kyle-sexton
kyle-sexton deleted the perf/rerun-ci-status-rate-wait branch November 19, 2026 22:04
@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.

1 participant