Skip to content

v0.3-T2 — ahc cost-profile CLI + wire EconomicPolicyEngine onto runtime path #122

Description

@sv-pro

Summary

Two closely related gaps that must be closed together:

  1. Implement ahc cost-profile <trace-set> CLI command (currently in roadmap but missing from compiler/cli.py)
  2. 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.pyEconomicPolicyEngine.evaluate_budget()
  • tests/runtime/test_invariants.py — add test_budget_exceeded_blocks_ir_construction
  • tests/economic/ — extend cost profile tests

Acceptance Criteria

  • ahc cost-profile <trace-dir> prints p50/p90/p99 profiles from trace files
  • IRBuilder.build() raises BudgetExceeded when estimated cost exceeds budget
  • test_budget_exceeded_blocks_ir_construction passes in test_invariants.py
  • At least one example manifest includes economic.model_pricing

Milestone

v0.3

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions