Two related changes to the /usage quota route, committed together because they
are entangled in the same code path.
1. Stop refreshing the Kimi OAuth token from this route (kb#87). Was already
present as uncommitted working-tree WIP, not authored in this commit's
session. Kimi rotates the refresh_token on every refresh (single-use), so an
independent refresh here invalidated the copy the CLI's creds file holds ->
the CLI's next refresh failed invalid_grant and wiped the whole login (the
recurring Adolf logout, incl. the 2026-07-17 06:15 wipe / task #86). Removes
KIMI_OAUTH_HOST, KIMI_CLIENT_ID, refreshKimiToken() and the kimiMemToken
cache; the CLI is now the sole refresher and this route only ever READS.
2. Serve the last good reading when the token is stale, instead of erroring.
Measured 2026-07-22: the access token's expires_in is 900s, so it is only
valid for 15 minutes after the CLI last refreshed it -- i.e. only within 15
minutes of an actual Adolf turn. Adolf is idle most of the day, so bare
reads failed far more often than they succeeded and quota gating was
effectively blind. /usage now caches every success and, on a stale token,
returns that payload with stale/as_of/age_s/stale_reason so callers can
judge whether it is fresh enough. Cache is mirrored to the workspace volume
so it survives restarts, and writes are best-effort so an unwritable volume
cannot break the route. Auth behaviour is unchanged by this half.
Payload shape is additive only -- existing kimi-usage -q filters keep working.
Verified live after rebuild: fresh read returns weekly 16% / 5h 5% with
stale:false; cache file written to /workspace/.adolf-llm/usage-cache.json;
kimi-usage -q '.window_5h.pct' returns 5.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>