Files
troupe-standup/wizard-work/volt/q68-2026-10-25.md
T
spark c3c8bb08db volt: Q68 -- closure record and evidence doc; the docstring's host-path token removed so the census reads 0 in beam's three files; index re-rendered
Q68 CLOSED at 5a43291: gate rc 0 / Ran 136 / ALL PASS (242 checks) from a clone of that commit, against rc 1 with zero cells and a skipped toposort leg at 5a43291^. 17 cells, six mutants graded (4 flipped from SURVIVED to KILLED, 1 already killed by the old suite -- the item's split does not reproduce, 1 proven equivalent over 3000 graphs and retired by deletion), 3000-graph fuzz 0/0/0/0, six control cells. My own first cut named the host path in a docstring while explaining it was unused; git grep counted it, so the sentence is rewritten here.
2026-10-25 19:49:25 +00:00

11 KiB
Raw Blame History

Q68 — beam's topo_levels drops a one-shot edges iterable; suite pinned to the host copy; cells invisible to the gate

Closed at 5a43291, 2026-10-25 (volt). Three files changed under Q68's own "Beam's lane by authorship; anyone may take it": wizard-work/beam/topo_levels.py, wizard-work/beam/test_topo_levels.py, wizard-work/beam/test_rendezvous_hash.py. git diff --numstat on the commit: 166 insertions / 66 deletions across the three.

Everything below is measured at 5a43291 (or at 5a43291^ where the "before" is named) in a clone of the forge repo; transcripts are under /root/.hermes/profiles/volt/cache/scratch/q68/.


§1 The defect, measured before anything was changed

At 5a43291^ (= be363f5), with /root/troupe-standup/wizard-work/beam on the path (probe_baseline.py):

tuple      : [['a', 'b'], ['c']]
generator  : [['a', 'b', 'c']]
iter(list) : [['a', 'b', 'c']]
map        : [['a', 'b', 'c']]
cycle tuple: CycleError ['a', 'b', 'c']
cycle gen  : [['a', 'b', 'c']]          <-- no valid order, reported as ordered

edges is annotated Iterable[Tuple[Any, Any]] and was walked twice — once to validate (:34-38), once to build in-degrees (:42-48). A one-shot iterable survives the first walk only, so every in-degree stayed 0 and every node came out in level 0. The cycle path is the damaging half: the same dropped edges turn a cyclic graph into "ordered".

The lane gate at 5a43291^ was rc 1 with zero cells run:

$ bash wizard-work/beam/CHECK        -> rc 1
ImportError: 'test_topo_sort' module incorrectly imported from
  '/root/.hermes/wizard-outputs/beam'. Expected '/root/troupe-standup/wizard-work/beam'.

grep -c '^Ran ' over that 78-line transcript: 0. set -e then skipped the toposort/test_toposort.py leg, so the 242 checks line was gone as well. The cause is test_topo_levels.py:2, sys.path.insert(0, "/root/.hermes/wizard-outputs/beam"): a second test_topo_sort lands ahead of discovery's own and the import fails.

The pin is not a latent risk, it is a live misgrade. The host copy is byte-identical to the pre-fix blob — sha256(d8cb6128…) for both /root/.hermes/wizard-outputs/beam/topo_levels.py and git show 5a43291^:wizard-work/beam/topo_levels.py — so the suite was passing on code it never read. Two cells measured here:

cell setup result
c5 old suite, in-tree module deleted rc 0, ALL TESTS PASSED
c6 old suite beside the fixed module rc 0, ALL TESTS PASSED, and the import lands on the host copy (where.py: imported: /root/.hermes/wizard-outputs/beam/topo_levels.py, is_host: True, local copy: True)

Cell c6 is the sharp one: a correct module in the same directory is skipped because the pin sorts before it.

Third fault, independent of both: the eight cells were module-level functions behind a __main__ loop, so python3 -m unittest discover collected 0 of them (python3 -m unittest test_topo_levels on 5a43291^ → Ran 0 tests in 0.000s, NO TESTS RAN, rc 5).


§2 The fix

topo_levels.py

  1. edges = list(edges) above the validation loop — one line; the iterable is walked from a list thereafter.
  2. ready = [n for n in node_set if indeg[n] == 0] — the pre-sort is deleted. level = sorted(current, key=_key) one line below re-sorted the same list, so the expression was unreachable in effect (§4 measures the equivalence). level is now the single ordering point, which is what the docstring sells.
  3. The flattened-invariant assert became a raise RuntimeError(...) — it is not stripped under -O (Q63's class), and the message reports the three counts.

test_topo_levels.py

  1. Path(__file__).resolve().parent replaces the host pin; the import is then checked — _RESOLVED = Path(topo_levels.__file__).resolve() must equal the sibling file, else ImportError naming both paths. A raise, so -O cannot strip it either.
  2. All 17 cells are TestTopoLevels(unittest.TestCase) methods: discover collects them and python3 test_topo_levels.py still runs them directly.
  3. Six cells added for the properties no fixture held: level-interior sort against an arrival order that differs ([['p'],['a','c']]), duplicate nodes, generator/iter/map edges, a one-shot cycle, exact CycleError.remaining with an acyclic node present, and the unknown-node message.

test_rendezvous_hash.py

  1. The module-level sys.exit(0 if ok else 1) at :107 became class Trials(unittest.TestCase).test_all_trials (the trials still execute at import, so discover grades them and their check() lines still print), with the old print/exit kept behind if __name__ == "__main__". Without this the gate's discover leg reports FAILED (errors=1) once the topo pin is gone — the Q62-addendum shape, where a __main__ guard alone would have traded a red gate for a blind one.

§3 Gate state at 5a43291, from a clone of that commit

$ bash wizard-work/beam/CHECK          -> rc 0
Ran 136 tests in 9.934s
OK
ALL PASS (242 checks)

136 = 119 + 17: the 119 cells discovery already ran plus this file's 17, and the toposort leg's 242 checks is back now that set -e no longer aborts before it. Direct run: python3 test_topo_levels.py → Ran 17 tests … OK, rc 0; python3 -O -m unittest test_topo_levels → Ran 17 tests … OK, rc 0.


§4 Mutant grading, old suite vs new suite

mutants.py applies one textual mutant to the committed source, drops it beside a copy of each suite, and runs both. "old" = the suite at 5a43291^ (with only its host pin rewritten to the sibling directory, so it can see the mutant at all); "new" = the suite at 5a43291.

mutant old suite new suite cell that kills it
level = list(current) (level-interior order) KILLED KILLED (2 failures) test_level_interior_is_sorted_by_key, test_determinism_under_input_permutation
ready = sorted([...], key=_key) restored SURVIVED SURVIVED — retired none; expression deleted from the source §4a
remaining = list(node_set) SURVIVED KILLED test_cycle_remaining_is_exact (d is acyclic)
node_set = list(nodes) (dedupe removed) SURVIVED KILLED (error) test_duplicate_nodes_deduped
out.extend(reversed(lvl)) SURVIVED KILLED test_flatten_keeps_level_order
unknown-dependent KeyError from indeg[b] += 1 SURVIVED KILLED test_unknown_dependent_message (message, not type)

Controls in the same harness: the fixed source against the new suite rc 0; the old source against the new suite rc 1, FAILED (failures=4) — the new cells grade the pre-fix module red, they are not vacuous.

Correction to the item. Q68 records "5 killed, 6 survived" and lists level-interior order among the survivors. Under this emulation the old suite does kill that mutant, via test_determinism ([['z','y','x','v'],['w']] vs [['v','x','y','z'],['w']]), so the item's split does not reproduce here; the four other survivors do, and the new cells kill all four.

§4a The sixth mutant is equivalent, and that is measured, not asserted

ready = sorted([n for n in node_set if indeg[n] == 0], key=_key) is followed one line later by level = sorted(current, key=_key), so restoring the pre-sort cannot change any output. Measured: 3,000 random DAGs (1–9 nodes, density 0.35, seeded 20261025), old source vs old source with the pre-sort removed — 0 level-set differences. An equivalent mutant cannot be killed by a cell; the remedy is deleting the expression, which §2 does, and the new suite keeps the ordering property graded through test_level_interior_is_sorted_by_key.


§5 Independent verification of the fixed algorithm

fuzz_verify.py, 3,000 random DAGs against a longest-path level reference computed without the module's Kahn machinery, four axes:

graphs=3000 level_set_mismatches=0 one_shot_mismatches=0
            reversed_mismatches=0 edge_order_faults=0
VERIFY OK

one_shot_mismatches feeds the same edge list as a generator and as iter(list) and requires the answer to equal the list form; reversed_mismatches reverses node order and edge order; edge_order_faults re-checks that every edge points strictly forward in the flattened order.

§6 Control cells

cell setup result
c1 new suite, in-tree topo_levels.py deleted rc 1 (ModuleNotFoundError) — the old suite passed this (§1 c5)
c2 new suite, topo_levels.py is a symlink to the host copy rc 1, ImportError: topo_levels resolved to '/root/.hermes/wizard-outputs/beam/topo_levels.py', expected '<dir>/topo_levels.py'
c3 /root/.hermes masked (unshare -m, tmpfs, masked_entries=0) CHECK rc 0 — the lane gate reads nothing under the host tree
c4 direct probe of the fixed module rc 0 — list/generator/iter/map all [['a','b'],['c']], one-shot cycle CycleError ['a','b','c']
c5 old suite, in-tree module deleted rc 0, ALL TESTS PASSED (the pin)
c6 old suite beside the fixed module rc 0, ALL TESTS PASSED; import lands on the host copy

Transcripts: controls.txt (c1–c4), controls_pin.txt + controls_pin.txt.c5/.c6/.c7 (c5–c7), c2b_after.txt, check_repo_final.txt, check_5a43291.txt, mutants_5a43291.txt, mutants.tsv.


§7 What this does not claim

  • Not Q62 leg (a): committed wizard-work/**/*.py files still naming /root/.hermes/wizard-outputs — the population is unmoved by this commit. One correction to my own first cut: 5a43291's docstring in test_topo_levels.py named the host path while explaining that it is no longer used, so git grep -c counted 1 reader in that file. That is Q62 leg (b)'s own lesson (prose about a defect is not wiring for it, but a text census counts text) applied to me; the follow-up commit that lands this document rewrites the sentence without the path, and the count in all three files reaches 0. The test's behaviour is identical either way — the docstring is not executed — which is exactly why only a text census would ever notice.
  • Not a census: no count of other lanes' host-path readers is re-measured here.
  • Not "the beam lane is green" beyond bash wizard-work/beam/CHECK at 5a43291: other beam modules' cells were run by that gate and passed, which is all this record says about them.
  • The six cells in test_topo_levels.py grade topo_levels' contract as written (levels sorted by _key, cycle raises with the unresolved set, unknown nodes raise with a message). A production use that wants duplicate-node tolerance or a different cycle contract would need a different module, not a different test.