Skip to content

fix(work-resolve-issue): wait out the rate limit in handoff-evidence reads - #17324

Merged
kyle-sexton merged 6 commits into
mainfrom
fix/handoff-evidence-wait-reset
Nov 19, 2026
Merged

kyle-sexton merged 6 commits into
mainfrom
fix/handoff-evidence-wait-reset

Conversation

@kyle-sexton

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

Copy link
Copy Markdown
Member

Refs: #16642

Summary

The issue lane's handoff jobs failed with "handoff evidence for resolve-issue-subscription still missing after 6 reads: the jobs read failed" whenever the GITHUB_TOKEN pool was empty. That ended 26 issue-lane runs on 2026-11-18 and 14 on 2026-11-17. The local causes page classed every one as a defect, because the message never said "rate limit".

Cause, the same in runs 44324786543, 44169091894, 42976995398 and 42706696627:

  1. Read 1 got GitHub's 403: "hit GitHub's core API rate limit: no call to it before 15:46:29Z", 14 minutes away.
  2. The bash rate guard refused reads 2 to 6 without sending them ("was not sent").
  3. handoff-evidence.sh counted each refusal as a failed read (max_failed=6), so the job gave up 2.0 to 2.4 minutes into the window.

The reads could not succeed before the reset, and nothing waited for it.

Fix

  • handoff-evidence.sh:
    • A read the rate guard refuses names the reset in its message: "the jobs read failed: GitHub's core API rate limit holds until ". A server-error hold names its HTTP status instead.
    • A step that sets API_BUDGET_WAIT_SECONDS waits for the reset once, through rate-guard.mjs's existing waitOut, then reads again, and that read does not count as failed.
    • The reads end at once only when the reset is past both the guard's budget and what is left of the reads' window. A reset the old jittered reads could outlast still gets them.
    • Callers that do not set the variable keep today's timing.
  • work-resolve-issue.yml: the steps in resolve-issue-handoff, resolve-issue-subscription-handoff and resolve-issue-stale set API_BUDGET_WAIT_SECONDS: "1200", and those jobs' timeouts go from 10 to 30 minutes to hold the wait. The credit-stop read is continue-on-error and never fails the run, so it is unchanged.
  • label-unblocked.mjs: work-unblock re-fires these runs after the reset by reading the handoff error as a rate-limit companion line (LIMIT_COMPANION). That pattern now also accepts the line with the rate-limit suffix, so the re-fire keeps working.

The wait depends on the in-flight rate-guard work. On main, waitOut's budget is a fixed 60 s. The 1200 s budget comes from API_BUDGET_WAIT_SECONDS in the end-of-run wait change (branch fix/lane-end-steps-wait-for-reset) and the budget source in #17320. Until those merge, this PR does two things:

  • Each of these failures names the rate limit.
  • A reset past the read window ends the job at read 1, instead of after about 2 minutes of reads the guard refuses.

Verification

  • node --test on handoff-evidence.test.mjs, label-unblocked.test.mjs, callers.test.mjs, signals.test.mjs and collect.test.mjs: 920 pass, 0 fail. New cases:
    • A reset 2 s away waits through waitOut, then reads again and writes posted=true.
    • A reset 90 s away, past the 60 s budget but inside the read window, keeps reading.
    • A reset 3000 s away ends after one read, with an error naming the core API rate limit.
    • The new error line is still a floor stop for work-unblock.
  • The local causes-page classifier classify() returns defect for the old line and infra for both new lines.
  • scripts/check-affected.sh --tests --uncommitted: 14 passed, 122 skipped. The pre-push check-affected also passed.

Related

🤖 Generated with Claude Code

kyle-sexton and others added 4 commits November 18, 2026 19:26
…reads

The issue lane's handoff jobs failed with "handoff evidence ... still
missing after 6 reads: the jobs read failed" when the GITHUB_TOKEN pool
was empty (runs 44324786543, 44169091894, 42976995398, 42706696627). The
first read got GitHub's 403, the rate guard then refused reads 2-6 without
sending them, and each refusal counted as a failed read, so the job gave
up about two minutes into a reset up to an hour away. The message named no
rate limit, so the causes page classed all of them as defects.

- handoff-evidence.sh: a read the rate guard refuses names the pool's
  reset in its message. A step that sets API_BUDGET_WAIT_SECONDS waits for
  the reset once through rate-guard.mjs's waitOut and reads again; a reset
  past the guard's budget ends the reads at once. Other callers keep their
  timing.
- work-resolve-issue.yml: the four handoff-evidence steps set
  API_BUDGET_WAIT_SECONDS to 1200, and their jobs' timeouts grow by
  20 minutes to hold the wait.

Refs: #16642

Co-Authored-By: Claude Opus 5.5 <[email protected]>
…doff error

work-unblock's floor reading (label-unblocked.mjs LIMIT_COMPANION) matched
the handoff error only as it ended at "the jobs read failed", so the
rate-limit suffix would have stopped it re-firing these runs after the
reset. It now takes the suffix too.

handoff-evidence.sh ends the reads early only when the reset is past both
the guard's wait budget and what is left of the reads' window, so a reset
the old jittered reads could outlast still gets them. The credit-stop
read is continue-on-error and never fails the run, so it takes no wait.

Refs: #16642

Co-Authored-By: Claude Opus 5.5 <[email protected]>
…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:51
@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:54:26.218284Z dc96528 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 c8c6ff439d02cdb3f9c2ea745ea94b5b87b42f3a: read 6 of 6 changed file(s); 0 finding(s), 0 as inline comments.

Security review: no security issues found

I read all 6 changed files in full from .claude-lane/pr.diff. This lane already reviewed an earlier head (dc96528e), so this review covers blocking findings only. The one prior entry is a summary with no findings, and nothing from it carries over.

Since the last review: the inline node --input-type=module -e snippet in handoff-evidence.sh now exits 3 when latch.waits(url) is false, and waited_out=1 is set only after that call succeeds. This fixes the settled thread on handoff-evidence.sh. Main was also merged in, so rate-guard.mjs no longer appears in the diff. Both settled threads are marked lines changed since resolution: no, and I'm not raising either again.

Trust-path and control checks:

  • work-resolve-issue.yml (trusted path):
    • What changed: the three handoff and stale jobs add API_BUDGET_WAIT_SECONDS: "1200", and their timeout-minutes go from 10 to 30.
    • Unchanged: the permissions: blocks (actions: read, contents: read), GH_TOKEN: ${{ github.token }}, and the jobs' if: conditions. The script still runs from the .base/ default-branch checkout.
    • Result: no token scope, trusted actor or kill switch is widened.
  • handoff-evidence.sh:
    • Inputs to the node call: the module path (realpath of a sibling path in .base/) and the jobs URL arrive as positional process.argv values, not as text inside the script. The URL is built only from the runner-set GITHUB_REPOSITORY and GITHUB_RUN_ID.
    • Messages: held_by echoes only the guard's own stop time and HTTP status.
    • Result: no injection surface and no untrusted text.
  • label-unblocked.mjs:
    • What changed: LIMIT_COMPANION now also accepts an optional : GitHub.* suffix after the existing timestamped ##[error]handoff evidence … the jobs read failed line.
    • What a match decides: only whether work-unblock re-fires a run after the reset. It grants no trust, token or merge decision.
  • Tests (callers.test.mjs, handoff-evidence.test.mjs, label-unblocked.test.mjs): assertions only, plus a node shim confined to the test.

The diff doesn't touch any of the owner's named friction holds, and no plugin manifest changed.

Spend: the three handoff and stale jobs can now run up to 30 minutes instead of 10 on the standard ubuntu-24.04 runners already in use, so they can wait out a rate-limit reset. That only means longer runs; it isn't a billing change.

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

claude-lane: claude-review

Comment thread .github/scripts/lib/handoff-evidence.sh Resolved
@github-actions

github-actions Bot commented Nov 19, 2026 •

Copy link
Copy Markdown
Contributor

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

Code review: PR #17324, wait out the rate limit in handoff-evidence reads (blocking only)

This lane already reviewed an earlier head (dc96528e), so this pass reports blocking findings only. I read every hunk of all 6 changed files in .claude-lane/pr.diff. I also read the unchanged code the new lines call:

  • rate-guard.mjs: createRateLimitLatch, waits and waitOut, waitBudgetMs, STOP_FILE
  • api-budget.bash: api_budget_stop_until, api_budget_server_status, api_budget_when
  • the .base sparse checkouts in work-resolve-issue.yml

No blocking findings.

Both earlier findings are fixed on this head:

  • The wait is spent only when it waits. At handoff-evidence.sh L234-L237, the node call exits 3 when latch.waits(url) is false. waited_out is set only when the call succeeds. The new 90 s test checks that read 2 tries the wait again by counting latch calls.
  • The rate-guard.mjs doc entry now matches the code. That file is no longer in this diff. waitBudgetMs reads API_BUDGET_WAIT_SECONDS and caps it at WAIT_BUDGET_SECONDS.workResolveIssue (1200), so the workflow's "1200" now sets the latch budget.

Other checks:

  • The guard loads in the jobs. All three handoff jobs sparse-check-out .github/actions/log-api-budget. rate-guard.mjs imports only node: built-ins, so $rate_guard resolves and loads from .base.
  • Node and bash agree on the stop file. Both read $RUNNER_TEMP/api-budget/stop, so waitOut waits for the same stop the bash guard wrote.
  • The wait fits the timeout. 30 min = 1800 s, which covers the 1200 s wait plus the 315 s jitter window.
  • The early break holds when no stop is listed. If the stop has expired or is not listed, stop is empty, the ${stop:-0} check passes, and the loop goes on reading.
  • work-unblock still re-fires these runs. The widened LIMIT_COMPANION pattern still ends at $, accepts the new : GitHub… suffix, and the new test confirms the line is still a floor stop.

Closing issue: the PR only says Refs: #16642. It closes no issue, so there are no acceptance criteria to check.

Path-scoped rules / paved paths: no .claude/rules/ glob matches a changed file. There is no paved-path row to apply.

Loosened-check verdict: pass. No check is loosened: the callers.test.mjs expectation is stricter, since it now also requires API_BUDGET_WAIT_SECONDS and checks the timeouts. The prompt had no loosened_check_verdict: or loosened_check_patterns: line, so I used fail with no consumer entries. It had no loosened_check_decision_record: line, so I did not check the citation requirement.

Verification: I ran nothing. The test counts in the PR body and the owner's replies (920 and 939 pass) are author-claimed and unverified.

Spend (not a hold): the three handoff jobs' timeout-minutes go from 10 to 30. At worst that is about 20 more minutes of standard GitHub-hosted runner time per job while a reset is waited out. No paid plan, larger runner or billing setting changes.

I checked the candidates against the source myself and dispatched no separate verifier.

Verifier dropped 0 of 0 candidates.

@melodic-automation-lanes melodic-automation-lanes Bot added the needs-session A pr-unblock stop a session builder takes: a change the lane cannot make. Not an owner stop. label Nov 19, 2026
@melodic-automation-lanes

Copy link
Copy Markdown
Contributor

The pr-unblock lane stopped address-feedback on this pull request: the pull request changes .github/workflows/, which the lane token cannot push, so the lane does not address its review threads. The lane labels it needs-session for a session builder, who makes the change this lane cannot, and the run ends in a failing pr-unblock/address-feedback status on the head the lane gated.

When a retry on this head can change the outcome, the lane runs one on its own, up to its per-head cap, and edits this comment if it stops again; a run that does not stop clears the status. When no retry can (a review thread the lane does not take or settle, or a failing check after the retries are spent), a person resolves the threads or gets the checks green, then dispatches the workflow below: that run finds the cause gone and clears the status. On a pull request the lanes App opened, the dispatchers start that run once per stop; on any other, a person does. A new commit to the branch starts clean.

To run it again on this head now, dispatch the pr-unblock workflow:

gh workflow run pr-unblock.yml -R melodic-software/claude-code-plugins -f pr-number=17324 -f activity=address-feedback

@github-actions

Copy link
Copy Markdown
Contributor

Lane run report

Field Value
Activity pr-unblock/report-escalation
Model rung 0
Leg base
Run job success
Activity step success
Commits pushed none recorded
Run 44457786197

Failed GitHub API calls

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

kyle-sexton and others added 2 commits November 19, 2026 00:16
…it waits

waitOut returns at once when the reset does not fit the latch's budget,
but waited_out was set before the call, so a reset just past the budget at
read 1 used up the only wait and a later read, whose reset now fit, never
waited. The node call now exits 3 when the latch would not wait, and
waited_out is set only after a wait ran, so each later refused read tries
again. The test records each latch call through a node wrapper.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@kyle-sexton
kyle-sexton added this pull request to the merge queue Nov 19, 2026
@melodic-automation-lanes melodic-automation-lanes Bot removed the needs-session A pr-unblock stop a session builder takes: a change the lane cannot make. Not an owner stop. label Nov 19, 2026
Merged via the queue into main with commit 1a9ac29 Nov 19, 2026
85 checks passed
@kyle-sexton
kyle-sexton deleted the fix/handoff-evidence-wait-reset branch November 19, 2026 05:52
@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