#!/usr/bin/env python3 """Compare every L18 SurfaceWorld matrix hash row with the approved L14 reference.""" import re import sys from pathlib import Path ROOT = Path(__file__).resolve().parents[4] RUNS = ROOT / "Saved/Linux/l18-matrix" REFERENCE = ROOT / "Saved/Linux/l14-final-hash-sw-clang-off-w12-r5.log" PATTERN = re.compile(r"^\[Pipeline(?:FullDetailHash|WholeViewHash|LODHash|ExactQueryHash)\].*$", re.M) expected = PATTERN.findall(REFERENCE.read_text(encoding="utf-8")) if not expected or len(expected) != 12: raise SystemExit(f"invalid L14 reference hash rows: {len(expected)}") logs = sorted(RUNS.glob("surface-world-*.log")) if len(logs) != 14: raise SystemExit(f"expected 14 SurfaceWorld matrix logs, found {len(logs)}") failed = [] for path in logs: actual = PATTERN.findall(path.read_text(encoding="utf-8", errors="replace")) if actual != expected: failed.append(path.name) print(f"[SurfaceHashMismatch] {path.name} expected={len(expected)} actual={len(actual)}") print(f"[SurfaceHashGate] reference={REFERENCE.name} rows={len(logs)} expected_rows=14 " f"result={'FAIL' if failed else 'PASS'}") raise SystemExit(1 if failed else 0)