format.py
python
sha256:106ef9e12cca7f3be3ffb2a6bd3abfa76f032dce453c9e5010d732a8d86f2e14
Reconcile reviewed credential compatibility 32254cd939885d9…
Human
patch
9 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
2 commits
sha256:106ef9e12cca7f3be3ffb2a6bd3abfa76f032dce453c9e5010d732a8d86f2e14
Reconcile reviewed credential compatibility 32254cd939885d9…
Human
patch
9 days ago
sha256:c87cf2c2f03da507f66f93922cb339a2cbebb33ad6372a6039032fb09a20da12
Reconcile reviewed Overseer recovery d47291d5d9030de5ebef71…
Human
minor
⚠
10 days ago