fix(validator): C2.6 — finiteness hardening, Infinity can no longer vacuously clear the gate (closes R-2)

IR schema now refuses non-finite numbers (allow_inf_nan=False on quantity/
unit_cost/claimed_saving_nok) and non-finite or negative assumption-band
endpoints; json.loads accepts the bare Infinity literal, so the bundle seam
is tested directly. ModelMapContract rejects empty-string model ids
(min_length=1). check_turn_safety_net documented as a deliberately
unreachable belt under the range-bound debate loop.

18 new tests; detach-proven (re-allow inf/nan -> 5 red, drop min_length ->
2 red). Full gate: 365 passed, ruff/format/mypy clean; golden untouched.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
Kjell Tore Guttormsen 2026-07-16 20:10:12 +02:00
commit e7ce6b0a31
6 changed files with 109 additions and 9 deletions

View file

@ -99,6 +99,18 @@ class TestModelMap:
with pytest.raises(ValidationError):
load(model_map={"profiles": {}})
def test_empty_string_model_id_rejected(self) -> None:
# C2.6: an empty-string model id satisfied dict[str, str] and slipped
# through to the client layer — it is a startup schema error.
with pytest.raises(ValidationError):
load(model_map={"profiles": {"anthropic": {"default": ""}}})
def test_empty_string_role_model_id_rejected(self) -> None:
with pytest.raises(ValidationError):
load(
model_map={"profiles": {"anthropic": {"default": "some-model-id", "proposer": ""}}}
)
def test_bundled_model_map_is_valid(self) -> None:
# model_map=None falls back to the bundled data/model_map.json, which must
# itself satisfy the contract (fail-fast on the shipped config too).