Budget (soft / hard spend)
Execution spend ceilings for graph and recipe runs. Module:
mechaharness.budget. Stability: evolving.
Surface
Item |
Value |
|---|---|
Module |
|
Enforced by |
|
Stability |
evolving |
Policy and ledger
BudgetPolicy declares optional soft_limit and hard_limit in abstract
cost units (unit: units | usd | tokens). hard_limit=None means
unlimited. Soft is optional; when both are set, soft must be <= hard.
Budget is the mutable spend ledger for one run. Nested subgraphs share the
ledger via Budget.child() so child NodeOutcome.cost_units count against
the parent ceiling.
Level |
Executor behavior |
|---|---|
Soft |
Wind down: cancel remaining open nodes; status |
Hard |
Fail: status |
Default node cost is 1.0 when a runner does not set cost_units.
SoftPoint kind="budget" is not this
Recipe soft-point kind="budget" means stop/turns / loop bounds — not
BudgetPolicy. Do not confuse the two.
Host recipe-run pattern
Hosts pass spend ceilings the same way as authorization (see Access control):
Per-run —
run_recipe(..., budget_policy=BudgetPolicy(...))or CLIrun_recipebody fieldbudget: {soft_limit, hard_limit, unit}.Instrumentor / story —
environment.budgetonuser_storybinds a default onCliInstrumentor; omit →BudgetPolicy.unlimited().Product verb —
run_budgeted_graphexercises a fixed compute graph under soft/hard or nested rollup (for acceptance walks).
from mechaharness.budget import BudgetPolicy
from mechaharness.recipe_runner import run_recipe
await run_recipe(
"verify_repair",
runners=runners,
budget_policy=BudgetPolicy(soft_limit=10, hard_limit=20),
grants=["core:graph.execute"],
)
environment:
budget:
soft_limit: 2
hard_limit: null
unit: units
Host-kit / adapters keep unlimited until a policy is supplied — intentional no-op defaults.
See also
Access control — grants + recipe-run kwargs
Host integration — HOST-08