Skip to content

Defer scheduled passes during GitHub quota exhaustion and reduce idle polling #739

Closed as not planned

Description

@JacobStephens2

This was generated by AI during triage.

Scheduled thirdshift passes continue making GitHub requests while the account's GraphQL quota is exhausted, producing repeated failures, including a misleadingly broad review failed notification before an Architecture review starts. Add quota-aware deferral and reduce avoidable GitHub reads from idle polling.

Confirmed operational evidence

The deployment was inspected over SSH on October 16, 2026. Its scheduler log, ~/.thirdshift/logs/cron.log, contains:

  • 126 quota-error lines between 2026-10-17 02:04:23 and 02:10:22 UTC, corresponding to October 16, 10:04:23–10:10:22 p.m. EDT. These are logged failures, not a measurement of total requests or points consumed.
  • At 02:09:21 UTC, seven scheduled Architect runs started; at 02:09:22, all seven logged the same gh issue list quota failure. This matches the reported 10:09 p.m. notification.
  • Successful GitHub reads resumed by 02:11 UTC. This establishes API recovery, not that the failed Architecture review subsequently ran or succeeded.
  • The crontab schedules 15 jobs every minute across seven repositories: seven Pickup runs, seven Architect runs, and one Security run. Requests continued throughout the exhausted window.
  • A later server-side gh api rate_limit snapshot showed GraphQL 4,792 / 5,000 points remaining. It is a later snapshot, not the failed request's reset metadata.

Representative error, with the account identifier redacted:

thirdshift: 02:09:22 gh issue list failed: GraphQL: API rate limit already exceeded for user ID <REDACTED>.

The reported notification included:

Result:       review failed
Review:       failed
Cause:        gh issue list failed: GraphQL: API rate limit already exceeded for user ID <REDACTED>.
Built with codex · gpt-6.1-sol · high (configured)
Took:         0s

This error identifies GitHub GraphQL exhaustion. The configured model line does not establish a model request ran or failed, and this notification supplies no evidence of an OpenAI subscription or API-credit limit.

At inspection, the installed binary reported thirdshift 0.11.2, and the deployment checkout was at 30424e6da199e6bbcd85d5acf8740c1cba7caf08. These identify the inspected environment; the binary's source revision was not independently verified.

Relevant implementation and prior checks

The inspected GitHub adapter lists labelled issues through gh issue list --limit 1000; gh_json propagates a nonzero command result immediately as gh issue list failed: .... A search of src/ and tests/ found no explicit GitHub quota/cooldown implementation. See the inspected GitHub adapter.

Searches of existing issues for rate limits, GitHub quota, GraphQL, backoff, and polling found no matching quota-deferral issue. No .out-of-scope/ rejection directory was present in the inspected checkout.

Preserve ADR 0009's scheduler ownership: each pass remains a short-lived command started by the operating system. Coordinate reporting with ADR 0011's Activity log.

Proposed behavior for maintainer triage

  • Recognize GitHub primary quota exhaustion and defer further affected scheduled requests until the reported reset time. Avoid immediate or minute-by-minute retries during a known exhausted window.
  • Make the cooldown effective across successive cron invocations and repositories using the same GitHub quota on one machine, with appropriate isolation between different credentials/accounts.
  • Report that GitHub quota prevented the pass from starting its review or work. A deferred pass must never be represented as a successful review, successful GitHub read, or empty work queue. Avoid repeated failure notifications for the same known cooldown window.
  • Let later scheduled passes resume normal selection after reset; preserve existing Ready issue, Claim, and Pass rules.
  • Reduce avoidable idle polling, through a documented scheduling recommendation and/or a measured reduction in GitHub reads. Do not silently change the user's crontab.

GitHub documents a normal user GraphQL allowance of 5,000 points per hour, shared by requests on the user's behalf. For primary exhaustion it instructs clients to wait until x-ratelimit-reset. See GitHub's rate-limit documentation.

Suggested validation and open decisions

Use a controlled fake GitHub response and clock rather than exhausting a real account. Verify that repeated scheduled invocations, including another repository sharing the same quota, do not repeat affected requests before reset; a later pass can resume after reset; unrelated failures still surface correctly; and deferral never claims review success. Measure idle read volume across a representative multi-repository schedule.

Maintainer decisions remain: the deferred outcome/exit status, notification policy, safe handling when reset metadata is unavailable, and a conservative default scheduling recommendation. This is filed as enhancement / needs-triage, not an agent-ready implementation brief.

The exact client or combination of clients that consumed the original quota is unknown. The schedule is confirmed load and the repeated attempts are confirmed behavior; neither proves thirdshift alone exhausted the account. No controlled code-level reproduction or implementation change was performed, and no server settings were changed during investigation.

Activity

  1. added
    enhancement
    needs-triage
    on Oct 17, 2026
  2. JacobStephens2 commented on Oct 17, 2026

    @JacobStephens2
    OwnerAuthor

    This was generated by AI during triage.

    Additional Security run evidence

    The same quota-exhaustion window affected the Security run on JacobStephens2/thirdshift, host stephens. The scheduler log records it starting at 2026-10-17 02:09:11 UTC (October 16, 10:09:11 p.m. EDT), followed at 02:09:12 by:

    gh issue list failed: GraphQL: API rate limit already exceeded for user ID <REDACTED>.
    

    The reported notification said Result: audit failed, Audit: audit failed, a configured Codex model, and Took: 0s, with no cause or log pointer. Surrounding matching emails were retrieved; the scheduler log establishes the exact 02:09 event. Source inspection places the failing Ready issue query before audit/session startup, so this is evidence of a GitHub gate failure, not a model failure or discovered vulnerability.

    #740 now owns truthful pre-audit status, a safe operational cause and a diagnostic route in the Security run's notification. This issue remains the home for cooldowns across scheduled passes, avoidable idle reads and repeated-alert policy; it stays enhancement / needs-triage with the existing policy decisions open. No duplicate quota-recovery issue was created, and no scheduler settings were changed.

  3. JacobStephens2 commented on Oct 25, 2026

    @JacobStephens2
    OwnerAuthor

    This was generated by AI during triage.

    Carried over from #1186 (closed as a duplicate): besides fewer requests, the ceiling can be raised. GitHub App installation tokens get their own rate limit, separate from the user's 5000/hr, and an Enterprise plan raises the limit.

  4. added
    in-progress
    and removed
    needs-triage
    on Nov 10, 2026
  5. JacobStephens2 commented on Nov 10, 2026

    @JacobStephens2
    OwnerAuthor

    This was generated by AI during triage.

    Investigation of existing #739 against selected Base main at 02c9654 confirms remaining work, with some original source observations now outdated. Recommend Day shift shaping before implementation.

    Evidence:

    • Labelled-issue selection now uses paginated REST requests, not the original gh issue list path (src/github.rs:385–430). GraphQL remains involved in Ready issue checks. The design must account for separate resource quotas.
    • Known primary-quota failures return immediately without short retries (src/github/check_read.rs:46; src/github.rs:1243). Neither the adapter nor Pass admission supplies a persistent cooldown shared across scheduled invocations and repositories.
    • Pickup's Sweep warns and continues after failed closed-issue reads, then attempts failure accounting (src/pickup.rs:317–400). In an empty-label case without an earlier local skip, Pickup performs four issue-list operations: two Sweep lists, failure accounting and Ready selection. This is a source-derived count, not measured request or point consumption.
    • Architect gate failures still become a failed review before its Process starts (src/architect.rs:345–401), and ending accounting uses review failed (src/run_ending.rs:465). Deferred admission needs truthful reporting.
    • Quota protection already exists for the Inbox: src/github/quota.rs and src/logs/github.rs:361 persist quota observations and pause reads until reset, retaining a 500-unit reserve. This does not provide Pass-wide cooldowns. Reuse suitable parsing and clock concepts without assuming the Inbox cache provides credential isolation.
    • Report Security run preflight failures without claiming the audit ran #740 is closed and its Security pre-audit reporting fix is present. Its fake-GitHub regression passed; do not reimplement that fix here.
    • docs/guide.md:3795 already recommends a 30-minute Pickup example and staggering repositories. Remaining polling work should measure current behavior and document a multi-repository budget rather than merely add another interval example.

    GitHub requires waiting until reset after primary exhaustion; GraphQL errors can arrive with HTTP 200, while REST exhaustion uses 403/429. See GraphQL limits and REST limits.

    Proposed shaping: shared primary-quota cooldown state; Pass integration with truthful outcomes and repeated-alert policy; and measured idle-read reduction with scheduling guidance. Preserve ADR 0009's short-lived OS-scheduled Passes, ADR 0011's Activity log behavior, and existing Ready issue, Claim and reservation rules. Do not edit crontabs automatically.

    Validation should use fake GitHub responses and controlled time: repeated and concurrent invocations across repositories sharing a quota, independent quota owners/resources, reset recovery, missing metadata, unrelated failures, and truthful deferral without treating failed reads as empty queues or successful reviews. Keep mutation completion and Claim cleanup safe. Current tests establish existing behavior, not an end-to-end shared cooldown.

    Questionnaire

    For the Day shift shaping #739: the repository confirms that Pass-wide cooldowns remain absent, while Inbox quota protection and Security pre-audit reporting already exist. These decisions are needed before agent implementation.

    1. Approve or revise this split: A) persistent cooldown coordination by GitHub host, effective quota owner and resource; B) Pass admission, truthful deferred outcomes and alert deduplication, depending on A; C) measured idle-read reduction and scheduling documentation, independently investigable. Should GitHub App authentication/setup remain separate operator work?
    2. Which Passes should the first implementation cover: Pickup, Architect and Security only, or also Triage, Review/Fix and Custom process Passes? Recommend applying the same admission rule whether a Pass is typed manually or started by cron, while preserving existing behavior for active work and required cleanup.
    3. Which authentication modes must be supported initially, and what sharing contract should identify a quota owner? Multiple tokens can represent one user; different users, installations and hosts must remain isolated. This determines the persistence key and credential-switch behavior without storing secrets.
    4. Should known cooldown deferral be an explicit skip exiting 0, recorded when its reason changes in the Activity log? Choose the Run notification policy: no email, one notification per shared cooldown window, or another specified policy. This resolves repeated alerts and deferred status wording.
    5. What bounded fallback should apply when exhaustion has no usable reset metadata, and should secondary limits be included now or shaped separately? Specify when another probe may occur so missing metadata causes neither minute-by-minute failures nor indefinite suppression.
    6. What maximum pickup latency and GitHub read budget should the scheduling work target across a representative set of repositories? This supplies measurable acceptance criteria; current source counts cannot establish production point consumption.
  6. added
    ready-for-human
    and removed
    in-progress
    on Nov 10, 2026
  7. JacobStephens2 commented on Nov 10, 2026

    @JacobStephens2
    OwnerAuthor

    This was generated by AI during triage.

    New evidence: a Ticket run lost at CI watching (#1968), and the fleet's scheduled load

    Failure. On 2026-11-10 at 20:02:15 UTC, the Pickup run of #1968 on host orchestrate stopped at CI watching after 1h 6m. The cause was gh api repos/JacobStephens2/thirdshift/actions/runs?head_sha=… failing with API rate limit exceeded for user ID 53905376 (HTTP 403). Work is preserved on issue-1968 / PR #1970, but the run ended failed and needs a manual Continuation. This is a costlier failure mode than an idle Pass failing: an hour of a run's progress stopped on a transient quota error that would have cleared at the reset (15:12 EST, about 70 minutes later). The REST core quota was at 0/5000 when checked; GraphQL still had 4687 left.

    Shared quota. Six hosts run scheduled Passes, and all authenticate as the same GitHub user (gh api graphql viewer returned the same user on each): Lima VM, orchestrate, dev, stephens.page, thirdshift.app and test. All share one 5000/hr REST quota. (preview, replay and etadventures-kinsta have no authenticated gh; the Mac's Pickup LaunchAgent is not loaded.) Each of the six hosts also runs a Console.

    Scheduled Pass starts per hour, before this change:

    Host Starts/hr Main contributors
    stephens.page ~182 Pickup on 15 repos every 10 min; fareloch, quadrille, thirdshift every 2 min
    orchestrate ~181 Pickup every minute on 2 repos; Fix every 2 min
    Lima VM ~162 Pickup every minute (stephens.page); Triage/Review/Fix every 5 min on 2 repos
    thirdshift.app ~150 Architect every minute; Pickup and Fix every 2 min
    dev ~127 tourbot Review and Fix every 2 min; Pickup on 2 repos every 2 min
    test ~38 tourbot Review (Codex) every 2 min

    Total: ~840 Pass starts/hr. The thirdshift repo alone had Pickup on five hosts every 2 minutes (~150/hr). At an unmeasured guess of ~6 REST calls per idle Pass, that alone would use the whole quota before any active run's CI watching. Rate-limit lines in the hosts' cron logs (all-time): stephens.page 259, thirdshift.app 135, orchestrate 56, dev 38, Lima 26, test 3.

    Operator mitigation applied (not a code change). Cron schedules were slowed to ~330 starts/hr. Architect on thirdshift.app now runs hourly. thirdshift Pickup runs every 2 min only on thirdshift.app; other hosts run it every 10 min, staggered. Every-minute Pickups now run every 5–10 min, and Lima's Triage/Review/Fix every 15 min. Prior crontabs are saved on each host as ~/crontab.before-2026-11-10b.

    Implications for shaping (Questionnaire items 2 and 6):

    • Active Commands need the quota protection too, not just Pass admission. A known primary-quota exhaustion during CI watching (and likely other in-run polling) should wait for the reset and resume rather than fail the run.
    • Budget guidance should be per GitHub user across hosts, not per host or repository. A fleet of hosts on one token multiplies every interval example in docs/guide.md.
    • Several Pickup runs on one repo from different hosts mostly read GitHub for nothing, because a Claim lets only one host take each issue. The scheduling docs could say so.
  8. JacobStephens2 commented on Nov 11, 2026

    @JacobStephens2
    OwnerAuthor

    This was generated by AI from a grill-with-docs session on this issue.

    Superseded by Spec #1994 (Tickets #1995, #1996, #1997). The questionnaire above was settled as follows:

    • Quota wait. This is the new term for the time until GitHub's quota for a GitHub user resets. During it, Passes are skipped and running Commands wait instead of failing.
    • Record. One per machine, keyed by GitHub host, logged-in user and resource (REST core, GraphQL), and shared with the Inbox. It isn't shared between hosts; each host learns from its own first failure or reserve check. No secrets are stored. With no reset time available, it assumes 15 minutes.
    • Passes. Every kind is covered, whether cron or a person starts it. A Pass is skipped while either resource is in a Quota wait or below a fixed 500 reserve, checked with the free gh api rate_limit.
      • The skip exits 0, sends no email, and writes an Activity log line only when the reason changes.
      • status and the Console show the Quota wait.
      • If the check itself fails, the Pass proceeds.
    • Running Commands. They wait instead of failing, for reads, writes and Claim cleanup after Stop. Each waits until the reset + 1 min + a random 0–60 s, with at most 2 h of waiting per Command.
      • Stop ends an ordinary wait.
      • The wait shows as a stage, and Slow is unchanged.
      • The Run notification says how long the Command waited.
      • Secondary limits: wait 60 s and retry, up to 5 times.
    • Out of scope:
  9. JacobStephens2 commented on Nov 11, 2026

    @JacobStephens2
    OwnerAuthor

    Closing as superseded by #1994.

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementready-for-human

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions