#!/usr/bin/env python3 """Step check for job #4473 (route 83, first look / step check of the held pursuit #4175). Decides whether the returns recorded after the step-setter #1830 already answer route 83's next experiment. Stdlib only, deterministic, offline. python stepcheck4473.py [--served DIR] [--json OUT] Reads only these served extracts (all fetched with `fetch_served.py`): served/route-83.json served/return-1830.json the step-setter served/return-1835.json the only return the server named as "linked" served/scan/return-1988.json job #4472, routeless discover, lane dir-558 served/scan/return-1983.json accepted audit on the same premise served/scan/return-1984.json explore on the same premise served/scan_after_1830.json the completeness scan over returns > 1830 A missing or unreadable input is a FAILED CHECK, never a crash. Exit 0 iff every check passes. Nothing here makes a mathematical claim about primes. """ from __future__ import annotations import argparse import json import math import os import sys HERE = os.path.dirname(os.path.abspath(__file__)) # ---------------------------------------------------------------- check ledger CHECKS: list[tuple[str, bool, str]] = [] def chk(name: str, ok: bool, note: str = "") -> None: CHECKS.append((name, bool(ok), note)) def load(path: str): try: with open(path, encoding="utf-8") as fh: return json.load(fh) except Exception as exc: # a missing input is a failed check, not a crash chk("input:" + os.path.basename(path), False, "%s: %s" % (type(exc).__name__, exc)) return None # ------------------------------------------------------------- small helpers def sieve_primes(n: int) -> list[int]: if n < 2: return [] s = bytearray([1]) * (n + 1) s[0] = s[1] = 0 for i in range(2, int(n ** 0.5) + 1): if s[i]: s[i * i::i] = bytearray(len(s[i * i::i])) return [i for i in range(n + 1) if s[i]] def primorial(x: int) -> int: r = 1 for p in sieve_primes(x): r *= p return r def report_text(rec: dict) -> str: parts = [] for k in ("report_md", "recipe_md", "finding", "human_md"): v = rec.get(k) if isinstance(v, str): parts.append(v) if isinstance(rec.get("research"), dict): parts.append(json.dumps(rec["research"])) return "\n".join(parts) # The step's own locator identifiers (return #1830, research.next_step). A return # that answers the step has to name at least one of the load-bearing ones. STEP_LOCATORS = ["2412.19644", "1208.5992", "1704.04831", "barban", "davenport", "halberstam", "siegel", "walfisz", "general sequence", "general-sequence", "bdh"] # route 83's own object vocabulary: the varE / lam0 / lam1 / E_d lane. STEP_OBJECT = ["lam0", "lam1", "vare", "e_d", "friable", "unbalanced cell", "smooth-aps", "attack-0830", "job1945", "recon-0830"] def hits(text: str, words) -> list[str]: low = text.lower() return sorted({w for w in words if w.lower() in low}) # ------------------------------------------------------------------- the run def run(served: str) -> dict: rt = load(os.path.join(served, "route-83.json")) r30 = load(os.path.join(served, "return-1830.json")) r35 = load(os.path.join(served, "return-1835.json")) r88 = load(os.path.join(served, "scan", "return-1988.json")) r83 = load(os.path.join(served, "scan", "return-1983.json")) r84 = load(os.path.join(served, "scan", "return-1984.json")) scan = load(os.path.join(served, "scan_after_1830.json")) # ---- A. the step and its provenance -------------------------------- if rt is not None: chk("A1 route-83 record is revision 6, state active", rt.get("revision") == 6 and rt.get("state") == "active", "rev=%s state=%s" % (rt.get("revision"), rt.get("state"))) chk("A2 route-83 last_return_id is 1830 and no job is waiting (next_job_id null)", str(rt.get("last_return_id")) == "1830" and rt.get("next_job_id") in (None, ""), "last=%s next=%s" % (rt.get("last_return_id"), rt.get("next_job_id"))) chk("A3 route-83 has exactly one open job: #4473, first_look, 0.25 h", [j.get("id") for j in (rt.get("jobs") or []) if j.get("status") == "assigned"] == ["4473"] and [j.get("budget_hours") for j in (rt.get("jobs") or []) if j.get("id") == "4473"] == ["0.25"], json.dumps([(j.get("id"), j.get("status"), j.get("budget_hours")) for j in (rt.get("jobs") or [])[:2]])) if rt is not None and r30 is not None: ns_rt = rt.get("next_step") ns_30 = (r30.get("research") or {}).get("next_step") chk("A4 the route's stored next_step is byte-identical to #1830's research.next_step", json.dumps(ns_rt, sort_keys=True) == json.dumps(ns_30, sort_keys=True)) if r30 is not None: ns = (r30.get("research") or {}).get("next_step") or {} q = (ns.get("question") or "").lower() m = (ns.get("method") or "").lower() chk("A5 #1830 sets the step: question names Barban-Davenport-Halberstam", "barban" in q and "davenport" in q and "halberstam" in q) chk("A6 #1830's method names the alternative source arXiv:2412.19644", "2412.19644" in m) chk("A7 #1830's step carries the fallback to the Kloosterman-fraction form", "kloosterman" in ((ns.get("failure") or "") + " " + m).lower() and "e^{-1}" in (ns.get("failure") or "")) chk("A8 #1830 outcome is progress and depends_on is [1035]", (r30.get("research") or {}).get("outcome") == "progress" and (r30.get("research") or {}).get("depends_on") == [1035], json.dumps((r30.get("research") or {}).get("depends_on"))) chk("A9 #1830 created_at = 2026-09-26T13:37:28.204Z", r30.get("created_at") == "2026-09-26T13:37:28.204Z", r30.get("created_at")) chk("A10 #1830's own model is not this session's model family", bool(r30.get("model")), "setter model=%s" % r30.get("model")) # ---- B. the comparison set ----------------------------------------- if r35 is not None: chk("B1 #1835 is route 134, outcome known, depends_on [1819]", str(r35.get("research_route_id")) == "134" and (r35.get("research") or {}).get("outcome") == "known" and (r35.get("research") or {}).get("depends_on") == [1819], "route=%s outcome=%s" % (r35.get("research_route_id"), (r35.get("research") or {}).get("outcome"))) t35 = report_text(r35) chk("B2 #1835 names none of the step's locator identifiers", hits(t35, STEP_LOCATORS) == [], str(hits(t35, STEP_LOCATORS))) chk("B3 #1835 names none of the step's object identifiers", hits(t35, STEP_OBJECT) == [], str(hits(t35, STEP_OBJECT))) chk("B4 #1835's subject is the platform mirror-cut / registry code, not the varE step", "recordmirrorcut" in t35.lower() and "questions.md" in t35.lower()) if scan is not None: rows = scan.get("rows") or [] chk("B5 the completeness scan covers ids 1831..1988 (151 present, 9 absent)", scan.get("lo") == 1831 and scan.get("hi") == 1990 and len(rows) == 151 and len(scan.get("absent") or []) == 9, "present=%d absent=%s" % (len(rows), scan.get("absent"))) # re-derive the hits from the served texts themselves, not from the # scanner's own keyword column texts, routes, missing = {}, {}, [] for r in rows: rec = load(os.path.join(served, "scan", "return-%s.json" % r["id"])) if rec is None: missing.append(r["id"]) continue texts[r["id"]] = report_text(rec) routes[r["id"]] = rec.get("research_route_id") chk("B5b every return the scan lists is on disk and re-readable", not missing, str(missing)) chk("B6 no return recorded after #1830 sits on route 83", [i for i, rt_ in routes.items() if str(rt_) == "83"] == []) chk("B6b the scanner reported no false-positive hit " "(every recorded hit token really occurs in that return's text)", all(k.lower() in texts.get(r["id"], "").lower() for r in rows for k in (r.get("hits") or [])), "per-return re-scan") loc = sorted(i for i, t in texts.items() if hits(t, STEP_LOCATORS)) chk("B7 the post-#1830 returns naming a step locator are #1857/#1861/#1876/#1916/" "#1928/#1951/#1969/#1978/#1981/#1983/#1984/#1986/#1988; #1951's is a search " "string only ('... Siegel Walfisz Titchmarsh divisor flip'), not a locator of " "this step's theorem", loc == [1857, 1861, 1876, 1916, 1928, 1951, 1969, 1978, 1981, 1983, 1984, 1986, 1988], str(loc)) obj = sorted(i for i in loc if hits(texts[i], STEP_OBJECT)) chk("B8 of those, the ones that also carry route 83's object vocabulary " "(varE / lam0 / lam1 / E_d / friable) are exactly #1983, #1984 and #1988", obj == [1983, 1984, 1988], str(obj)) chk("B9 the other locator hits are other lanes' own BDH/Vinogradov vocabulary, " "not the varE object (#1857 max-over-y, #1861 floor-form kill, #1876 route 89 band, " "#1916/#1928 route 169 census, #1951 a search string, #1969 equal-ratio, " "#1978/#1981/#1986 this session's route-36/45/36 step checks)", all(i not in obj for i in (1857, 1861, 1876, 1916, 1928, 1951, 1969, 1978, 1981, 1986))) # ---- C. what the answering return actually says --------------------- if r88 is not None and r30 is not None: chk("C1 #1988 is recorded after #1830", str(r88.get("created_at")) > str(r30.get("created_at")), "%s > %s" % (r88.get("created_at"), r30.get("created_at"))) chk("C2 #1988 is routeless (research_route_id null) and has no research object", r88.get("research_route_id") in (None, "") and r88.get("research") in (None, {}), "route=%s" % r88.get("research_route_id")) chk("C3 #1988 is job #4472, lane 32 (`dir-558`), status recorded", str(r88.get("job_id")) == "4472" and str(r88.get("lane_id")) == "32" and r88.get("status") == "recorded") t88 = report_text(r88) chk("C4 #1988 locates Harper arXiv:2412.19644v1 Theorem 1 at the page", "2412.19644v1" in t88 and "Theorem 1" in t88 and "read in the paper's HTML at the statement" in t88) chk("C5 #1988 states the located range `sqrt(2x) < Q <= x`", "sqrt(2x) < Q <= x" in t88) chk("C6 #1988 maps it onto the route-83 dictionary as d > (2L)^(1/3)", "d > (2L)^(1/3)" in t88 and "Q = d" in t88 and "x = L/d" in t88) chk("C7 #1988 states the step does not close (so the step is NOT answered)", "The step still does not close" in t88) chk("C8 #1988 re-derives the refuted printed prefix (H_w) and keeps the lam0-average target", "(H_w)" in t88 and "lam0" in t88 and "prefix" in t88.lower()) # F2 table, read from the served report t88_flat = " ".join(t88.split()) row19 = "| 19 | 0.3853 | 0.8487 | 0.9642 | 0.9856 | 0.9856 | -3.273753 |" row23 = "| 23 | 0.3960 | 0.8621 | 0.9746 | 0.9994 | 0.9994 | -3.824747 |" chk("C9 #1988's F2 table rows for x = 19 and x = 23 are as quoted", row19 in t88_flat and row23 in t88_flat) chk("C10 #1988 quotes the covered sub-range as the top 13.1 % (19#) / 13.7 % (23#)", "13.1 %" in t88 and "13.7 %" in t88) chk("C11 #1988 quotes the covered share of the measured cell as < 0.06 %", "< 0.06 %" in t88) if r83 is not None and r84 is not None: t83, t84 = report_text(r83), report_text(r84) chk("C12 #1983 is an accepted audit naming both Harper sources", r83.get("status") == "accepted" and r83.get("final_rung") == "proven" and "1208.5992" in t83 and "2412.19644" in t83) chk("C13 #1984 names both Harper sources and the printed (H_w)", "1208.5992" in t84 and "2412.19644" in t84 and "(H_w)" in t84) # ---- D. independent arithmetic (re-derived, not read) --------------- P19, P23 = primorial(19), primorial(23) chk("D1 19# = 9699690 and 23# = 223092870 by an independent sieve", P19 == 9699690 and P23 == 223092870, "%d %d" % (P19, P23)) chk("D2 the split exponent is interior: 1/3 < 2/5, so (2L)^(1/3) < L^(2/5) with room 1/15", abs((2 / 5 - 1 / 3) - 1 / 15) < 1e-15) frac = {} for x, L in ((19, P19), (23, P23)): ln = math.log(L) # covered log-share of the moduli range [1, L^(2/5)]: the part d > (2L)^(1/3) frac[x] = (2 / 5 * ln - 1 / 3 * (ln + math.log(2))) / (2 / 5 * ln) chk("D3 the closed form 1/6 - 5ln2/(6lnL) reproduces 13.1 % (19#) and 13.7 % (23#)", abs(frac[19] - 0.1308) < 5e-4 and abs(frac[23] - 0.1366) < 5e-4, "%.5f %.5f" % (frac[19], frac[23])) chk("D4 the split point (2L)^(1/3) is 268.70 at 19# and 764.14 at 23#", abs((2 * P19) ** (1 / 3) - 268.6969) < 5e-3 and abs((2 * P23) ** (1 / 3) - 764.1382) < 5e-3, "%.4f %.4f" % ((2 * P19) ** (1 / 3), (2 * P23) ** (1 / 3))) share19, share23 = 0.9856, 0.9994 # #1988's F2 column d < (2L)^(1/3) chk("D5 the range the located theorem covers carries 1 - 0.9994 = 6.0e-4 at 23# " "(= the quoted < 0.06 %)", abs((1 - share23) - 6e-4) < 1e-12 and (1 - share23) < 0.0006 + 1e-15) chk("D6 the mass sits far below the split: d <= 100 carries 0.9746 at 23#, split at 764.1", share23 > 0.97 and (2 * P23) ** (1 / 3) > 100) chk("D7 both measured levels have the same sign: the covered part is the top " "log-fraction only and grows with x (0.1308 -> 0.1366)", frac[23] > frac[19] > 0.13) # ---- E. the decision ------------------------------------------------ chk("E1 the step demands a written lemma for sum_{d<=L^(2/5)} lam0(d)|E_d| = o(ln^2 y); " "nothing on record writes it, so the outcome is not `known`", r88 is not None and "The step still does not close" in report_text(r88)) chk("E2 the step's first clause is answered (the theorem is located, its range mapped), " "so the outcome is not `promising` either: the old step is replaced", r88 is not None and "d > (2L)^(1/3)" in report_text(r88)) passed = sum(1 for _, ok, _ in CHECKS if ok) failed = [n for n, ok, _ in CHECKS if not ok] return {"checks": len(CHECKS), "passed": passed, "failed": failed, "covered_log_fraction": {"19#": frac.get(19), "23#": frac.get(23)}, "all_pass": not failed} def main() -> int: try: sys.stdout.reconfigure(encoding="utf-8", errors="replace") except Exception: pass ap = argparse.ArgumentParser() ap.add_argument("--served", default=os.path.join(HERE, "served")) ap.add_argument("--json", default=None) a = ap.parse_args() res = run(a.served) for name, ok, note in CHECKS: print("%s %s%s" % ("PASS" if ok else "FAIL", name, (" [%s]" % note) if note else "")) print("ALL_PASS %s (%d/%d)" % (res["all_pass"], res["passed"], res["checks"])) if a.json: with open(a.json, "w", encoding="utf-8") as fh: json.dump({"checks": [{"name": n, "pass": ok, "note": nt} for n, ok, nt in CHECKS], "summary": res}, fh, indent=1) return 0 if res["all_pass"] else 1 if __name__ == "__main__": raise SystemExit(main())