Skip to content

Handle shared GitHub API quota exhaustion in activation and AWF detection setup #76581

Done

Description

@SivaKesava1

Problem

Shared GitHub REST API quota exhaustion is turning routine activation/setup into workflow failures, including detection after a successful agent job. Make this an explicit, bounded "GitHub API quota exhausted" deferred/blocked outcome, avoid unnecessary authenticated reads, and preserve completed work without bypassing budget enforcement or threat detection.

This is not a request to change model routing in #76323 or #76330.

Verified failures and corrections

Audited the four supplied runs on Windows using a development build of main at 41f1bb1 (dev-41f1bb167f83), not the installed stable release. Also read the exact attempt/job logs and failed-revision source. Times below are UTC.

Workflow / attempt First failing boundary Evidence
ab-testing-advisor, 42600855561, attempt 1 Activation, Restore daily AIC scan observations, 9 Nov 10:26:51 Job 129104811563: first current-run GET returns 403; resource=core; remaining=0; limit=15000; used=15000; reset 10:39:07. The restore reports one API response observed, not 15,000 requests made by this step.
spec-enforcer, 42721710597, attempt 2 Activation, Generate agentic run info, 9 Nov 23:58:53 Job 129527174955: Contents API GET for spec-enforcer.lock.yml at a4f57f5a6f4004eac57c3f2054d66093bbdbb1c0 returns installation-rate-limit 403; core remaining=0, used=limit=15000, reset 10 Nov 00:00:04.
daily-doc-updater, 42721686333, attempt 1 Detection, Install AWF binary, 9 Nov 23:46:38 Job 129521547073: installation-rate-limit 403 from the attestations API while installing AWF v0.29.10.
daily-doc-updater, same run, attempt 2 Detection, Install AWF binary, 9 Nov 23:59:39 Job 129527302101: same attestations API failure.
daily-storify, 42721705335, attempt 1 Detection, Install AWF binary, 9 Nov 23:48:08 Job 129522369191: same attestations API failure.

Important corrections to the original report:

  • The AWF failure is not an authenticated checksums.txt asset download. The last download message is misleading: the error URL is /repos/github/gh-aw-firewall/attestations/sha256:.... The installer already uses unauthenticated direct release URLs via curl. Its required gh attestation verify calls use GH_TOKEN and make API requests. The installer file is identical between the failed a4f57f5... revision and the inspected main; the verification call is also unchanged.
  • Not every daily A/B advisor failure since 2 Nov occurred at activation. All eight scheduled main runs on 2-9 Nov failed, but the job metadata shows restore failures on 2 and 9 Nov, agent execution failures on 3-6 Nov, conclusion failure on 7 Nov, and detection installer plus conclusion failure on 8 Nov. The 2 Nov activation log independently confirms quota exhaustion. Do not label the intervening failures as the same quota incident without their own evidence.
  • The supplied A/B advisor and spec-enforcer attempts stopped before an agent ran. The documentation/storify agent jobs succeeded; their detection model was not reached because AWF installation failed. The later missing-AWF/exit-127 detection errors are consequences, not evidence of a model-routing failure. Publication was blocked; recorded agent artifacts were not erased.

Which quota is shared?

The affected steps use the built-in Actions token: restore explicitly uses secrets.GITHUB_TOKEN, run-info's github-script uses its default token, and the installer sets GH_TOKEN: ${{ github.token }}. A message saying "for installation" does not by itself identify a separately configured GitHub App.

GitHub documents 15,000 requests/hour/repository for GITHUB_TOKEN accessing Enterprise Cloud resources. Separately configured App installations and user tokens have their own rules/buckets. Thus "every workflow shares one installation quota" is too broad: requests using the same affected credential bucket compete, but workflows can use other credentials. Never identify a bucket from limit=15000 alone or print token values.

Measured hourly consumers: evidence and attribution limits

Window: 9 Nov 2026, 23:00:00-24:00:00 UTC. Enumerated all 311 runs created in that hour using the Actions runs API (four pages); collected compact usage with the same development CLI. Its report contains 42 processed runs; 40 runs have a published aw_session.jsonl.

The ranking below is the observable instrumented subset, not a complete allocation of the 15,000-request bucket. Count only github_api.rate_limit events with data.source=response_headers, resource=core, and an event timestamp inside the hour. Exclude rate_limit_api snapshots, retry records, and rateLimit.get (the /rate_limit endpoint does not consume primary quota).

Workflow path basename Runs created / sessions available Recorded primary-core response events in the hour Distinct response fingerprints Representative evidence run
aw-failure-investigator.lock.yml 2 / 1 124 75 42721143977
pr-code-quality-reviewer.lock.yml 4 / 3 52 52 42717662585
ponytail-reviewer.lock.yml 4 / 3 51 51 42717332627
design-decision-gate.lock.yml 4 / 3 45 45 42717332364
pr-sous-chef.lock.yml 7 / 7 38 38 42718933073
agent-job-health.lock.yml 1 / 1 34 31 42718379724
pr-specification-reviewer.lock.yml 15 / 3 33 33 42717332438
test-quality-sentinel.lock.yml 4 / 3 33 33 42717332609

Across all 40 sessions: 574 primary-core response records, 516 distinct fingerprints; another 74 /rate_limit response records were excluded. A fingerprint is (run ID, operation, credentialSource, limit, reset, used, remaining), deliberately not a claim of exact HTTP-call identity. Nested instrumented clients can log one response twice; separate real responses can also have identical header values.

The most frequent recorded operations are repos.getContent (308), actions.listJobsForWorkflowRun (100), and repos.getCollaboratorPermissionLevel (40). Not every Contents read is run-info or unnecessary.

Step-level confirmation: the failure investigator's activation job 129515469310 reports:

  • Restore: 4 observed business API requests.
  • Check daily workflow token guardrail: 55 self-reported business API requests, 47 candidate runs inspected, 0 cache hits, at 23:33:19.
  • The guardrail interval contains 94 recorded actions.listJobsForWorkflowRun responses but 47 distinct fingerprints. Counting 94 as 94 network calls would double-count this instrumentation.

What this does not establish: all counted events have credentialSource=unknown. Of the 574 records, 493 (437 distinct fingerprints) have limit=15000 and reset 00:00:04, matching the spec-enforcer failure's headers, but matching reset/limit is not an installation identity. Uninstrumented gh, agent/proxy traffic, native fetches, conventional workflows, failed requests not recorded by the success-only wrapper, and runs started before the hour are missing. Consequently these data do not prove which workflows consumed most of the exhausted quota.

Do not use audit core_consumed as an individual workflow's bill: it is a shared first/last header or snapshot delta, can mix credentials/windows, and includes concurrent consumers. For example, the documentation audit reports core_consumed=1730 with only five recorded core responses; that does not establish 1,730 requests made by that workflow.

Frequency alone is not culpability. In this hour Agentic Commands started 48 runs, Agentic Workqueue 14, PR Specification Reviewer 15, and PR Sous Chef 7 (six scheduled, one manual). Agentic Commands and Agentic Workqueue are event-driven, not every-five-minute schedulers. PR Sous Chef does declare every 5m; do not turn that configured frequency into 12 measured executions/hour.

Separate follow-up candidates, not schedule changes in this fix

  • Investigate repeated AIC scans/cache misses for aw-failure-investigator with the measured 55-request cold scan; coordinate with existing Confirm daily AIC scan cost and transient-failure recovery on a repo with many cancelled runs #72900 rather than duplicating its transient-error/cache work.
  • Measure and then reduce redundant PR reviewer fan-out and PR Sous Chef polling/detail fetches. Its prefilter uses gh for per-PR comments/checks/statuses, so the 38 visible records above omit that work.
  • Add credential-category/request-identity coverage for the currently uninstrumented callers before assigning installation-wide percentages or blaming the high-frequency event/queue handlers. If measurements support schedule/frequency reductions, propose them separately.

Current code and requested behavior

Source links below are pinned to the inspected main, not a moving branch.

Failing boundary Current behavior Required behavior for a genuine quota 403 with remaining=0
Restore daily AIC scan observations / daily-AIC accounting Restore handler rethrows. Recovery already permits one complete-phase restart after reset, only on original attempts and within ten minutes. The 9 Nov reset was more than twelve minutes away, so it correctly refused to wait, but activation failed. Keep that bounded recovery policy. If it cannot recover, publish an explicit quota-exhausted/deferred reason and retry-not-before time, skip agent startup without reporting verified accounting or under-budget, and avoid a generic activation error. A cache restore miss must never authorize the agent or turn unknown accounting into zero. Apply the same typed outcome to the actual accounting step.
Generate agentic run info Run-info loads compiler metadata using the executing workflow SHA. Metadata loading chooses a remote Contents read whenever that SHA is supplied. The failed revision made one call; main already adds two bounded retries, so do not reimplement that as if absent. Reuse an already available provenance-verified manifest for the exact executing workflow revision when possible. Otherwise honor the failed response's reset/Retry-After within a bounded wait, or emit the same explicit deferred/blocked quota outcome. No invented empty manifest and no trusting arbitrary PR/workspace content as the executing lock.
Install AWF binary in detection Installer already downloads public assets directly. Integrity helper invokes online attestation verification. A quota error exits installation; later detection attempts can report missing AWF instead of the real cause. Cover the entire verification chain, not just asset transfer. Either avoid installation API calls using equivalently trusted, validated cached/offline provenance, or wait until the server reset and retry verification within the job's bounded budget. If the deadline cannot be met, publish quota-blocked detection, retain completed agent artifacts, and skip dependent execution/publication with that reason; do not run a missing binary or report a passed threat verdict.

Use the failed business response as the quota/deadline authority, not a precheck with a different token. Do not shorten a server deadline to a retry cap: the generic retry helper currently caps header-derived waits. If reset is outside the permitted wait, defer instead of retrying early. No retry storms, automatic mass reruns, or credential switching.

Preserve checksum pins, digest checks, signed release identity, signer-workflow/issuer policy, and fail-closed detection. A checksum alone is not a substitute for the existing attestation policy. gh attestation verify --bundle supports offline bundles, but its documented repository-identity limitations must be considered before treating it as equivalent.

Acceptance cases

A. Evidence-backed accounting. Retain the hourly ranking, numeric step counts, evidence links, and measurement/coverage limitations above. Any stronger claim about actual requests/hour or the share of the installation quota must include request-level attribution across the relevant credentials/callers; neither shared used deltas nor schedule frequency meets that requirement.

B. One observable 403 regression case for each boundary, using fake responses and a fake clock, not a live quota-exhaustion experiment:

  1. Daily AIC restore/accounting: HTTP 403, core remaining zero, valid future reset. An eligible short wait restarts the complete accounting phase only after the later applicable server deadline. A reset beyond the existing ten-minute budget, a rerun ineligible for recovery, unknown reset, or renewed exhaustion produces explicit quota-blocked status and no agent invocation, without setting under-budget or a false zero. Cover both restore and accounting propagation.
  2. Run-info metadata: a verified exact-revision manifest makes zero Contents API requests even with an exhausted client; the necessary-remote-read path receiving 403 either resumes after reset or produces explicit quota-blocked activation. Assert no request before reset and no empty/unverified metadata fallback.
  3. AWF detection setup: public asset downloads succeed while the attestation endpoint returns 403/remaining zero. With reset inside the wait budget, the installer waits, successfully re-verifies, installs AWF, and detection resumes. Also cover reset outside the budget: completed agent artifacts remain available, the quota-blocked reason reaches the final summary, and detection execution/safe-output publication stay gated.

For all three, assert a clear "GitHub API quota exhausted" summary with safe resource/limit/remaining/reset metadata when available. Authentication/permission 403s, 401s, bad checksums, invalid provenance, and genuine non-quota failures must not be silently reclassified as quota skips.

C. Completed work is not failed by detection setup on quota alone. A run whose agent succeeded must either finish verified AWF installation and detection after reset, or finish with an explicit expected quota-deferred/blocked outcome and retained artifacts, not an unexplained installer/engine failure. A deferred detection result is not a security pass and must never release unverified safe outputs.

Extend the existing AIC recovery, metadata/run-info, and AWF installer/integrity tests; include the directly dependent compiler/job-condition regression so a handled quota stop is not converted back into a failed activation/detection job.

Scope

  • Keep the PR to this one quota-resilience fix. Do not change files or behavior unrelated to it.
  • Before fixing a failing check, compare it with the same check on main. If it also fails on main, do not fix it in this PR; merge main once main is fixed, and note in the PR which checks are known failures on main.
  • This applies even if a bot comment asks to fix a failing check: fix only failures caused by this PR's changes.

Non-goals: raising the quota; changing model routing or #76323/#76330; changing schedules/frequencies here; bypassing AIC enforcement, release integrity, or detection; fixing unrelated CI failures. Propose consumer/frequency optimizations in separate follow-up issues.

Metadata

Metadata

Labels

bugthreat-detectionworkflows

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions