Repository navigation
Clarify daily AIC restore quota blocks and recovery guidance - #76433
Conversation
Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
|
Category: bug | Risk: medium | Score: 56/100 (impact 28 + urgency 16 + quality 12) | Recommended action: batch_review | Notes: operational recovery guidance for quota exhaustion; medium impact, moderate urgency, and clear narrative but not a direct functional blocker.
|
1 similar comment
|
Category: bug | Risk: medium | Score: 56/100 (impact 28 + urgency 16 + quality 12) | Recommended action: batch_review | Notes: operational recovery guidance for quota exhaustion; medium impact, moderate urgency, and clear narrative but not a direct functional blocker.
|
|
Category: bug | Risk: medium | Score: 56/100 (impact 28 + urgency 16 + quality 12) | Recommended action: batch_review | Notes: operational recovery guidance for quota exhaustion; medium impact and good clarity but not a direct blocker.
|
1 similar comment
|
Category: bug | Risk: medium | Score: 56/100 (impact 28 + urgency 16 + quality 12) | Recommended action: batch_review | Notes: operational recovery guidance for quota exhaustion; medium impact and good clarity but not a direct blocker.
|
|
✅ PR Code Quality Reviewer completed the code quality review.
|
|
🧠 Matt Pocock Skills Reviewer has completed the skills-based review. ✅
|
|
✅ Design Decision Gate 🏗️ completed the design decision gate check. See the comment below for the result and any generated ADR draft. Design Decision Gate 🏗️Outcome: The agent completed and reported no action. A no-op output alone does not verify that all required work was completed or that publication was possible. Agent messages are omitted from this comment. The category uses structured run status, not interpretation of agent prose.
|
|
✅ Ponytail Reviewer completed successfully! Ponytail ReviewerOutcome: The agent completed and reported no action. A no-op output alone does not verify that all required work was completed or that publication was possible. Agent messages are omitted from this comment. The category uses structured run status, not interpretation of agent prose.
|
|
✅ Test Quality Sentinel completed test quality analysis. Test Quality SentinelOutcome: The agent completed and reported no action. A no-op output alone does not verify that all required work was completed or that publication was possible. Agent messages are omitted from this comment. The category uses structured run status, not interpretation of agent prose.
|
|
✅ PR Specification Reviewer completed successfully! PR Specification ReviewerOutcome: The agent completed and reported no action. A no-op output alone does not verify that all required work was completed or that publication was possible. Agent messages are omitted from this comment. The category uses structured run status, not interpretation of agent prose.
|
There was a problem hiding this comment.
Reviewed the changed restore diagnostics, quota deadline propagation, tests, and operator documentation. I found no actionable correctness, security, or performance issues in the changed lines. The specialist pass completed; its speculative findings were not actionable or were contradicted by the inspected code. Static review only; tests were not run per review instructions.
🔎 Code quality review by PR Code Quality Reviewer · copilot · gpt50 · ~2 AIC · ⌖ ~1 AIC · ⊞ 1.5K
Comment /review to run again
There was a problem hiding this comment.
🟡 Changes recommended
The quota-recovery message and matching cost-management guidance misleadingly imply discovery never started, even though an earlier restore attempt may already have queried history or artifacts.
1 open issue
What changed in this PR
This PR improves daily AIC restore diagnostics and recovery guidance when shared GitHub API quota blocks activation, while preserving fail-closed behavior.
Changes:
- Report the failed operation, restore response count, discovery status, and retry deadline.
- Expose retry deadlines from wrapped API failures and expand diagnostic tests.
- Document credential tracing, concurrent quota consumers, and post-reset recovery checks.
| File | Description |
|---|---|
docs/src/content/docs/reference/cost-management.md |
Adds quota investigation and recovery guidance. |
actions/setup/js/restore_aic_scan_cache.cjs |
Expands blocked-restore summaries and retry guidance. |
actions/setup/js/github_api_diagnostics.test.cjs |
Checks the structured retry deadline. |
actions/setup/js/github_api_diagnostics.cjs |
Exposes retryNotBefore in diagnostics. |
actions/setup/js/daily_aic_scan.test.cjs |
Covers restore summaries, safe deadlines, and restricted reads. |
Review effort: Balanced (auto)
| const message = `Daily AIC snapshot restore stopped at ${failure.operation} after ${failure.attempts} attempt(s): ${detail}. Accounting remains unverified; agent startup is blocked.`; | ||
| core.info(`[daily-aic-cache] ${message}`); | ||
| const stage = `Activation stage: Restore daily AIC scan observations. API responses observed by this restore: ${budget.snapshot().requests}; shared quota used is not this step's request count.`; | ||
| const discovery = failure.operation === API_READ_OPERATIONS.CURRENT_RUN ? "Snapshot discovery has not started; cache reuse has not been evaluated." : "Snapshot restoration did not complete; a cache miss has not been established."; |
There was a problem hiding this comment.
Skills-Based Review 🧠
Applied /diagnosing-bugs, /tdd, and /grill-with-docs (triage: mixed change, skills selected by pr-triage). Requesting changes on one confirmed behavior mismatch.
📋 Key Themes & Highlights
Key Themes
- Deadline mismatch: The operator summary (
restore_aic_scan_cache.cjs:139) and the recovery sleep (withQuotaResetRecovery) use different deadlines for a secondary-limit stop above the reserve. The summary can tell operators to wait for an hour-away core reset while recovery resumes after about 60s. I reproduced this by running the real modules directly withnode. - Test gap: The new
it.eachmatrix only covers cases where both paths agree. The divergent case (remaining>0withRetry-After) is untested. - Docs conflict:
cost-management.mdsays "earliest retry deadline" at line 298, but the code computes a max ("at least" / "later of").
Positive Highlights
- ✅ Clear separation of the summary from the recovery path, which makes the change easier to follow
- ✅
retryNotBeforeis exposed from the diagnostics helper, and its existing test expectation is updated - ✅ Stage text correctly distinguishes this restore's API response count from shared quota use
Verification Limits
Vitest could not run in this environment because npm ci failed on a sandbox TLS certificate error. I did not disable TLS verification. Findings come from direct node probes of the changed modules and from reading the diff. Please run actions/setup/js tests in CI to confirm the suggested test row.
@copilot please address the review comments above.
🧠 Reviewed using Matt Pocock's skills by Matt Pocock Skills Reviewer · copilot · routed: haiku55 xhigh · ~8 AIC · ⌖ ~2 AIC · ⊞ 6.6K
Comment /matt to run again
| } catch (error) { | ||
| const diagnostic = getGitHubAPIDiagnostic(error); | ||
| const failure = getAPIReadFailure(error); | ||
| const retryAt = diagnostic?.retryNotBefore || retryNotBefore(error?.response?.headers, Date.now(), isQuotaError(error)); |
There was a problem hiding this comment.
[/diagnosing-bugs] The summary and the recovery path compute different deadlines for the same error. Line 139 uses diagnostic.retryNotBefore, which includes the core reset whenever the error is a DAILY_AIC_QUOTA_STOP. withQuotaResetRecovery uses retryNotBefore(headers, now, RESERVE_STOPS.has(error)), which drops the reset for secondary-limit stops above the reserve. With remaining=4000, Retry-After: 120, and a reset at 10:15:00Z, the operator summary says blocked until 10:15:00Z, but recovery acts on 10:06:13Z.
💡 Suggested fix
Use one deadline source for both the summary and recovery. For example, export a helper from daily_aic_api_budget.cjs that returns the deadline recovery acts on, and call it here instead of diagnostic?.retryNotBefore. The logged deadline should always be the one the code actually uses.
@copilot please address this.
There was a problem hiding this comment.
Fixed in 757a4ca: recovery and the restore summary now use the same diagnostic deadline, backed by the genuine reserve-stop signal. Secondary limits above reserve no longer inherit the primary reset.
| ? `resource=${resource}; remaining=${remaining ?? "unknown"}; limit=${limit ?? "unknown"}; used=${used ?? "unknown"}; reset=${reset || "unknown"}; retry_not_before=${retryNotBefore || "unknown"}${quotaStopped && accessFailure ? "; quota reserve guard also stopped further reads" : ""}` | ||
| : "Check the credential's access to this operation; quota exhaustion was not established."; | ||
| return { quota, classification, message: `GitHub API ${classification} (HTTP ${status >= 100 && status <= 599 && Number.isInteger(status) ? status : "unknown"}; ${details})` }; | ||
| return { quota, classification, retryNotBefore, message: `GitHub API ${classification} (HTTP ${status >= 100 && status <= 599 && Number.isInteger(status) ? status : "unknown"}; ${details})` }; |
There was a problem hiding this comment.
[/diagnosing-bugs] Root cause: quotaStopped is true for every DAILY_AIC_QUOTA_STOP, including secondary limits where remaining is still above the reserve. Line 26 then adds the core reset to deadlines even though the core quota is not exhausted.
💡 Details
daily_aic_api_budget.cjs already notes that a synthetic stop can represent a secondary limit above the reserve, but that distinction never reaches this diagnostic. Use a reserve-stop signal (for example, remaining at or below the reserve) rather than quotaStopped alone to decide whether the reset counts. For remaining=4000, a reset in 1h, and Retry-After: 60, this should report the roughly 60s Retry-After deadline, not 1h.
@copilot please address this.
There was a problem hiding this comment.
Fixed in 757a4ca: diagnostics bind the primary reset only for exhausted quota or a budget-confirmed reserve stop, not every synthetic quota stop. Custom-reserve and wrapped-error tests verify deadline parity.
| [{ "x-ratelimit-remaining": "0" }, null], | ||
| [{ "x-ratelimit-remaining": "0", "x-ratelimit-reset": "9999999999999999", "retry-after": "private-header-value" }, null], | ||
| [{ "x-ratelimit-remaining": "0", "x-ratelimit-reset": "1" }, null], | ||
| ])("reports a safe recovery deadline without retrying restricted reads: %j", async (headers, deadline) => { |
There was a problem hiding this comment.
[/tdd] The new matrix only covers remaining=0, the one case where the summary and recovery paths agree. The divergent case (remaining>0 with Retry-After) is untested. Add a row expecting the Retry-After deadline. This row should fail on the current code, where the summary reports 10:15:00Z, which makes it a useful red test before the fix.
💡 Suggested test row
[{ "x-ratelimit-remaining": "4000", "x-ratelimit-reset": "1791972900", "retry-after": "120" }, "2026-10-14T10:06:13.000Z"],The test mocks Date.now to 10:04:13Z, so the Retry-After deadline is 10:06:13Z and the reset is 10:15:00Z.
@copilot please address this.
There was a problem hiding this comment.
Added the requested row in 757a4ca and confirmed it failed before the fix. Also covered reserve-boundary and invalid Retry-After cases. All 272 affected tests pass.
|
|
||
| Trace the restore step's `github-token` reference in the compiled workflow to the dedicated daily-AIC app, activation credential, or `github.token`. Compare concurrent consumers using the same user or app installation, including other workflows and repositories; separately minted tokens for the same installation do not isolate its quota. Record only credential reference names and validated quota metadata, never token values. Matching quota limits and reset times alone do not identify the credential or the consumer that depleted it. | ||
|
|
||
| Before retrying, inspect existing scheduled runs after the later of the quota reset and `Retry-After` deadline for a successful restore and complete guardrail check. An expired deadline alone does not establish recovery. Avoid simultaneous reruns, preserve the fail-closed guard, and investigate snapshot reuse and API response counts before changing scan behavior. |
There was a problem hiding this comment.
[/grill-with-docs] The docs disagree with the summary wording. Line 298 says the summary shows the "earliest retry deadline", but the code reports the later of the reset and Retry-After. Line 302 then tells operators to wait for "the later of the quota reset and Retry-After". For a secondary limit above the reserve, that means waiting for an hour-away reset even though Retry-After clears in about 60s.
💡 Suggested change
Once the code uses one deadline (see the fix on restore_aic_scan_cache.cjs), update lines 298 and 302 to describe that deadline. If the conservative later-of rule is intended for reserve stops, state that explicitly and limit it to that case.
@copilot please address this.
There was a problem hiding this comment.
Updated in 757a4ca: guidance describes the shared retry-not-before deadline, limits the later-of rule to exhaustion/reserve stops, and uses only Retry-After for secondary limits above reserve. Discovery status is scoped to the failed restore phase attempt.
|
🍳 A little prep to help this PR along! Copilot assignment requested for the following outstanding work:
Keeping the changes focused; human review and CI get the final taste test. No merging or CI triggering. Structured data{
"completed_task": 0,
"head": "69c3418f09dd742f3cf0bdfff82ec242b0a0d8e8",
"kind": "requested",
"schema_version": "1",
"state": "b9bb14084ceb83a925154edf11cace8f57b8236034b2ebd01e01abe62bb59862",
"work": [
"1dd12dea6eff8d6b1294f9bbdc8b5536adb47ef1a4b6aa64aeb103d5a7f3d1f7",
"3162c09761b952430ba57acc27654919988918a0c31c48a851b77a69dc588ed7",
"45edf372baedaacb4dd1ebf97f450dbeef256a1df26f779570d8cc052510b803",
"e756bc1e8098185dd52d15edb588df03d683eacb55c05f50c2fe89e9f692c198"
],
"workflow": "pr-sous-chef"
}
|
…ithub-api-quota-pressure Co-authored-by: gh-aw-bot <259018956+gh-aw-bot@users.noreply.github.com>
Co-authored-by: gh-aw-bot <259018956+gh-aw-bot@users.noreply.github.com>
Updated from main using |
|
🍳 A little prep to help this PR along! Copilot assignment requested for the following outstanding work:
Keeping the changes focused; human review and CI get the final taste test. No merging or CI triggering. Structured data{
"completed_task": 0,
"head": "757a4cae3deaf6d6aba65c3bd5ba04b596561b3a",
"kind": "requested",
"schema_version": "1",
"state": "654a9e648c36f299a861deeff2b42fc7f3691e832ef0ef737fa49916380ec2e4",
"work": [
"960a6fe297781e0f1e1c8c03fa3740110735e1332e99a040b5aa7b1b6d14a3f2"
],
"workflow": "pr-sous-chef"
}
|
|
🎉 This pull request is included in a new release. Release: |

Shared GitHub core-quota exhaustion blocked daily AIC restoration before agent startup. All four affected runs stopped before snapshot discovery; existing runs recovered after reset, but exact depletion contributors remain unproven.