from pathlib import Path ROOT = Path(__file__).resolve().parents[2] def test_detection_lab_exposes_persisted_threshold_calibration_comparison() -> None: detection_lab = ROOT / "frontend" / "src" / "components" / "detection" / "DetectionLab.tsx" app = ROOT / "frontend" / "src" / "App.tsx" todo = ROOT / "docs" / "TODO.md" source = detection_lab.read_text(encoding="utf-8") app_source = app.read_text(encoding="utf-8") todo_source = todo.read_text(encoding="utf-8") assert "qualityChecks: QualityCheckRead[]" in source assert "buildCalibrationRows(detectionRuns, qualityChecks)" in source assert "Calibration comparison" in source assert "Compare persisted detection runs by confidence threshold" in source assert "Best F1 candidate" in source assert "Best precision candidate" in source assert "Lowest false-positive pressure" in source assert "Threshold" in source assert "Precision" in source assert "Recall" in source assert "F1" in source assert "False positives" in source assert "False negatives" in source assert "Promote only after checking evidence across AOIs" in source assert "No calibration comparison available yet" in source assert "metricValue(check, 'f1')" in source assert "metricValue(check, 'precision')" in source assert "metricValue(check, 'recall')" in source assert "metricValue(check, 'false_positives')" in source assert "confidenceThresholdForRun(run)" in source assert "qualityChecks={qualityChecks}" in app_source assert "[x] Add full threshold calibration comparison UX" in todo_source