"""Phase Z2 deterministic verification utilities (IMP-16-U1 port). Ports the H3 deterministic subset of src/content_verifier.py into a Phase Z-owned module so the Phase Z pipeline never imports the Phase Q reference-only module (which co-hosts H4/H5 Kei/AI assets). Scope: deterministic, pure, no I/O, no LLM call, no httpx/SSE. Wiring into Step 1/2/14/21/22 is gated behind IMP-07 (see docs/architecture/IMP-16-U2-WIRING-DESIGN.md when u11 lands). """ from __future__ import annotations import re from dataclasses import dataclass, field from difflib import SequenceMatcher from html.parser import HTMLParser @dataclass class VerificationResult: """Single-axis deterministic verification outcome. Mirrors the Phase Q VerificationResult shape so callers ported from that surface keep their field access; the value semantics are Phase Z-owned (no Phase Q area defaults baked in). """ passed: bool area_name: str checks: dict[str, bool] = field(default_factory=dict) score: float = 0.0 errors: list[str] = field(default_factory=list) warnings: list[str] = field(default_factory=list) class _TextExtractor(HTMLParser): """Extract visible text only. Skips