This repository was archived by the owner on Sep 30, 2026. It is now read-only.
Repository navigation
usage: converge Anthropic/OpenAI usage cache on quota-axi shared file (rebased) - #23
Merged
Merged
Conversation
Each live jcode session kept its own in-memory usage cache, so N sessions
meant N independent pollers hitting the provider usage endpoints, the likely
cause of the constant 429s. quota-axi now owns one host-wide on-disk usage
cache; this points jcode's Anthropic and OpenAI usage fetchers at that same
file so the whole host makes roughly one usage fetch per provider-account per
TTL regardless of session count (Phase 1 of ADR 0031).
Two-layer design: the existing per-session in-memory cache stays as L1; the
shared file (${XDG_CACHE_HOME:-~/.cache}/quota-axi/quotas.json, schemaVersion
1) is L2, read-through and write-through. L2 is scoped to the host-active
account (host-global disk state read the same way by every session and by
quota-axi) and only successful fetches are written through, so all error and
429 backoff stays owned by L1 and existing backoff semantics are preserved.
The on-disk format, window identities, atomic 0600 write, and provider
ordering byte-match quota-axi's merged implementation so both tools share one
file rather than maintaining parallel formats.
Colocated tests cover round-trip conversion, byte-level schema match against
quota-axi, reading a real quota-axi-written record, stale-record rejection,
error-state exclusion (backoff preservation), schema-version guarding, and
upsert ordering.
# Conflicts: # AGENTS.md # scripts/swallowed_error_budget.json
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Rebase of #21 onto current master. Resolves the ratchet-baseline conflict (swallowed_error) by taking master's baseline then re-running the guardrail --update to re-add this PR's own +7 delta from the new shared_cache.rs. Also resolves the accessors.rs semantic conflict, keeping BOTH master's per-account-label L1 cache key (429-storm fix) AND this PR's L2 skip for non-active rotation probes. Supersedes #21; do not merge both. See #21 for full description.