Expand description
Shared wire types for the ai-provider-quota module’s usage.get payload.
The quota module serves an array of ProviderUsage per request; ALF’s
router (codexbar-window-extractors.ts), astrocyte’s capacity axis, and the
ck quota renderer all consume that shape. This crate is the single
definition those consumers compile against, so the wire shape cannot drift
without a shared-crate PR every side reviews.
§Shape, not policy
These are pure data types. Read-time transform semantics are PRODUCER behavior documented on the relevant fields but NOT enforced here:
- Banked-reset relaxation: the quota module may zero
RateWindow::used_percent(the EFFECTIVE number consumers pace on) and carry the provider-reported truth inRateWindow::raw_used_percent. A consumer renders whatever the wire says; a sudden0 → hightransition is an honest disarm (credits spent / auth broke), not a glitch. - Cache-only partial arrays: the quota module never blocks on a fetch, so a result may omit providers not yet swept. Missing ≠ zero.
- Degraded entries ride in-band: a provider fetch failure is a normal
ProviderUsagecarryingerror, not a request-level failure.
§Serialization contract consumers depend on
- camelCase keys (
usedPercent,resetsAt,windowMinutes,windowKind,extraRateWindows,rawUsedPercent,accountInfo,savedResets,usedCount,totalCount). - A healthy entry MUST NOT carry
error(consumers skip truthy-errorentries), so it is omitted when absent. - A window is emitted when it has a
usedPercent;resetsAtis OPTIONAL and omitted when the provider reports no reset (never fabricated).
Modules§
- window_
kind - The values
RateWindow::window_kindcarries today.
Structs§
- Account
Identity - Shared account-identity type (commons#13, operator-ratified 2026-08-29).
- Account
Info - Account labels and subscription information supplied by a provider or vault.
- Account
Ref - An account identity value bundled with how it was obtained.
- Amount
- An amount of money or credit, in integer minor units.
- Breakdown
Row - One category’s part of a window’s consumption.
- Credit
Expiry - One saved reset credit and its expiry time.
- Extra
Window - A per-model window bundled under one account (e.g. Antigravity’s Geminis).
- Pool
- A prepaid balance or credit pool on an account.
- Provider
Usage - One provider/account’s usage entry. The
/usageresponse is an array of these. A fetch failure becomes an entry carryingerror(silent-degrade), never a failure of the whole array. - Rate
Window - One rate-limit window: how much of a quota pool is spent and when it resets.
- Regeneration
- A stated replenishment mechanic for a window.
- Regeneration
Rate - How much quota returns, and over what period.
- Saved
Resets - Saved reset credits reported by Codex’s read-only credits endpoint.
- Stale
- Why an entry is being served through a failure, and since when.
- Usage
- The window topology for one account: up to three account-wide pools plus an optional list of per-model pools.
- Usage
Breakdown - A window’s consumption split by category, as the upstream reports it.
Enums§
- Account
RefProvenance - The two ways an account identity reaches the wire, with opposite staleness properties.
- Pool
Basis - How a pool’s
remainingwas obtained. - Pool
Funding - Where a pool’s balance came from, which decides what a consumer may promise.