derive.py python
27 lines 775 B
Raw
sha256:c07f2f34a0db9f43fe866f157d1935322008545ff8940c06c7c921eb219c55ab NXP-b DONE: independent BV-r2 pass + ISR (SD-17) Human minor ⚠ breaking 2 days ago
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
File History 1 commit
sha256:c07f2f34a0db9f43fe866f157d1935322008545ff8940c06c7c921eb219c55ab NXP-b DONE: independent BV-r2 pass + ISR (SD-17) Human minor 2 days ago