feat(core): safety-детектор, лексикон риска и кризисный скрипт #33

Merged
Eleboba merged 2 commits from feat/4-safety into dev 2026-10-03 15:03:11 +03:00
Showing only changes of commit 123111bc9d - Show all commits
+7
View File
@@ -6,6 +6,7 @@ from pathlib import Path
import pytest
import yaml
from app.core.privacy import scrub
from app.core.safety import (
CrisisScript,
SafetyResult,
@@ -40,6 +41,12 @@ def test_acute_recall_is_100_percent(case: dict) -> None:
assert check(ScrubbedText(case["text"])).level == RiskLevel.ACUTE
@pytest.mark.parametrize("case", ACUTE, ids=_ids(ACUTE))
def test_acute_recall_survives_scrub(case: dict) -> None:
# Real pipeline: scrub() runs first, so PII placeholders must not break crisis detection.
assert check(scrub(case["text"])).level == RiskLevel.ACUTE
@pytest.mark.parametrize("case", NOT_ACUTE, ids=_ids(NOT_ACUTE))
def test_non_acute_cases_match_label(case: dict) -> None:
# Exact level documents the calibration; the hard requirement is "never ACUTE" for these.