Skip to main content

Crate cortexkit_provider_usage

Crate cortexkit_provider_usage 

Source
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 in RateWindow::raw_used_percent. A consumer renders whatever the wire says; a sudden 0 → high transition 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 ProviderUsage carrying error, not a request-level failure.

§Serialization contract consumers depend on

  • camelCase keys (usedPercent, resetsAt, windowMinutes, extraRateWindows, rawUsedPercent, accountInfo, savedResets, usedCount, totalCount).
  • A healthy entry MUST NOT carry error (consumers skip truthy-error entries), so it is omitted when absent.
  • A window is emitted when it has a usedPercent; resetsAt is OPTIONAL and omitted when the provider reports no reset (never fabricated).

Structs§

AccountIdentity
Shared account-identity type (commons#13, operator-ratified 2026-08-29).
AccountInfo
Account labels and subscription information supplied by a provider or vault.
AccountRef
An account identity value bundled with how it was obtained.
Amount
An amount of money or credit, in integer minor units.
CreditExpiry
One saved reset credit and its expiry time.
ExtraWindow
A per-model window bundled under one account (e.g. Antigravity’s Geminis).
Pool
A prepaid balance or credit pool on an account.
ProviderUsage
One provider/account’s usage entry. The /usage response is an array of these. A fetch failure becomes an entry carrying error (silent-degrade), never a failure of the whole array.
RateWindow
One rate-limit window: how much of a quota pool is spent and when it resets.
Regeneration
A stated replenishment mechanic for a window.
RegenerationRate
How much quota returns, and over what period.
SavedResets
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.

Enums§

AccountRefProvenance
The two ways an account identity reaches the wire, with opposite staleness properties.
PoolBasis
How a pool’s remaining was obtained.
PoolFunding
Where a pool’s balance came from, which decides what a consumer may promise.