Skip to content

Separate rate-budget accounting by authentication context - #29

Merged
ewhauser merged 1 commit into
mainfrom
budget-auth-contexts
Aug 4, 2026
Merged

Separate rate-budget accounting by authentication context#29
ewhauser merged 1 commit into
mainfrom
budget-auth-contexts

Conversation

@ewhauser

@ewhauser ewhauser commented Aug 4, 2026

Copy link
Copy Markdown
Owner

Fixes #25 — App-JWT and installation-token traffic no longer share one REST budget state.

  • Per-context ResourceBudget (installation REST / App-JWT REST / GraphQL), with per-context floors, secondary backoff, and admission; header observations update only their own context.
  • Full context-routing audit: repository REST + GraphQL → installation; deliveries APIs → App JWT; installation-token mint calls → App JWT (the subtle one — they authenticate with the JWT).
  • Lease snapshots persist both contexts as additional installation_budgets class rows — migration-free, upgraded databases keep valid rows.
  • C-B3 metrics gain an auth_context label; ops/alerts.yaml and ops/DASHBOARD.md updated so no expression references the dead unlabeled series.
  • Deterministic regression for the incident's masking failure mode: conflicting concurrent headers, both contexts asserted independently.

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

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>
@ewhauser
ewhauser merged commit 45af06c into main Aug 4, 2026
5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Separate rate-budget accounting for App-JWT and installation-token requests

1 participant