derive.py python
27 lines 775 B
Raw
sha256:106ef9e12cca7f3be3ffb2a6bd3abfa76f032dce453c9e5010d732a8d86f2e14 Reconcile reviewed credential compatibility 32254cd939885d9… Human patch 8 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 2 commits
sha256:106ef9e12cca7f3be3ffb2a6bd3abfa76f032dce453c9e5010d732a8d86f2e14 Reconcile reviewed credential compatibility 32254cd939885d9… Human patch 8 days ago
sha256:c87cf2c2f03da507f66f93922cb339a2cbebb33ad6372a6039032fb09a20da12 Reconcile reviewed Overseer recovery d47291d5d9030de5ebef71… Human minor ⚠ 9 days ago