Expand description
QuotaTracker — the per-provider availability decision layer
(RFC-031 v2 §4).
Unifies three signals into one verdict per provider:
- Live quota snapshot (v2 primary) — when a
[
crate::api::quota::QuotaFetcher] exists for the provider, its most recentsuper::live_quota::QuotaSnapshotis the authoritative signal for both eligibility andremaining_percent. Auto-discovers providers that the user has not added to[[token-maxing.providers]]. - Self-tracked counter (fallback) —
ProviderBudgettracks tokens oxios itself sent. Used when no live fetcher exists, or as a consistency check between polls. - Reactive cooldown (safety net) — when a real request 429s
or hits
QuotaExhausted/Transient, we mark the providerCooledDownuntilresets_at ?? now + window. Drift failsafe.
§Decision rule (v2)
availability(p):
if reactive_cooldown[p] active: return CooledDown(...)
if live_snapshot(p) exists:
if plan_type == Metered: return Ineligible // metered-never
if plan_type == Subscription && usable signal:
rem% = live.remaining_percent
if rem% <= min_remaining_percent: return Draining
return Available
// v1 fallback: config gate + self-tracked counter.
if !cfg.is_eligible(p): return Ineligible
rem% = counter[p].remaining_percent
...Structs§
- Cooldown
Record - Quota
Tracker - The
QuotaTracker. - Quota
Tracker Snapshot - Recalibration
Record
Enums§
- Availability
- Per-provider availability verdict (RFC-031 §4).
- Recalibration
Outcome