#!/usr/bin/env python3 """job2543-checks.py -- documentary verification ledger for the cross-lane synthesis. Reads ONLY files this run already fetched into ../replies/ (no network). Every check is an exact-string / exact-value assertion against an accepted return payload or a served document fetched this turn. Prints a JSON ledger; exit 0 iff all_pass. Checks are grouped: A* the claim about the served fold-arithmetic-bridge.md being the PRE-patch text while return #101 is integrated/proven; B* the quoted facts of return #152 (L7 transfer) and its served note; C* the quoted facts of return #101 (all-depth sub-2 certificate) and #151's band audit; D* the prior-work / channel record. """ import json, os, re, sys HERE = os.path.dirname(os.path.abspath(__file__)) REPLIES = os.path.join(HERE, "..", "replies") def load(name): with open(os.path.join(REPLIES, name), encoding="utf-8") as f: return json.load(f) def raw(name): d = load(name) return d["raw"] if isinstance(d, dict) and "raw" in d else json.dumps(d) def check(results, name, ok, detail): results.append({"check": name, "pass": bool(ok), "detail": detail}) def main(): r = [] r101 = load("return101.json") r151 = load("return151.json") r152 = load("return152.json") fab = raw("fold-arithmetic-bridge.json") fem = raw("fixed-endpoint-discrepancy.json") l7 = raw("l7transfer.json") # A -- return #101 provenance and the served-doc drift check(r, "A1 #101 accepted/proven", r101.get("status") == "accepted" and r101.get("final_rung") == "proven", f"status={r101.get('status')} final_rung={r101.get('final_rung')}") check(r, "A2 #101 patch integrated", r101.get("patch_status") == "integrated" and r101.get("effects_applied_at"), f"patch_status={r101.get('patch_status')} effects_applied_at={r101.get('effects_applied_at')}") rev = [f for f in r101.get("files", []) if f["name"] == "fold-arithmetic-bridge.md"] rev_bytes = rev[0]["bytes"] if rev else None check(r, "A3 #101 revises fold-arithmetic-bridge.md", rev is not None and r101.get("revision_path") == "research/fold-arithmetic-bridge.md", f"revision_path={r101.get('revision_path')} revised_bytes={rev_bytes}") check(r, "A4 served doc is the PRE-patch text (no Proposition 6)", "Proposition 6" not in fab and "1973" not in fab, f"served_has_Proposition6={'Proposition 6' in fab} served_has_1973={'1973' in fab}") old = "The rigorous sub-2 ranges remain (4,4.8] and (8,infinity). On (4.8,8]" check(r, "A5 served doc still carries the pre-patch sub-2 sentence", old in fab, f"served_raw_chars={len(fab)} revised_bytes={rev_bytes} added_chars={None if rev_bytes is None else rev_bytes-len(fab)}") patch = r101.get("patch") or "" check(r, "A6 #101 patch adds section 4b and c*_real<=1973/1000", "4b. All-depth sub-2 certificate" in patch and "1973/1000" in patch, f"patch_has_4b={'4b. All-depth sub-2 certificate' in patch} patch_has_1973={'1973/1000' in patch}") # C -- #101 scope and #151 band reach check(r, "C1 served note leaves (Cov_u) and (Dec_1) undecided", "decide (Cov_u) or" in fab and "(Dec_1)" in fab, f"scope_sentence_present={'decide (Cov_u) or' in fab}") check(r, "C2 #101 leaves Cov_u/Dec_1 unaltered", "does not alter the unproved Cov_u or Dec_1 inputs" in (r101.get("report_md") or ""), "report_md quote present" if "does not alter the unproved Cov_u or Dec_1 inputs" in (r101.get("report_md") or "") else "MISSING") check(r, "C3 #151 says (4.9) is band-only, one sufficient input", "(4.9) is one stronger sufficient input" in fem and "P_band" in fem, f"fem_has_band_claim={'(4.9) is one stronger sufficient input' in fem} P_band={'P_band' in fem}") # B -- #152 / L7 l7q = "No transfer mechanism in the corpus reaches L7" check(r, "B1 L7 note verdict: no mechanism reaches L7", l7q in l7, l7q) check(r, "B2 union-bound transfer vacuous from x=11", "The budget passes 1 at `x = 11`" in l7, "exact CRT budget sentence present") check(r, "B3 vector sieve 5.2974 > beta2 and K_BF=5.158064680330", "5.2974" in l7 and "5.158064680330" in l7, f"has_5.2974={'5.2974' in l7} has_K_BF={'5.158064680330' in l7}") check(r, "B4 #152 audit reports L7 stays OPEN", "L7 stays OPEN" in (r152.get("report_md") or ""), "report_md quote present" if "L7 stays OPEN" in (r152.get("report_md") or "") else "MISSING") # D -- prior work / channels with open(os.path.join(HERE, "..", "arxiv-search.json"), encoding="utf-8") as f: arx = json.load(f) allfail = all(str(v[0]) != "200" for v in arx.values()) check(r, "D1 arXiv API channel failed for control and topical queries", allfail, "; ".join(f"{k}={v[0]}:{v[1]}" for k, v in arx.items())) check(r, "D2 #101 cites return #99 and message #303", r101.get("cites", {}).get("returns") == [99] and r101.get("cites", {}).get("messages") == [303], json.dumps(r101.get("cites"))) all_pass = all(c["pass"] for c in r) print(json.dumps({"ledger": "job2543-checks", "version": 1, "checks": r, "passed": sum(1 for c in r if c["pass"]), "total": len(r), "all_pass": all_pass}, indent=1)) return 0 if all_pass else 1 if __name__ == "__main__": sys.exit(main())