Expand description
Per-scope cost budgets + spend aggregation (CH-06, fable §R11 / §7).
Builds on the existing opt-in cost estimation (LlmConfig.cost_tracking,
estimate_cost, the uar_llm_cost_usd metric). This module adds the
accounting layer the runtime was missing: aggregate spend per run / task /
session / agent, declare budget envelopes, and emit threshold-crossing
events so the UI and operators can react before a runaway burns the budget.
In-memory and lock-light — a single-process aggregator suitable for the runtime hot path. Durable roll-ups (SurrealDB/Postgres) can layer on top by subscribing to the emitted events; that persistence is intentionally out of scope here.
Structs§
- Budget
Limit - A configured budget limit for one
(scope, scope_id). - Cost
Budget Tracker - Thread-safe cost-budget tracker. Cloneable handle over shared state.
Enums§
- Budget
Scope - The dimension a budget / spend record is keyed on.
- Budget
Status - Result of recording spend against a budget.