Add cross-examine gate script
Browse files1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253"""cross-examine-patch.py — Emergency-sync Secondary Brain gate.
Loads Lighthouse CI output and the Chrome DevTools MCP report and cross-examines them (primary/secondary cohesion). Fails the gate unless both agree.Usage: python scripts/cross-examine-patch.py \ --preview <url> --lighthouse <lhci manifest> --secondary <mcp report.json>"""import argparseimport jsonimport pathlibimport sys
parser = argparse.ArgumentParser()parser.add_argument("--preview")parser.add_argument("--lighthouse")parser.add_argument("--secondary")args = parser.parse_args()
print(f"Cross-examining patch at {args.preview}")
failures = []warnings = []
# ---- Lighthouse CI manifest ------------------------------------------------lh_path = pathlib.Path(args.lighthouse) if args.lighthouse else Noneif lh_path and lh_path.exists(): manifest = json.loads(lh_path.read_text()) for run in manifest if isinstance(manifest, list) else [manifest]: if run.get("categories", {}).get("performance", {}).get("score", 0) < 0.9: failures.append(f"Lighthouse performance < 0.9: {run.get('categories', {}).get('performance', {}).get('score')}") if run.get("categories", {}).get("accessibility", {}).get("score", 0) < 1.0: failures.append("Lighthouse accessibility < 1.0")else: warnings.append("No Lighthouse manifest found — relying on MCP secondary report")
# ---- Chrome DevTools MCP secondary report ----------------------------------secondary_path = pathlib.Path(args.secondary) if args.secondary else Noneif secondary_path and secondary_path.exists(): data = json.loads(secondary_path.read_text()) if data.get("verdict") != "pass": failures.append(f"Secondary brain verdict: {data.get('verdict')} -> {data.get('reasoning')}")else: failures.append("Secondary brain report missing — gate cannot pass")
for w in warnings: print(f"WARN: {w}")if failures: print("FAIL:") for f in failures: print(f" - {f}") sys.exit(1)print("PASS: Both primary and secondary brain agree — cohesive unit verified")scripts/cross-examine-patch.pyAdded+53