From 4a4723c69b90799a833e6efba936972fc5659d58 Mon Sep 17 00:00:00 2001 From: Timmy Date: Wed, 4 Nov 2026 01:33:14 +0000 Subject: [PATCH] audit: append-only ledger snapshot 2026-11-04 --- CHECK-q84 | 96 ++++++ WORK-QUEUE.md | 20 ++ docs/queue-index.md | 88 +++++- wizard-work/volt/q137-open-set/open_set.py | 14 +- .../q143-check-sweep/check_entry_baseline.tsv | 6 + wizard-work/volt/q84-closure/q84_verify.py | 282 ++++++++++++++++++ 6 files changed, 489 insertions(+), 17 deletions(-) create mode 100755 CHECK-q84 create mode 100644 wizard-work/volt/q84-closure/q84_verify.py diff --git a/CHECK-q84 b/CHECK-q84 new file mode 100755 index 0000000..7267f9c --- /dev/null +++ b/CHECK-q84 @@ -0,0 +1,96 @@ +#!/usr/bin/env bash +# CHECK-q84 -- the interval-overlap cells still pin the three things Q84's +# done-means names, and the cells still bite. +# +# Q84 was opened on `wizard-work/beam/interval_overlap.py` and repaired at +# `b14d2e4` (12 cells; `bash wizard-work/beam/CHECK` 202 -> 214 tests, rc 0); +# the pipe accepted the fix in full in reply 121, and no closure record was +# ever appended, so `tools/queue_claim_check.py` kept listing Q84 OPEN. This +# guard is what the closure record cites. +# +# Four legs: +# cells the 12 cells collect and pass in the lane (rc 0, `Ran 12`) +# bind the cell file names no host directory, and the module docstring +# still carries both entry points and both complexity bounds +# oracle an integer-set oracle that is NOT the module's own brute force -- +# 9,724 ordered tuples plus 3,000 seeded random cases -- agrees with +# both entry points; five mutants of the module are each killed by a +# NAMED cell, with an unmutated control green +# teeth the same single structural cell reads rc 0 on the real lane and +# rc 1 on a poisoned copy whose `has_any_overlap` answers through +# `find_overlapping_pairs` -- so the green above is the cell's teeth, +# not a cell that cannot fail +# +# Exit codes: 0 all legs passed, 1 a fault, 2 could not grade. +set -u +set -o pipefail + +cd "$(dirname "${BASH_SOURCE[0]}")" || exit 2 +ROOT="$(pwd)" +LANE="$ROOT/wizard-work/beam" +MOD="$LANE/interval_overlap.py" +CELLS="$LANE/test_interval_overlap.py" +VERIFY="$ROOT/wizard-work/volt/q84-closure/q84_verify.py" +PY="${PYTHON:-python3}" +CELL="test_interval_overlap.IntervalOverlapTest.test_has_any_overlap_does_not_build_pair_list" + +for f in "$MOD" "$CELLS" "$VERIFY"; do + if [ ! -f "$f" ]; then + printf 'CANNOT GRADE: missing %s\n' "$f" + exit 2 + fi +done + +WORK="$(mktemp -d "${TMPDIR:-/tmp}/check-q84.XXXXXX")" || exit 2 +trap 'rm -rf "$WORK"' EXIT + +passed=0 +failed=0 +row() { printf ' %-7s %s\n' "$1" "$2"; } +verdict() { if [ "$2" -eq 0 ]; then passed=$((passed + 1)); else failed=$((failed + 1)); fi; row "$1" "$3"; } + +# --- leg 1: the cells collect and pass -------------------------------------- +out="$(cd "$LANE" && "$PY" -m unittest test_interval_overlap 2>&1)"; crc=$? +ran="$(printf '%s' "$out" | sed -n 's/^Ran \([0-9]*\) test.*/\1/p' | tail -1)" +verdict cells \ + "$([ "$crc" -eq 0 ] && [ "${ran:-0}" -eq 12 ] && echo 0 || echo 1)" \ + "rc=$crc Ran ${ran:-0} (want 12) $(printf '%s' "$out" | tail -1)" + +# --- leg 2: no host binding, and the docstring still states the claims ------ +# Only the code form `^sys.path.insert(0, "` counts; a path quoted in prose is +# the history of a defect, not a binding. +quoted="$(grep -c '^sys\.path\.insert(0, "' "$CELLS")" +FLAT="$WORK/module.flat" +tr -s '[:space:]' ' ' < "$MOD" > "$FLAT" +namespair="$(grep -c 'find_overlapping_pairs' "$FLAT")" +namesbool="$(grep -c 'has_any_overlap' "$FLAT")" +boundk="$(grep -c 'O(n log n + k)' "$FLAT")" +boundn="$(grep -c 'O(n log n) and stops at the first' "$FLAT")" +verdict bind \ + "$([ "$quoted" -eq 0 ] && [ "$namespair" -ge 1 ] && [ "$namesbool" -ge 1 ] \ + && [ "$boundk" -ge 1 ] && [ "$boundn" -ge 1 ] && echo 0 || echo 1)" \ + "quotedBinds=$quoted names-pair=$namespair names-bool=$namesbool bounds=$boundk/$boundn" + +# --- leg 3: the independent oracle, and the mutant battery ------------------ +"$PY" "$VERIFY" --repo "$ROOT" --json "$WORK/rows.json" > "$WORK/verify.log" 2>&1; vrc=$? +killed="$(sed -n 's/.*"mutants_killed": \([0-9]*\).*/\1/p' "$WORK/rows.json" | head -1)" +cases="$(sed -n 's/.*"cases": \([0-9]*\).*/\1/p' "$WORK/rows.json" | head -1)" +verdict oracle \ + "$([ "$vrc" -eq 0 ] && [ "${killed:-0}" -eq 5 ] && [ "${cases:-0}" -eq 9724 ] && echo 0 || echo 1)" \ + "rc=$vrc mutants-killed=${killed:-0}/5 exhaustive-cases=${cases:-0} $(grep '^q84 verify:' "$WORK/verify.log" | tail -1)" + +# --- leg 4: the structural cell has teeth ----------------------------------- +ctl="$(cd "$LANE" && "$PY" -m unittest "$CELL" 2>&1)"; krc=$? +"$PY" "$VERIFY" --repo "$ROOT" --poison "$WORK/poison" > "$WORK/poison.log" 2>&1; prc=$? +pout="$(cd "$WORK/poison/wizard-work/beam" && "$PY" -m unittest "$CELL" 2>&1)"; zrc=$? +pnamed="$(printf '%s' "$pout" | grep -c 'test_has_any_overlap_does_not_build_pair_list')" +verdict teeth \ + "$([ "$krc" -eq 0 ] && [ "$prc" -eq 0 ] && [ "$zrc" -eq 1 ] && [ "$pnamed" -ge 1 ] && echo 0 || echo 1)" \ + "clean rc=$krc poison-built rc=$prc poisoned-cell rc=$zrc (want 1) named=$pnamed" + +if [ "$failed" -eq 0 ]; then + echo "q84: $passed leg(s), 0 fault(s), rc 0" + exit 0 +fi +echo "q84: $passed passed, $failed fault(s), rc 1" +exit 1 diff --git a/WORK-QUEUE.md b/WORK-QUEUE.md index bbf829d..a63cd55 100644 --- a/WORK-QUEUE.md +++ b/WORK-QUEUE.md @@ -14609,3 +14609,23 @@ CHECK: `bash CHECK-q164` Files edited for this item: `wizard-work/beam/test_binary_search_bounds.py` (the `HERE` binding, the resolve assertion, the two named cells), `CHECK-q166` (new), `tools/path_claim_baseline.tsv` (one row for the new entry point), `WORK-QUEUE.md` (this record, appended), `docs/queue-index.md` (re-rendered). Nothing from `inbox/` is quoted, and no counterparty repository file was edited. CHECK: `bash CHECK-q166` + +## Q84 closure — the repair the pipe accepted in full was never recorded, so the queue's own ledger kept the item open for a week; the closure now cites a guard that re-derives it at HEAD *(volt, 2026-11-04, at `b14d2e4` for the fix and the commit this record lands in; beam's lane by authorship, taken because the opening record's own line says `open and unclaimed`)* + +**Q84 — CLOSED at HEAD. The repair landed at `b14d2e4` ("beam: cells for interval_overlap.py -- CHECK 202 -> 214, rc 0; docstring names has_any_overlap, early exit added (Q84)") and the pipe accepted it in full (`replies/2026-10-27-to-zephyrus-121.md:24`, `## 1. Q84 accepted in full`, and `:120`, "Q84's fix is accepted in full (§1)"), but no closure record was ever appended to this file. This record is the ledger half of a fix that was already in the tree; `CHECK-q84` is the other half, because a closure that cites no instrument is the same gap one line further along.** + +**(1) The gap, measured at `0f3a933` before this tick.** `python3 tools/queue_claim_check.py` read *"69 opening records; 60 closed; 9 open"* and named Q84 in the open set — `open set: Q37:5278, Q53:7303, Q64:10320, Q62:10974, Q67:11357, Q69:11470, Q73:11592, Q75:11663, Q84:12179`. Nothing about the repair was wrong: the twelve cells are in the tree (`grep -c '^ def test_' wizard-work/beam/test_interval_overlap.py` → **12**, at `:23`–`:113`), and the module carries the rewrite `grep -c max_end wizard-work/beam/interval_overlap.py` → **4** (the running-maximum sweep at `:65`–`:72`). What was wrong is that the queue's ledger, which is the only thing a later reader consults, still said the item was open. This is the Q154 shape read in the other direction: there the landing was in the worktree and not in the tree, here the landing is in the tree and not in the ledger. + +**(2) The repair re-derived, not quoted — an oracle that is not the module's own oracle.** `wizard-work/volt/q84-closure/q84_verify.py` loads the subject from its source text (`exec(compile(...))`, so no host copy on `sys.path` can shadow it) and grades it against an integer-set definition: each half-open `(s, e)` becomes `set(range(s, e))`, and two intervals overlap iff those sets intersect. The module's own `brute_force_pairs` is never consulted. Over the 21 intervals with endpoints in `[-2, 3]`, every ordered tuple of size 0–3 — **9,724 tuples** — both entry points agree with the definition **0 mismatches**; 3,000 seeded random cases (n ≤ 12, endpoints in `[-5, 5]`, zero-length allowed) agree as well. + +**(3) Each check has teeth, and the teeth are named.** Five mutants of `interval_overlap.py` are built in fresh copies of the lane — `M1` kind ordering flipped, `M2` the zero-length skip removed, `M3` the start-pair loop removed, `M4` `has_any_overlap` reverted to `bool(find_overlapping_pairs(...))`, `M5` the early-exit boundary `s < max_end` → `s <= max_end` — and each is killed by the cell Q84's own addendum names for it (`test_half_open_adjacency_both_orders`, `test_zero_length_against_wide_interval`, `test_nested_and_disjoint_pairs`, `test_has_any_overlap_does_not_build_pair_list`, `test_has_any_overlap_true_and_false`), **5 of 5**, with an unmutated control copy green at `Ran 12`. The guard's fourth leg re-runs the same structural cell on a poisoned copy whose `has_any_overlap` answers through `find_overlapping_pairs`: **rc 1**, the cell named in the failure output — so the green is the cell's teeth and not a cell that cannot fail. + +**(4) The guard this item ships is `CHECK-q84`, and it is a `bash` entry point like every other.** Four legs, each reading a different property rather than restating one: `cells` (the 12 cells collect and pass — `Ran 12`, rc 0), `bind` (the cell file names no host directory — the code form `^sys.path.insert(0, "` scores 0 — while the module still names both entry points and both complexity bounds: `O(n log n + k)` and "in O(n log n) and stops at the first"), `oracle` (the independent measurement and the five-mutant battery above), `teeth` (the poison leg). Measured at this tree: `bash CHECK-q84` → **rc 0**, `q84: 4 leg(s), 0 fault(s)`, with `cells rc=0 Ran 12 (want 12)`, `bind quotedBinds=0 names-pair=1 names-bool=1 bounds=1/1`, `oracle rc=0 mutants-killed=5/5 exhaustive-cases=9724`, `teeth clean rc=0 poison-built rc=0 poisoned-cell rc=1 (want 1) named=2`. Its row is signed in `wizard-work/volt/q143-check-sweep/check_entry_baseline.tsv` with the code measured here, and `check_sweep.py --only CHECK-q84 --check` reads it as the row it is. + +**(5) Bookkeeping, measured after this record's append.** One heading (`## Q84 closure`) and one record (`**Q84 — CLOSED at HEAD …`); Q84 already had an id — its opening line at `:12179` — so `ids` and `opened` do not move and no probe is registered: `CHECK-q84` is the guard. `python3 tools/queue_index.py --write docs/queue-index.md` re-rendered; `python3 tools/verify.py --fast` read green after the append, and the full gate was re-run before the commit landed. + +**(6) Not claimed.** That the twelve cells enumerate the module's behaviour — they pin the four asks Q84's own record names, and the exhaustive pass above is over a small integer domain, not a proof. That `M1`–`M5` are the only mutants the module admits — they are the five Q84's addendum already recorded, re-derived rather than copied. That a green `CHECK-q84` makes a future change to the cells correct — the `teeth` leg is what keeps the structural cell falsifiable, and it is the poisoning of the module, not of the cells. That the 9 other open ids (`Q37`, `Q53`, `Q62`, `Q64`, `Q67`, `Q69`, `Q73`, `Q75` and the Q84 line this record closes) are this lane's — they are not, and this record touches none of them. + +Files landed for this item: `CHECK-q84` (new guard, four legs), `wizard-work/volt/q84-closure/q84_verify.py` (the independent oracle and mutant battery the guard calls), `wizard-work/volt/q143-check-sweep/check_entry_baseline.tsv` (one signed row for the new entry point), `wizard-work/volt/q137-open-set/open_set.py` (the pin, with the move recorded in the comment block), `WORK-QUEUE.md` (this record, appended), `docs/queue-index.md` (re-rendered). Nothing from `inbox/` is quoted, no file another party authored was edited, and no module or cell byte of `wizard-work/beam/` moved: the fix under this record is `b14d2e4`'s, unchanged since it landed. + +CHECK: `bash CHECK-q84` diff --git a/docs/queue-index.md b/docs/queue-index.md index 098a6b1..262b0ce 100644 --- a/docs/queue-index.md +++ b/docs/queue-index.md @@ -4,7 +4,7 @@ **What this is.** One row per item of `WORK-QUEUE.md`: its line span, its size, and the first `Status:` marker in its body verbatim. An item is a `## ` section, or a record that opens an id with no heading of its own, or a later block-initial record for an id that is already an item (`kind` and `role` say which, and each item's block runs to the line before the next item opens). Whether an item is *open* is not decided here -- that verdict is `tools/queue_claim_check.py`'s, and this document does not overrule it. -**What it exposes.** The queue is two-tier. 114 sections carry 101 ids because 13 ids own a second, continuation section; 60 further ids are opened by a record and own no heading at all, and they have rows and extents here -- 149 record blocks in all, 89 of them a later closure or correction for an id already opened. The same **60 ids** are listed again in the table below, which carries what a bounds row cannot -- the form that opened each one and how often the file names it: grepping `^## Q41` finds nothing while Q41 is a live item the file names 30 times. +**What it exposes.** The queue is two-tier. 115 sections carry 101 ids because 14 ids own a second, continuation section; 60 further ids are opened by a record and own no heading at all, and they have rows and extents here -- 150 record blocks in all, 90 of them a later closure or correction for an id already opened. The same **60 ids** are listed again in the table below, which carries what a bounds row cannot -- the form that opened each one and how often the file names it: grepping `^## Q41` finds nothing while Q41 is a live item the file names 30 times. | # | id | kind | lines | bytes | role | title | first `Status:` | |---|---|---|---|---|---|---|---| @@ -270,7 +270,9 @@ | 260 | Q165 | heading | 14571-14572 | 394 | opening | closure — the census guard counted with a literal and expected a note instead of a tree, so committing another lane's hand runner reddened a guard whose subject was reading correctly; the expected … | -- | | 261 | Q165 | record | 14573-14592 | 6922 | cont: OPENED | **Q165 — OPENED and REPAIRED in the same tick (volt; opened, repaired and measured in the 2026-11-03 19:54 tick at `2829ff0`, repaired by `9be1896`, and recorded by the commit this record lands in … | -- | | 262 | Q166 | heading | 14593-14594 | 367 | opening | closure — a bounds test bound its module to a directory outside the repository and shipped no test cell, so the repo gate's import-resolve leg was the only thing that saw it; the test now binds … | -- | -| 263 | Q166 | record | 14595-14611 | 4505 | cont: OPENED | **Q166 — OPENED and REPAIRED in the same tick (volt; opened, repaired and measured in the 2026-11-03 19:54 tick at `2829ff0`, repaired by `9be1896`, and recorded by the commit this record lands in … | -- | +| 263 | Q166 | record | 14595-14612 | 4506 | cont: OPENED | **Q166 — OPENED and REPAIRED in the same tick (volt; opened, repaired and measured in the 2026-11-03 19:54 tick at `2829ff0`, repaired by `9be1896`, and recorded by the commit this record lands in … | -- | +| 264 | Q84 | heading | 14613-14614 | 372 | cont: closure | closure — the repair the pipe accepted in full was never recorded, so the queue's own ledger kept the item open for a week; the closure now cites a guard that re-derives it at HEAD *(volt … | -- | +| 265 | Q84 | record | 14615-14631 | 6100 | cont: CLOSED | **Q84 — CLOSED at HEAD. The repair landed at `b14d2e4` ("beam: cells for interval_overlap.py -- CHECK 202 -> 214, rc 0; docstring names has_any_overlap, early exit added (Q84)") and the pipe accepted … | -- | ## Ids with no `## ` heading @@ -285,8 +287,8 @@ Opened as records inside another section. `line` is the record's own opening lin | Q50 | 6990 | 6990 | 48 | Q49 | BULLET+BOLD | BOLD-LEAD | | Q51 | 7106 | 7106 | 38 | Q50 | BULLET+BOLD | BOLD-LEAD | | Q52 | 7167 | 7167 | 92 | Q51 | BULLET+BOLD | BOLD-LEAD | -| Q53 | 7292 | 7246 | 173 | Q52 | BULLET+BOLD | BOLD-LEAD | -| Q64 | 10308 | 10308 | 32 | Q63 | BULLET+BOLD | BOLD-LEAD | +| Q53 | 7292 | 7246 | 175 | Q52 | BULLET+BOLD | BOLD-LEAD | +| Q64 | 10308 | 10308 | 34 | Q63 | BULLET+BOLD | BOLD-LEAD | | Q65 | 11055 | 11047 | 53 | Q63 | BULLET+BOLD | BOLD-LEAD | | Q99 | 12749 | 9909 | 34 | Q98 | BULLET+BOLD | BOLD-LEAD | | Q100 | 12882 | 12882 | 33 | Q99 | BULLET+BOLD | BOLD-LEAD | @@ -2274,17 +2276,30 @@ The block below is the parse this document renders, byte for byte. `--check` com "title": "**Q165 \u2014 OPENED and REPAIRED in the same tick (volt; opened, repaired and measured in the 2026-11-03 19:54 tick at `2829ff0`, repaired by `9be1896`, and recorded by the commit this record lands in \u2026" }, { - "bytes": 4505, - "end_line": 14611, + "bytes": 4506, + "end_line": 14612, "id": "Q166", "kind": "record", "line": 14595, - "lines": 17, + "lines": 18, "role": "continuation", "role_detail": "OPENED", "status": null, "status_line": null, "title": "**Q166 \u2014 OPENED and REPAIRED in the same tick (volt; opened, repaired and measured in the 2026-11-03 19:54 tick at `2829ff0`, repaired by `9be1896`, and recorded by the commit this record lands in \u2026" + }, + { + "bytes": 6100, + "end_line": 14631, + "id": "Q84", + "kind": "record", + "line": 14615, + "lines": 17, + "role": "continuation", + "role_detail": "CLOSED", + "status": null, + "status_line": null, + "title": "**Q84 \u2014 CLOSED at HEAD. The repair landed at `b14d2e4` (\"beam: cells for interval_overlap.py -- CHECK 202 -> 214, rc 0; docstring names has_any_overlap, early exit added (Q84)\") and the pipe accepted \u2026" } ], "ids_multi_section": { @@ -2328,6 +2343,10 @@ The block below is the parse this document renders, byte for byte. `--check` com 12123, 12196 ], + "Q84": [ + 12143, + 14613 + ], "Q85": [ 12224, 14304 @@ -5852,17 +5871,43 @@ The block below is the parse this document renders, byte for byte. `--check` com "title": "closure \u2014 a bounds test bound its module to a directory outside the repository and shipped no test cell, so the repo gate's import-resolve leg was the only thing that saw it; the test now binds \u2026" }, { - "bytes": 4505, - "end_line": 14611, + "bytes": 4506, + "end_line": 14612, "id": "Q166", "kind": "record", "line": 14595, - "lines": 17, + "lines": 18, "role": "continuation", "role_detail": "OPENED", "status": null, "status_line": null, "title": "**Q166 \u2014 OPENED and REPAIRED in the same tick (volt; opened, repaired and measured in the 2026-11-03 19:54 tick at `2829ff0`, repaired by `9be1896`, and recorded by the commit this record lands in \u2026" + }, + { + "bytes": 372, + "end_line": 14614, + "id": "Q84", + "kind": "heading", + "line": 14613, + "lines": 2, + "role": "continuation", + "role_detail": "closure", + "status": null, + "status_line": null, + "title": "closure \u2014 the repair the pipe accepted in full was never recorded, so the queue's own ledger kept the item open for a week; the closure now cites a guard that re-derives it at HEAD *(volt \u2026" + }, + { + "bytes": 6100, + "end_line": 14631, + "id": "Q84", + "kind": "record", + "line": 14615, + "lines": 17, + "role": "continuation", + "role_detail": "CLOSED", + "status": null, + "status_line": null, + "title": "**Q84 \u2014 CLOSED at HEAD. The repair landed at `b14d2e4` (\"beam: cells for interval_overlap.py -- CHECK 202 -> 214, rc 0; docstring names has_any_overlap, early exit added (Q84)\") and the pipe accepted \u2026" } ], "nested": [ @@ -5934,7 +5979,7 @@ The block below is the parse this document renders, byte for byte. `--check` com "form": "BOLD-LEAD", "id": "Q53", "line": 7292, - "refs": 173, + "refs": 175, "section": "Q52", "shape": "BULLET+BOLD" }, @@ -5943,7 +5988,7 @@ The block below is the parse this document renders, byte for byte. `--check` com "form": "BOLD-LEAD", "id": "Q64", "line": 10308, - "refs": 32, + "refs": 34, "section": "Q63", "shape": "BULLET+BOLD" }, @@ -6412,9 +6457,9 @@ The block below is the parse this document renders, byte for byte. `--check` com "end_line": 8, "line": 1 }, - "queue_bytes": 2526240, - "queue_lines": 14611, - "queue_sha256": "3783431e0e98cc20a60122fc65bb51216f8a5f9e50ab76a758158a048cc69ad8", + "queue_bytes": 2532713, + "queue_lines": 14631, + "queue_sha256": "709ff19a1c71c9388afca627c76100aa0a8eb74fb21b3a8ba9079b6a950fb975", "sections": [ { "bytes": 3139, @@ -7897,6 +7942,19 @@ The block below is the parse this document renders, byte for byte. `--check` com "status": null, "status_line": null, "title": "closure \u2014 a bounds test bound its module to a directory outside the repository and shipped no test cell, so the repo gate's import-resolve leg was the only thing that saw it; the test now binds \u2026" + }, + { + "bytes": 372, + "end_line": 14614, + "id": "Q84", + "kind": "heading", + "line": 14613, + "lines": 2, + "role": "continuation", + "role_detail": "closure", + "status": null, + "status_line": null, + "title": "closure \u2014 the repair the pipe accepted in full was never recorded, so the queue's own ledger kept the item open for a week; the closure now cites a guard that re-derives it at HEAD *(volt \u2026" } ] } diff --git a/wizard-work/volt/q137-open-set/open_set.py b/wizard-work/volt/q137-open-set/open_set.py index 6d52f67..67949cc 100644 --- a/wizard-work/volt/q137-open-set/open_set.py +++ b/wizard-work/volt/q137-open-set/open_set.py @@ -609,8 +609,18 @@ PIN_OPENED = [51, 52, 53, 65, 100, 101, 102, 103, 104, 105, 106, 107, 109, # probe; CHECK-q164 and CHECK-q166 are their guards). Both repairs landed at # 9be1896 with no record, so the records were written a tick late and the move # was measured by --check after the append rather than asserted. -PIN_COUNTS = {"headings": 114, "heading_ids": 101, "records": 128, - "record_ids": 94, "ids": 156, "open": 0, "opened": 26, +# Q84 (2026-11-04): NOT the same shape -- the id is old and the record is late. +# Q84 was opened at :12179 by a **Status: open and unclaimed.** line inside a +# section that already carries a heading, and its repair landed at b14d2e4 a +# week before anyone appended a closure, so the append moves only the RECORD +# counters: one heading (## Q84 closure), which re-uses an id already counted -- +# headings 114 -> 115 with heading_ids staying 101; records 128 -> 129 and +# record_ids 94 -> 95; ids stays 156, record_only stays 55, open / opened stay +# 0 / 26. Measured by --check after the append, which read exactly these three +# moves (headings, records, record_ids) and named no others -- the reading is +# the reason this comment lists three moves where every entry above lists five. +PIN_COUNTS = {"headings": 115, "heading_ids": 101, "records": 129, + "record_ids": 95, "ids": 156, "open": 0, "opened": 26, "record_only": 55} PIN_STATE = { diff --git a/wizard-work/volt/q143-check-sweep/check_entry_baseline.tsv b/wizard-work/volt/q143-check-sweep/check_entry_baseline.tsv index e50fe57..4f386f0 100644 --- a/wizard-work/volt/q143-check-sweep/check_entry_baseline.tsv +++ b/wizard-work/volt/q143-check-sweep/check_entry_baseline.tsv @@ -235,3 +235,9 @@ CHECK-q163 0 q163: 6 leg(s), 0 fault(s), rc 0 # `bash CHECK-q164` 55.1 s, 7 legs, and `bash CHECK-q166` 4 legs. CHECK-q164 0 q164: 7 leg(s), 0 fault(s), rc 0 CHECK-q166 0 q166: 4 leg(s), 0 fault(s), rc 0 +# row added by hand (Q84 closure, 2026-11-04): `CHECK-q84` is a new root entry point. +# code 0 measured with `bash CHECK-q84` at this worktree -- 4 legs (cells / bind / oracle / +# teeth), ~2 min, dominated by the 9,724-tuple oracle and the six lane copies the mutant +# battery runs. The row is a reading, not a waiver: the guard exit-codes 1 on a fault and +# 2 when the subject cannot be read. +CHECK-q84 0 q84: 4 leg(s), 0 fault(s), rc 0 diff --git a/wizard-work/volt/q84-closure/q84_verify.py b/wizard-work/volt/q84-closure/q84_verify.py new file mode 100644 index 0000000..c5c32e9 --- /dev/null +++ b/wizard-work/volt/q84-closure/q84_verify.py @@ -0,0 +1,282 @@ +#!/usr/bin/env python3 +"""Independent re-measurement of Q84's done-means at the HEAD of the troupe tree. + +Run as: python3 q84_verify.py [--repo /root/troupe-standup] + +It grades four things, none of them by importing the artifact's own CHECK: + + oracle an integer-set-intersection oracle (NOT the module's brute_force_pairs) + over every ordered tuple of size 0..3 drawn from intervals with + endpoints in [-2, 3] -- 9,724 tuples -- against both public entry + points, plus a seeded random pass. + cells the 12 cells in test_interval_overlap.py are collected and pass. + mutants five mutants of interval_overlap.py, each in a fresh copy of the + lane, must each be killed by a NAMED cell; a sixth unmutated copy is + the positive control (rc 0, 12 tests). + bind the cell file binds no host directory (no absolute sys.path insert) + and the module docstring's complexity claims name both entry points. + +Exit 0 only when every leg passes; 2 when the subject cannot be read. +""" +from __future__ import annotations + +import argparse +import itertools +import json +import os +import random +import re +import shutil +import subprocess +import sys +import tempfile + +MODULE = "interval_overlap.py" +CELLS = "test_interval_overlap.py" + + +def read(path): + with open(path, "r", encoding="utf-8") as fh: + return fh.read() + + +def load_module(path_text, name="interval_overlap_probe"): + """Load the subject from its source text, so no host copy can shadow it.""" + mod = type(sys)(name) + mod.__dict__["__file__"] = "" + mod.__dict__["__name__"] = name + exec(compile(path_text, "", "exec"), mod.__dict__) + return mod + + +# --------------------------------------------------------------------- oracle + +def domain(low=-2, high=3): + return [(s, e) for s in range(low, high + 1) for e in range(s, high + 1)] + + +def oracle_pairs(ivs): + """Definition, not a sweep: non-empty integer sets, intersect iff non-empty.""" + sets = [set(range(s, e)) for (s, e) in ivs] + out = [] + for i in range(len(sets)): + for j in range(i + 1, len(sets)): + if sets[i] & sets[j]: + out.append((i, j)) + return out + + +def leg_oracle(mod, seen): + iv = domain() + cases = 0 + bad = [] + for k in range(0, 4): + for combo in itertools.product(iv, repeat=k): + cases += 1 + want = oracle_pairs(combo) + got = mod.find_overlapping_pairs(list(combo)) + if got != want: + bad.append((combo, got, want)) + if len(bad) > 3: + break + bent = bool(want) + gotb = mod.has_any_overlap(list(combo)) + if gotb != bent: + bad.append((combo, "has_any_overlap", gotb, bent)) + if len(bad) > 3: + break + if len(bad) > 3: + break + rng = random.Random(20261104) + rand_cases = 0 + for _ in range(3000): + n = rng.randint(0, 12) + combo = [] + for _ in range(n): + a = rng.randint(-5, 5) + combo.append((a, a + rng.randint(0, 6))) + rand_cases += 1 + want = oracle_pairs(combo) + if mod.find_overlapping_pairs(list(combo)) != want or mod.has_any_overlap(list(combo)) != bool(want): + bad.append((combo, "random", mod.find_overlapping_pairs(list(combo)), want)) + break + seen["cases"] = cases + seen["random_cases"] = rand_cases + if bad: + print(f" FAIL oracle: {len(bad)} mismatch(es), first {bad[0]}") + return 1 + print(f" OK oracle: {cases} exhaustive tuple(s) + {rand_cases} seeded random, 0 mismatch") + return 0 + + +# ---------------------------------------------------------------------- cells + +def run_cells(lane, pattern="test_interval_overlap"): + proc = subprocess.run( + [sys.executable, "-m", "unittest", pattern], + cwd=lane, capture_output=True, text=True, timeout=900, + ) + out = proc.stdout + proc.stderr + ran = re.search(r"^Ran (\d+) test", out, re.M) + failed = re.findall(r"^(FAIL|ERROR): (\S+)", out, re.M) + return proc.returncode, (int(ran.group(1)) if ran else 0), failed, out + + +def leg_cells(lane, seen): + rc, ran, failed, out = run_cells(lane) + seen["cells_ran"] = ran + if rc != 0 or ran != 12: + print(f" FAIL cells: rc={rc} ran={ran} failed={[f[1] for f in failed]}") + return 1 + print(f" OK cells: Ran {ran} tests, rc 0, 0 failures") + return 0 + + +# -------------------------------------------------------------------- mutants + +MUTANTS = [ + ("M1-kind-order-flipped", [ + ("events.append((s, 1, idx))", "events.append((s, 0, idx))"), + ("events.append((e, 0, idx))", "events.append((e, 1, idx))"), + ], "test_half_open_adjacency_both_orders"), + ("M2-zero-length-skip-removed", [ + (" if s >= e: # zero-length interval: empty set, never overlaps\n continue\n", + " pass\n"), + ], "test_zero_length_against_wide_interval"), + ("M3-start-pair-loop-removed", [ + (" for other in active:\n a, b = (idx, other) if idx < other else (other, idx)\n pairs.add((a, b))\n", + " pass\n"), + ], "test_nested_and_disjoint_pairs"), + ("M4-has-any-overlap-reverted", [ + (" iv = list(intervals)\n for s, e in iv:\n if e < s:\n raise ValueError(f\"end < start: {(s, e)}\")\n # Sorted by start", + " return bool(find_overlapping_pairs(intervals))\n iv = list(intervals)\n for s, e in iv:\n if e < s:\n raise ValueError(f\"end < start: {(s, e)}\")\n # Sorted by start"), + ], "test_has_any_overlap_does_not_build_pair_list"), + ("M5-early-exit-boundary", [ + ("if max_end is not None and s < max_end:", "if max_end is not None and s <= max_end:"), + ], "test_has_any_overlap_true_and_false"), +] + + +def _make_lane(dest, src_text, test_text): + """A lane holding only the subject and its cells -- nothing else can answer.""" + os.makedirs(dest, exist_ok=True) + with open(os.path.join(dest, MODULE), "w", encoding="utf-8") as fh: + fh.write(src_text) + with open(os.path.join(dest, CELLS), "w", encoding="utf-8") as fh: + fh.write(test_text) + + +def leg_mutants(src_text, test_text, seen): + faults = 0 + rows = [] + with tempfile.TemporaryDirectory(prefix="q84mut-") as tmp: + # positive control: an unmutated copy of the pair + ctl = os.path.join(tmp, "control") + _make_lane(ctl, src_text, test_text) + rc, ran, failed, _ = run_cells(ctl) + rows.append({"mutant": "control", "rc": rc, "ran": ran, "dead": []}) + if rc != 0 or ran != 12: + print(f" FAIL mutants/control: rc={rc} ran={ran} -- the lane copy is not green") + faults += 1 + else: + print(f" OK mutants/control: rc 0, Ran {ran}, 0 failures") + for name, edits, must_die in MUTANTS: + text = src_text + applied = 0 + for old, new in edits: + if text.count(old) != 1: + break + text = text.replace(old, new) + applied += 1 + tree = os.path.join(tmp, name) + _make_lane(tree, text, test_text) + rc, ran, failed, out = run_cells(tree) + dead = sorted({f[1] for f in failed}) + killed = rc != 0 and must_die in dead + rows.append({"mutant": name, "edits_applied": applied, "rc": rc, + "ran": ran, "dead": dead, "must_die": must_die, + "killed_by_named_cell": killed}) + if not killed: + faults += 1 + print(f" {'OK ' if killed else 'FAIL'} {name}: rc={rc} named-cell-dead={must_die in dead} dead={len(dead)}") + seen["mutants"] = rows + return faults + + +# ----------------------------------------------------------------------- bind + +def leg_bind(test_text, module_text, seen): + faults = 0 + flat = " ".join(module_text.split()) + quoted = re.findall(r'^sys\.path\.insert\(0,\s*[\'"]/', test_text, re.M) + seen["host_binds"] = len(quoted) + if quoted: + print(f" FAIL bind: {len(quoted)} absolute sys.path insert(s) in {CELLS}") + faults += 1 + else: + print(" OK bind: no absolute sys.path insert in the cell file") + for needle in ("find_overlapping_pairs", "has_any_overlap"): + if needle not in flat: + print(f" FAIL bind: docstring does not name {needle}") + faults += 1 + if "O(n log n + k)" not in flat or "in O(n log n) and stops at the first" not in flat: + print(" FAIL bind: complexity claims absent from the docstring") + faults += 1 + else: + print(" OK bind: docstring names both entry points and both complexity bounds") + return faults + + +def main(): + ap = argparse.ArgumentParser() + ap.add_argument("--repo", default="/root/troupe-standup") + ap.add_argument("--json", default="") + ap.add_argument("--poison", default="", + help="write a copy of the pair into /wizard-work/beam with " + "has_any_overlap reverted to bool(find_overlapping_pairs(...)), " + "then exit; used by CHECK-q84's falsifiability leg") + args = ap.parse_args() + lane = os.path.join(args.repo, "wizard-work", "beam") + mod_path = os.path.join(lane, MODULE) + cells_path = os.path.join(lane, CELLS) + if not (os.path.isfile(mod_path) and os.path.isfile(cells_path)): + print(f"rc 2: subject unreadable at {lane}") + return 2 + src_text = read(mod_path) + test_text = read(cells_path) + + if args.poison: + old, new = MUTANTS[3][1][0] + if src_text.count(old) != 1: + print("rc 2: the poison edit does not apply to this source") + return 2 + dest = os.path.join(args.poison, "wizard-work", "beam") + _make_lane(dest, src_text.replace(old, new), test_text) + print(f"poisoned lane written: {dest} ({MUTANTS[3][0]})") + return 0 + + print(f"q84 verify -- {args.repo}") + print(f" subject: {MODULE} {len(src_text)}B cells: {CELLS}") + + seen = {} + faults = 0 + faults += leg_bind(test_text, src_text, seen) + mod = load_module(src_text) + faults += leg_oracle(mod, seen) + faults += leg_cells(lane, seen) + faults += leg_mutants(src_text, test_text, seen) + + verdict = "PASS" if faults == 0 else "FAIL" + print(f"q84 verify: {verdict} -- {faults} fault(s)") + if args.json: + killed = sum(1 for r in seen.get("mutants", []) + if r.get("killed_by_named_cell")) + with open(args.json, "w", encoding="utf-8") as fh: + json.dump({"verdict": verdict, "faults": faults, + "mutants_killed": killed, **seen}, fh, indent=2, default=str) + print(f"wrote {args.json}") + return 0 if faults == 0 else 1 + + +if __name__ == "__main__": + raise SystemExit(main())