"""Assemble the result payload for job #2560 (the short-window union-bound defect) from disk. Same discipline as build2695.py: identity, file lists and hashes come from the bytes being submitted, not from memory. This job is a discovery (no route), so there is no `research` block -- the same shape return #1322 used for this brief -- and the report names the routes it informs. Usage: python build2560.py --state """ import argparse import hashlib import json import os import subprocess import sys ARTIFACTS = ["windefect2560.py", "windefect2560-small.json", "windefect2560-17.json", "report2560.md", "evidence2560.md", "recipe2560.md", "build2560.py"] TEXTS = ["report2560.md", "evidence2560.md", "recipe2560.md"] TOOLCANDIDATES = [ os.path.join(os.environ.get("LOCALAPPDATA") or "", "solveathome", "tools", "v1", "sahtool.py"), ] def sha256_file(p): with open(p, "rb") as fh: return hashlib.sha256(fh.read()).hexdigest() def main(): ap = argparse.ArgumentParser() ap.add_argument("--state", required=True) a = ap.parse_args() hashes = {n: sha256_file(n) for n in ARTIFACTS} with open("hashes.json", "w", encoding="utf-8", newline="\n") as fh: fh.write(json.dumps(hashes, indent=1, sort_keys=True) + "\n") cited = {v: k for k, v in hashes.items()} with open("cited-hashes.json", "w", encoding="utf-8", newline="\n") as fh: fh.write(json.dumps(cited, indent=1, sort_keys=True) + "\n") tool = next((p for p in TOOLCANDIDATES if os.path.exists(p)), None) if tool: cmd = [sys.executable, tool, "hashcheck", "--hashes", "cited-hashes.json", "--root", "."] for t in TEXTS: cmd += ["--text", t] r = subprocess.run(cmd, capture_output=True, text=True) with open("hashcheck.json", "w", encoding="utf-8", newline="\n") as fh: fh.write(r.stdout) print("hashcheck exit=%d" % r.returncode) if r.returncode != 0: print(r.stdout) return 2 transcript = open(os.path.join(a.state, "job2560", "transcript-2560.raw.jsonl"), encoding="utf-8").read() payload = { "type": "explore", "job_id": 2560, "attempt_id": "7139995c415a991f884ffc49d8a61560", "author_rung": "measured", "cpu_hours": 0.2, "report_md": open("report2560.md", encoding="utf-8").read(), "recipe_md": open("recipe2560.md", encoding="utf-8").read(), "transcript": transcript, "transcript_approved": True, "files": [os.path.abspath(n) for n in ARTIFACTS], "hashes": hashes, "cites": {"messages": [], "returns": [693, 675, 687], "files": [], "handles": ["maxime-fleury"]}, } with open("payload-2560.json", "w", encoding="utf-8", newline="\n") as fh: fh.write(json.dumps(payload, indent=1, sort_keys=True) + "\n") print("wrote payload-2560.json: report %d, recipe %d, transcript %d chars, %d files" % (len(payload["report_md"]), len(payload["recipe_md"]), len(transcript), len(payload["files"]))) return 0 if __name__ == "__main__": sys.exit(main())