format.py python
27 lines 1.2 KB
Raw
sha256:8461d44b77376fbf06fa7c3e085d309e3010fd8d5886d63c63e69ce118811ad4 docs: record AFF-b feature-tip SHAs after AFF-b-ISR commit. Human 3 days ago
1 """Format spend-awareness lines for CLI surfaces (§PC.7)."""
2
3 from __future__ import annotations
4
5 from tools.cost_awareness.surface import CostAwarenessReport, CostSlice
6
7
8 def format_cost_awareness_lines(report: CostAwarenessReport) -> tuple[str, ...]:
9 """Human-readable spend-awareness lines for status and governance-sync."""
10 if not report.enabled:
11 return ()
12 if report.invalid:
13 return (f"cost_awareness: invalid — {report.violation}",)
14 if not report.slices:
15 return ("cost_awareness: no paid step in active slice",)
16 if not any(slice_.paid_step_before_spend for slice_ in report.slices):
17 return ("cost_awareness: no paid step in active slice",)
18 return tuple(_format_slice(slice_) for slice_ in report.slices if slice_.paid_step_before_spend)
19
20
21 def _format_slice(slice_: CostSlice) -> str:
22 tier = slice_.model_tier
23 band = slice_.cost_class
24 tier_label = f"{tier} ({band})" if band != "unknown" else tier
25 tier_hint = f"[{slice_.phase_tier}]" if slice_.phase_tier else "[*]"
26 paid = "paid step before spend" if slice_.paid_step_before_spend else "no metered spend"
27 return f"cost_awareness: {slice_.phase_id} {tier_hint} → {tier_label} — {paid}"
File History 1 commit
sha256:8461d44b77376fbf06fa7c3e085d309e3010fd8d5886d63c63e69ce118811ad4 docs: record AFF-b feature-tip SHAs after AFF-b-ISR commit. Human 3 days ago