feat(dse): kuratierter DSEAgent + Snapshot-Tab (Art. 13/14, kein Firehose)

DSEAgent wrappt die existierende ART13_CHECKLIST (33 kuratierte Pflichtangaben
L1 + Detailchecks L2) → strukturierter AgentOutput, NICHT der 90k-Library-
Firehose (eCall/Gesundheit/Telekom-Lärm). GET /snapshots/{id}/dse-check spiegelt
impressum-check; doc_input_from_snapshot generalisiert. Frontend: generischer
AgentModuleTab (lazy → AgentResultTab) für Impressum + DSE; DSE-Tab in der
Snapshot-Seite. Plus HRB-Pattern \d→\d+ (volle Registernummer als Beleg).

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
This commit is contained in:
Benjamin Admin
2026-06-11 12:46:46 +02:00
parent be93859645
commit 76be96556d
10 changed files with 352 additions and 40 deletions
@@ -53,15 +53,15 @@ def _derive_scope(profile_dict: dict) -> list[str]:
return sorted(scope)
def impressum_input_from_snapshot(snap: dict) -> dict | None:
"""Baut den ImpressumAgent-Input aus einem gespeicherten Snapshot (kein
Re-Crawl). Pure + testbar: zieht den Impressum-Text aus doc_entries, leitet
den Scope aus scan_context + Profil ab (identisch zur Live-Auswertung) und
nimmt site_label als company_name-Fallback. None, wenn kein Impressum-Text.
def doc_input_from_snapshot(snap: dict, doc_type: str) -> dict | None:
"""Baut den AgentInput für EINEN Doc-Type aus einem gespeicherten Snapshot
(kein Re-Crawl). Pure + testbar: zieht den Text aus doc_entries, leitet den
Scope aus scan_context + Profil ab (identisch zur Live-Auswertung) und nimmt
site_label als company_name-Fallback. None, wenn kein/zu kurzer Text.
"""
docs = snap.get("doc_entries") or []
text = next((e.get("text") or e.get("content") or ""
for e in docs if e.get("doc_type") == "impressum"), "")
for e in docs if e.get("doc_type") == doc_type), "")
if len((text or "").strip()) < _MIN_TEXT:
return None
profile = snap.get("profile") or {}
@@ -70,7 +70,7 @@ def impressum_input_from_snapshot(snap: dict) -> dict | None:
| set(_derive_scope(profile))
)
return {
"doc_type": "impressum",
"doc_type": doc_type,
"text": text,
"business_scope": scope,
"company_name": (profile.get("company_name") or snap.get("site_label") or ""),
@@ -78,6 +78,11 @@ def impressum_input_from_snapshot(snap: dict) -> dict | None:
}
def impressum_input_from_snapshot(snap: dict) -> dict | None:
"""Rückwärtskompatibler Alias für den Impressum-Endpoint."""
return doc_input_from_snapshot(snap, "impressum")
async def run_agent_outputs(state: dict) -> None:
"""Für jedes Topic mit registriertem v3-Agent + ausreichend Text:
Agent laufen lassen, AgentOutput ablegen + als SSE topic-Event
@@ -295,6 +295,33 @@ async def snapshot_impressum_check(snapshot_id: str):
db.close()
@router.get("/snapshots/{snapshot_id}/dse-check")
async def snapshot_dse_check(snapshot_id: str):
"""DSE-Analyse aus dem Snapshot (kein Re-Crawl): laeuft den kuratierten
DSEAgent (Art. 13/14, ART13_CHECKLIST — KEIN Library-Firehose) auf dem
gespeicherten DSE-Text und liefert den AgentOutput fuer den Tab."""
from fastapi import HTTPException
from database import SessionLocal
from compliance.services.check_snapshot import load_snapshot
from compliance.services.specialist_agents import REGISTRY, AgentInput
from compliance.api.agent_check._agent_outputs import (
doc_input_from_snapshot,
)
db = SessionLocal()
try:
snap = load_snapshot(db, snapshot_id)
if not snap:
raise HTTPException(status_code=404, detail="snapshot not found")
agent_input = doc_input_from_snapshot(snap, "dse")
if not agent_input:
return {"findings": [], "recommendations": [], "mc_coverage": [],
"notes": "kein DSE-Text im Snapshot", "confidence": 0.0}
out = await REGISTRY.get("dse").evaluate(AgentInput(**agent_input))
return out.model_dump(mode="json")
finally:
db.close()
@router.get("/admin/benchmark")
async def benchmark(
industry: str = "",