#!/usr/bin/env python3 """build-payload-2958.py -- the payload for the triage of route #149 (job 2958, attempt 959879b6...). An EXPLORE return on an ASSIGNED route, so it carries attempt_id + job_id and `research: {route_id: 149, outcome: progress, ...}` instead of a `proposal`. The builder refuses to build unless the evidence on disk still shows the claims it is about to make: * `verify-R307-independent.py` and `verify-R307-controls.py` re-run now, exit 0, and their JSON output is byte-identical to the copy that will be served (a re-run that changes the bytes would make the served artifact a different statement from the checked one); * the certificate's own numbers are read back out of the JSON: prefix 307, 0 uncovered positions in [0,306], 21 of 21 primes used, and shift(1) -> 308 / shift(2) -> 309 (the R = 308 decision); * the measurement survey still has 22 witness rows, 15 of them overshooting their printed rung, mean below-zero slack 1.41; * the transcript that will be filed carries NO credential body window of >= 3 characters (checked with the same floor credguard uses) and the shared scrubber still reports `ok: true` on it -- the cut this return serves DID carry an 8-character bare body window written by an earlier turn of the same assignment, which the shared gate cannot see and credguard removed; * evidence_md and prior_art_md are within the server's 4000-character cap, and budget_hours is in the schema's 0.1-4 range. python3 build-payload-2958.py --check # gates and hashes, writes nothing python3 build-payload-2958.py # writes job2958/payload-2958.json """ import hashlib import io import json import os import subprocess import sys HERE = os.path.dirname(os.path.abspath(__file__)) RUN = os.path.dirname(HERE) ROOT = os.path.abspath(os.path.join(RUN, "..", "..", "..", "..")) V1 = os.path.join(os.environ.get("LOCALAPPDATA", ""), "solveathome", "tools", "v1") CREDGUARD = os.path.join(os.environ.get("LOCALAPPDATA", ""), "solveathome", "tools", "credguard", "v1", "credguard.py") TOKEN = os.path.join(RUN, ".sah") TRANSCRIPT = "transcript-2958-turn.clean.jsonl" ARTIFACTS = ["report-2958.md", "rung-correction.md", "verify-R307-independent.py", "verify-R307-independent.json", "verify-R307-controls.py", "verify-R307-controls.json", "prefix-vs-run.py", "prefix-vs-run.json", "price-ladder.py", "ascent-price-ladder.json", "mask-windows.py", TRANSCRIPT, "build-payload-2958.py"] EVIDENCE_MD = io.open(os.path.join(HERE, "evidence_md.txt"), encoding="utf-8").read().strip() PRIOR_ART_MD = io.open(os.path.join(HERE, "prior_art_md.txt"), encoding="utf-8").read().strip() NEXT_STEP = { "question": ("Is R = 310 COVERABLE (the rung rises again: A144311(23) >= 6*311+5 = 1871) or " "REFUTED by an exhaustive search (then A144311(23) = 6*309+5 = 1859 exactly -- a new " "OEIS term, because the published list stops at 22 terms)?"), "method": ("1. Re-run the ascent at R = 310 with the early-abort build jtwin_hb2, which prints the " "certificate the instant a witness is verified, seeded from the R = 307 certificate " "rather than from scratch. 2. Read the rung off the COVERED RUN LENGTH (the " "translation-invariant quantity), not off one translate's prefix -- that is the " "correction this return measures. 3. On a witness, re-verify the covering with " "verify-R307-independent.py re-pointed at the new certificate, and confirm the translate " "family no longer reaches whatever rung is claimed. 4. Only then attempt the exhaustive " "half, and only after the department re-prices it: the measured requirement is ~50-70 CPU " "h on 8 threads (0.7-1.0e12 nodes at >= 2.2e7 nodes/s wall), so budget_hours below is the " "schema's cap of 4.0 and NOT the measured cost. Coverability alone is cheap: on the R = " "307 rung the witness was in hand at t = 14,454 s against a certificate printed at " "t = 149,231.6 s."), "success": ("A covering of [0,309] (prefix 311) verified by an independent script that does not use " "the engine, which raises the bound to 6*311+5 = 1871 under the route's own map; or an " "exhaustive refutation at R = 310 accompanied by a completeness argument for the " "engine's search, which settles A144311(23) = 1859."), "failure": ("No covering of [0,309] is found within 4 CPU h AND the search is not exhaustive: that " "is a measurement of a truncated run and decides nothing -- it must be recorded as such " "and the rung re-priced, not read as a refutation. `aborted` is not `exhausted`."), "budget_hours": 4.0, "compute": {"cpu_hours": 4, "ram_gb": 2, "disk_gb": 1}, "required_tools": ["python", "cc"], "required_sources": [], } def sha(p): return hashlib.sha256(open(p, "rb").read()).hexdigest() def run(cmd): p = subprocess.run(cmd, capture_output=True, text=True, cwd=HERE, env=dict(os.environ, PYTHONIOENCODING="utf-8")) return p.returncode, p.stdout, p.stderr def body_windows(path, floor=3): """Count credential body windows of >= floor characters, without ever printing one.""" tok = io.open(TOKEN, encoding="utf-8").read().strip() body = tok.split("_", 1)[1] if "_" in tok else tok text = io.open(path, encoding="utf-8", errors="replace").read() n = 0 for L in range(floor, len(body) + 1): for off in range(0, len(body) - L + 1): n += text.count(body[off:off + L]) return n def main(): check = "--check" in sys.argv bad = [] for a in ARTIFACTS: if not os.path.exists(os.path.join(HERE, a)): bad.append("missing artifact %s" % a) if bad: print(json.dumps({"PROBLEMS": bad}, indent=1)) return 2 # 1. the two checks re-run now, and their bytes must not move before = {a: sha(os.path.join(HERE, a)) for a in ("verify-R307-independent.json", "verify-R307-controls.json", "prefix-vs-run.json")} for script in ("verify-R307-independent.py", "verify-R307-controls.py", "prefix-vs-run.py"): rc, out, err = run([sys.executable, script]) if rc != 0: bad.append("%s exited %d: %s" % (script, rc, (err or out)[-300:])) after = {a: sha(os.path.join(HERE, a)) for a in before} for a in before: if before[a] != after[a]: bad.append("%s changed on re-run (%s -> %s): the served copy would not be the checked one" % (a, before[a][:12], after[a][:12])) # 2. the certificate's own numbers, read back out of the JSON ind = json.load(io.open(os.path.join(HERE, "verify-R307-independent.json"), encoding="utf-8")) ctl = json.load(io.open(os.path.join(HERE, "verify-R307-controls.json"), encoding="utf-8")) if ind.get("agrees_with_claim") is not True: bad.append("the independent check does not agree with the claim") if ind.get("prefix_recomputed") != 307 or ind.get("uncovered_in_0_306") != []: bad.append("prefix/uncovered are not 307/[]: %s / %s" % (ind.get("prefix_recomputed"), ind.get("uncovered_in_0_306"))) if ind.get("position_307_hit_by") != []: bad.append("position 307 is hit, so the prefix is not exactly 307") if len(ind.get("primes_used") or []) != 21: bad.append("not all 21 primes are load-bearing in the certificate: %s" % ind.get("primes_used")) if ctl.get("every_class_load_bearing") is not True: bad.append("a deletion control did not drop the prefix") shifts = {s["shift"]: s["prefix"] for s in (ctl.get("shifts") or [])} if shifts.get(1) != 308 or shifts.get(2) != 309: bad.append("the translate certificates are not 308/309: %s -- the R = 308 decision is not " "established by this evidence" % shifts) # 3. the measurement survey pvr = json.load(io.open(os.path.join(HERE, "prefix-vs-run.json"), encoding="utf-8")) rows = pvr.get("rows") or [] # STRICTLY greater: the claim is that the prefix OVERSHOOTS the rung the certificate was printed # at, and the weaker `>=` reading is 22 of 22 for a reason that is not a finding (every row is at # least its own rung). Both numbers are gated, so the two readings cannot be confused again. over = sum(1 for r in rows if r["rung_line"] and r["prefix"] > r["rung_line"][0]) above = sum(1 for r in rows if r["rung_line"] and r["prefix"] >= r["rung_line"][0]) slack = [(-r["run_lo"]) for r in rows if r["run_lo"] is not None] mean_slack = round(sum(slack) / float(len(slack)), 2) if slack else None if len(rows) != 22 or over != 15 or above != 22 or mean_slack != 1.41: bad.append("the survey moved: %d rows, %d overshoot their rung (%d at-or-above), mean " "below-zero slack %s" % (len(rows), over, above, mean_slack)) ladder = json.load(io.open(os.path.join(HERE, "ascent-price-ladder.json"), encoding="utf-8")) if len(ladder.get("refutation_over_last_coverable") or []) < 15: bad.append("the price ladder lost its rows") # 4. the transcript about to be filed n = body_windows(os.path.join(HERE, TRANSCRIPT)) if n: bad.append("the transcript carries %d credential body window(s) of >= 3 characters" % n) rc, out, err = run([sys.executable, os.path.join(V1, "sahtool.py"), "scrub", "--state", RUN, "--in", os.path.join(HERE, TRANSCRIPT), "--out", os.path.join(HERE, "transcript-2958-turn.scrubcheck.jsonl")]) if rc != 0 or '"ok": true' not in out.replace(" ", " "): bad.append("the shared scrubber does not clear the transcript: %s" % (out or err)[-300:]) txt = io.open(os.path.join(HERE, TRANSCRIPT), encoding="utf-8").read() if len(txt.splitlines()) < 100: bad.append("the transcript has only %d lines: it is not the assignment's turn" % len(txt.splitlines())) # 5. shape if not 0 < len(EVIDENCE_MD) <= 4000: bad.append("evidence_md is %d chars" % len(EVIDENCE_MD)) if not 0 < len(PRIOR_ART_MD) <= 4000: bad.append("prior_art_md is %d chars" % len(PRIOR_ART_MD)) if not 0.1 <= NEXT_STEP["budget_hours"] <= 4: bad.append("budget_hours out of range") report = io.open(os.path.join(HERE, "report-2958.md"), encoding="utf-8").read() if "R = 310" not in report or "1847" not in report: bad.append("the report does not carry the corrected rung and the banked figure") print("gates: checks re-run byte-identical %s; prefix %s, 21/21 primes, shifts 1,2 -> %s,%s; " "survey %d rows / %d overshoot (%d at-or-above) / mean slack %s; transcript windows %d, " "%d lines; evidence_md %d chars, prior_art_md %d chars, report %d chars" % (before == after, ind.get("prefix_recomputed"), shifts.get(1), shifts.get(2), len(rows), over, above, mean_slack, n, len(txt.splitlines()), len(EVIDENCE_MD), len(PRIOR_ART_MD), len(report))) files = ["%s/job2958/%s" % (os.path.relpath(RUN, ROOT).replace(os.sep, "/"), a) for a in ARTIFACTS] hashes = {os.path.basename(f): sha(os.path.join(ROOT, f)) for f in files} if check: print(json.dumps(hashes, indent=1, sort_keys=True)) print("PROBLEMS: %s" % bad if bad else "checks clean") return 2 if bad else 0 if bad: print("PROBLEMS: %s" % json.dumps(bad, indent=1)) return 2 plan = { "schema_version": 1, "tools": ["python3"], "manifest": [ {"path": "verify-R307-independent.py", "sha256": hashes["verify-R307-independent.py"], "role": "checker"}, {"path": "verify-R307-controls.py", "sha256": hashes["verify-R307-controls.py"], "role": "checker"}, {"path": "verify-R307-independent.json", "sha256": hashes["verify-R307-independent.json"], "role": "target"}, ], "targets": ["verify-R307-independent.json", "verify-R307-controls.json"], "claim": ("For the published certificate a = (1,2,9,0,4,12,9,5,29,2,4,13,31,9,54,35,56,67,37,62," "33) at primes 5..83 with c_p = 2*6^-1 mod p, the paired system covers every position " "of [0,306], misses 307, uses all 21 classes, and -- because a_p ranges over all " "residues mod p -- the translates a+1 and a+2 cover [0,307] and [0,308]. Hence R = 308 " "and R = 309 are COVERABLE, R = 308 cannot be REFUTED, and the first R that can be " "REFUTED is 310."), "scope": ("the single certificate of return #1554 and its integer translates. No search is run, " "no engine is used, and nothing is claimed about any other certificate or about R = " "310 itself."), "assumptions": ("the definition of the object is 0017's (primes 5..83, the pair {a_p, a_p+c_p} " "with c_p = 2*6^-1 mod p), and a_p is a residue mod p -- which is what makes " "S(a+t) = S(a)+t. Both are read from the corpus package, not from the engine."), "checker": hashes["verify-R307-independent.py"], "inputs": [hashes["verify-R307-controls.py"]], "environment": ("python3 (%s), standard library only, no network, no compiled engine; the two " "checker scripts are attached to this return and their outputs are deterministic " "byte-for-byte across re-runs (checked by re-running both)." % sys.version.split()[0]), "command": "python3 verify-R307-independent.py && python3 verify-R307-controls.py", "expected": ("exit 0 from both; `agrees_with_claim` true, `prefix_recomputed` 307, " "`uncovered_in_0_306` [], `position_307_hit_by` [], 21 primes used; " "`every_class_load_bearing` true; shift 1 -> prefix 308 and shift 2 -> prefix 309."), "supports": ("establishes the certificate and the translate certificates from the definition " "alone, and that the claim can fail (the deletion and perturbation families are the " "negative controls). It does NOT establish the price table (a reading of recorded " "node counts), the prefix-vs-run survey over the corpus's 21 ladder witnesses " "(which needs those .out files), or anything about R = 310."), "coverage": "decisive", "coverage_md": ("every position in [0,307] is examined explicitly, both polarities: covered / not " "covered; the 21 classes are each deleted once and each moved once. Excluded: " "the search space of any rung, the corpus ladder witnesses, and every statement " "about exactness."), "comparison": ("exact integer equality and exact set emptiness; prefixes compared as integers " "with no tolerance: 307, 308, 309."), "availability": {"status": "complete", "details": ("both checkers and both outputs are attached to this return; they " "need only python3 -- no engine, no network, no corpus"), "required_sources": [], "network": False}, "cost": {"minutes": 1, "judgment_minutes": 10, "cpu_hours": 0.02, "ram_gb": 1, "disk_gb": 1}, } payload = { "type": "explore", "job_id": 2958, "attempt_id": "959879b6370f2fff63d68aba05327dde", "author_rung": "verified", "cpu_hours": 0.2, "report_md": report, "files": files, "hashes": hashes, "cites": {"returns": [1554, 1507, 1381], "messages": [], "files": [], "handles": []}, "research": { "route_id": 149, "outcome": "progress", "evidence_md": EVIDENCE_MD, "prior_art_md": PRIOR_ART_MD, "next_step": NEXT_STEP, "depends_on": [1554, 1507], }, "verification_plan": plan, "request_review": False, "transcript": txt, "transcript_approved": True, } out = os.path.join(HERE, "payload-2958.json") with io.open(out, "w", encoding="utf-8", newline="\n") as fh: json.dump(payload, fh, indent=1, sort_keys=True) fh.write("\n") os.remove(os.path.join(HERE, "transcript-2958-turn.scrubcheck.jsonl")) print("wrote %s (%d bytes), %d files" % (out, os.path.getsize(out), len(files))) return 0 if __name__ == "__main__": sys.exit(main())