feat(use-cases): deterministisches source_regulation-Mapping + Primaerzweck [migration-approved]
CI / detect-changes (push) Successful in 8s
CI / branch-name (push) Has been skipped
CI / guardrail-integrity (push) Has been skipped
CI / secret-scan (push) Has been skipped
CI / dep-audit (push) Has been skipped
CI / sbom-scan (push) Has been skipped
CI / build-sha-integrity (push) Failing after 4s
CI / validate-canonical-controls (push) Successful in 12s
CI / loc-budget (push) Successful in 14s
CI / go-lint (push) Has been skipped
CI / python-lint (push) Has been skipped
CI / nodejs-lint (push) Has been skipped
CI / nodejs-build (push) Has been skipped
CI / test-go (push) Has been skipped
CI / iace-gt-coverage (push) Has been skipped
CI / test-python-backend (push) Successful in 31s
CI / test-python-document-crawler (push) Has been skipped
CI / test-python-dsms-gateway (push) Has been skipped
CI / detect-changes (push) Successful in 8s
CI / branch-name (push) Has been skipped
CI / guardrail-integrity (push) Has been skipped
CI / secret-scan (push) Has been skipped
CI / dep-audit (push) Has been skipped
CI / sbom-scan (push) Has been skipped
CI / build-sha-integrity (push) Failing after 4s
CI / validate-canonical-controls (push) Successful in 12s
CI / loc-budget (push) Successful in 14s
CI / go-lint (push) Has been skipped
CI / python-lint (push) Has been skipped
CI / nodejs-lint (push) Has been skipped
CI / nodejs-build (push) Has been skipped
CI / test-go (push) Has been skipped
CI / iace-gt-coverage (push) Has been skipped
CI / test-python-backend (push) Successful in 31s
CI / test-python-document-crawler (push) Has been skipped
CI / test-python-dsms-gateway (push) Has been skipped
Use-Case-Zuordnung jetzt DETERMINISTISCH aus der Quell-Regulierung (statt LLM/scope-category): control_parent_links.source_regulation (79% der 13.588 MCs) -> Keyword-Mapper -> ~30 Domaenen-Use-Cases. 117/117 Regulierungen gemappt (dse 44 Leitlinien, code_security 10, network_security 9, ...). - use_case_registry.py: 37 Use Cases (Doku + Security + Produkt/Sektor: cra/ai_act/mica/mdr/maschinen/batterie/ehds/dsa/dma/psd2/aml/lksg/...) + use_case_for_regulation() Keyword-Mapper (117 Regulierungen abgedeckt). - migration 150: is_primary auf mc_use_case_mappings + neue mc_regulations (MC->source_regulation, n:m, is_primary) als feine Filter-Dimension. - classify_mc_use_cases.py: source_regulation-getriebener Seed; Primaerzweck = dominante Regulierung, Mehrfachzwecke = weitere. PYTHONPATH-Bootstrap. - 18 Registry-Tests gruen (Mapper-Abdeckung + Konsistenz-Invariante). Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
@@ -110,3 +110,38 @@ def test_seed_empty_and_none_safe():
|
||||
vmethods=[None], etypes=[None])
|
||||
assert ucs == [] and m is None
|
||||
assert reg.seed_classify() == ([], None)
|
||||
|
||||
|
||||
# ── Deterministischer Regulierung→Use-Case-Mapper ───────────────────
|
||||
|
||||
|
||||
def test_regulation_mapper_known():
|
||||
cases = {
|
||||
"OWASP Top 10 (2021)": "code_security",
|
||||
"NIST SP 800-207 (Zero Trust)": "network_security",
|
||||
"Cyber Resilience Act (CRA)": "cra",
|
||||
"DSGVO (EU) 2016/679": "dse",
|
||||
"EDPB Facial Recognition": "dse", # Leitlinie → Datenschutz
|
||||
"TKG": "impressum",
|
||||
"TDDDG": "cookie_banner",
|
||||
"Markets in Crypto-Assets (MiCA)": "mica",
|
||||
"BGB": "agb",
|
||||
}
|
||||
for reg_str, expected in cases.items():
|
||||
assert reg.use_case_for_regulation(reg_str) == expected, reg_str
|
||||
|
||||
|
||||
def test_regulation_mapper_abgb_before_bgb():
|
||||
# 'ABGB' enthaelt 'bgb' — die abgb-Regel MUSS zuerst greifen.
|
||||
assert reg.use_case_for_regulation("AT ABGB") == "handelsrecht"
|
||||
|
||||
|
||||
def test_regulation_mapper_unknown_returns_none():
|
||||
assert reg.use_case_for_regulation("Voellig Unbekanntes Gesetz") is None
|
||||
assert reg.use_case_for_regulation(None) is None
|
||||
|
||||
|
||||
def test_all_regulation_rules_point_to_valid_use_cases():
|
||||
for _needle, uc in reg._REGULATION_RULES:
|
||||
assert uc in reg.REGISTRY, uc
|
||||
assert reg.REGISTRY[uc].enabled
|
||||
|
||||
Reference in New Issue
Block a user