"""Saejae-1 P1 form test (2026-10-15), no Rhino: engine gate reports of data/새재1교P1 (G1 + G5) PASS with negatives detected, the pier exists with its template, reference piers unchanged (검증/open19_snapshot_after.json).""" import json import sys from pathlib import Path APP = Path(__file__).resolve().parents[1] sys.path.insert(0, str(APP)) sys.path.insert(0, str(APP / "tools")) from open19_snapshot import snapshot # noqa: E402 ok = True def check(name, cond, detail=""): global ok ok &= bool(cond) print("PASS" if cond else "FAIL", name, str(detail)[:300], flush=True) ref = json.loads((APP / "검증" / "open19_snapshot_after.json").read_text(encoding="utf-8")) now = snapshot() for k in ref: check(f"{k}: table records / proposals unchanged", ref[k]["records"] == now[k]["records"] and ref[k]["proposals"] == now[k]["proposals"]) D = APP / "data" / "새재1교P1" P = json.loads((D / "params.json").read_text(encoding="utf-8")) X = json.loads((D / "expected.json").read_text(encoding="utf-8")) check("scope G1 + G2 + G3 + G4 + G5, checker g1_pedestal.py", P["scope"] == ["G1", "G2", "G3", "G4", "G5"] and X["checkers"]["G1"] == "g1_pedestal.py") check("spread footing (no piles), 10 bearings on 5 shared pedestals", "piles" not in P and len(P["bearing_seats"]["bearings"]) == 10 and len(P["bearing_seats"]["pedestals"]) == 5) check("saved template", (APP / "data" / "_템플릿" / "새재1교P1형" / "params.json").exists()) for g, n, tot in (("G1", 138, 138), ("G2", 41, 41), ("G3", 72, 76), ("G4", 189, 189), ("G5", 183, 183)): # G3: 4 planned FAIL (B5~B8 count 51 vs 53) r = json.loads((D / "runs" / "current" / f"{g}_gate.json").read_text(encoding="utf-8")) check(f"{g} gate PASS {n}/{tot}, negatives detected", r["verdict"] == "PASS" and r["summary"]["passed"] == n and r["summary"]["total"] == tot and all(v["detected"] for v in r["negative"].values()), r["summary"]) print("RESULT", "PASS" if ok else "FAIL") sys.exit(0 if ok else 1)