U1 (runtime, u1-u10): new Phase Z-owned deterministic verification module src/phase_z2_verification_utils.py (335 LOC, stdlib only) porting H3 utility surface — VerificationResult, extract_text_from_html, normalize_for_comparison, extract_keywords, strip_meta_lines, split_into_sentences, verify_text_preservation, detect_invented_text. 10 unit tests under tests/phase_z2/test_pz2_vu_*.py (56 tests). u11 (design-only): docs/architecture/IMP-16-U2-WIRING-DESIGN.md fixes the Step 1/2/14/21/22 reverse-path contract, redesigned frame-contract pattern reservation (IMP-20), and IMP-07 hard-gate criteria. No runtime wiring lands in this commit — U2 stays blocked until IMP-07 reverse path is implemented + verified + runtime-hit. Guardrails: no src.content_verifier import; no FORBIDDEN_KEI_MEMOS / generate_with_retry / REQUIRED_PATTERNS / verify_structure / verify_area / verify_all_areas usage; no AI / Kei / httpx / SSE path; AI-isolation contract upheld (utility is deterministic). Tests: 56 targeted PASS (0.19s), 15 regression baseline PASS (7.59s). Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
60 lines
2.0 KiB
Python
60 lines
2.0 KiB
Python
"""u1 — VerificationResult dataclass surface (IMP-16-U1).
|
|
|
|
Locks the Phase Z verification utility module anchor and the
|
|
VerificationResult shape so downstream units (u2~u10) can rely on it
|
|
without importing src.content_verifier.
|
|
"""
|
|
from __future__ import annotations
|
|
|
|
import ast
|
|
import importlib
|
|
|
|
import pytest
|
|
|
|
|
|
def test_module_importable_without_content_verifier():
|
|
mod = importlib.import_module("src.phase_z2_verification_utils")
|
|
tree = ast.parse(open(mod.__file__, encoding="utf-8").read())
|
|
for node in ast.walk(tree):
|
|
if isinstance(node, ast.Import):
|
|
for alias in node.names:
|
|
assert "content_verifier" not in alias.name, (
|
|
"Phase Z verification utility must not import "
|
|
"src.content_verifier"
|
|
)
|
|
elif isinstance(node, ast.ImportFrom):
|
|
assert node.module is None or "content_verifier" not in node.module, (
|
|
"Phase Z verification utility must not import "
|
|
"src.content_verifier"
|
|
)
|
|
|
|
|
|
def test_verification_result_defaults():
|
|
from src.phase_z2_verification_utils import VerificationResult
|
|
|
|
r = VerificationResult(passed=True, area_name="zone_test")
|
|
assert r.passed is True
|
|
assert r.area_name == "zone_test"
|
|
assert r.checks == {}
|
|
assert r.score == 0.0
|
|
assert r.errors == []
|
|
assert r.warnings == []
|
|
|
|
|
|
def test_verification_result_independent_default_collections():
|
|
from src.phase_z2_verification_utils import VerificationResult
|
|
|
|
a = VerificationResult(passed=False, area_name="a")
|
|
b = VerificationResult(passed=False, area_name="b")
|
|
a.checks["x"] = True
|
|
a.errors.append("e")
|
|
a.warnings.append("w")
|
|
assert b.checks == {} and b.errors == [] and b.warnings == []
|
|
|
|
|
|
def test_verification_result_required_fields():
|
|
from src.phase_z2_verification_utils import VerificationResult
|
|
|
|
with pytest.raises(TypeError):
|
|
VerificationResult() # type: ignore[call-arg]
|