This document specifies the mathematics and presentation rules for quota interpretation, runway derivation, pace calculations, and output format tiering in quota-axi.
Quota Availability & Bound Conflicts
Implemented in src/interpretation.ts:
- Effective Availability: Analyzes provider windows across all scopes (
all_models, product scopes, model scopes). - Bound Conflict Detection:
availability()accepts an optional own-windows argument.- When every window metered strictly for a scope reports remaining allowance, but an inherited account-wide window reports zero, quota-axi publishes
effectiveAvailability[].boundConflictand reports the scope status asunknownrather than assertingexhausted_noworeffective 0. - Used for Codex model windows (
additional_rate_limits/rateLimitsByLimitId). Other providers keep their account bounds unless empirical proof of non-enforcement exists.
Pace & Runway Calculations
Implemented in src/pace.ts:
- Cycle-Average Pace: Every projection assumes cycle-average consumption across the active window. There is no
projectionBasisfield anywhere in the API model. - Reserve Percentage Points (
reservePercentPoints):- Quantifies how usage tracks against elapsed window time.
- Positive values indicate usage is tracking behind the elapsed time clock (headroom remaining).
- Negative values indicate usage is running ahead of the reset clock (burn rate higher than cycle average).
- Effective Usable Runway: Aggregates all authoritative bounds to determine time until exhaustion, preserving uncertainty if any binding window lacks timing metadata. Runway is dynamic and never cached.
- Selection Signal (
effectiveAvailability[].selection):- Computed purely from reported figures via
summarizeEffectiveSelectioninsrc/pace.ts. - Published field name is centralized in
SELECTION_SCALAR_KEYinsrc/types.ts. - If any bounding window lacks usable pace data, the whole scope is deemed unmeasurable (no scalar published,
unmeasurableWindowIdslisted). A not-yet-triggered zero-use window (noresetsAtplus zero usage) is fully available and is excluded from the weighted mean instead of blocking; when every bounding window is untriggered the scope publishes no scalar and reportsunknownwith nounmeasurableWindowIds. - Data only: quota-axi never routes, recommends, or ranks winners.
- Computed purely from reported figures via
Output Formats & Tier Splitting
1. Default TOON Report (src/render.ts)
Structured into three concise decision blocks:
quota[]: One fully populated row per measurable scope.exhaustion[]: Sparse block for finite-runway scopes, joined onprovider+scope.attention[]: Sparse block capturing every non-nominal condition (degraded sources, warnings, unmeasurable scopes, soft expiry).
Core Invariants:
- Every requested provider must appear in
quota[]orattention[], except providers with positive evidence of absence, which default TOON omits and counts in a single help line;--fulland an explicit--providername them. quota[]rows preserve provider declaration order and are never metric-sorted.spendPriorityrenders literalunknown, never0. An unknown or stale scope receives noquota[]row; any finite runway is preserved inattention[].
2. JSON Tier Splitting (--json vs --full)
--json: Normalized quota model with derivation inputs demoted to--full.--full: Includes account identities, diagnostic logs, and per-source attempts.- Demotion Rule: Demote at renderer serialization time only (
quotaJsonReportinsrc/render.ts). The in-memory model retains all fields so--tuiand--fullhave full context.
3. Human Terminal Interface (--tui)
- Pure card renderer in
src/tui.ts; interactive live loop insrc/tui-live.ts. - Viewport Management:
renderQuotaTuiis height-independent.src/tui-viewport.ts(scrollFrame) windows the output to fit terminal dimensions, clipping oversized lines and providing scroll affordances without terminal overflow. - Humanized Presentation:
through_resetrenders ason pace ✓.- Pace is visualized via bar fill and
┃marker (no multiple chip or legend). - Projected exhaustion displays as relative countdown (
empty in Nd Nh). - Headline bar uses the binding window's own label (
week,session,credits).
4. CLI Fast Path
- Bare
-v,-V, or--versionroutes throughaxi-sdk-js/fast-pathand the leafsrc/version.ts. - Dynamically imports
src/cli.jsso provider dependencies and network graph never load on version checks.