derive.py file-level

at sha256:a · View file ↗ · Intel ↗

History
1 files
1 commits
0 hotspots
0 🧊 dead
0 💥 blast risk
sha256:6 fix(ISR): default require_independent_second_reviewer to require Opera… · aaronrene · Sep 2, 2026
1 """Deterministic ``paid_step_before_spend`` derivation (§PC.4)."""
2
3 from __future__ import annotations
4
5 from tools.model_routing.labels import HUMAN_TIER
6
7 COST_CLASS_ORDER = {"free": 0, "low": 1, "moderate": 2, "high": 3}
8
9
10 def derive_cost_view(
11 model_tier: str,
12 cost_bands: dict[str, str | None],
13 ) -> tuple[str, bool]:
14 """Return ``(cost_class, paid_step_before_spend)`` for a resolved tier.
15
16 Pure function — no I/O. ``cost_bands`` maps tier id to declared band or
17 ``None`` when the tier entry omits ``cost_class``.
18 """
19 if model_tier == HUMAN_TIER:
20 return "free", False
21
22 band = cost_bands.get(model_tier)
23 if band is None:
24 return "unknown", True
25 if band == "free":
26 return "free", False
27 return band, True