Write run_loop(plan, caps) — the metered loop, as a function you can
point at any plan with any budget. Per iteration, in order:
- If the step number exceeds
caps["max_steps"]→ printstop: step-capand return. - If
spent + COST[tool]exceedscaps["max_cost_usd"](strictly) → printstop: cost-cap ($X.XX spent)and return. - Otherwise spend, then print
step N: tool $X.XXwith the running total.
If the plan runs out naturally, print
stop: plan-complete ($X.XX spent).
All money is $ + two decimals. Three runs exercise all three exits:
step 1: get_failing_jobs $0.02
step 2: read_log_tail $0.05
step 3: open_issue $0.09
stop: plan-complete ($0.09 spent)
step 1: get_failing_jobs $0.02
step 2: rerun_job $0.13
step 3: rerun_job $0.24
step 4: rerun_job $0.35
stop: step-cap
step 1: rerun_job $0.11
step 2: rerun_job $0.22
stop: cost-cap ($0.22 spent)