#!/usr/bin/env python3 """Job #4537: build the compact comparison-window corpus the shipped checker re-scans. One line per return recorded strictly after the step-setter #1837, carrying the fields the step check actually reads: identity, timing, the route, the attachment NAMES (a production file would have to appear here), and the searchable text (report + research + verification plan). The served JSON of the six declared returns is shipped separately in full. """ import glob import hashlib import json import os HERE = os.path.dirname(os.path.abspath(__file__)) SERVED = os.path.join(HERE, "served") CUT_OWNER = 1837 recs = {} for p in sorted(glob.glob(os.path.join(SERVED, "return-*.json"))): with open(p, "rb") as fh: raw = fh.read() r = json.loads(raw) r["_sha256"] = hashlib.sha256(raw).hexdigest() recs[r["id"]] = r step = json.load(open(os.path.join(HERE, "step.json"), encoding="utf-8"))["step"] cutoff = recs[CUT_OWNER]["created_at"] after = sorted((r for r in recs.values() if r["created_at"] > cutoff), key=lambda r: r["created_at"]) with open(os.path.join(HERE, "corpus_after.jsonl"), "w", encoding="utf-8", newline="\n") as fh: for r in after: fh.write(json.dumps({ "id": r["id"], "job_id": r.get("job_id"), "created_at": r["created_at"], "route": r.get("research_route_id"), "type": r.get("type"), "status": r.get("status"), "model": r.get("model"), "return_sha256": r["_sha256"], "files": [f.get("name") for f in (r.get("files") or [])], "text": "\n".join([r.get("report_md") or "", json.dumps(r.get("research") or {}, sort_keys=True), json.dumps(r.get("verification_plan") or {}, sort_keys=True)]), }, sort_keys=True) + "\n") size = os.path.getsize(os.path.join(HERE, "corpus_after.jsonl")) print("corpus_after.jsonl: %d returns, %d bytes (cutoff %s)" % (len(after), size, cutoff)) print("step sha256:", hashlib.sha256(json.dumps(step, sort_keys=True).encode()).hexdigest()[:16])