fabro/lib/foundation
Bryan Helmkamp b32164b086
Add [run.limits] run budgets: halt runs on token/cost spend
A run can now carry an optional spend budget. New [run.limits] settings
table with max_cost (USD) and max_tokens; when accumulated LLM spend
exceeds either limit, the run halts immediately and fails with the
existing BudgetExhausted failure reason.

- RunBudget (fabro-model): thread-safe accumulator shared across the
  engine, agent sessions, hooks, and the prompt path. Charges per LLM
  response; queues one-shot 80% warnings drained into run notices.
- Enforcement is inline at every usage-recording site: the agent turn
  loop (interrupting like the wall-clock timeout via a new
  InterruptReason::BudgetExhausted), subagent sessions, the one-shot
  prompt path with schema-repair retries, context compaction, web_fetch
  summarization, and prompt/agent hooks (which skip once the budget is
  spent, matching their fail-open posture).
- Budget exhaustion terminates the run as an engine-level error
  (fabro_core::Error::BudgetExhausted, following the StallTimeout
  pattern) so fail edges are not followed, plus a between-stage gate for
  non-LLM stages and a run-start gate that makes a resumed
  budget-failed run fail fast until the limit is raised (spend is
  seeded from the billing projection).
- Exposed on the RunNamespace OpenAPI schema (RunLimitsSettings);
  Rust and TypeScript clients regenerated; docs updated.

Known gaps, by design for now: ACP external agents report no usable
per-response usage (cumulative UsageUpdate capture is a follow-up), and
post-run PR content generation is outside the engine.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
2026-08-06 14:22:10 -04:00
..
build-support refactor: organize crates into three layers 2026-07-23 17:59:34 -04:00
fabro-api Add [run.limits] run budgets: halt runs on token/cost spend 2026-08-06 14:22:10 -04:00
fabro-auth fix(model): prefer MOONSHOT_API_KEY 2026-07-31 09:14:58 -04:00
fabro-client Merge remote-tracking branch 'origin/main' into feat/async-pr-create 2026-08-04 15:04:24 -04:00
fabro-config Add [run.limits] run budgets: halt runs on token/cost spend 2026-08-06 14:22:10 -04:00
fabro-core Add [run.limits] run budgets: halt runs on token/cost spend 2026-08-06 14:22:10 -04:00
fabro-db refactor: organize crates into three layers 2026-07-23 17:59:34 -04:00
fabro-dev Add [run.limits] run budgets: halt runs on token/cost spend 2026-08-06 14:22:10 -04:00
fabro-http refactor: organize crates into three layers 2026-07-23 17:59:34 -04:00
fabro-macros refactor: organize crates into three layers 2026-07-23 17:59:34 -04:00
fabro-model Add [run.limits] run budgets: halt runs on token/cost spend 2026-08-06 14:22:10 -04:00
fabro-oauth refactor: organize crates into three layers 2026-07-23 17:59:34 -04:00
fabro-options-metadata refactor: organize crates into three layers 2026-07-23 17:59:34 -04:00
fabro-proc refactor: organize crates into three layers 2026-07-23 17:59:34 -04:00
fabro-redact refactor: organize crates into three layers 2026-07-23 17:59:34 -04:00
fabro-static Merge remote-tracking branch 'origin/main' into fix/modal-provider-catalog 2026-08-01 09:32:19 -04:00
fabro-telemetry refactor: organize crates into three layers 2026-07-23 17:59:34 -04:00
fabro-template fix(workflow): harden script value interpolation 2026-07-28 17:21:35 -04:00
fabro-test refactor: organize crates into three layers 2026-07-23 17:59:34 -04:00
fabro-types Add [run.limits] run budgets: halt runs on token/cost spend 2026-08-06 14:22:10 -04:00
fabro-util Neutralize runtime for_each labels before display 2026-07-28 19:52:59 -04:00
fabro-vault refactor: organize crates into three layers 2026-07-23 17:59:34 -04:00