Skip to content

Clarify daily AIC restore quota blocks and recovery guidance - #76433

Merged
pelikhan merged 4 commits into
mainfrom
copilot/investigate-github-api-quota-pressure
Nov 10, 2026
Merged

pelikhan merged 4 commits into
mainfrom
copilot/investigate-github-api-quota-pressure

Conversation

Copilot AI commented Nov 10, 2026 •

Copy link
Copy Markdown
Contributor

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.

  • Diagnostics: Report the activation stage, restore response count versus shared quota usage, and whether cache discovery began.
  • Recovery: Surface the earliest retry deadline, including wrapped failures; retain fail-closed and Retry-After behavior without adding requests or retries.
  • Operator guidance: Explain credential-reference tracing, concurrent-consumer investigation, and checking existing post-reset runs before queuing reruns.

Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
Copilot AI changed the title [WIP] Investigate shared GitHub API quota pressure in daily AIC observation restore Clarify daily AIC restore quota blocks and recovery guidance Nov 10, 2026
Copilot AI requested a review from pelikhan November 10, 2026 07:05
@github-actions

Copy link
Copy Markdown
Contributor

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.

Generated by 🔧 PR Triage Agent · copilot · mai11 · ~9 AIC · ⌖ ~2 AIC · ⊞ 15.8K · ◷

1 similar comment
@github-actions

Copy link
Copy Markdown
Contributor

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.

Generated by 🔧 PR Triage Agent · copilot · mai11 · ~9 AIC · ⌖ ~2 AIC · ⊞ 15.8K · ◷

@github-actions

Copy link
Copy Markdown
Contributor

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.

Generated by 🔧 PR Triage Agent · copilot · mai11 · ~9 AIC · ⌖ ~2 AIC · ⊞ 15.8K · ◷

1 similar comment
@github-actions

Copy link
Copy Markdown
Contributor

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.

Generated by 🔧 PR Triage Agent · copilot · mai11 · ~9 AIC · ⌖ ~2 AIC · ⊞ 15.8K · ◷

@pelikhan
pelikhan marked this pull request as ready for review November 10, 2026 14:29
Copilot AI adaptive review requested due to automatic review settings November 10, 2026 14:29
@github-actions

github-actions Bot commented Nov 10, 2026 •

Copy link
Copy Markdown
Contributor

✅ PR Code Quality Reviewer completed the code quality review.

🔎 Code quality review by PR Code Quality Reviewer

@github-actions

github-actions Bot commented Nov 10, 2026 •

Copy link
Copy Markdown
Contributor

🧠 Matt Pocock Skills Reviewer has completed the skills-based review. ✅

🧠 Reviewed using Matt Pocock's skills by Matt Pocock Skills Reviewer

@github-actions

github-actions Bot commented Nov 10, 2026 •

Copy link
Copy Markdown
Contributor

✅ 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: reported_no_action

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.

Generated from Design Decision Gate 🏗️ · routed: haiku55 xhigh · ~1 AIC · ⌖ ~2 AIC · ◇ ~1 AIC · ⊞ 8.5K · ◷

🏗️ ADR gate enforced by Design Decision Gate 🏗️

@github-actions

github-actions Bot commented Nov 10, 2026 •

Copy link
Copy Markdown
Contributor

✅ Ponytail Reviewer completed successfully!

Ponytail Reviewer

Outcome: reported_no_action

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.

Generated from Ponytail Reviewer · routed: gpt61 medium · ~4 AIC · ⌖ ~1 AIC · ◇ ~1 AIC · ⊞ 181 · ◷

Generated by Ponytail Reviewer for #76433

@github-actions

github-actions Bot commented Nov 10, 2026 •

Copy link
Copy Markdown
Contributor

✅ Test Quality Sentinel completed test quality analysis.

Test Quality Sentinel

Outcome: reported_no_action

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.

Generated from Test Quality Sentinel · routed: haiku55 xhigh · ~1 AIC · ⌖ ~2 AIC · ◇ ~1 AIC · ⊞ 7.2K · ◷

🧪 Test quality analysis by Test Quality Sentinel

@github-actions

github-actions Bot commented Nov 10, 2026 •

Copy link
Copy Markdown
Contributor

✅ PR Specification Reviewer completed successfully!

PR Specification Reviewer

Outcome: reported_no_action

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.

Generated from PR Specification Reviewer · gpt56 · ~2 AIC · ⌖ ~1 AIC · ◇ ~1 AIC · ⊞ 1.6K · ◷

Generated by PR Specification Reviewer for #76433

@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.

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

Copilot AI 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.

🟡 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.";

@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.

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 with node.
  • Test gap: The new it.each matrix only covers cases where both paths agree. The divergent case (remaining>0 with Retry-After) is untested.
  • Docs conflict: cost-management.md says "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
  • ✅ retryNotBefore is 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));

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.

[/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.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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})` };

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.

[/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.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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) => {

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.

[/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.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

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.

[/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.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

@gh-aw-bot

Copy link
Copy Markdown
Collaborator

@copilot

🍳 A little prep to help this PR along! Copilot assignment requested for the following outstanding work:

  1. Update this branch with the latest main using make merge-main, resolving any conflicts and preserving the intended changes.
  2. Review (actions/setup/js/restore_aic_scan_cache.cjs:139): address unresolved feedback - Review comment
  3. Review (actions/setup/js/github_api_diagnostics.cjs:88): address unresolved feedback - Review comment
  4. Review (actions/setup/js/daily_aic_scan.test.cjs:1124): address unresolved feedback - Review comment
  5. Review (docs/src/content/docs/reference/cost-management.md:302): address unresolved feedback - Review comment

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"
}

Generated by 👨🍳 PR Sous Chef · pi · routed: haiku55 xhigh · ~4 AIC · ⌖ ~2 AIC · ⊞ 6.9K · ◷
Comment /souschef to run again

Copilot AI and others added 2 commits November 10, 2026 15:22
…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>

Copilot AI commented Nov 10, 2026

Copy link
Copy Markdown
Contributor Author

@copilot

🍳 A little prep to help this PR along! Copilot assignment requested for the following outstanding work:...

Updated from main using make merge-main (4ea31a0) and addressed all four linked comments in 757a4ca. Final validation passed, including 272 affected tests; merge checks compiled all 365 workflows. Secret scanning passed. CodeQL timed out and prohibited rerunning, so that review remains incomplete. No PR merge or CI dispatch was performed.

@gh-aw-bot

Copy link
Copy Markdown
Collaborator

@copilot

🍳 A little prep to help this PR along! Copilot assignment requested for the following outstanding work:

  1. Update this branch with the latest main using make merge-main, resolving any conflicts and preserving the intended changes.
  2. Fix failing check github-advanced-security (FAILURE): Check run.

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"
}

Generated by 👨🍳 PR Sous Chef · pi · routed: haiku55 xhigh · ~2 AIC · ⌖ ~2 AIC · ⊞ 6.9K · ◷
Comment /souschef to run again

@pelikhan
pelikhan merged commit fbd5077 into main Nov 10, 2026
68 of 70 checks passed
@pelikhan
pelikhan deleted the copilot/investigate-github-api-quota-pressure branch November 10, 2026 15:52
Copilot stopped work on behalf of gh-aw-bot due to an error November 10, 2026 15:52
@github-actions

Copy link
Copy Markdown
Contributor

🎉 This pull request is included in a new release.

Release: v1.2.3

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Daily AIC observation restore blocks scheduled workflows after shared GitHub API quota exhaustion

4 participants