#!/usr/bin/env python3 """Recompute the full 16-seed sweep summaries and landing band margins.""" from __future__ import annotations import json from pathlib import Path from PassageEnvelopeAudit import _landing_content_band_audit ROOT = Path(__file__).resolve().parents[4] OUT = ROOT / "Saved/Linux/l156/seeds" def finalize(kind: str) -> dict: directory = OUT / kind partial = directory / "runs-partial.json" results = json.loads(partial.read_text(encoding="utf-8")) if partial.is_file() else [] for row in results: layout_path = ROOT / row["layout"] bands = _landing_content_band_audit( json.loads(layout_path.read_text(encoding="utf-8"))) if layout_path.is_file() else [] band_pass = len(bands) == 6 and all(entry["passed"] for entry in bands) envelope = row.get("envelope_audit") or {} envelope["landing_content_band"] = bands envelope["landing_content_band_passed"] = band_pass envelope["passed"] = bool(envelope.get("passed") and band_pass) row["envelope_audit"] = envelope checks = row.setdefault("checks", {}) checks["envelope"] = bool(envelope["passed"] and envelope.get("outside_chamber_conflicts") == 0) checks["envelope_negative_control"] = bool( envelope.get("negative_controls") == envelope.get("negative_controls_expected") == 1) checks["landing_content_band"] = band_pass failed = [name for name, passed in checks.items() if not passed] row["verdict"] = "PASS" if not failed else "FAIL" row["reason"] = ", ".join(failed) if failed else "all requested gates pass" results.sort(key=lambda row: row["seed"]) completed = len(results) passed = sum(row["verdict"] == "PASS" for row in results) missing = sorted(set(range(16)) - {row["seed"] for row in results}) summary = {"kind": kind, "source_stamp": ( "4bf096c0a06f72eb765ff8785d55c00ded946ed1bd1f39fa1914b3658ceb61f0"), "completed": completed, "passed": passed, "failed": completed - passed, "missing_seeds": missing, "status": "PASS" if completed == 16 and passed == 16 else "FAIL", "results": results} partial.write_text(json.dumps(results, indent=2) + "\n", encoding="utf-8") (directory / "summary.json").write_text(json.dumps(summary, indent=2) + "\n", encoding="utf-8") print(f"[L156SeedSweepFinal] kind={kind} passed={passed}/{completed} " f"missing={len(missing)} status={summary['status']}") return summary if __name__ == "__main__": import argparse parser = argparse.ArgumentParser(description=__doc__) parser.add_argument("--kind", choices=("tunnel-network", "vertical-shafts"), required=True) args = parser.parse_args() raise SystemExit(0 if finalize(args.kind)["status"] == "PASS" else 1)