Summary
Two closely related gaps that must be closed together:
- Implement
ahc cost-profile <trace-set> CLI command (currently in roadmap but missing from compiler/cli.py)
- Wire
EconomicPolicyEngine.evaluate_budget() onto the runtime enforcement path — the economic module exists but is not currently called anywhere
Depends on: #120 (v0.2 Phase 4 compiler integration)
Background
CostProfileStore.percentile() is implemented and tested (tests/economic/test_cost_profile_store.py), but:
- There is no CLI command to derive profiles from trace files
EconomicPolicyEngine.evaluate_budget() is never called in any runtime module — cost enforcement is currently inert
Scope
ahc cost-profile <trace-set> — read execution traces, aggregate cost observations, print p50/p90/p99 per (action_name, model_name) pair
- Wire
EconomicPolicyEngine.evaluate_budget() into IRBuilder.build() (after capability and provenance checks, before execution)
- Add example manifest with
economic.model_pricing section
- Ensure
BudgetExceeded surfaces correctly in the enforcement path
Key Files
src/agent_hypervisor/compiler/cli.py — add cost-profile command
src/agent_hypervisor/runtime/ir.py — wire economic check into IRBuilder.build()
src/agent_hypervisor/economic/economic_policy.py — EconomicPolicyEngine.evaluate_budget()
tests/runtime/test_invariants.py — add test_budget_exceeded_blocks_ir_construction
tests/economic/ — extend cost profile tests
Acceptance Criteria
Milestone
v0.3
Summary
Two closely related gaps that must be closed together:
ahc cost-profile <trace-set>CLI command (currently in roadmap but missing fromcompiler/cli.py)EconomicPolicyEngine.evaluate_budget()onto the runtime enforcement path — the economic module exists but is not currently called anywhereDepends on: #120 (v0.2 Phase 4 compiler integration)
Background
CostProfileStore.percentile()is implemented and tested (tests/economic/test_cost_profile_store.py), but:EconomicPolicyEngine.evaluate_budget()is never called in any runtime module — cost enforcement is currently inertScope
ahc cost-profile <trace-set>— read execution traces, aggregate cost observations, print p50/p90/p99 per(action_name, model_name)pairEconomicPolicyEngine.evaluate_budget()intoIRBuilder.build()(after capability and provenance checks, before execution)economic.model_pricingsectionBudgetExceededsurfaces correctly in the enforcement pathKey Files
src/agent_hypervisor/compiler/cli.py— addcost-profilecommandsrc/agent_hypervisor/runtime/ir.py— wire economic check intoIRBuilder.build()src/agent_hypervisor/economic/economic_policy.py—EconomicPolicyEngine.evaluate_budget()tests/runtime/test_invariants.py— addtest_budget_exceeded_blocks_ir_constructiontests/economic/— extend cost profile testsAcceptance Criteria
ahc cost-profile <trace-dir>prints p50/p90/p99 profiles from trace filesIRBuilder.build()raisesBudgetExceededwhen estimated cost exceeds budgettest_budget_exceeded_blocks_ir_constructionpasses intest_invariants.pyeconomic.model_pricingMilestone
v0.3