derive.py
python
sha256:a78e7e5a8740e03315f325d19edeb3aa1b306b3337d04abbaa9a9e0f3bbeb7a1
docs: MuseHub-first before ISR #74 — staging solidify NEXT
Human
1 day 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:a78e7e5a8740e03315f325d19edeb3aa1b306b3337d04abbaa9a9e0f3bbeb7a1
docs: MuseHub-first before ISR #74 — staging solidify NEXT
Human
1 day ago