From 80a2e3687f3dee2e89c2f21d1f1584d3f831bec5 Mon Sep 17 00:00:00 2001 From: spark Date: Sat, 24 Oct 2026 18:26:47 +0000 Subject: [PATCH] q63: beam/verify_toposort_none -- asserts to _check(), so -O cannot print ALL VERIFIED on a broken toposort; record the unwired one-off status in-file --- wizard-work/beam/verify_toposort_none.py | 20 +++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) diff --git a/wizard-work/beam/verify_toposort_none.py b/wizard-work/beam/verify_toposort_none.py index a215ff6..a0df9ce 100644 --- a/wizard-work/beam/verify_toposort_none.py +++ b/wizard-work/beam/verify_toposort_none.py @@ -1,20 +1,30 @@ +# Q63 (2026-10-24): no committed gate invokes this file -- `git grep -F -n verify_toposort_none.py HEAD +# -- '*.py' '*.sh' CHECK` matches nothing outside this file -- so it is a one-off +# artifact, run by hand against its subject, not a standing check. """Verification artifact for toposort None-deps and one-shot materialisation.""" import os, sys sys.path.insert(0, os.path.dirname(os.path.abspath(__file__))) from toposort import topo_sort + +def _check(cond, msg="check failed"): + """Explicit failure path -- survives `python3 -O`, where `assert` is compiled away.""" + if not cond: + raise SystemExit(f"FAIL: {msg}") + + def gen(): yield "b" # None dep cases r = topo_sort({"a": None}) -assert r.sorted == ["a"] and r.cycle is None, r +_check(r.sorted == ["a"] and r.cycle is None, r) r = topo_sort({"a": ["z"], "z": None}) -assert r.sorted == ["z", "a"] and r.cycle is None, r +_check(r.sorted == ["z", "a"] and r.cycle is None, r) r = topo_sort({"a": None, "b": ["c"], "c": ["b"]}) -assert r.sorted is None and set(r.cycle) == {"b", "c"}, r +_check(r.sorted is None and set(r.cycle) == {"b", "c"}, r) # generator materialisation (must equal list case) -assert topo_sort({"a": gen()}).sorted == topo_sort({"a": ["b"]}).sorted == ["b", "a"] +_check(topo_sort({"a": gen()}).sorted == topo_sort({"a": ["b"]}).sorted == ["b", "a"]) # self-loop unchanged -assert topo_sort({"a": ["a"]}).cycle == ["a"] +_check(topo_sort({"a": ["a"]}).cycle == ["a"]) print("ALL VERIFIED")