Skip to content

fix(pr-pipeline): wait out a near reset instead of dropping a Refine dispatch - #17411

Merged
kyle-sexton merged 1 commit into
mainfrom
fix/wait-out-reset-dropped-dispatches
Nov 19, 2026
Merged

kyle-sexton merged 1 commit into
mainfrom
fix/wait-out-reset-dropped-dispatches

Conversation

@kyle-sexton

Copy link
Copy Markdown
Member

No related issue: friction fix from the 2026-11-19 gh-monitor run. Dispatches that a GitHub token budget stop dropped were never sent again after the reset.

Summary

The pr-refine dispatch for a pull request, and intake's issue refinement, can each be sent only by the run of the event that started them. A token budget stop near a reset dropped both, and nothing re-sent them:

Fix

Both jobs now wait out the reset, using the wait budget the rate guard already has (D410/D417 pattern), rather than adding a re-send path.

  • pr-unblock-dispatch refine job: sets API_BUDGET_WAIT_SECONDS: "1200". The rate guard's patient latch waits out a stop-floor or refused answer whose reset is within 1200 s, then sends the POST. The event, sender and attempt stay the same, so the trusted-trigger rules (ADR 0090) are unchanged.
  • check-kill-switch: new opt-in input wait-seconds. When a budget stop's reset is inside it, the job sleeps to one second past the reset, reads /rate_limit once more (a secondary-limit call, no core spend), and decides again with the projection gate still on. Only intake's refine-select sets it. The other 15 start gates do not, so they don't all start at the reset.
  • Both jobs' timeouts go from 10 to 30 minutes, which holds the wait.
  • Extra API calls: the PR side makes none. The issue side makes at most one /rate_limit read for each stop it waits out.
  • Signal for a before and after count:
    • Issue side: started after the reset in the start-gate notice.
    • PR side: the rate guard's existing POST .../pr-refine.yml/dispatches waits Ns for GitHub's rate limit to reset.

Not covered: a manual kill switch has no reset to wait for. A stop more than 20 minutes before its reset still drops, as it does today. The PR Review legs and merge-group CI Status run in other workflows.

Verification

  • Tests written first and seen failing (5 red), then passing:
    • check-kill-switch.test.mjs: tonight's 467 s stop waits once and starts; a stop still low after the reset stops again with its new reset; a reset past the budget stops at once; no or invalid wait-seconds never waits; a switch stop never waits; refine-select is the only job that waits, and its timeout holds the wait.
    • workflow-gates.test.mjs: the refine dispatch step's wait equals WAIT_BUDGET_SECONDS.workResolveIssue, inside the job timeout.
  • node --test over check-kill-switch, workflow-gates, refine-event-dispatch, rate-guard, and every other suite that reads the three changed files: 0 failures.
  • The pre-push check-affected hook passed.

Related

🤖 Generated with Claude Code

…dispatch

A Refine dispatch on a pull request and intake's issue refinement each
had one sender: the event's own run. A GitHub token budget stop dropped
it, and nothing sent it again after the reset.

- pr-unblock-dispatch's refine job sets API_BUDGET_WAIT_SECONDS 1200,
  so the rate guard waits out a stop whose reset is near and then sends
  the pr-refine dispatch, instead of ending red.
- check-kill-switch takes a wait-seconds input. A budget stop whose
  reset is inside it waits for the reset and reads the budget once more.
  Only intake's refine-select sets it.
- Both jobs' timeouts rise to 30 minutes to hold the wait.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@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-19T07:19:35.339665Z cb82a37 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

Copy link
Copy Markdown
Contributor

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

Security review: PR #17411 (cb82a37)

No security issues found. I read every hunk of all 8 changed files. Two of them are on trusted paths: .github/actions/check-kill-switch/** and .github/workflows/{intake-triage,pr-unblock-dispatch}.yml.

What I checked

  • Kill switch (trust control): still stops lanes.
    • In check-kill-switch.mjs, the switch check still runs first. The new wait sits inside the existing proceed === "true" && BUDGET_CHECK === "true" branch, so a switch stop never waits.
    • After the wait, the budget is read again with the projection gate still on. A stop on that second reading still gives proceed=false.
    • waitBudget fails closed. A missing input, an invalid one, or one at or under 60 s returns 0. So does a failed import, which also logs a warning. rate-guard.mjs's waitBudgetMs caps the value at WAIT_BUDGET_SECONDS.workResolveIssue (1200).
    • A missing or NaN reset makes waitMs NaN. The <= comparison is then false, so the start stops without waiting.
    • The switch values are passed as step env at the start of the step and are not read again after the wait. Downstream intake jobs (refine-issue, refine-issue-subscription, refine-issue-fallback, apply-refinement) each run their own check-kill-switch (intake-triage.yml L1021, L1373, L1670, L1928). So a switch flipped during the wait still stops the model run.
  • Trust and token scope: nothing widened.
    • refine-select keeps contents: read, issues: read and pull-requests: read. Its who trusted-actor check still runs after the gate. The wait-seconds value is a hard-coded literal, not untrusted input.
    • In pr-unblock-dispatch.yml, the refine job keeps its permissions block. The only change there is API_BUDGET_WAIT_SECONDS: "1200" on the existing dispatch step, which feeds the rate guard's existing patient-wait path. The sender, event and trusted-trigger inputs are unchanged.
  • Tests and changelog: these change no security behavior.

Spend (not a hold, not counted as a finding): refine-select and the refine dispatch job can each now sit idle on a standard ubuntu-24.04 runner for up to 20 minutes per budget stop. Their timeouts go from 10 to 30 minutes, which uses more Actions runner minutes. The issue side also makes at most one extra /rate_limit read per wait.

critical-findings: 0

@github-actions

Copy link
Copy Markdown
Contributor

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

Code review: no blocking findings

I read all 8 changed files in full. The change gives two dispatch paths a way to wait out a near rate-limit reset instead of dropping their work:

  • In check-kill-switch, a new opt-in wait-seconds input. Only intake's refine-select sets it.
  • In the pr-unblock-dispatch refine job, API_BUDGET_WAIT_SECONDS: "1200", which uses the rate guard's existing patient latch.

What I checked:

  • The gate's wait logic (check-kill-switch.mjs L186-224).
    • The cap comes from rate-guard's waitBudgetMs. Empty, non-numeric, 0 or >1200 values fall back to SERVER_RETRY_BUDGET_MS, and waitBudget turns that into 0. So an unset or invalid input never waits, which matches the tests.
    • The second reading calls now() again inside the read closure, so the projection is judged against the window after the reset.
    • A switch stop never reaches the budget path.
    • A refused read falls back to now + 60, so it waits about 61 s and then reads once more. That fits the design.
  • The dynamic import. import("../log-api-budget/rate-guard.mjs") resolves because every budget job checks out log-api-budget beside the gate (an existing test checks this). Its only side effect at import time is an exit hook, and that hook is gated on API_BUDGET_SCRIPT, which this action does not set.
  • The PR side. refine-event-dispatch.mjs goes through budgetedFetch and retryServerErrors with rateLimitLatch. createRateLimitLatch's default budgetMs = waitBudgetMs() reads the step's API_BUDGET_WAIT_SECONDS, so the latch becomes patient as the PR says. The step only waits on a stop-floor before the POST is sent; a refused write is still never sent again.
  • Timeouts. Both jobs go from 10 to 30 minutes. That holds 600 s of work plus the 1200 s wait, and both new tests assert it. Also, cancel-in-progress: true on refine lets a newer push cancel a run that is waiting, and the record steps already run on cancel.
  • Test regexes. The wait-seconds step indentation (10 spaces) and the refine-select timeout regex match the workflow text at head.
  • No verification of my own. This lane has no shell, so I ran no tests. The PR's node --test results are the author's claim and I have not checked them.

Minor, not counted as a finding: the module header of check-kill-switch.mjs still says the /rate_limit read "is made once, with no retry" (L17-L18). With wait-seconds set, it is now read twice. The README qualifies the same sentence in the new paragraph, but the module comment does not.

Spend, not a hold: a budget stop near its reset can now keep a GitHub-hosted ubuntu-24.04 runner idle for up to 20 minutes per waited run. This happens in refine-select and in the refine dispatch job. There are no extra core API calls; the gate makes at most one more /rate_limit read per wait.

Other review inputs:

  • Closing issue: none. The PR context says it is a friction fix with no related issue, so there were no acceptance criteria to check.
  • Path rules: no .claude/rules/ file's paths: matches a changed file.
  • Loosened checks: the timeout changes are job timeouts, which this criterion does not judge. The timeout-minutes: 10 to 30 test assertion follows an intended config change and rejects the old value, so it does not accept more. The kill-switch gate still decides on a fresh reading, so it does not accept more under the same conditions.
  • Plugin manifests: no plugin.json or marketplace.json changes.
  • Embedded instructions: none in the PR context.
  • Citations: the prompt had no loosened_check_decision_record: line, so I did not check the citation requirement. With no verdict or patterns lines, I used fail and no consumer entries.

Loosened-check verdict: fail (lane default; no verdict or patterns line in the prompt); patterns: 0

Verifier dropped 0 of 0 candidates.

@kyle-sexton
kyle-sexton added this pull request to the merge queue Nov 19, 2026
Merged via the queue into main with commit 18171a7 Nov 19, 2026
55 checks passed
@kyle-sexton
kyle-sexton deleted the fix/wait-out-reset-dropped-dispatches branch November 19, 2026 08:16
@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