#!/usr/bin/env python3 """Route 148 step (1): for each published verdict-producing reader, remove the instant from the record it consumes, re-run it, and classify: CHANGED / REFUSED-AND-STATED / SILENTLY-UNCHANGED. Inputs (all public, fetched by sha256 from /files/): #1541 census.py, #1541 sahdated-write-exemptions.json, #1549 sahdated-1.1.1-served.py, #1549 verify-producers-probe.py, #1549 producers-probe.json, and #1541's job2830 *.py laid out under pop/job2830/. usage: python3 reader_table_2940.py (run from the directory holding f1541/ f1549/ v111/ pop/) stdout: deterministic JSON (paths relative, no clock values). """ import ast, contextlib, copy, hashlib, importlib.util, io, json, os, subprocess, sys, tempfile H = lambda p: hashlib.sha256(open(p, "rb").read()).hexdigest() SD = "v111/sahdated.py" INSTANT = ("covered_at", "observed_at", "measured_at", "generated_at", "walked_at", "stamped_at", "recorded_at", "written_at", "at") def strip(rec): r = copy.deepcopy(rec) for k in INSTANT: r.pop(k, None) return r def run(argv): p = subprocess.run([sys.executable] + argv, capture_output=True, text=True) return p.returncode, p.stdout.replace(os.getcwd() + "/", "") rows = [] td = tempfile.mkdtemp(prefix="rt2940-") # 1. census.py load_state, extracted verbatim by AST from #1541 (census.py imports unpublished siblings) src = open("f1541/census.py", encoding="utf-8").read() fn = next(n for n in ast.parse(src).body if isinstance(n, ast.FunctionDef) and n.name == "load_state") spec = importlib.util.spec_from_file_location("sd", SD); sd = importlib.util.module_from_spec(spec); spec.loader.exec_module(sd) ns = {"os": os, "json": json, "sys": sys, "Covered": sd.Covered, "Undated": sd.Undated, "STATE": None} exec(compile(ast.Module(body=[fn], type_ignores=[]), "census.py:load_state", "exec"), ns) base = {"tool": "census.py/1.0", "at": "2026-09-23T16:53:44Z", "projections": {"6": {"status": "pending"}}} res = {} for tag, rec in (("dated", base), ("stripped", strip(base))): p = os.path.join(td, "census-state-%s.json" % tag); json.dump(rec, open(p, "w")) err = io.StringIO() with contextlib.redirect_stderr(err): got = ns["load_state"](p) res[tag] = {"returns_baseline": got is not None, "stderr": err.getvalue().replace(td + "/", "")} rows.append({"reader": "census.py load_state (#1541, verbatim function)", "consumes": "census baseline (`at`)", "dated": res["dated"], "stripped": res["stripped"], "class": "REFUSED-AND-STATED" if res["dated"]["returns_baseline"] and not res["stripped"]["returns_baseline"] and "cannot be read as current" in res["stripped"]["stderr"] else "UNEXPECTED", "consequence": "the pass runs FULL and judges no diff"}) # 2./3. sahdated 1.1.1 CLI readers of the published exemption list ex = json.load(open("f1541/sahdated-write-exemptions.json")) pe = os.path.join(td, "exemptions-stripped.json"); json.dump(strip(ex), open(pe, "w")) d_rc, d_out = run([SD, "producers", "pop/job2830", "--exempt", "f1541/sahdated-write-exemptions.json"]) s_rc, s_out = run([SD, "producers", "pop/job2830", "--exempt", pe]) rows.append({"reader": "sahdated 1.1.1 producers --exempt", "consumes": "exemption list (`covered_at`)", "dated": {"exit": d_rc, "last": d_out.strip().splitlines()[-1]}, "stripped": {"exit": s_rc, "last": s_out.strip().splitlines()[0].split(" ")[0]}, "class": "REFUSED-AND-STATED" if d_rc == 0 and s_rc == 3 else "UNEXPECTED", "consequence": "no site verdict is printed"}) d_rc, d_out = run([SD, "audit", "f1541/sahdated-write-exemptions.json"]) s_rc, s_out = run([SD, "audit", pe]) rows.append({"reader": "sahdated 1.1.1 audit", "consumes": "any record", "dated": {"exit": d_rc, "last": d_out.strip().splitlines()[-1]}, "stripped": {"exit": s_rc, "last": s_out.strip().splitlines()[-1][:60]}, "class": "CHANGED" if d_rc == 0 and s_rc == 2 else "UNEXPECTED", "consequence": "VERDICT undated, exit 2 (the audit's purpose)"}) # 4. verify-producers-probe.py (#1549) on its own target, dated vs stripped tg = json.load(open("f1549/producers-probe.json")) pt = os.path.join(td, "producers-probe.json"); json.dump(strip(tg), open(pt, "w")) sha = H("f1549/sahdated-1.1.1-served.py") d_rc, d_out = run(["f1549/verify-producers-probe.py", "--target", "f1549/producers-probe.json", "--sahdated-sha256", sha, "--sahdated", "f1549/sahdated-1.1.1-served.py"]) s_rc, s_out = run(["f1549/verify-producers-probe.py", "--target", pt, "--sahdated-sha256", sha, "--sahdated", "f1549/sahdated-1.1.1-served.py"]) dj, sj = json.loads(d_out), json.loads(s_out) for j in (dj, sj): j.pop("target", None) same = dj == sj rows.append({"reader": "verify-producers-probe.py (#1549)", "consumes": "producers-probe.json (`at`, `covered_at`, `written_at`)", "dated": {"exit": d_rc, "verdict": dj.get("verdict")}, "stripped": {"exit": s_rc, "verdict": sj.get("verdict")}, "outputs_equal_except_target_path": same, "class": "SILENTLY-UNCHANGED" if same and d_rc == s_rc else "CHANGED", "consequence": "none needed: it checks fixture text against a pinned module hash, not currency"}) # 5. accepted-text-published.py (#1541): network + token, not executed; code reading src5 = open("f1541/accepted-text-published.py", encoding="utf-8").read().splitlines() reads = [i + 1 for i, l in enumerate(src5) if "blob" in l] rows.append({"reader": "accepted-text-published.py --watch (#1541)", "consumes": "census watch output (`at`)", "method": "code reading (lines %s): only blob['moved_values'] is read; not executed (needs network and the proposer's token path)" % reads, "class": "SILENTLY-UNCHANGED (by reading)", "consequence": "its output names the watch PATH but not the watch's instant, so a stale watch yields readings stamped now"}) # 6. audit-transport-codes.py: in the proposer's private tree, not published rows.append({"reader": "audit-transport-codes.py (proposer tree)", "consumes": "adjudication record (`covered_at`)", "method": "not published on any route-148 return; #1541/#1549 report it (externally reported, not rerun)", "class": "CHANGED (externally reported)", "consequence": "3 rows UNRESOLVED -> ARRIVED AFTER when the instant became generated (#1541)"}) print(json.dumps({"inputs": {p: H(p) for p in ("f1541/census.py", "f1541/sahdated-write-exemptions.json", "f1549/sahdated-1.1.1-served.py", "f1549/verify-producers-probe.py", "f1549/producers-probe.json")}, "rows": rows}, indent=1, sort_keys=True)) import shutil shutil.rmtree(td)