"""Job #996: is #191's caveat ("the three random: lines cannot be recovered") measured, not just asserted? Structure only, and deterministic: run the ORIGINAL served probe three times, take the set of line indices on which the three runs differ from one another, and compare that set with the line indices on which the SEEDED probe differs from the original's first run. The random DRAW values are never printed, so the output does not depend on which numbers were drawn -- only on which lines carry them. """ import hashlib import json import re import subprocess ORIG = "job996/files/probe-original.js" SEED = "job996/files/probe-seeded.js" def run(path): r = subprocess.run(["node", path], capture_output=True, text=True, timeout=120) assert r.returncode == 0, r.stderr return r.stdout.splitlines() def differing(a, b): return sorted(i for i, (x, y) in enumerate(zip(a, b)) if x != y) runs = [run(ORIG) for _ in range(3)] n = len(runs[0]) assert all(len(r) == n for r in runs), [len(r) for r in runs] vary = set() for a in range(3): for b in range(a + 1, 3): vary |= set(differing(runs[a], runs[b])) seeded = run(SEED) vs = set(differing(runs[0], seeded)) # the listed-case lines are the first seven; the random: lines are the rest kinds = [("listed" if not ln.startswith(" random:") else "random") for ln in runs[0]] random_lines = [i for i, k in enumerate(kinds) if k == "random"] listed_lines = [i for i, k in enumerate(kinds) if k == "listed"] out = { "probe": ORIG, "seeded": SEED, "runs": 3, "lines": n, "lines_varying_across_original_runs": sorted(vary), "lines_right_of_random_value_column": random_lines, "lines_varying_original_vs_seeded": sorted(vs), "listed_case_lines_identical_across_all_runs": all( runs[0][i] == runs[1][i] == runs[2][i] == seeded[i] for i in listed_lines), "non_random_lines_identical_original_vs_seeded": sorted(vs) == sorted(vary), "residues_drawn_are_the_only_difference": sorted(vs) == sorted(random_lines), "stdout_sha_original_run1": hashlib.sha256(("\n".join(runs[0]) + "\n").encode()).hexdigest(), "stdout_sha_seeded": hashlib.sha256(("\n".join(seeded) + "\n").encode()).hexdigest(), "listed_case_digest": hashlib.sha256( ("\n".join(seeded[i] for i in listed_lines) + "\n").encode()).hexdigest(), } print(json.dumps(out, indent=1))