Repository navigation
Inference budget guard on the gateway chat path (opt-in, INFERENCE_BUDGET_ENABLED).
- Atomic reserve → execute → settle per tenant or API key: Redis Lua (shared across replicas) or an in-process lock (per process), integer micro-USD
429when over budget;503fail-closed on store down, timeout, corrupt data or malformed policy;X-AI-Budget-Warning: soft_thresholdat the soft ratio- Each reservation is settled once: actual usage when known, the estimate when usage is unknown or the model may have run, a refund when it never ran
- ASC-shaped decision envelopes; evidence in
docs/EVIDENCE.md/docs/results.json; design indocs/budget-guard.md - CI runs multiprocess concurrency tests against a real Redis service container
Limits, on this test suite: the pre-request estimate can differ from actual usage; settlement lags if Redis fails after the upstream call; one Redis, not multi-region billing.