feat(agent): Impressum Rechtsform-Gates + USt-optional (Phase 3)

Die 8 Audit-Klassifizierungs-Felder (scan_context) treiben jetzt den
business_scope der Agenten (vorher gespeichert, aber nicht genutzt).
Rechtsform-Gates als opt-out (excludes_scope): Verein -> kein
Handelsregister-Finding, e.K. -> kein Vertretungsberechtigte-Finding;
unbekannte Rechtsform bleibt anwendbar. USt-IdNr optional -> fehlt =
kein Finding. Rechts-Zuordnung vom Domain-Experten bestaetigt.

- _classification.py: scan_context_to_scope (8 Felder -> scope-Tokens)
- mcs.py: MC.excludes_scope + MC.optional; IMP-MC-004/006 Gate-Tokens;
  IMP-MC-005 optional; scope_matches respektiert excludes_scope
- agent.py: optional -> kein Finding bei Abwesenheit
- _agent_outputs.py: scope = scan_context vereinigt LLM-Profil-Fallback
- Tests gruen: v3 25, Groundtruth 13, CI-Pfad 14 (+ SSE-Loop-Fix)

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
This commit is contained in:
Benjamin Admin
2026-06-10 20:37:56 +02:00
parent 65de90114a
commit b7a7e70731
6 changed files with 229 additions and 21 deletions
@@ -16,6 +16,9 @@ from __future__ import annotations
import logging
from compliance.services.specialist_agents import REGISTRY, AgentInput
from compliance.services.specialist_agents.impressum._classification import (
scan_context_to_scope,
)
from ._sse import emit
@@ -59,7 +62,14 @@ async def run_agent_outputs(state: dict) -> None:
origin_domain = (
getattr(req, "origin_domain", None) or ""
) or state.get("domain", "")
scope = _derive_scope(profile_dict)
# Phase 3: die 8 Wizard-Felder (scan_context) sind der primäre
# Scope-Treiber; das LLM-Profil ergänzt nur (v.a. regulated_profession,
# das die 8 Felder nicht ausdrücken können).
scan_context = getattr(req, "scan_context", None)
scope = sorted(
set(scan_context_to_scope(scan_context))
| set(_derive_scope(profile_dict))
)
outputs: dict[str, dict] = state.get("agent_outputs") or {}
for topic, agent_id in _TOPIC_AGENTS.items():