Skip to content
This repository was archived by the owner on Sep 30, 2026. It is now read-only.

usage: converge Anthropic/OpenAI usage cache on quota-axi shared file (rebased) - #23

Merged
yjuyjuy merged 3 commits into
masterfrom
fm/asw-jcode-cache-converge-rebased
Aug 14, 2026
Merged

yjuyjuy merged 3 commits into
masterfrom
fm/asw-jcode-cache-converge-rebased

Conversation

@yjuyjuy

@yjuyjuy yjuyjuy commented Aug 13, 2026

Copy link
Copy Markdown
Owner

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.

Chris Yuan and others added 3 commits August 13, 2026 18:27
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
@yjuyjuy
yjuyjuy merged commit b69955e into master Aug 14, 2026
10 of 11 checks passed
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants