#!/usr/bin/env python3 """Job #4537 (route 148 step check): the comparison scan, written to scan.json. Reads the fetched served record under ./served (or ./, for a fresh run beside the shipped inputs) and records, for every return recorded strictly after the step-setter #1837: * identity and timing, the route it sits on, and its attachment names; * which of the step's vocabulary words its searchable text carries; * the relation verdict used by the step check. It runs no experiment and reproduces no computation a return already made: it only reads. """ import glob import json import os import re HERE = os.path.dirname(os.path.abspath(__file__)) SERVED = os.path.join(HERE, "served") if not os.path.isdir(SERVED): SERVED = HERE VOCAB = ["sahdated", "instant_fields", "hashed-artifact", "object-level", "job2830", "1.1.3", "2940", "reader_table", "limit test", "unresolved"] STEP = json.load(open(os.path.join(HERE, "step.json"), encoding="utf-8"))["step"] # the returns the brief names to compare against, and what each is NAMED = { 1541: ("route 148 origin", "sahdated 1.1.1: the contract exists; no object-level guard"), 1549: ("route 148", "recognition gaps measured; still a whole-file guard"), 1562: ("routeless file repair", "#1549's selftest log repaired; not this step"), 1837: ("route 148 step-setter", "sahdated 1.1.2: window guard; LIMIT residual declared"), 2004: ("route 141", "patch queue mapping; names #1837 as unrelated"), 2019: ("route 148 previous step check", "comparison only; the step copied forward"), 2024: ("route 100", "the server listed it; names #2019 as unrelated to its step"), } recs = {} for p in sorted(glob.glob(os.path.join(SERVED, "return-*.json"))): with open(p, encoding="utf-8") as fh: r = json.load(fh) recs[r["id"]] = r cutoff = recs[1837]["created_at"] rows = [] for r in sorted((x for x in recs.values() if x["created_at"] > cutoff), key=lambda x: x["created_at"]): t = "\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)]).lower() hits = [v for v in VOCAB if v in t] prod = [f.get("name") for f in (r.get("files") or []) if re.search(r"sahdated|2940|2830|producers", f.get("name") or "", re.I)] rows.append({"id": r["id"], "created_at": r["created_at"], "route": r.get("research_route_id"), "type": r.get("type"), "status": r.get("status"), "model": r.get("model"), "vocab_hits": hits, "n_vocab": len(hits), "production_files": prod, "implements_step": False}) scan = { "job_id": 4537, "route_id": 148, "reading": "2026-09-28 (fetch of the served return and route records)", "step_setter": {"return_id": 1837, "created_at": cutoff}, "step_question": STEP["question"], "window": {"n_returns": len(rows), "first": rows[0]["id"], "last": rows[-1]["id"]}, "vocabulary": VOCAB, "strong_hits": [r["id"] for r in rows if r["n_vocab"] >= 3], "route_148_in_window": [r["id"] for r in rows if str(r["route"]) == "148"], "production_files_in_window": [(r["id"], n) for r in rows for n in r["production_files"]], "named_returns": [{"id": i, "role": NAMED[i][0], "settles_step": False, "relation": NAMED[i][1]} for i in sorted(NAMED)], "conclusion": ("no return recorded after the step-setter implements or tests the object-level " "guard or the typed hashed-artifact exemption; the step is copied forward " "unchanged"), "rows": rows, } with open(os.path.join(HERE, "scan.json"), "w", encoding="utf-8", newline="\n") as fh: fh.write(json.dumps(scan, indent=1, sort_keys=True) + "\n") print("scan.json: %d returns after #1837, strong hits %s, route-148 rows %s" % (len(rows), scan["strong_hits"], scan["route_148_in_window"]))