Skip to content

fix(pr-pipeline): cap lane API calls at 3 attempts and wait out rate limits ( 9205 slice 3, part 2) - #12350

Merged
kyle-sexton merged 1 commit into
mainfrom
work-resolve-issue/issue-12292-41423803436-1
Nov 2, 2026
Merged

kyle-sexton merged 1 commit into
mainfrom
work-resolve-issue/issue-12292-41423803436-1

Conversation

@melodic-automation-lanes

Copy link
Copy Markdown
Contributor

Refs: #12292

Summary

Opened by the work-resolve-issue lane. The run's own summary:

This fixes the element 1 (retry) script gaps from the outage-posture audit in docs/outage-posture-audit.md, each with a test. The shared client (retryServerErrors under createGitHub and budgetedFetch) now sends a read at most 3 times with full jitter. enable-auto-merge's withRetry resends only GraphQL mutations, so a query goes out at most 3 times, not 12. retry-fetch.mjs (3 identical copies) waits out a rate limit before resending: retry-after, else the x-ratelimit-reset, else 60 s for a secondary limit. Those waits stay within 60 s per client, and a fetch the rate guard already wraps is left to the guard. report-escalation.sh posts its non-idempotent comment once. The other script gaps in the audit are listed in remaining; the work-unblock element 2 fix turned out not to be script-only (see not_done).

Remaining work

  • shared, elements 1 and 2: .github/actions/log-api-budget/rate-guard.mjs: wait out a short reset instead of refusing every call, and hold instead of failing the step
  • shared, element 2: .github/actions/log-api-budget/api-budget.bash: print a notice instead of ::error:: when the caller holds green
  • work-resolve-issue, elements 1, 2 and 4: .github/scripts/work-resolve-issue/report-outcome.mjs (--find-prior goes red on a failed read; the PR create is sent again after a network error and a read-back) and stop-routes.json (retry-spent fails the issue even when every retry was a fault)
  • work-resolve-issue and pr-refine, elements 1, 2 and 6: .github/scripts/lib/handoff-evidence.sh: etag on the repeated paginated job-listing poll, jittered waits, and a green hold instead of exit 1
  • intake-triage, elements 2 and 4: .github/scripts/intake-triage/apply-verdict.mjs and admit.mjs: hold green on a read error (the lane has no cron, so it needs a re-trigger) and do not treat a failed visibility read as private
  • work-unblock, elements 2, 3 and 6: .github/scripts/work-unblock/label-unblocked.mjs: hold green on a failed sweep listing together with a sweepSince window that does not start after a held run; breaker-trip records; sweep etag
  • pr-refine, elements 3 and 4: .github/scripts/pr-unblock/fix-docs-dispatch.mjs (counts a red outage run as done) and .github/actions/report-check-run/decide.mjs (a no-verdict run posts a failure nothing closes)
  • pr-review, pr-review-security and pr-verify, elements 3 and 5: .github/scripts/maintenance-reconcile-lost-runs/reconcile.mjs: recorded one-time re-run gated on the status page
  • pr-verify, elements 2 and 6: .github/scripts/pr-verify/resolve-pr.mjs (completeness throws set exitCode 1) and the re-run record poll in check-trusted-trigger.mjs without etag
  • pr-unblock, elements 1, 2, 3, 4 and 6: .github/scripts/pr-unblock/request-budget.mjs (a rate-limited POST is sent again; waits up to 6 minutes), dispatch.mjs (a non-5xx read failure exits 1), limit-stop.mjs (per-head cap acts as a stored breaker), escalation-routes.json (a job fault files a fail rou
  • pr-merge, elements 1 and 2: .github/scripts/pr-merge/enable-auto-merge.mjs (a listing at the limit throws red) and .github/actions/request-lane-token/action.yml (sleeps up to 480 s)

Not verified

  • The node and bash test suites (check-trusted-trigger.test.mjs, retry-fetch.test.mjs, request-budget.test.mjs, dispatch.test.mjs, report-escalation.test.sh, enable-auto-merge.test.mjs) were not run: this lane cannot run node or the test scripts. Expected values were traced by hand and by the review s
  • Tidy skipped: the change touches the shared path .github/ and 13 files across 3 areas, over the tidy cutoffs (10 files, 1 area).
  • typos not installed here (check-affected skipped it); the CI-only scanners check-affected lists (line-citations, purged-em-dashes, lychee and others) are left to the PR's CI.
  • The work-unblock element 2 gap (a failed sweep listing exits 1) is not a script-only fix. sweepSince starts the next window at the last successful sweep, so holding this run green would make the next sweep skip the closes this run missed. The fix also has to change how the window is chosen. This is
  • The intake-triage element 2 gap (exitCode 1 on a read error) was not changed. The lane has no cron, so holding green would leave nothing to retry the issue. That fix needs a re-trigger and is listed in remaining.
  • The handoff-evidence.sh etag gap (element 6) was not fixed: the read is a paginated gh api --paginate, so conditional requests need per-page etag handling. Listed in remaining.

Fix

  • .github/actions/check-trusted-trigger/check-trusted-trigger.mjs: SERVER_RETRY_DELAYS_MS goes from [2000, 4000, 8000] to [2000, 4000], so a read gets at most 3 attempts; equal jitter becomes full jitter (random share of the delay); header comment updated.
  • .github/actions/check-trusted-trigger/check-trusted-trigger.test.mjs: attempt counts, waits and the 60 s budget tests updated for 3 attempts and full jitter; new full-jitter test; the withRetry test now expects 3 sends for a query.
  • .github/scripts/work-resolve-issue/retry-fetch.mjs (and identical copies in .github/scripts/apply-patch/ and .github/scripts/pr-unblock/): new exported rateLimitWait. A resendable request refused with a 403 or 429 rate limit waits for retry-after, else the reset when remaining is 0, else 60 s for a
  • .github/scripts/work-resolve-issue/retry-fetch.test.mjs: five new tests: the waits for retry-after, reset and secondary limits; a non-limit 403 and a non-resendable write returned at once; the 60 s budget; the 3-attempt cap shared with 5xx retries; a counted fetch left to the rate guard.
  • .github/scripts/pr-merge/enable-auto-merge.mjs: withRetry resends only a GraphQL mutation that fails on the network; queries are left to the client's own retry. Comments updated.
  • .github/scripts/pr-unblock/report-escalation.sh: the escalation and lane-stopped comment POSTs go out once instead of up to 3 times with sleeps; header comment updated.
  • .github/scripts/pr-unblock/report-escalation.test.sh: the comment-failure cases now expect one POST, no back-off and exit 1; the next-run recovery cases are unchanged.
  • .github/scripts/pr-unblock/request-budget.test.mjs: budgetedFetch's 5xx resend tests updated for 3 attempts and full jitter.
  • .github/scripts/pr-unblock/dispatch.test.mjs: a history read that keeps answering 502 now expects 3 sends, not 4.
  • docs/outage-posture-audit.md: the Remaining section records what part 2 fixed, narrows the shared, work-resolve-issue, pr-unblock and pr-merge script rows to what is still open, and records the work-unblock sweep-window finding.
  • .changes/pr-pipeline/work-resolve-issue-issue-12292-41423803436-1-da054bf7.md: new patch changelog fragment for the pr-pipeline convention.

Verification

The runner ran each check from the base copy against 0086caa:

  • scripts/check-changelog-fragments.sh --check: passed
  • scripts/check-changed-skills.sh --merge-base: passed

The run reports:

  • read https: //docs.github.com/en/rest/using-the-rest-api/best-practices-for-using-the-rest-api: when retry-after is present, wait that many seconds; when x-ratelimit-remaining is 0, wait until x-ratelimit-reset (UTC epoch seconds); otherwise wait at least one minute for a secondary limit, then back
  • read https: //docs.github.com/en/rest/using-the-rest-api/rate-limits-for-the-rest-api: primary and secondary limits both answer 403 or 429; a primary limit sets x-ratelimit-remaining to 0; a secondary limit's message says you exceeded a secondary rate limit.
  • check-changelog-fragments: all 60 fragments valid.
  • check-changed-skills: no changed skills, nothing to gate.
  • check-affected: 11 passed, 4 skipped (ruff: no .py; typos: not installed; validate-plugins and changed-skills: no plugin or skill changed) over 13 changed files.
  • cant-fail-scan --check on check-trusted-trigger.test.mjs, retry-fetch.test.mjs, request-budget.test.mjs and dispatch.test.mjs: PASS, no findings. On report-escalation.test.sh: PASS, with one advisory zero-assertion finding from the bash-harness adapter that was already there before this change.
  • Local review in a fresh-context subagent (review-venue.txt absent): every changed expectation traced correctly. Its confirmed findings were fixed: a stale 4-send assertion in dispatch.test.mjs; retry-fetch stacking its rate-limit wait on budgetedFetch's and the rate latch's own, so a counted fetch i
  • Diff stat: the three retry-fetch.mjs copies were written from one content and show identical stats (50 lines changed each).
  • The lane run: https://github.com/melodic-software/claude-code-plugins/actions/runs/41423803436

Left out: the items under Not verified.

Related

#12292

Lane-Activity: work-resolve-issue/resolve-issue
@github-actions

github-actions Bot commented Nov 2, 2026

Copy link
Copy Markdown
Contributor

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

Security review: PR #12350 (head 0086caa)

No security issues found.

critical-findings: 0

I read all 13 changed files in .claude-lane/pr.diff and checked them against the PR description. Five of them match trusted paths, so I read each one's whole change and what it gates:

  • .github/actions/check-trusted-trigger/check-trusted-trigger.mjs
    • What changed: SERVER_RETRY_DELAYS_MS goes from [2000, 4000, 8000] to [2000, 4000], and the jitter changes from equal to full (Math.round(random() * delay)).
    • What I checked: Only the timing and number of resends change. The rules for which requests can be resent are the same: idempotent, mutations sent once, the 60 s budget. Nothing in this hunk touches the trusted-actor read or the trust decision, so this does not widen who passes the trusted-trigger check.
  • .github/scripts/pr-merge/enable-auto-merge.mjs (merge-hold file)
    • What changed: withRetry now resends only a GraphQL request whose query matches \bmutation\b, which covers ARM_MUTATION and DISARM_MUTATION at L312/L317. Queries are left to createGitHub's own 3 attempts.
    • What I checked: No hold rule, arm condition or disarm condition changes. A read that still fails takes the same error path as before, only after fewer resends. No merge hold is weakened.
  • .github/scripts/{apply-patch,pr-unblock,work-resolve-issue}/retry-fetch.mjs
    • What changed: A new rateLimitWait resends a 403/429 rate-limit response, but only for requests that were already resendable (resend). A non-resendable write still goes out once.
    • What I checked:
      • Rate-limit waits are capped at 60 s per wrapper.
      • A fetch already marked api-budget.counted is skipped.
      • Response bodies are read only through clone(), and nothing new is logged: the retry line still prints only method, URL and status.
      • No token or header values are exposed.
  • .github/scripts/pr-unblock/report-escalation.sh
    • What changed: The escalation and lane-stopped comment POSTs go out once instead of three times. On failure the script still calls die, and the label is still written before the comment.
    • What I checked: The escalation hold (the label) is unchanged. No interpolation or command-injection surface was added.

The test files, docs/outage-posture-audit.md and the changelog fragment change no runtime behaviour.

Embedded text: I found no instructions in the PR description or linked issue text aimed at this lane.

Spend: Rate-limit resends can add up to 60 s of runner time per client. That draws on prepaid Actions/API usage, so it is not a hold.

@github-actions

github-actions Bot commented Nov 2, 2026

Copy link
Copy Markdown
Contributor

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

Code review: PR #12350 (outage posture element 1, part 2)

No findings. I read every hunk of all 13 changed files. I also read the code around the changes in check-trusted-trigger.mjs (retryServerErrors, graphqlQuery) and enable-auto-merge.mjs (withRetry, transient), plus the existing tests that touch them.

What I checked

  • Shared client (retryServerErrors). With SERVER_RETRY_DELAYS_MS = [2000, 4000] and full jitter, a read gets at most 3 attempts. I traced each changed test expectation against the loop:
    • spent counts failed attempt time plus the waits, so the 60 s budget test gives 10×(2+4) s = 60 s, and the eleventh call stops after its first send (10 * 3 + 1 sends).
    • The 28 s-per-attempt test gives 28 + 2 + 28 = 58 s; the next 4 s wait would reach 62 s, so it raises after 2 sends.
    • The header's "about 46 s" (2×20 s attempts + 2 s + 4 s) is correct.
  • enable-auto-merge withRetry. It now resends only bodies matching \bmutation\b. Every query the script defines (PULLS_QUERY, DETAIL_QUERY, THREAD_PAGE_QUERY, AUTO_MERGE_STATE_QUERY, UNLABELED_QUERY) starts with query, sends no operationName and contains no mutation/subscription word. So graphqlQuery in the shared client treats each as idempotent, and none loses its retry. The arm and disarm resend tests in enable-auto-merge.test.mjs (for example the [4000, 8000] jitter case) still hold. No test there relies on a query being resent by withRetry.
  • retry-fetch.mjs rateLimitWait.
    • A rate-limited answer counts toward the same 3 attempts. The last attempt skips the check because cap === undefined.
    • A wait that would take the per-wrapper total past 60 s returns the answer, and a non-limit 403 is still returned at once.
    • The counted marker is set by countsRequests before retryFetch wraps the fetch (request-budget.mjs:130, rate-guard.mjs:345/600), so reading it once when the wrapper is built is safe.
    • The three copies are byte-identical, which the existing copy-equality test enforces.
  • report-escalation.sh. Both comment POSTs go out once and die on failure. The test stub's setup makes a new $STUB for each case, so the new "no back-off" check reads that case's own sleeps file. The next-run recovery cases are unchanged.
  • Changelog fragment and the audit doc's Remaining section match the code.

Not verified

I could not run the node or bash test suites in this lane. The PR body says the author's lane couldn't run them either. The expectations above were traced by hand, not executed.

Scope notes

  • Closing issue. The PR body says Refs: #12292, not a closing reference, and the context file has no closing-issue section, so I checked no acceptance criteria.
  • Path rules. Of the .claude/rules/ files, only cost-claims.md matches a changed file (docs/outage-posture-audit.md). That doc makes no cost claims.
  • Paved paths. The standards index has no paved-path row.
  • Security. A security lane runs here, so security findings are left to it.
  • Spend. No new spend. Fewer resends mean fewer API calls; the added rate-limit waits use at most 60 s of runner time per client.

@melodic-automation-lanes

Copy link
Copy Markdown
Contributor Author

Unattended merge: native auto-merge leaves this pull request unarmed at head 0086caa2f4628c7dff1b3ccdae26d9d5009c4cc8. The lanes clear this reason on their own; the next scheduled run judges it again.

pr-merge's gate refuses its verifier verdict (verify:missing)

@kyle-sexton
kyle-sexton added this pull request to the merge queue Nov 2, 2026
Merged via the queue into main with commit fbf9020 Nov 2, 2026
49 checks passed
@kyle-sexton
kyle-sexton deleted the work-resolve-issue/issue-12292-41423803436-1 branch November 2, 2026 10:43
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