Skip to content

perf(ci): pace GITHUB_TOKEN spend so busy hours stop tripping the kill switch #17460

Description

@kyle-sexton

The repository's GITHUB_TOKEN pool (5,000 calls/h) runs out in every busy hour, which sets the CI kill switch: 15 trips on 2026-11-18 and 9 on 2026-11-19, each 0-14 minutes before the hourly reset. CI spent 103,065 calls in 24 h (4,294/h average). Quiet hours (29-43 runs/h) did not trip.

Cause

  • The brake drives its own cycle: on BRAKE-CLEAR the hub dispatches pr-merge and work-unblock at once (token-headroom.sh:124), and lanes check the budget only when they start, so jobs already running spend it to 0%. 15 of the last 26 trips were refusals (calls already rejected).
  • Top consumers (calls/h, from limits/gh-job-calls.jsonl): CI Status 586; pr-merge.yml 727 over three jobs (PR-scoped runs ~92 calls each, mostly listing other workflows' runs); pr-dispatch-feedback 536; Check Intent 288; reconcile-lost-runs 200 (30-minute cron); Wait For Refine 161 (a poll duplicated in the two review workflows).

Done when

  • Spend is paced across the hour (no burst dispatch at BRAKE-CLEAR; running jobs check headroom before each costly phase), and a 24 h window shows at most a few trips.
  • Run lists are filtered by head SHA in pr-merge.yml; (the review keeps its Wait For Refine poll: owner decision D34, melodic-software/architecture#159;) reconcile-lost-runs runs hourly; pr-dispatch-feedback is gated with if: so it does not start for events it ignores. Expected saving ~330-570 calls/h.
  • The before/after calls per hour for each consumer are recorded from limits/gh-job-calls.jsonl.

Measurements and file:line basis: the API usage investigation of 2026-11-19 (read-only; numbers from logs the hub already writes).

Activity

  1. added
    needs-triage
    on Nov 19, 2026
  2. github-actions commented on Nov 19, 2026

    @github-actions
    Contributor

    Size: Medium
    Complexity: Medium
    Uncertainty: Known
    Flags: none
    Blocked by: none
    Blast radius: the review and Check Intent workflows, a new recovery workflow or step, and their tests; every CI run that spends GITHUB_TOKEN calls.
    Reversible: yes; revert the workflow and test changes.
    Open questions: none

    Decision recorded. The owner's rule of 2026-11-20 (comment above: "Build (a) only if that run shows at least 3 zero windows"; pre-set rule "at least 3 zero windows: build Phase 2 ... with the post-reset recovery pass") is applied as written. The busy-day re-measure of 2026-11-21 (24 h ending 20:49:50Z) counted 3 of 50 token windows at core_remaining == 0, which meets it. The note that two of the three coincided with a host overload does not change the rule. Recorded by the hub, applying the owner's rule.

    Done before this: the reconciler runs hourly, pr-dispatch-feedback jobs are gated with if:, and the merges listed in the 2026-11-20 measurement.

    Left for the lane: review and Check Intent deferral on projected token budget; a post-reset recovery pass with its own in-flight cap; tests for the deferral and the cap.

    Link: #17460 (comment)

    This decision settles the open questions. The remaining work is the three lane items listed in it. The quiet-host re-measure is host work and is not a lane item. Merged #17508, #17517, #17531 and #17533 already cover earlier parts of this issue.

    Automated triage. A maintainer reviews it.

  3. removed
    needs-triage
    on Nov 19, 2026
  4. melodic-automation-lanes commented on Nov 19, 2026

    @melodic-automation-lanes
    Contributor

    {"v":1,"actor_id":337595936,"title_sha256":"b9d79e15394684868e80dd7492faaedb551014eb2b4db489528839f82149d267","body_sha256":"7c49fed3fd14618dbcda30edd82e1622d413fc637aa019dc1ad47e1a0cb4f825"}

  5. melodic-automation-lanes commented on Nov 19, 2026

    @melodic-automation-lanes
    Contributor

    {"v":1,"actor_id":337595936,"title_sha256":"b9d79e15394684868e80dd7492faaedb551014eb2b4db489528839f82149d267","body_sha256":"7c49fed3fd14618dbcda30edd82e1622d413fc637aa019dc1ad47e1a0cb4f825"}

  6. kyle-sexton commented on Nov 19, 2026

    @kyle-sexton
    MemberAuthor

    Claimed by the GitHub Optimization session (owner's local login), with the hub's agreement. It ships one small PR per consumer, each with before/after calls per hour from limits/gh-job-calls.jsonl.

    Correction to my first version of this comment: the per-consumer numbers in the issue body stand. The log writes one row per job per rate-limit reset window (limits-sampler.sh, the row function's comment), so repeated (run, job) rows are window parts, not duplicates. Over the last 24 h the rows sum to 104.5k calls, against 109.6k on the token pool's own counter across 57 windows.

  7. 21 remaining items

  8. github-actions commented on Nov 22, 2026

    @github-actions
    Contributor
    No description provided.
  9. melodic-automation-lanes commented on Nov 22, 2026

    @melodic-automation-lanes
    Contributor

    The work-resolve-issue lane stopped partway through this issue and needs a person.

    Reason: security

    Matched security word: token. A match holds the stop whether or not the text names a risk, so read the word in context below.

    Why, in the run's own words:

    patch-protected-path: .github/workflows/pr-verify.yml (and .github/workflows/maintenance-reconcile-lost-runs.yml). The recorded decision's first item, Check Intent runs deferring on the projected token budget, needs the Check Intent job's check-kill-switch step in .github/workflows/pr-verify.yml (line 145) to pass defer: "true", defer-job and resolved-config, plus a step that writes the defer config, as pr-review-hosted.yml:108-126 does. The second item, a recovery pass a few minutes after each hourly token reset, needs a trigger change in .github/workflows/maintenance-reconcile-lost-runs.yml: today it runs only on cron "4 * * * *" (line 73), and the token resets drift (07:51Z, 18:55Z, 19:55Z in the 2026-11-21 re-measure). The lane cannot push a change to .github/workflows/**.

    What the run says it did not do:

    • Check Intent deferral: needs .github/workflows/pr-verify.yml, a protected path
    • Post-reset recovery pass with its own in-flight cap: needs a trigger change in .github/workflows/maintenance-reconcile-lost-runs.yml (or a new workflow), a protected path
    • Tests for the deferral and the recovery pass's cap: they depend on the two workflow changes above
    • Tidy, review, build and test: not run, because the run stopped before any edit and the working tree is unchanged

    Run: https://github.com/melodic-software/claude-code-plugins/actions/runs/45076645727

    To retry, set Work status to agent-ready again (clearing the needs-human hold).

  10. added
    host-run
    on Nov 22, 2026
  11. kyle-sexton commented on Nov 22, 2026

    @kyle-sexton
    MemberAuthor

    Hub: the 22:45Z stop matched token in "projected token budget" (the GITHUB_TOKEN API budget), not a secret or account risk. The real stop is the protected path: both items change .github/workflows/, which lane tokens may not push (hub Q1, 2026-10-30). Routed host-run; the hub builds it in a session worktree against the recorded decision.

  12. removed
    host-run
    on Nov 22, 2026
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

    No labels
    No labels

    Type

    Fields

    Work status

    needs-human

    Priority

    medium

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions