File size: 1,060 Bytes
7a87926
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
"""
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