""" SPEC traceability tests. These tests exist to prevent subtle drift between: - `ylff/documentation/SPECIFICATIONS.md` (locked semantics/thresholds) - implementation code paths (teacher/audit/inference) They are intentionally small and high-signal. """ import pytest from ylff.services.audit.gates import REGIME_SCALE_BIAS_THRESHOLDS, CoverageThresholds from ylff.services.audit.models import OperatingRegime pytestmark = pytest.mark.spec def test_spec_gate_1_scale_bias_thresholds_match_spec(): # SPEC §5.4.3 Gate 1 thresholds assert REGIME_SCALE_BIAS_THRESHOLDS[OperatingRegime.INDOOR_CONSTRAINED] == 0.02 assert REGIME_SCALE_BIAS_THRESHOLDS[OperatingRegime.INDOOR_LARGE] == 0.03 assert REGIME_SCALE_BIAS_THRESHOLDS[OperatingRegime.OUTDOOR_URBAN] == 0.05 assert REGIME_SCALE_BIAS_THRESHOLDS[OperatingRegime.OUTDOOR_NATURAL] == 0.08 def test_spec_gate_2_thresholds_match_spec(): # SPEC §5.4.3 Gate 2 thresholds t = CoverageThresholds() assert t.coverage_abs_r_le_2_min == 0.80 assert t.median_abs_r_max == 1.5