Skip to content

fix(work-resolve-issue): wait for the token's reset after the model ran instead of failing - #17321

Merged
kyle-sexton merged 7 commits into
mainfrom
fix/lane-end-steps-wait-for-reset
Nov 19, 2026
Merged

kyle-sexton merged 7 commits into
mainfrom
fix/lane-end-steps-wait-for-reset

Conversation

@kyle-sexton

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

Copy link
Copy Markdown
Member

Refs: #16642

Summary

On 2026-11-18 six work-resolve-issue runs failed as the GITHUB_TOKEN pool emptied, 409-987 s before its 22:46:50Z reset. Four lost work:

Run Issue Where it died Work before it died
44405800674 #17230 Run Checks > Resolve the config (stop-floor, 33 of 5000), Report Outcome > Check the trigger (403), Report Statuses (403) branch work-resolve-issue/issue-17230-44405800674-1 pushed, no PR
44405894333 #17279 Resolve Issue Subscription / Scan > Scan the outputs for credentials (getBranch 403) model finished; nothing uploaded, no branch
44406236443 #17286 the same scan step model finished; no branch
44406300700 #16642 the same scan step model finished; no branch
44405833741 #17232 Report Statuses only (stop-floor, 62 of 5000) PR #17302 opened
44406269499 #17285 handoff and stale reads (gh wrapper) the model never ran

Fix

  • rate-guard.mjs: API_BUDGET_WAIT_SECONDS sets the latch's wait budget (60 s by default, whole seconds up to 3600). Only under a longer budget, a stop-floor answer GitHub served no longer fails its step when the next call waits the reset out, and the latch resends a refused GET once after the wait. With the default, every lane behaves as before. The 5xx budget stays 60 s.
  • pr-run-activity-read.yml, pr-run-activity-write.yml: a rate-limit-wait-seconds input (default 0, today's behaviour for every other lane). The write runner's run job gets it as the guard's budget; the read runner's leak scan resends a rate-limited read once within it, and the scan job's timeouts grow from 20/10 to 40/30 minutes only when it is set.
  • work-resolve-issue.yml: passes 1200 to every runner call and sets it on Run Checks and Report Statuses, whose timeouts go from 10 to 30. 1200 s holds every stop measured above (max 987 s).
  • post-statuses.mjs: when report-outcome did not finish, the Report Statuses job names the lane branch the run left; findPrior reuses a branch with no PR whose run left no outcome marker.
  • The pr-pipeline outage-posture element 1 and the outage-posture audit's work-resolve-issue row record the exception.

Not covered: the gh wrapper (api-budget.bash, copied verbatim into pr-require-checks.yml) still refuses without waiting, so the handoff and stale reads can still fail. apply-issue-patch does not depend on the handoff job (work-resolve-issue.yml needs: [resolve-issue, resolve-issue-subscription, resolve-issue-fallback]), so a scanned patch is still applied. No start-gate threshold changes.

Cost and timing: a waiting job holds its runner for up to 20 min, against today's measured peak of 57 of 60 Actions jobs. Actions minutes cost nothing because the repository is public. This touches work-resolve-issue.yml and both runner workflows, so lane runs in flight at merge stop on stale workflow files and re-fire.

Verification

  • node --test on rate-guard.test.mjs (165 pass), post-statuses.test.mjs (24 pass), and the two leak-scan cases in callers.test.mjs. The new rate-guard cases fail when the floor and resend behaviours are disabled.
  • scripts/check-affected.sh --tests: 14 passed, 175 skipped.
  • actionlint on the three workflows: clean.

Related

🤖 Generated with Claude Code

kyle-sexton and others added 5 commits November 18, 2026 19:02
…an instead of failing

On 2026-11-18 six lane runs failed as the GITHUB_TOKEN pool emptied,
409-987 s before its 22:46:50Z reset. Three lost a finished model run
(the leak scan's getBranch was refused, so no patch was uploaded) and one
kept a pushed branch but opened no PR (Check the trigger and Run Checks
failed on the stop-floor).

- rate-guard.mjs: API_BUDGET_WAIT_SECONDS sets the latch's wait budget
  (60 s by default, at most an hour). A stop-floor answer GitHub served
  no longer fails the step when the next call waits the reset out, and a
  latch with a longer budget resends a refused GET itself once.
- pr-run-activity-read.yml and -write.yml take rate-limit-wait-seconds;
  the leak scan's two reads wait out a rate limit within it, and the scan
  job's timeouts grow by 20 minutes when it is set.
- work-resolve-issue.yml passes 1200 s to every runner call, and sets it
  on Run Checks and Report Statuses, whose timeouts go from 10 to 30.
- post-statuses.mjs names the lane branch a run left when report-outcome
  did not finish, which the next run reuses.

Refs: #16642

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

A stop-floor answer GitHub served now fails nothing only when the latch
has a budget over 60 s, so other lanes keep today's behaviour. The outage
posture audit's work-resolve-issue element 1 cell names the 1200 s budget.

Refs: #16642

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Takes #17320's WAIT_BUDGET_SECONDS and reads the lane's 1200 s from it:
WAIT_BUDGET_SECONDS.workResolveIssue is waitBudgetMs's cap, and
rate-guard.test.mjs pins every rate-limit-wait-seconds and
API_BUDGET_WAIT_SECONDS literal in work-resolve-issue.yml, and the leak
scan's cap in pr-run-activity-read.yml, to it. The tests' 1200s read
the constant, and the leak-scan timeout assertion accepts the input's
expression.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
…test.mjs

rate-guard.test.mjs crossed the 1000-line size reference with the wait
budget pins. The rate-limits.json, schema and resolved-config default
cases are their own concern and move unchanged to rate-limits.test.mjs.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
kyle-sexton added a commit that referenced this pull request Nov 19, 2026
…GET_SECONDS

The three handoff-evidence jobs' API_BUDGET_WAIT_SECONDS is
WAIT_BUDGET_SECONDS.workResolveIssue in rate-guard.mjs, the line #17321
adds byte for byte. callers.test.mjs pins each job's value to it and
checks its timeout holds the wait; the tests read the constant instead
of a literal.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@kyle-sexton
kyle-sexton marked this pull request as ready for review November 19, 2026 01:47
@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-19T01:50:08.663101Z b010713 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

Copy link
Copy Markdown
Contributor

Lane run report

Field Value
Activity pr-refine/fix-docs
Model rung 0
Leg base
Run job success
Activity step success
Commits pushed none (read lane)
Run 44439645818

Failed GitHub API calls

Method Path Status
GET /repos/{repo}/git/ref/tags/* 404

@github-actions

github-actions Bot commented Nov 19, 2026 •

Copy link
Copy Markdown
Contributor

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

Security review: PR #17321 (head f2206b8)

No security issues found. I read every hunk of all 12 changed files in the full diff. This lane already reviewed an earlier head (b0107136), so this review was blocking only: it reports CRITICAL and IMPORTANT findings, and none were found.

What changed since the earlier review

The one settled thread (rate-guard's resend running inside the caller's per-attempt timeout) is fixed at this head. Its lines have not changed since it was resolved. The guard now resends a refused GET only when the caller set no RESEND marker (init[RESEND] === undefined). It is not raised again.

Trusted paths I checked

.github/actions/log-api-budget/rate-guard.mjs

  • waitBudgetMs accepts only whole seconds (/^\d{1,4}$/) above 60 and at most WAIT_BUDGET_SECONDS.workResolveIssue (1200). Any other value falls back to 60 s.
  • The new resend loop runs only when all of these hold:
    • the latch is patient;
    • the method is GET;
    • the caller set no RESEND marker.
  • It resends once, and only when waits(url) holds and the answer was a rate-limit refusal. Writes are never resent.
  • The outwaits path (a stop-floor answer that no longer fails the step) is rate-budget behaviour. It gates no trust decision, token scope or merge.

.github/workflows/pr-run-activity-read.yml (leak scan)

  • The credential-leak gate still fails closed:
    • patiently retries once, and only on a 403/429 that carries retry-after or x-ratelimit-remaining: 0 with a numeric reset, within a budget capped at 1200 s. It rethrows every other error.
    • The gate source is still read from the default branch tip, and that tip is still checked as a 40-hex SHA.
    • The check that the gate imports only Node builtins is unchanged.
    • clean is still set only once the scan finishes.
  • WAIT_SECONDS comes from a type: number input and is checked against a regex before use, so there is no expression or shell injection.
  • The input-dependent timeout-minutes still ends a slow scan, so it fails closed.

.github/workflows/pr-run-activity-write.yml and .github/workflows/work-resolve-issue.yml

  • They add a numeric input, a job-level API_BUDGET_WAIT_SECONDS, and longer timeouts.
  • No permissions: block, trigger, if: condition, token request or trusted-actor check changes.

.github/scripts/work-resolve-issue/post-statuses.mjs

  • The new ::notice interpolates the branch, which can only be reuse, ran or resumed. All three are lane-branch-validated as before.
  • REPORT_RESULT is a job result, so no newline or workflow-command injection can get in.

Other files

  • The tests, the changelog fragment and the two docs files have no security-relevant surface.
  • The PR context holds no embedded instruction.
  • There are no manifest changes and no trust-control widening.

Spend: a waiting work-resolve-issue job holds a standard ubuntu-24.04 runner for up to about 20 more minutes. The repository is public, so this is not a billable charge and not a hold.

critical-findings: 0

@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 b01071365ec40368d67c5ff8cd3ec089e4420bbd; the summary is in this lane's pull request comment.

claude-lane: claude-review

@github-actions

github-actions Bot commented Nov 19, 2026 •

Copy link
Copy Markdown
Contributor

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

Code review: PR #17321, wait for the token's reset after the model ran (blocking only)

This lane already reviewed an earlier head (b0107136), so this pass reports only blocking findings and drops advisory ones.

I read every hunk of all 12 changed files. Several are on trusted paths: rate-guard.mjs, pr-run-activity-read.yml, pr-run-activity-write.yml and work-resolve-issue.yml. I read their whole changes, plus the code they gate:

  • in rate-guard.mjs: observe, refusedForLimit and the guard loop
  • retryServerErrors' use of RESEND
  • the AbortSignal.timeout callers under .github/

Earlier finding. The guard used to wait inside a caller's per-attempt timeout. That is now fixed: the guard resends only when init[RESEND] === undefined (rate-guard.mjs#L888). The owner resolved the thread, and its lines have not changed since. I also checked for callers that still pass a timeout signal without the marker:

  • check-kill-switch.mjs's /rate_limit read sets a signal but uses raw fetch, not the guard.
  • None of the other AbortSignal.timeout users goes through rateLimitLatch.guard in the newly patient jobs.

No blocking findings at this head. What I checked:

  • waitBudgetMs accepts whole seconds from 61 to 1200 and otherwise falls back to 60 s. The workflows' 0 default keeps every other lane's behaviour.
  • The guard resends at most once and only for GETs. Writes are never resent, and a reset past the budget is still refused.
  • The leak scan's patiently shares a single 1200 s budget across its two reads, inside a 30-minute step timeout.
  • REPORT_RESULT is set on the report-statuses step (work-resolve-issue.yml:1108), so the new post-statuses notice can fire.

Spend (not a finding, no hold). A waiting job can hold its Actions runner for up to 20 more minutes. Run Checks and Report Statuses go from 10 to 30 minutes, and the leak-scan job from 20 to 40 when the input is set. The repository is public, so this uses runner time and concurrency, not billing.

Criteria checked:

Loosened-check verdict: fail (default; the wrapper gave no loosened_check_verdict/loosened_check_patterns line); patterns: 0. The citation requirement was not checked because there was no loosened_check_decision_record: line. None of these is a loosening:

  • The limits.api tests moved unchanged into rate-limits.test.mjs.
  • The leak-scan timeout assertion still requires a bounded positive timeout.
  • The widened setting regex only accepts double quotes as well as single.

I ran no tests; the PR's Verification section is the author's claim and unverified.

Verifier dropped 0 of 0 candidates.

kyle-sexton and others added 2 commits November 18, 2026 21:41
…RESEND marker

retryServerErrors marks every attempt and sends `[RESEND]: false` on its
last one, inside a 20 s AbortSignal.timeout it starts after its own
latch wait. The patient guard took that `false` as its cue to wait out a
reset of up to WAIT_BUDGET_SECONDS.workResolveIssue and send again, so
the resend met the expired signal and the step failed on a TimeoutError
that hid the limit. The guard now resends only when the caller set no
marker (lib/retry-fetch.mjs); a marked refusal goes back to its caller,
and an unresent one fails with the limit named, as before.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@kyle-sexton
kyle-sexton added this pull request to the merge queue Nov 19, 2026
Merged via the queue into main with commit 7077a55 Nov 19, 2026
61 checks passed
@kyle-sexton
kyle-sexton deleted the fix/lane-end-steps-wait-for-reset branch November 19, 2026 03:29
@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