feat(b17): Stufe 4 banner-tour + Stufe 5 annotierte Screenshots + V2-default

Stufe 4 — Cookie-Banner-Tour vor dem Accept-Klick:
  - audit_walk_banner_tour.tour_cookie_banner(): öffnet Settings
    (16 Phrase-Varianten), scrollt vertikal, aktiviert jedes
    [role=tab], expandet jedes [aria-expanded=false] / details /
    summary + 14 CMP-spezifische Selektoren. Max 35 Klicks,
    Best-Effort.
  - audit_walk_recorder ruft tour_cookie_banner() VOR
    _try_accept_banner auf — Reviewer sieht den vollen Consent-
    Katalog im Video (Vendor-Liste, Kategorien, Zwecke).
  - Recorder unter 500 LOC (412+155 split).

Stufe 5 — Annotierte Screenshots pro Finding:
  - finding_annotator.annotate_url(): WebKit headless, JS-Inject
    eines rot-banner-Labels oben + roter Outline um das Element
    (Selector oder Text-Match).
  - finding_annotator.annotate_findings(): dispatched 3 Cases —
    B1 Tap-Target (Anchor markiert mit "Tap-Target X×Y px"),
    B16 URL-Slug-Drift (404-Seite mit "/<slug> 404"),
    B13 Widerruf (Footer markiert "Widerruf-Link fehlt").
  - routes_audit_walk.POST /annotate-findings (consent-tester).
  - _b17_wiring ruft annotate-findings nach record_audit_walk und
    speichert annotations in walk.annotations.
  - audit_walk_zip_builder packt PNGs nach findings/<name>.png ins
    ZIP — Reviewer hat Beweis-Bilder im Postfach.

Plausibility Circuit-Breaker:
  - Nach 6 consecutive empty batches (PLAUSIBILITY_EMPTY_BUDGET=6)
    bricht die ganze Phase ab statt 200 Calls zu warten. Fix für
    qwen3-down + große DSE-Sites (BMW: ohne Breaker 21min, mit
    Breaker ~3min).

audit_walk_zip_builder fängt walk.annotations ab und legt sie unter
  findings/<fname>.png im ZIP-Anhang ab.

V2-Default:
  - docker-compose.yml backend-compliance.environment.MAIL_RENDER_V2:
    default 'true'. Ohne diesen Override liefert die Engine
    weiterhin das alte Legacy-Mail-Layout, in dem die B-Wiring-
    Blöcke nicht sichtbar sind.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
Benjamin Admin
2026-06-07 20:44:42 +02:00
parent e8ff75cbfe
commit b16130369a
8 changed files with 540 additions and 0 deletions
@@ -73,6 +73,40 @@ async def run_b17(state: dict) -> None:
if not walk or not walk.get("walk_id"):
return
# Stufe-5: annotierte Screenshots pro Finding. Schickt die
# gesammelten findings (B1 mobile + B16 slug-drift + B13 widerruf)
# zum consent-tester der pro Finding ein PNG erzeugt.
annotations: list[dict] = []
try:
findings_for_annot: list[dict] = []
rf = state.get("reachability_finding")
if rf and not rf.get("passed", True):
findings_for_annot.append({
"check_id": "COOKIE-CONSENT-UX-001",
"mobile_playwright": rf.get("mobile_playwright") or {},
})
for f in (state.get("extra_findings") or []):
cid = (f.get("check_id") or "").upper()
if cid in ("URL-SLUG-DRIFT-001", "WIDERRUF-REACH-001"):
findings_for_annot.append(f)
if findings_for_annot:
async with httpx.AsyncClient(timeout=120.0) as c:
r = await c.post(
f"{CONSENT_TESTER_URL}/annotate-findings",
json={"findings": findings_for_annot,
"home_url": homepage},
timeout=120.0,
)
if r.status_code == 200:
annotations = (r.json() or {}).get("annotations") or []
logger.info(
"B17 annotations: %d Screenshots erzeugt",
len(annotations),
)
except Exception as e:
logger.warning("annotate-findings request failed: %s", e)
walk["annotations"] = annotations
state["audit_walk"] = walk
state["audit_walk_html"] = _render(walk)
logger.info(
@@ -151,6 +185,11 @@ def _render(walk: dict) -> str:
n = a.get("expanded", 0)
detail = (f"{n} Akkordeon/Details-Sektion(en) entfaltet"
if n else "Keine Akkordeons gefunden")
elif act == "tour_cookie_banner":
n = a.get("clicks", 0)
opened = "Settings geöffnet" if a.get("settings_opened") \
else "kein Settings-Trigger gefunden"
detail = f"Cookie-Banner-Tour: {n} Klicks ({opened})"
rows.append(
f"<tr><td style='padding:4px 8px;font-family:monospace;"
f"color:#475569;'>{html.escape(ts)}</td>"