Separate rate-budget accounting by authentication context - #29
Merged
Conversation
The budget gate held one REST ResourceBudget for two GitHub pools: App JWT (~5,000/hr for the app) and installation tokens (15,000/hr on GHEC). Their x-ratelimit headers overwrote each other's shared admission state, so during the 2026-08-04 incident ghsync reported remaining budget and kept admitting while GitHub returned rate limit exceeded for the installation. Budget state is now keyed by credential context. Every request path declares its context -- repository REST and GraphQL as installation auth; delivery list/redelivery as App JWT; installation-token MINT calls as App JWT (they authenticate with the App JWT even though they produce installation tokens), admitted inside the outer request's concurrency slot. Header observations update only their own context; floors, secondary backoff, and admission are per-context, so a JWT backoff cannot starve installation-class traffic or vice versa. The lease snapshot persists both contexts as additional installation_ budgets class rows (text keys; existing rest/graphql rows remain valid, no migration). C-B3 metrics gain an auth_context label with ops/alerts.yaml and ops/DASHBOARD.md expressions updated to match. A deterministic scripted-response regression proves conflicting concurrent headers from both contexts produce correct admission for each -- the merged-header masking failure mode. Fixes #25 Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #25 — App-JWT and installation-token traffic no longer share one REST budget state.
ResourceBudget(installation REST / App-JWT REST / GraphQL), with per-context floors, secondary backoff, and admission; header observations update only their own context.installation_budgetsclass rows — migration-free, upgraded databases keep valid rows.auth_contextlabel;ops/alerts.yamlandops/DASHBOARD.mdupdated so no expression references the dead unlabeled series.Built and adversarially reviewed by paired Codex sol-xhigh agents in a dedicated worktree (parallel with #26/#27/#28). Full gate green locally.
🤖 Generated with Claude Code