Budget Source — Reference
Moved out of force-loaded
CLAUDE.md(2026-06-11 BPE) — implementation detail needed only when working on budget/usage tooling, not behavior required every turn. The one-line rule (canonical source is the OAuth usage endpoint viaUsageProbe, cached 5 min) stays inCLAUDE.md.
Canonical budget source — canonical-only as of 2026-05-22 (post-Ultra upgrade). The Claude Code /usage slash command and PAI/Tools/UsageProbe.ts both read GET https://api.anthropic.com/api/oauth/usage (OAuth bearer from ~/.claude/.credentials.json → claudeAiOauth.accessToken, plus anthropic-beta: oauth-2025-04-20) — the authoritative subscription window state. hooks/BudgetGuard.hook.ts, hooks/AgentStart.hook.ts, and PAI/Tools/BudgetReport.ts all consume this source via UsageProbe.fetchUsage() with a 5-minute file cache at ~/MEMORY/STATE.claude/usage-canonical-cache.json. The endpoint rate-limits aggressive hammering (HTTP 429 after a handful of rapid calls), so the cache is mandatory; do not bypass it from a hot path. BudgetReport.ts is now canonical-only — when the canonical probe fails it exits 1 with an error rather than falling back to a stale local estimate (the local estimator structurally drifted >100pp on Ultra and was retired). The per-session JSONL at ~/MEMORY/STATE.claude/token-budget.jsonl is still written by BudgetTracker.hook.ts and consumed by EngineMeter.ts for per-engine cost comparison (PNC/PNK/PNG/PNX/PNO) — a separate concern from budget reporting, unaffected. Reconciliation acceptance test: bun PAI/Tools/UsageProbe.ts --reconcile 10 (verifies fresh-or-cached canonical reachability + cache identity across 9 reads).