#!/usr/bin/env python3 """job1525-checks.py — offline verification for job #1525 (cross-lane synthesis). Reads the eight served return payloads saved by this run under `runs/run_20260916_175540_tzzI-A/work/job1525/replies/` and (a) confirms the numeric strings quoted in `job1525-report.md` are really in the payloads (custody check: the numbers are channel-read, not re-derived here), and (b) computes the derived quantities the synthesis uses (slack series, per-step decrements, deceleration, W1grid ratio decay, scale of the modulus levels). Every printed claim in the report that is labelled `measured` is one of these checks. Nothing is asymptotic; no served file is edited. Exit 0 iff all checks pass. """ import json import os import re import sys HERE = os.path.dirname(os.path.abspath(__file__)) REPLIES = os.path.join(HERE, "replies") results = [] def check(name, ok, detail): results.append({"name": name, "ok": bool(ok), "detail": detail}) return ok def load(rn): with open(os.path.join(REPLIES, "return%s.json" % rn), encoding="utf-8") as fh: d = json.load(fh) return d.get("return", d) def body(r): return r.get("report_md") or "" # ---------------------------------------------------------------- custody: #159 r159 = load(159) b159 = body(r159) tct = [("17", 0.8881), ("19", 0.8975), ("23", 0.9180), ("29", 0.9324), ("37", 0.9477), ("41", 0.9551)] missing = [s for s, _ in tct if ("%s" % s) not in b159] for _, v in tct: missing += [] if ("%.4f" % v) in b159 else ["%.4f" % v] check("159 custody: TCT fold series 0.8881..0.9551 present verbatim in the served payload", not missing, "folds quoted and found; missing=%r" % (missing,)) check("159 custody: max at theta = 72 and frontier theta = 546 = G2(41#) named in the payload", ("θ = 72" in b159 or "theta = 72" in b159) and "546" in b159, "both anchors present in report_md") # derived: slack 1 - ratio, per-step decrements, deceleration of the increment slack = [(fold, 1.0 - v) for fold, v in tct] decr = [round(slack[i][1] - slack[i + 1][1], 4) for i in range(len(slack) - 1)] mean_decr = sum(decr) / len(decr) check("159 derived: slack 1 - max(N_new/RHS) shrinks at every fold 17..41", all(decr[i] > 0 for i in range(len(decr))), "slack=%r decrements=%r" % ([round(s, 4) for _, s in slack], decr)) check("159 derived: the last increment is below the mean increment (deceleration)", decr[-1] < mean_decr, "last=%.4f mean=%.4f" % (decr[-1], mean_decr)) # ---------------------------------------------------------------- custody: #165 r165 = load(165) b165 = body(r165) check("165 custody: worst D_y/x = -0.004283 at j = 27 against the -0.16 falsifier", "-0.004283" in b165 and "-0.16" in b165, "quoted values present in the payload") check("165 custody: W1grid/x 0.322294 (j=26) -> 0.127406 (j=34), monotone fall named", "0.322294" in b165 and "0.127406" in b165 and "monotonic" in b165.lower(), "endpoints and the monotonicity statement present in the payload") check("165 custody: F1/F2/F3 all reported as not triggered", b165.count("**no**") >= 2 and "F1" in b165 and "F2" in b165 and "F3" in b165, "falsifier verdicts present in the payload") # derived: W1grid decay over folds 26..34 decay = 0.127406 / 0.322294 per_fold = decay ** (1.0 / 8.0) check("165 derived: W1grid mass retains 0.3953x over 8 folds (per-fold factor 0.8905)", abs(decay - 0.39531) < 5e-5 and abs(per_fold - 0.89047) < 5e-5, "decay=%.5f per_fold=%.5f" % (decay, per_fold)) # ---------------------------------------------------------------- custody: #161/#162 b161 = body(load(161)) check("161 custody: max L = 4 at p = 31; every column reads 1 from p = 127", "Maximum L = 4 at p = 31" in b161 and "from p = 127" in b161, "both anchors present in the payload") b162 = body(load(162)) check("162 custody: the three censuses 214708725 / 6226553025 / 217929355875 present", all(s.replace(",", "") in b162.replace(",", "") for s in ("214,708,725", "6,226,553,025", "217,929,355,875")), "all three integers present in the payload") # ---------------------------------------------------------------- custody: #101/#4 r101 = load(101) b101 = body(r101) check("101 custody: all-depth sub-2 certificate c*_real(u) <= 1973/1000 < 2 for every u > 4", "1973/1000" in b101 and "u>4" in b101.replace(" ", ""), "certificate text present in the payload") r4 = load(4) b4 = body(r4) check("4 custody: Opera de Cribro Thms 9.16-9.18 reached at OCR, Iwaniec-Kowalski 17.2 NOT reached", "9.16" in b4 and "17.2" in b4 and ("NOT REACHED" in b4 or "not reached" in b4.lower()), "both custody admissions present in the payload") # ---------------------------------------------------------------- derived: level decoupling consumed = 0.1 # TWIN-REDUCTION.md consumes Q = T^{1/10} stated = 0.5 # (M) is stated at Q <= T^{1/2}(log T)^-B published = "logarithmic" # Opera de Cribro 9.16-9.18 / I-K 17.2 level check("derived: the consumer's level (1/10) is strictly below the stated level (1/2)", consumed < stated, "consumed=%s stated=%s published=%s -> the published level is stronger than needed" % (consumed, stated, published)) check("derived: neither finite instrument in the twin lane records a modulus level " "(no 'Q =' / level parameter in the #159 or #165 payloads)", not re.search(r"\bQ\s*=\s*x\^\{\s*1/1?0\s*\}", b159 + b165), "searched both payloads for a level parameter") failed = [r for r in results if not r["ok"]] summary = { "job": 1525, "tool": "job1525-checks.py", "replies_read": sorted(os.listdir(REPLIES)), "checks": results, "passed": len(results) - len(failed), "total": len(results), "all_passed": not failed, "note": "custody checks confirm the quoted numbers are the served payload's own; the derived " "checks are finite arithmetic over those payload values. No served file was edited and " "no asymptotic statement is made.", } with open(os.path.join(HERE, "checks.json"), "w", encoding="utf-8") as fh: json.dump(summary, fh, indent=1, sort_keys=False) fh.write("\n") for r in results: print("%-5s %s" % ("PASS" if r["ok"] else "FAIL", r["name"])) if not r["ok"]: print(" %s" % r["detail"]) print("%d/%d passed; wrote checks.json" % (summary["passed"], summary["total"])) sys.exit(0 if summary["all_passed"] else 1)