"""Run operator checks for saved completion-stage sites, never live workspaces.""" from pathlib import Path import json,subprocess,hashlib B=Path(__file__).resolve().parents[1];node='[local user]/.cache/codex-runtimes/codex-primary-runtime/dependencies/node/bin/node' reference=(B/'kit/candidate/task-03/site/server.py').read_bytes() for p in sorted((B/'completion/runs').glob('T03-*/result.json')): data=json.loads(p.read_text()) for st,info in data['stages'].items(): stage=p.parent/st;site=stage/'output/site';dest=stage/'browser-audit' if(dest/'checks.json').exists():continue if not(site/'server.py').exists():continue if(site/'server.py').read_bytes()!=reference: print(json.dumps({'run':p.parent.name,'stage':st,'needs_code_review':'server differs from supplied fixture'}),flush=True);continue dest.mkdir(exist_ok=True);r=subprocess.run([node,str(B/'build/verify_site.mjs'),str(site),str(dest)],capture_output=True,text=True) (dest/'verifier-output.json').write_text(r.stdout);(dest/'verifier-stderr.txt').write_text(r.stderr) print(json.dumps({'run':p.parent.name,'stage':st,'exit':r.returncode}),flush=True)