# Repair of return #1372 (checker): the checker now performs the stdout byte comparison # instead of asserting that stdout cannot be compared. # # Base (served) : f6df183be28a1ba7d5ad1eaa2bcad82b0c123a0a9656e3bad80f08f5e266f386 # Repaired : 438ee90848c3f4200612c03fb8bfb6265a0ed845dfa13014210a41139d35abf0 # # Apply from the package root: patch -p1 < rerun-1372.patch --- a/rerun-1372.py +++ b/rerun-1372.py @@ -19,8 +19,8 @@ Exit codes: 0 all checks pass, 3 a check failed, 2 the directory is incomplete. -Every file is read as served; nothing is fetched and no network is used. Deterministic apart from -the artifact timings the author's own script prints to stdout (see note in the output). +Every file is read as served; nothing is fetched and no network is used. Deterministic: the +artifact and the author's stdout are both compared byte for byte against pinned digests. """ import argparse import hashlib @@ -32,6 +32,21 @@ # sha256 of the served target artifact, arrangement-composite.json, as served by return #1372 and # as reproduced byte for byte on 2026-09-22 by the executing run. TARGET_SHA = "3a04416d0add73883cd62d7afaf25af7f144c9bcac7fbbe2153f2c9d22f87ba9" + +# sha256 of the author's `--mode composite` stdout under the REPAIRED arrangement-stats.py +# (return #1372 revision, script sha 3c56ea89...). The repaired stream is the artifact only +# -- two JSON documents of counts and verdicts, no paths and no timings. +# +# NEWLINES: this digest is taken over the stream with newlines normalized to LF, which is +# exactly what subprocess text=True hands us, so it is the same number on a Windows and a +# POSIX worker. A digest of the RAW bytes would not be portable: measured here, the served +# pre-repair stream was 175 CRLFs on Windows and would have hashed differently on Linux. +# The repaired revision ALSO writes stdout LF-only, so on both platforms its raw bytes now +# equal this normalized form -- the normalization is belt and braces, not a crutch. +# +# The pre-repair bytes printed per-500-row elapsed seconds into this same stream, which is +# why they had no digest at all; performing this comparison is what the repair buys. +EXPECTED_CHILD_STDOUT_SHA = "5ac372df87986407b3b66bcd353a8fdb707ffb2e34570bfd56308320d528cec0" # The five published custody gates (route 112/98/100/117 lineage), as the author's GATES list holds # them: (base, killer set, expected K*). Kept here so the plan is auditable without the module. @@ -62,7 +77,12 @@ ap.add_argument("--dir", required=True) ap.add_argument("--skip-composite", action="store_true") ap.add_argument("--target-sha", default=TARGET_SHA) + ap.add_argument("--expect-stdout", default=EXPECTED_CHILD_STDOUT_SHA, + help="pinned sha256 of the author's composite stdout; pass `none` to " + "compare only the file artifact (the pre-repair behaviour)") a = ap.parse_args() + if a.expect_stdout == "none": + a.expect_stdout = None # older, weaker check: the file artifact alone missing = [f for f in REQUIRED if not os.path.exists(os.path.join(a.dir, f))] if missing: @@ -94,24 +114,34 @@ if not a.skip_composite: rc, out, err = run(["arrangement-stats.py", "--mode", "composite", "--cap", "2000000"], a.dir, timeout=1800) - # the author's script writes progress+timing to stdout, then two JSON objects; take them - # by shape rather than by line number so a progress line cannot shift the parse. + # the author's script writes two JSON objects on stdout (progress and timing go to + # stderr in the repaired revision); take them by shape rather than by line number so a + # stray line cannot shift the parse. custody = block('{\n "rows"', out) claims = block('{\n "claims"', out) art = os.path.join(a.dir, "arrangement-composite.json") got = sha256(art) if os.path.exists(art) else None + child_stdout_sha = hashlib.sha256(out.encode()).hexdigest() + script_sha = sha256(os.path.join(a.dir, "arrangement-stats.py")) + stdout_ok = a.expect_stdout is None or child_stdout_sha == a.expect_stdout checks.append({"name": "composite rerun reproduces the served artifact", "exit_code": rc, "stderr_tail": err[-400:] if rc else "", + "script_sha256": script_sha, "artifact_sha256": got, "expected_sha256": a.target_sha, "byte_identical": got == a.target_sha, + "stdout_sha256": child_stdout_sha, + "expected_stdout_sha256": a.expect_stdout, + "stdout_byte_identical": stdout_ok, "custody_all_match": bool(custody and custody.get("all_match")), "must_hold_violations": (claims or {}).get("must_hold_violations"), - "pass": rc == 0 and got == a.target_sha + "pass": rc == 0 and got == a.target_sha and stdout_ok and bool(custody and custody.get("all_match"))}) - checks.append({"note": "stdout of the author's script carries per-500-row progress with " - "timings, so the stdout stream is not byte-reproducible; the file " - "artifact is. This is the defect already recorded in the return's " - "own file_notes."}) + checks.append({"note": "The repaired revision moves progress and elapsed seconds to " + "stderr, so BOTH the file artifact and the stdout stream are " + "compared above. Under the served (pre-repair) bytes the stdout " + "digest was not reproducible and only the file artifact could be " + "compared; passing --expect-stdout none restores that older, " + "weaker check."}) ok = all(c.get("pass") for c in checks if "pass" in c) print(json.dumps({"ok": ok, "method": "rerun", "expected_answer_visible": True,