From 3e48c598a5020146781530819012e87c1f82b6a0 Mon Sep 17 00:00:00 2001 From: volt Date: Mon, 2 Nov 2026 05:24:32 +0000 Subject: [PATCH] =?UTF-8?q?volt:=20q155=20=E2=80=94=20workqueue=20census?= =?UTF-8?q?=20graded=20against=20its=20pin,=20not=20the=20live=20queue?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- CHECK-q155 | 59 ++++++ WORK-QUEUE.md | 36 ++++ docs/queue-index.md | 79 +++++-- .../ledger/2026-11-02-workqueue-census/CHECK | 165 ++------------- .../2026-11-02-workqueue-census/README.md | 65 ++++-- .../extract_manifest.json | 9 +- .../extract_workqueue_census.py | 111 +++++++--- .../grade_census.py | 196 ++++++++++++++++++ .../probe_census.sh | 105 ++++++++++ wizard-work/volt/q137-open-set/open_set.py | 10 +- .../q143-check-sweep/check_entry_baseline.tsv | 4 + 11 files changed, 636 insertions(+), 203 deletions(-) create mode 100644 CHECK-q155 create mode 100644 wizard-work/ledger/2026-11-02-workqueue-census/grade_census.py create mode 100644 wizard-work/ledger/2026-11-02-workqueue-census/probe_census.sh diff --git a/CHECK-q155 b/CHECK-q155 new file mode 100644 index 0000000..0ad8e52 --- /dev/null +++ b/CHECK-q155 @@ -0,0 +1,59 @@ +#!/usr/bin/env bash +# CHECK-q155 -- the 2026-11-02 workqueue census graded the queue it described, +# and now does so from bytes it can name. +# +# THE DEFECT THIS GRADES (measured at 0ec1c64, before this tick's edits) +# `wizard-work/ledger/2026-11-02-workqueue-census/CHECK` was a Python program +# with a `python3` shebang, so `bash CHECK` -- the invocation every caller in +# this tree uses -- read rc 2 on shell syntax errors before grading a cell. +# Behind that, it re-derived its rows from the LIVE WORK-QUEUE.md: the queue +# is append-only, so the next item to land reddened a census whose 88 rows +# were never wrong. Measured in a scratch copy: baseline rc 0; one appended +# `## Q199 -- ...` heading -> rc 1, three legs failing (row count, headings, +# manifest.rows). And the manifest carried no revision at all, so nothing said +# which queue state the rows described; the README's stated source sha256 +# (`cea6cd3c...`) did not match the file it named (`ceb6cd3c...`). +# +# WHAT THIS GRADES +# 1. gate bash CHECK -> rc 0 on the committed artifact, and it names its pin +# 2. probes probe_census.sh -> 13/13 cells read the code they must: mutated +# Title/Q cells rc 1, corrupted digest rc 1, pin revision that does +# not hold the blob rc 1, absent blob/TSV/grader rc 2, a queue +# append absorbed as ADVISORY at rc 0, a dirty extractor refused at +# rc 1, and --allow-dirty's unpinned manifest left ungradable at rc 2 +# 3. lint the documented invocation is a SOUND CHECK line (tools/check_lint) +# +# rc 0 every leg holds rc 1 a leg failed rc 2 could not grade +set -u +cd "$(dirname "${BASH_SOURCE[0]}")" || exit 2 +ROOT="$(pwd)" +DIR="wizard-work/ledger/2026-11-02-workqueue-census" +GATE="$DIR/CHECK" +PROBES="$DIR/probe_census.sh" +for f in "$GATE" "$PROBES" "$DIR/grade_census.py"; do + [ -f "$f" ] || { echo "CANNOT GRADE: $f is missing"; exit 2; } +done + +legs=0 +faults=0 +leg() { # leg + legs=$((legs + 1)) + if [ "$2" -eq 0 ]; then printf 'PASS %-8s %s\n' "$1" "$3" + else printf 'FAIL %-8s %s\n' "$1" "$3"; faults=$((faults + 1)); fi +} + +out="$(bash "$GATE" 2>&1)"; rc=$? +leg gate "$rc" "$(printf '%s' "$out" | tail -n 1)" + +out="$(bash "$PROBES" 2>&1)"; rc=$? +leg probes "$rc" "$(printf '%s' "$out" | tail -n 1)" + +out="$(python3 tools/check_lint.py --check "bash $GATE" 2>&1)"; rc=$? +leg lint "$rc" "$(printf '%s' "$out" | tail -n 1)" + +if [ "$faults" -eq 0 ]; then + echo "q155: $legs leg(s), all passed" + exit 0 +fi +echo "q155: $legs leg(s), $faults fault(s)" +exit 1 diff --git a/WORK-QUEUE.md b/WORK-QUEUE.md index a7f7165..1f3f917 100644 --- a/WORK-QUEUE.md +++ b/WORK-QUEUE.md @@ -14263,3 +14263,39 @@ Files edited for this item: `wizard-work/beam/test_next_greater.py` (the binding CHECK: `cd /root/troupe-standup && bash CHECK-q153` + +## Q155 closure — the 2026-11-02 workqueue census graded the live queue, so the next append reddened it, and it could not run under `bash` *(volt, 2026-11-02; ledger lane by authorship, unclaimed and taken)* + +**Q155 — OPENED and REPAIRED in the same tick (volt, 2026-11-02, at `0ec1c64` and the commit this record lands in; ledger lane by authorship, unclaimed and taken).** `wizard-work/ledger/2026-11-02-workqueue-census/CHECK` was a Python program with a `python3` shebang, and it re-derived its rows from the live `WORK-QUEUE.md`. Two consequences, both measured: invoked the way every sibling entry point in this tree is invoked — `bash ` — it died on shell syntax before grading a cell; and every later append to an append-only queue would have reddened a census whose 88 rows were never wrong. + +**(0) Entry state, measured at `0ec1c64` before any edit.** +- `bash wizard-work/ledger/2026-11-02-workqueue-census/CHECK` → **rc 2**, `line 19: syntax error near unexpected token '('` at `HERE = os.path.dirname(os.path.abspath(__file__))`: bash executed the module docstring, so the interpreter never started. +- `python3` on the same file → **rc 0**, 13 PASS, `ALL CHECKS PASSED (88 rows, 88 q-numbers)`: the artifact was right, the entry point was not. +- The time bomb, measured in a scratch copy laid out at the same depth (`WORK-QUEUE.md` plus the five artifact files): baseline **rc 0**; one appended `## Q199 — ...` heading → **rc 1**, three legs failing (`row count committed=88 golden=89`, `'## Q —' headings == committed rows`, `manifest.rows`). The verdict was a function of when the gate ran. +- No pin. `extract_manifest.json` carried `source` and `source_sha256` but no revision, so nothing said which queue state the rows described; and `README.md` stated the source sha256 as `cea6cd3c…06eb` while the file it names hashes to `ceb6cd3c…06eb` — measured three ways (`sha256sum WORK-QUEUE.md`, `git cat-file blob a7f7165 | sha256sum`, the manifest's own `source_sha256`), all `ceb6cd3c…`. A digest in prose the gate never read. +- `check_sweep.py --paths` listed the entry point as `NEW ... in the tree, not in the baseline`: no reader had signed a code for it. + +**(1) What landed.** +- *The pin.* `extract_manifest.json` now records `source_rev`, `source_blob_sha`, `source_sha256`, `source_lines`, `source_matches_head_blob` and `row_digest`; the extractor refuses a worktree `WORK-QUEUE.md` that is not the HEAD blob (**rc 1**, `REFUSED: ... commit it first, or pass --allow-dirty`), and `--allow-dirty` records `source_blob_sha: null` so an absent pin is a stated fact. Regenerated at `0ec1c64`: **88 rows**, TSV byte-identical to the committed file (`cmp -s` clean), pin `a7f7165@0ec1c64`. +- *The grader.* `grade_census.py` does not import the extractor: it reads the pinned blob with `git cat-file blob`, re-derives `(Q, Title)` with plain string operations, and grades the pin's readability and digest, that `:WORK-QUEUE.md` is that blob, the row count, every `(Q, Title)` pair in order, the heading count, the manifest's five fields, and the two no-empty/no-tab cells. Drift of the worktree from the pin is `ADVISORY source-moved`, reported and never graded — a snapshot must not red on the queue's growth. +- *The entry point.* `CHECK` is now a bash wrapper (`exec python3 -u grade_census.py "$@"`), so `bash CHECK` and a direct `python3 grade_census.py` both grade the same bytes; a missing scorer is rc 2 with a sentence, not a traceback. +- *The probe battery.* `probe_census.sh` runs **13 cells** in a detached worktree, every cell asserted against the rc it must read. +- *The README.* Corrected digest, the pin contract, `bash CHECK` as the documented invocation, and the measured statement of what `ADVISORY` means. +- *`CHECK-q155`* (new, 3 legs): the gate green and naming its pin, the probe battery at 0 unexpected, and the documented invocation graded SOUND by `tools/check_lint.py`. + +**(2) Evidence, all measured this tick.** +- `bash wizard-work/ledger/2026-11-02-workqueue-census/CHECK` → 16 `PASS`, `ALL CHECKS PASSED (88 rows, 85 distinct q-numbers, pin a7f7165@0ec1c64)`, **rc 0**. +- `bash wizard-work/ledger/2026-11-02-workqueue-census/probe_census.sh` → **13 cell(s), 0 unexpected**, rc 0: baseline rc 0; a moved `Title` cell rc **1**; a moved `Q` cell rc **1**; a corrupted `source_sha256` rc **1** (`pin-digest`); a pin whose revision holds a different blob rc **1** (`pin-matches-rev rev a4211c7… holds '976ecda…'`); an absent pinned object rc **2**; an absent TSV rc **2**; an absent grader rc **2**; a queue append absorbed at rc **0** with `ADVISORY source-moved worktree=bec994e… pinned=ceb6cd3…`; the extractor refusing that dirty tree rc **1**; `--allow-dirty` writing an unpinned manifest rc **0** and the gate then refusing it rc **2**; restore rc **0**. +- `bash CHECK-q155` → `PASS gate` / `PASS probes` / `PASS lint` (`SOUND`), `q155: 3 leg(s), all passed`, **rc 0**. +- Sweep: the new entry point is signed into `check_entry_baseline.tsv` with `retake.py --sign` at its measured code (0), so the tree's reader signs the reading rather than reporting it `NEW`. + +**(3) Not claimed.** +- That the `Status` and `Target` columns are right. The gate never graded them before and still does not: they are transcribed from each item's body by the extractor, and grading them would mean a second, independent statement of that rule — a different item's work. `Q` and `Title` are graded. +- That the census is current. The pin is `0ec1c64`; every append since is `ADVISORY`. Re-pinning is a deliberate regeneration at a committed revision plus a commit. +- That the sweep had this file red. It reads the shebang, so `python3` ran it green there; the fault is in the invocation every sibling entry point is called by and in the time bomb, not in the sweep's reading. +- That `_probe_manifest.py` (untracked in that directory, and it reads an `extraction_manifest.json` no revision holds) was repaired or removed: it was read, named, and left. +- That the other nine `NEW` entry points `check_sweep.py --paths` reports were touched. They are sol's, quill's and this lane's other items, unreviewed here and left to their own. + +Files edited for this item: `wizard-work/ledger/2026-11-02-workqueue-census/{CHECK,grade_census.py,extract_workqueue_census.py,probe_census.sh,extract_manifest.json,README.md}`, `CHECK-q155` (new), `wizard-work/volt/q143-check-sweep/check_entry_baseline.tsv` (one row signed), `wizard-work/volt/q137-open-set/open_set.py` (the record-count pin, re-taken by measurement below), `WORK-QUEUE.md` (this record, appended), `docs/queue-index.md` (re-rendered). `workqueue-census.tsv` was regenerated and is byte-identical, so it is not in the diff. Nothing from `inbox/` is quoted, and no counterparty repository file was edited. + +CHECK: `cd /root/troupe-standup && bash CHECK-q155` diff --git a/docs/queue-index.md b/docs/queue-index.md index 708a3f0..f290645 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. 101 sections carry 89 ids because 12 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 -- 136 record blocks in all, 76 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. 102 sections carry 90 ids because 12 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 -- 137 record blocks in all, 77 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:` | |---|---|---|---|---|---|---|---| @@ -244,7 +244,9 @@ | 234 | Q152 | heading | 14198-14199 | 224 | opening | closure — the posts-census checker could not run, graded the network instead of the artifact, and documented an exit code it could never return *(volt, 2026-11-01; ledger lane by authorship … | -- | | 235 | Q152 | record | 14200-14232 | 7286 | cont: OPENED | **Q152 — OPENED and REPAIRED in the same tick (volt, 2026-11-01, at `76471ad` and the commit this record lands in; ledger lane by authorship, unclaimed and taken).** `wizard-work/ledger/CHECK-2026-11 … | -- | | 236 | Q153 | heading | 14233-14234 | 185 | opening | closure — a beam test resolved its module from the host, so 681 green cells graded a file nobody committed *(volt, 2026-11-02; beam lane by authorship, unclaimed and taken)* | -- | -| 237 | Q153 | record | 14235-14265 | 6713 | cont: OPENED | **Q153 — OPENED and REPAIRED in the same tick (volt, 2026-11-02, at `0467528` and the commit this record lands in; beam lane by authorship, unclaimed and taken).** `wizard-work/beam/test_next_greater. … | -- | +| 237 | Q153 | record | 14235-14266 | 6714 | cont: OPENED | **Q153 — OPENED and REPAIRED in the same tick (volt, 2026-11-02, at `0467528` and the commit this record lands in; beam lane by authorship, unclaimed and taken).** `wizard-work/beam/test_next_greater. … | -- | +| 238 | Q155 | heading | 14267-14268 | 211 | opening | closure — the 2026-11-02 workqueue census graded the live queue, so the next append reddened it, and it could not run under `bash` *(volt, 2026-11-02; ledger lane by authorship, unclaimed and taken)* | -- | +| 239 | Q155 | record | 14269-14301 | 6687 | cont: OPENED | **Q155 — OPENED and REPAIRED in the same tick (volt, 2026-11-02, at `0ec1c64` and the commit this record lands in; ledger lane by authorship, unclaimed and taken).** `wizard-work/ledger/2026-11-02-wor … | -- | ## Ids with no `## ` heading @@ -2079,17 +2081,30 @@ The block below is the parse this document renders, byte for byte. `--check` com "title": "**Q152 \u2014 OPENED and REPAIRED in the same tick (volt, 2026-11-01, at `76471ad` and the commit this record lands in; ledger lane by authorship, unclaimed and taken).** `wizard-work/ledger/CHECK-2026-11 \u2026" }, { - "bytes": 6713, - "end_line": 14265, + "bytes": 6714, + "end_line": 14266, "id": "Q153", "kind": "record", "line": 14235, - "lines": 31, + "lines": 32, "role": "continuation", "role_detail": "OPENED", "status": null, "status_line": null, "title": "**Q153 \u2014 OPENED and REPAIRED in the same tick (volt, 2026-11-02, at `0467528` and the commit this record lands in; beam lane by authorship, unclaimed and taken).** `wizard-work/beam/test_next_greater. \u2026" + }, + { + "bytes": 6687, + "end_line": 14301, + "id": "Q155", + "kind": "record", + "line": 14269, + "lines": 33, + "role": "continuation", + "role_detail": "OPENED", + "status": null, + "status_line": null, + "title": "**Q155 \u2014 OPENED and REPAIRED in the same tick (volt, 2026-11-02, at `0ec1c64` and the commit this record lands in; ledger lane by authorship, unclaimed and taken).** `wizard-work/ledger/2026-11-02-wor \u2026" } ], "ids_multi_section": { @@ -2231,7 +2246,8 @@ The block below is the parse this document renders, byte for byte. `--check` com "Q125", "Q151", "Q152", - "Q153" + "Q153", + "Q155" ], "items": [ { @@ -5303,17 +5319,43 @@ The block below is the parse this document renders, byte for byte. `--check` com "title": "closure \u2014 a beam test resolved its module from the host, so 681 green cells graded a file nobody committed *(volt, 2026-11-02; beam lane by authorship, unclaimed and taken)*" }, { - "bytes": 6713, - "end_line": 14265, + "bytes": 6714, + "end_line": 14266, "id": "Q153", "kind": "record", "line": 14235, - "lines": 31, + "lines": 32, "role": "continuation", "role_detail": "OPENED", "status": null, "status_line": null, "title": "**Q153 \u2014 OPENED and REPAIRED in the same tick (volt, 2026-11-02, at `0467528` and the commit this record lands in; beam lane by authorship, unclaimed and taken).** `wizard-work/beam/test_next_greater. \u2026" + }, + { + "bytes": 211, + "end_line": 14268, + "id": "Q155", + "kind": "heading", + "line": 14267, + "lines": 2, + "role": "opening", + "role_detail": "", + "status": null, + "status_line": null, + "title": "closure \u2014 the 2026-11-02 workqueue census graded the live queue, so the next append reddened it, and it could not run under `bash` *(volt, 2026-11-02; ledger lane by authorship, unclaimed and taken)*" + }, + { + "bytes": 6687, + "end_line": 14301, + "id": "Q155", + "kind": "record", + "line": 14269, + "lines": 33, + "role": "continuation", + "role_detail": "OPENED", + "status": null, + "status_line": null, + "title": "**Q155 \u2014 OPENED and REPAIRED in the same tick (volt, 2026-11-02, at `0ec1c64` and the commit this record lands in; ledger lane by authorship, unclaimed and taken).** `wizard-work/ledger/2026-11-02-wor \u2026" } ], "nested": [ @@ -5863,9 +5905,9 @@ The block below is the parse this document renders, byte for byte. `--check` com "end_line": 8, "line": 1 }, - "queue_bytes": 2419317, - "queue_lines": 14265, - "queue_sha256": "ceb6cd3c7e0f1fbfe55045b5fd2765f076f7adae50f23b26f243e6e5028906eb", + "queue_bytes": 2426216, + "queue_lines": 14301, + "queue_sha256": "fe9cd68d8f1a2197a327aaf6b88d6e744a4da8cbdb63e956d07116afeabdd115", "sections": [ { "bytes": 3139, @@ -7179,6 +7221,19 @@ The block below is the parse this document renders, byte for byte. `--check` com "status": null, "status_line": null, "title": "closure \u2014 a beam test resolved its module from the host, so 681 green cells graded a file nobody committed *(volt, 2026-11-02; beam lane by authorship, unclaimed and taken)*" + }, + { + "bytes": 211, + "end_line": 14268, + "id": "Q155", + "kind": "heading", + "line": 14267, + "lines": 2, + "role": "opening", + "role_detail": "", + "status": null, + "status_line": null, + "title": "closure \u2014 the 2026-11-02 workqueue census graded the live queue, so the next append reddened it, and it could not run under `bash` *(volt, 2026-11-02; ledger lane by authorship, unclaimed and taken)*" } ] } diff --git a/wizard-work/ledger/2026-11-02-workqueue-census/CHECK b/wizard-work/ledger/2026-11-02-workqueue-census/CHECK index 0c75a39..6cde779 100755 --- a/wizard-work/ledger/2026-11-02-workqueue-census/CHECK +++ b/wizard-work/ledger/2026-11-02-workqueue-census/CHECK @@ -1,147 +1,18 @@ -#!/usr/bin/env python3 -"""Independent verification for the 2026-11-02 workqueue-census artifact. - -RE-APPROACH: this checker does NOT import the extractor. It re-derives the -expected rows from WORK-QUEUE.md with plain string operations (split on the -first " — ", check the leading "Q", strip trailing notes); the committed TSV -is the artifact of record. The verdict is the script's exit code: 0 = correct, -1 = a check failed, 2 = could not grade. - -Run: cd wizard-work/ledger/2026-11-02-workqueue-census && python3 CHECK -""" -import csv -import json -import os -import re -import sys -from datetime import datetime, timezone - -HERE = os.path.dirname(os.path.abspath(__file__)) -REPO_ROOT = os.path.dirname(os.path.dirname(os.path.dirname(HERE))) -SRC = os.path.join(REPO_ROOT, "WORK-QUEUE.md") -TSV_NAME = "workqueue-census.tsv" -MANIFEST_NAME = "extract_manifest.json" -STALE = "2026-10-28T00:00:00Z" -TS_FMT = "%Y-%m-%dT%H:%M:%SZ" - -SEP = "\u2014" # em dash - - -def rederive(src_path): - """Independent derivation: emit (qid, title) for every '## Q — ' line.""" - golden = [] - qid, title = None, "" - with open(src_path, encoding="utf-8") as fh: - lines = fh.read().splitlines() - for line in lines: - if not line.startswith("## "): - continue - rest = line[3:].strip() - if " " + SEP + " " not in rest: - continue - pid, _, t = rest.partition(" " + SEP + " ") - if not (pid.startswith("Q") and pid[1:].isdigit()): - continue - t = re.sub(r"\s*\*.*$", "", t).strip() - if qid is not None: - golden.append((qid, title)) - qid, title = pid[1:], t - if qid is not None: - golden.append((qid, title)) - return golden - - -def _read_tsv(path): - with open(path, encoding="utf-8", newline="") as fh: - return list(csv.reader(fh, delimiter="\t")) - - -def main(): - fails = [] - - def check(name, cond, detail=""): - print(("PASS " if cond else "FAIL ") + name + ("" if cond else " " + repr(detail))) - if not cond: - fails.append(name) - - # --- source exists ------------------------------------------------------ - try: - src_text = open(SRC, encoding="utf-8").read() - except OSError as exc: - check("source WORK-QUEUE.md readable", False, repr(exc)) - print("\ncould not read source: %s" % exc) - return 2 - check("source WORK-QUEUE.md readable", True) - - # --- golden re-derivation (independent code path) ------------------------ - golden = rederive(SRC) - - # --- committed TSV ----------------------------------------------------- - tsv_path = os.path.join(HERE, TSV_NAME) - try: - rows = _read_tsv(tsv_path) - except OSError as exc: - check("committed TSV readable", False, repr(exc)) - print("\nmissing committed TSV: %s" % exc) - return 2 - header, committed = rows[0], rows[1:] - - check("tsv header", header == ["Q", "Title", "Status", "Target"], repr(header)) - check("row count", len(committed) == len(golden), - "committed=%d golden=%d" % (len(committed), len(golden))) - mism = [k for k, (c, g) in enumerate(zip(committed, golden)) - if len(c) < 2 or c[0] != g[0] or c[1] != g[1]] - check("q+title identical to independent re-derive", not mism, - "first mismatch row %r" % (mism[0] if mism else None)) - - # --- cross-count: '## Q<n> —' headings on disk vs committed rows -------- - headings = [ln for ln in src_text.splitlines() - if ln.startswith("## ") and (" " + SEP + " ") in ln[3:]] - q_headings = [ln for ln in headings - if ln[3:].strip().split(" " + SEP + " ", 1)[0].startswith("Q") - and ln[3:].strip().split(" " + SEP + " ", 1)[0][1:].isdigit()] - check("'## Q<n> —' headings == committed rows", - len(q_headings) == len(committed), - "headings=%d rows=%d" % (len(q_headings), len(committed))) - - # --- manifest ----------------------------------------------------------- - manifest_path = os.path.join(HERE, MANIFEST_NAME) - try: - man = json.load(open(manifest_path, encoding="utf-8")) - except (OSError, ValueError) as exc: - check("manifest readable JSON", False, repr(exc)) - man = {} - check("manifest.rows == rows", man.get("rows") == len(golden), - "manifest=%r actual=%d" % (man.get("rows"), len(golden))) - auto = man.get("extracted_at_utc", "") - check("manifest.extracted_at_utc present", isinstance(auto, str) and auto, repr(auto)) - parseable = False - if isinstance(auto, str) and auto: - try: - datetime.strptime(auto, TS_FMT).replace(tzinfo=timezone.utc) - parseable = True - except ValueError: - pass - check("manifest.extracted_at_utc parseable UTC", parseable, repr(auto)) - check("manifest.extracted_at_utc not the stale constant", auto != STALE, repr(auto)) - check("manifest.generated_by present", isinstance(man.get("generated_by"), str) - and man["generated_by"], repr(man.get("generated_by"))) - - # --- corruption --------------------------------------------------------- - empty = [r for r in committed if len(r) < 2 or not r[0] or not r[1]] - check("no empty q/title", not empty, repr(empty[:1])) - bad_tab = [r for r in committed if len(r) >= 3 and "\t" in r[2]] - check("status contains no literal tab", not bad_tab, repr(bad_tab[:1])) - bad_tab2 = [r for r in committed if len(r) >= 4 and "\t" in r[3]] - check("target contains no literal tab", not bad_tab2, repr(bad_tab2[:1])) - - if fails: - print("\n%d check(s) FAILED" % len(fails)) - return 1 - print("\nALL CHECKS PASSED (%d rows, %d q-numbers)" - % (len(committed), len(set(q_headings)))) - return 0 - - -if __name__ == "__main__": - sys.exit(main()) +#!/usr/bin/env bash +# CHECK -- 2026-11-02 workqueue-census, graded against the queue revision it pins. +# +# Entry point: this is the file every caller in this tree invokes, and it is +# invoked with `bash` (the q143 sweep honours the shebang, tools/verify.py's +# doc-command leg and a reader who types the path do not). It was a Python +# program with a `python3` shebang, so `bash CHECK` read rc 2 on shell syntax +# errors before grading anything. The grader moved to grade_census.py; this +# wrapper is the stable entry point, and it also passes through any argument. +# +# rc 0 green -- every leg passed +# rc 1 a fault (a moved cell, a digest that does not match, a stale pin) +# rc 2 could not grade (no git, no pin, no artifact) +set -u +HERE="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" || exit 2 +[ -f "$HERE/grade_census.py" ] || { + echo "CANNOT GRADE: grade_census.py missing beside this entry point"; exit 2; } +exec python3 -u "$HERE/grade_census.py" "$@" diff --git a/wizard-work/ledger/2026-11-02-workqueue-census/README.md b/wizard-work/ledger/2026-11-02-workqueue-census/README.md index 2391f54..6a1d651 100644 --- a/wizard-work/ledger/2026-11-02-workqueue-census/README.md +++ b/wizard-work/ledger/2026-11-02-workqueue-census/README.md @@ -1,32 +1,59 @@ # workqueue-census — 2026-11-02 -Typed census of every numbered work-queue (Q) item in `WORK-QUEUE.md` (the -committed source, sha256 `cea6cd3c…06eb`, 14,265 lines). +Typed census of every numbered work-queue (Q) item in `WORK-QUEUE.md`. + +The census is a **snapshot**, and it says which one: `extract_manifest.json` pins +the queue revision and blob the rows were read from — + + source_rev 0ec1c643fa5cfcb996266423013de2b553eb0c95 + source_blob_sha a7f716593b91c0db930d8ed7e78eb23a2d0f0d51 (WORK-QUEUE.md) + source_sha256 ceb6cd3c7e0f1fbfe55045b5fd2765f076f7adae50f23b26f243e6e5028906eb + source_lines 14265 + rows 88 + +(The README this replaces stated the source sha256 as `cea6cd3c…06eb`; the blob +pinned above hashes to `ceb6cd3c…06eb`. One hex character, in prose the gate did +not read — which is why the digest is now a graded leg rather than a caption.) ## Artifact -`workqueue-census.tsv` — tab-separated, header `Q | Title | Status | Target`. -One row per Q item, sourced verbatim from the live `WORK-QUEUE.md`. +`workqueue-census.tsv` — tab-separated, header `Q | Title | Status | Target`, +one row per Q heading at the pinned revision. `Q` and `Title` are graded against +an independent re-derivation; `Status` and `Target` are transcribed from the +item's body and are **not** certified by this gate. -## Rules (documented for the CHECK) +## Rules * A Q item is a line matching `^## Q<n> — <title>`. * Trailing `*(notes)*` on the title is stripped. -* `Status` is the `**Status: ...` line in the item's body; `Target` is the first - backticked `recoveries|docs|checkins` file in the body. +* `Status` is the first `**Status: ...` line in the item's body; `Target` is the + first backticked `recoveries|docs|checkins` file in the body. * Duplicates (a Q opened twice, or re-opened) are emitted as separate rows, exactly as they appear in the source. ## Reproduce / verify ```bash -python3 extract_workqueue_census.py # regenerate the TSV + manifest -python3 CHECK # independent re-derivation; exit 0 iff green +bash CHECK # grade the artifact against its pin +python3 extract_workqueue_census.py # regenerate TSV + manifest at HEAD +python3 extract_workqueue_census.py --help # usage; a bad flag is rc 2 ``` -The CHECK re-derives the expected rows from `WORK-QUEUE.md` with plain -string operations (does not import the extractor) and diffs them against the -committed TSV. Exit code is the verdict: `0` = correct, nonzero = wrong. +`CHECK` is a bash entry point over `grade_census.py` (the same shape as the two +check-in censuses that Q151 repaired): every caller in this tree invokes an entry +point with `bash`, and before this wrapper `bash CHECK` read rc 2 on shell syntax +errors without grading a cell. The grader is a separate program from the +extractor and does not import it. + +`probe_census.sh` runs a 13-cell battery in a detached worktree, so the gate's +red readings are measured rather than asserted: a moved `Title` cell, a moved `Q` +cell, a corrupted digest, a pin whose revision does not hold that blob, an absent +pinned object, an absent TSV, an absent grader, a queue append the pin absorbs +(ADVISORY), the extractor refusing a dirty source, `--allow-dirty` writing an +unpinned manifest that the gate then refuses to grade, and a restore. + +Exit codes: `0` green, `1` a fault, `2` could not grade (no pin, no artifact, no +grader). A `2` is never a pass. ## Column contract @@ -35,3 +62,17 @@ committed TSV. Exit code is the verdict: `0` = correct, nonzero = wrong. * `Status` — the `**Status: ...` line, verbatim (may carry a trailing `**`). * `Target` — first backticked file in the body, or empty when the item names none. + +## What the pin does and does not buy + +The queue is append-only, so a gate that re-derived from the live file reddened +on the next tick's own append — it graded the world, not the artifact (measured: +one appended heading turned the pre-repair `python3 CHECK` from rc 0 into rc 1 +with three failing legs). Grading the pinned blob removes that time bomb: a +later append is reported as `ADVISORY source-moved` and changes no verdict. + +The pin does not make the census current. Re-pinning is a deliberate +`python3 extract_workqueue_census.py` at a committed revision plus a commit; the +extractor refuses to pin a dirty `WORK-QUEUE.md` unless `--allow-dirty` is +passed, and that path records `source_blob_sha: null` — which the gate reads as +ungradable, not as green. diff --git a/wizard-work/ledger/2026-11-02-workqueue-census/extract_manifest.json b/wizard-work/ledger/2026-11-02-workqueue-census/extract_manifest.json index c1e0867..d569cd3 100644 --- a/wizard-work/ledger/2026-11-02-workqueue-census/extract_manifest.json +++ b/wizard-work/ledger/2026-11-02-workqueue-census/extract_manifest.json @@ -1,6 +1,10 @@ { "source": "WORK-QUEUE.md", + "source_rev": "0ec1c643fa5cfcb996266423013de2b553eb0c95", + "source_blob_sha": "a7f716593b91c0db930d8ed7e78eb23a2d0f0d51", "source_sha256": "ceb6cd3c7e0f1fbfe55045b5fd2765f076f7adae50f23b26f243e6e5028906eb", + "source_lines": 14265, + "source_matches_head_blob": true, "rows": 88, "columns": [ "Q", @@ -8,8 +12,9 @@ "Status", "Target" ], + "row_digest": "960ca42062bb8b5b871d138f86a31a5b539894ac5589971ce5288fc751f21ee6", "extract_rule": "A Q item is a line matching ^## Q<n> \u2014 <title>; trailing '*(notes)*' stripped; Status = '**Status: ...' line; Target = first backticked recoveries|docs|checkins file in the body. Duplicates emitted as separate rows.", "artifact": "workqueue-census.tsv", "generated_by": "ledger (extract lane)", - "extracted_at_utc": "2026-11-02T00:00:00Z" -} \ No newline at end of file + "extracted_at_utc": "2026-11-02T05:18:59Z" +} diff --git a/wizard-work/ledger/2026-11-02-workqueue-census/extract_workqueue_census.py b/wizard-work/ledger/2026-11-02-workqueue-census/extract_workqueue_census.py index a44e294..7251fa8 100644 --- a/wizard-work/ledger/2026-11-02-workqueue-census/extract_workqueue_census.py +++ b/wizard-work/ledger/2026-11-02-workqueue-census/extract_workqueue_census.py @@ -1,5 +1,5 @@ #!/usr/bin/env python3 -"""Extract a structured census of every numbered work-queue (Q) item from WORK-QUEUE.md. +"""Extract a structured census of every numbered work-queue (Q) item, and pin it. Artifact columns: Q | Title | Status | Target Rule (documented for the CHECK): a Q item is a line matching @@ -9,22 +9,39 @@ Target are the **Status: ... and the first backticked recoveries|docs|checkins file referenced within the item's body. Duplicates (the same Q number opened twice, or re-opened) are emitted as separate rows, exactly as-is in the source. -Usage: python3 extract_workqueue_census.py +THE PIN. A census is a snapshot, and the queue it snapshots is append-only: a +gate that re-derives from the live file reddens on the next tick's own append, +which grades the world instead of the artifact. So the manifest records the +revision and blob the rows were read from (`source_rev`, `source_blob_sha`), the +CHECK grades those bytes, and the worktree's drift from the pin is an ADVISORY, +never a fault. + +The pin is honest or the extractor refuses: if the worktree's WORK-QUEUE.md is +not the HEAD blob, it writes nothing and exits 1 ("commit it first"), unless +`--allow-dirty` is passed, which snapshots the worktree and records +`source_blob_sha: null` so the absence of a pin is a stated fact. + +Usage: python3 extract_workqueue_census.py [--allow-dirty] [--stamp TS] Writes workqueue-census.tsv + extract_manifest.json into the directory this -script lives in (wizard-work/ledger/2026-11-02-workqueue-census/). +script lives in. Exit 0 written, 1 refused (dirty source), 2 usage error. """ +import argparse +import hashlib import json import os import re +import subprocess import sys -import urllib.request +from datetime import datetime, timezone HERE = os.path.dirname(os.path.abspath(__file__)) REPO_ROOT = os.path.dirname(os.path.dirname(os.path.dirname(HERE))) -SRC = os.path.join(REPO_ROOT, "WORK-QUEUE.md") +SRC_REL = "WORK-QUEUE.md" +SRC = os.path.join(REPO_ROOT, SRC_REL) OUT_DIR = HERE TSV_NAME = "workqueue-census.tsv" MANIFEST_NAME = "extract_manifest.json" +HEADER = ["Q", "Title", "Status", "Target"] HEADING_RE = re.compile(r"^## Q(\d+) — (.*)$") STATUS_RE = re.compile(r"^\*\*Status:(.*)$") @@ -38,9 +55,12 @@ def strip_note(title): return NOTE_RE.sub("", title).strip() -def extract(src): - with open(src, encoding="utf-8") as fh: - lines = fh.read().splitlines() +def git(*args): + return subprocess.run(["git", "-C", REPO_ROOT] + list(args), + capture_output=True, check=False) + + +def extract(lines): rows = [] i, n = 0, len(lines) while i < n: @@ -60,41 +80,76 @@ def extract(src): target = tm.group(1).strip() if status and target: break - j += 1 - if lines[j].startswith("## "): + if line.startswith("## "): break + j += 1 rows.append((q, title, status, target)) - i = j + i = max(j, i + 1) continue i += 1 return rows -def main(): - rows = extract(SRC) - os.makedirs(OUT_DIR, exist_ok=True) - tsv_path = os.path.join(OUT_DIR, TSV_NAME) - with open(tsv_path, "w", encoding="utf-8", newline="") as fh: - fh.write("Q\tTitle\tStatus\tTarget\n") - for q, title, status, target in rows: - fh.write(f"{q}\t{title}\t{status}\t{target}\n") - import hashlib +def main(argv=None): + ap = argparse.ArgumentParser(add_help=True) + ap.add_argument("--allow-dirty", action="store_true", + help="snapshot the worktree even when it is not the HEAD blob") + ap.add_argument("--stamp", default=None, + help="extracted_at_utc to record (default: now, UTC)") + args = ap.parse_args(argv) - src_hash = hashlib.sha256(open(SRC, "rb").read()).hexdigest() + try: + with open(SRC, "rb") as fh: + src_bytes = fh.read() + except OSError as exc: + print("REFUSED: cannot read %s: %r" % (SRC_REL, exc)) + return 1 + text = src_bytes.decode("utf-8") + src_hash = hashlib.sha256(src_bytes).hexdigest() + + rev = git("rev-parse", "HEAD").stdout.decode().strip() + pin_sha = git("rev-parse", "HEAD:%s" % SRC_REL) + pin_blob = pin_sha.stdout.decode().strip() if pin_sha.returncode == 0 else "" + pinned = git("cat-file", "blob", pin_blob).stdout if pin_blob else b"" + matches_head = bool(pin_blob) and pinned == src_bytes + if not matches_head and not args.allow_dirty: + print("REFUSED: %s in the worktree is not the blob at HEAD:%s " + "(commit it first, or pass --allow-dirty)" % (SRC_REL, SRC_REL)) + return 1 + + rows = extract(text.splitlines()) + tsv_path = os.path.join(OUT_DIR, TSV_NAME) + body = "".join("%s\t%s\t%s\t%s\n" % r for r in rows) + with open(tsv_path, "w", encoding="utf-8", newline="") as fh: + fh.write("\t".join(HEADER) + "\n") + fh.write(body) + + stamp = args.stamp or datetime.now(timezone.utc).strftime("%Y-%m-%dT%H:%M:%SZ") manifest = { - "source": "WORK-QUEUE.md", + "source": SRC_REL, + "source_rev": rev, + "source_blob_sha": pin_blob if matches_head else None, "source_sha256": src_hash, + "source_lines": len(text.splitlines()), + "source_matches_head_blob": matches_head, "rows": len(rows), - "columns": ["Q", "Title", "Status", "Target"], - "extract_rule": "A Q item is a line matching ^## Q<n> — <title>; trailing '*(notes)*' stripped; Status = '**Status: ...' line; Target = first backticked recoveries|docs|checkins file in the body. Duplicates emitted as separate rows.", - "artifact": "workqueue-census.tsv", + "columns": HEADER, + "row_digest": hashlib.sha256(body.encode("utf-8")).hexdigest(), + "extract_rule": "A Q item is a line matching ^## Q<n> — <title>; trailing " + "'*(notes)*' stripped; Status = '**Status: ...' line; Target = " + "first backticked recoveries|docs|checkins file in the body. " + "Duplicates emitted as separate rows.", + "artifact": TSV_NAME, "generated_by": "ledger (extract lane)", - "extracted_at_utc": "2026-11-02T00:00:00Z", + "extracted_at_utc": stamp, } with open(os.path.join(OUT_DIR, MANIFEST_NAME), "w", encoding="utf-8") as fh: json.dump(manifest, fh, indent=2) - print(f"rows: {len(rows)}") - print(f"written: {tsv_path}") + fh.write("\n") + print("rows: %d" % len(rows)) + print("pin: %s@%s" % (pin_blob[:7] if matches_head else "none (dirty)", + rev[:7])) + print("written: %s" % tsv_path) return 0 diff --git a/wizard-work/ledger/2026-11-02-workqueue-census/grade_census.py b/wizard-work/ledger/2026-11-02-workqueue-census/grade_census.py new file mode 100644 index 0000000..286972c --- /dev/null +++ b/wizard-work/ledger/2026-11-02-workqueue-census/grade_census.py @@ -0,0 +1,196 @@ +#!/usr/bin/env python3 +"""Independent, pin-bound verification of the 2026-11-02 workqueue-census. + +RE-APPROACH: this grader does NOT import the extractor. It reads the queue bytes +that the manifest pins -- `git cat-file blob <source_blob_sha>` -- and re-derives +the expected (Q, Title) rows with plain string operations, then compares them +cell for cell against the committed TSV. Grading the pinned blob rather than the +worktree is the difference between a gate on an artifact and a gate on today's +file: the queue is append-only, so every later item would otherwise redden a +census whose rows were never wrong. + +WHAT IT GRADES + 1. pin-readable the pinned object exists and is a blob (else rc 2: cannot + grade -- neither a pass nor a fault) + 2. pin-digest sha256(blob) == manifest.source_sha256 + 3. pin-matches-rev `git rev-parse <source_rev>:WORK-QUEUE.md` == source_blob_sha + 4. row-count re-derived rows from the blob == committed TSV rows + 5. q-title every (Q, Title) pair identical, in order + 6. headings `## Q<n> -- ` headings in the blob == committed rows + 7. manifest rows / columns / artifact / generated_by / stamp shape + 8. cells no empty Q or Title; no literal tab inside Status or Target + 9. drift ADVISORY only: the worktree queue differs from the pin + (reported, never graded -- a snapshot must not red on the + queue's growth) + +Run: bash CHECK (the tree's invocation; wrapper over this file) + python3 grade_census.py +Exit: 0 green, 1 a fault, 2 could not grade. +""" +import csv +import hashlib +import json +import os +import re +import subprocess +import sys +from datetime import datetime + +HERE = os.path.dirname(os.path.abspath(__file__)) +REPO_ROOT = os.path.dirname(os.path.dirname(os.path.dirname(HERE))) +TSV_NAME = "workqueue-census.tsv" +MANIFEST_NAME = "extract_manifest.json" +SRC_REL = "WORK-QUEUE.md" +TS_FMT = "%Y-%m-%dT%H:%M:%SZ" +SEP = "\u2014" # em dash +HEADER = ["Q", "Title", "Status", "Target"] + + +def git(*args, stdin_bytes=None): + return subprocess.run( + ["git", "-C", REPO_ROOT] + list(args), + input=stdin_bytes, capture_output=True, check=False) + + +def rederive(text): + """Independent derivation: emit (qid, title) for every '## Q<n> -- <title>'.""" + golden = [] + qid, title = None, "" + for line in text.splitlines(): + if not line.startswith("## "): + continue + rest = line[3:].strip() + if " " + SEP + " " not in rest: + continue + pid, _, t = rest.partition(" " + SEP + " ") + if not (pid.startswith("Q") and pid[1:].isdigit()): + continue + t = re.sub(r"\s*\*.*$", "", t).strip() + if qid is not None: + golden.append((qid, title)) + qid, title = pid[1:], t + if qid is not None: + golden.append((qid, title)) + return golden + + +def heading_count(text): + n = 0 + for line in text.splitlines(): + rest = line[3:].strip() if line.startswith("## ") else "" + if not rest or (" " + SEP + " ") not in rest: + continue + pid = rest.split(" " + SEP + " ", 1)[0] + if pid.startswith("Q") and pid[1:].isdigit(): + n += 1 + return n + + +def main(): + fails = [] + + def check(name, cond, detail=""): + print(("PASS " if cond else "FAIL ") + name + + ("" if cond else " " + repr(detail))) + if not cond: + fails.append(name) + + try: + man = json.load(open(os.path.join(HERE, MANIFEST_NAME), encoding="utf-8")) + except (OSError, ValueError) as exc: + print("CANNOT GRADE: manifest unreadable: %r" % (exc,)) + return 2 + + blob_sha = man.get("source_blob_sha") + rev = man.get("source_rev") + if not (isinstance(blob_sha, str) and re.fullmatch(r"[0-9a-f]{40}", blob_sha or "") + and isinstance(rev, str) and rev): + print("CANNOT GRADE: manifest pins no (source_rev, source_blob_sha): %r" + % ({"source_rev": rev, "source_blob_sha": blob_sha},)) + return 2 + + kind = git("cat-file", "-t", blob_sha) + if kind.returncode != 0 or kind.stdout.strip() != b"blob": + print("CANNOT GRADE: pinned object %s is not a readable blob" % blob_sha) + return 2 + blob = git("cat-file", "blob", blob_sha).stdout + text = blob.decode("utf-8") + check("pin-readable", True, "") + + digest = hashlib.sha256(blob).hexdigest() + check("pin-digest", digest == man.get("source_sha256"), + "blob=%s manifest=%r" % (digest, man.get("source_sha256"))) + + at_rev = git("rev-parse", "%s:%s" % (rev, SRC_REL)).stdout.decode().strip() + check("pin-matches-rev", at_rev == blob_sha, + "rev %s holds %r" % (rev, at_rev)) + + check("manifest.source is repo-relative", man.get("source") == SRC_REL, + repr(man.get("source"))) + + try: + with open(os.path.join(HERE, TSV_NAME), encoding="utf-8", newline="") as fh: + rows = list(csv.reader(fh, delimiter="\t")) + except OSError as exc: + print("CANNOT GRADE: committed TSV unreadable: %r" % (exc,)) + return 2 + header, committed = rows[0], rows[1:] + check("tsv header", header == HEADER, repr(header)) + + golden = rederive(text) + check("row-count", len(committed) == len(golden), + "committed=%d golden=%d" % (len(committed), len(golden))) + mism = [k for k, (c, g) in enumerate(zip(committed, golden)) + if len(c) < 2 or c[0] != g[0] or c[1] != g[1]] + check("q-title identical to independent re-derive", not mism, + "first mismatch row %r" % (mism[0] if mism else None)) + check("headings == committed rows", + heading_count(text) == len(committed), + "headings=%d rows=%d" % (heading_count(text), len(committed))) + + check("manifest.rows == re-derived rows", man.get("rows") == len(golden), + "manifest=%r golden=%d" % (man.get("rows"), len(golden))) + check("manifest.columns", man.get("columns") == HEADER, repr(man.get("columns"))) + check("manifest.artifact", man.get("artifact") == TSV_NAME, + repr(man.get("artifact"))) + check("manifest.generated_by present", + isinstance(man.get("generated_by"), str) and bool(man["generated_by"]), + repr(man.get("generated_by"))) + stamp = man.get("extracted_at_utc", "") + ok_stamp = False + if isinstance(stamp, str) and stamp: + try: + datetime.strptime(stamp, TS_FMT) + ok_stamp = True + except ValueError: + pass + check("manifest.extracted_at_utc parseable UTC", ok_stamp, repr(stamp)) + + empty = [r for r in committed if len(r) < 2 or not r[0] or not r[1]] + check("no empty q/title", not empty, repr(empty[:1])) + check("status carries no literal tab", + not [r for r in committed if len(r) >= 3 and "\t" in r[2]], "") + check("target carries no literal tab", + not [r for r in committed if len(r) >= 4 and "\t" in r[3]], "") + + live = os.path.join(REPO_ROOT, SRC_REL) + try: + with open(live, "rb") as fh: + live_digest = hashlib.sha256(fh.read()).hexdigest() + except OSError: + live_digest = None + if live_digest != digest: + print("ADVISORY source-moved worktree=%s pinned=%s" + % ((live_digest or "absent")[:12], digest[:12])) + + print() + if fails: + print("%d check(s) FAILED" % len(fails)) + return 1 + print("ALL CHECKS PASSED (%d rows, %d distinct q-numbers, pin %s@%s)" + % (len(committed), len({g[0] for g in golden}), blob_sha[:7], rev[:7])) + return 0 + + +if __name__ == "__main__": + sys.exit(main()) diff --git a/wizard-work/ledger/2026-11-02-workqueue-census/probe_census.sh b/wizard-work/ledger/2026-11-02-workqueue-census/probe_census.sh new file mode 100644 index 0000000..d234e75 --- /dev/null +++ b/wizard-work/ledger/2026-11-02-workqueue-census/probe_census.sh @@ -0,0 +1,105 @@ +#!/usr/bin/env bash +# probe_census.sh -- prove the 2026-11-02 workqueue-census gate can fail. +# +# Every cell copies the census directory into a detached worktree of HEAD (the +# pin resolves there, because a worktree shares the repository's objects), +# mutates exactly one thing, and runs the entry point the tree invokes -- +# `bash CHECK`. A gate whose only measured state is green is a print, not a +# check: these cells are the red and ungradable readings. +# +# rc 0 every cell read the code it must read; rc 1 a cell read something else. +set -u +ROOT="$(git -C "$(dirname "${BASH_SOURCE[0]}")" rev-parse --show-toplevel)" || exit 1 +SRC_DIR="$ROOT/wizard-work/ledger/2026-11-02-workqueue-census" +WT="$(mktemp -d "${TMPDIR:-/tmp}/census-probe.XXXXXX")/wt" +git -C "$ROOT" worktree add --detach "$WT" HEAD >/dev/null 2>&1 || { + echo "CANNOT PROBE: git worktree add failed"; exit 1; } +trap 'git -C "$ROOT" worktree remove --force "$WT" >/dev/null 2>&1' EXIT + +DIR="$WT/wizard-work/ledger/2026-11-02-workqueue-census" +for f in CHECK grade_census.py extract_workqueue_census.py extract_manifest.json workqueue-census.tsv; do + cp "$SRC_DIR/$f" "$DIR/$f" +done + +cells=0 +faults=0 +cell() { # cell <name> <want-rc> <got-rc> <detail> + cells=$((cells + 1)) + if [ "$2" -eq "$3" ]; then + printf 'ok %-22s rc=%s %s\n' "$1" "$3" "$4" + else + printf 'FAIL %-22s want rc=%s got rc=%s %s\n' "$1" "$2" "$3" "$4" + faults=$((faults + 1)) + fi +} +fresh() { # fresh <name> -> a private copy at the same depth inside the worktree + # the depth matters: grade_census.py resolves the repo from its own path, so a + # copy outside wizard-work/ledger/ would grade a directory that is not a repo + cp -a "$DIR" "$WT/wizard-work/ledger/$1" + printf '%s\n' "$WT/wizard-work/ledger/$1" +} + +# 1 baseline +out="$(bash "$DIR/CHECK" 2>&1)"; rc=$? +cell baseline 0 "$rc" "$(printf '%s' "$out" | tail -n 1)" + +# 2 one title cell moved +d="$(fresh c-title)"; sed -i '2s/\tRecover the fifteen silent rooms\t/\tMUTANT TITLE\t/' "$d/workqueue-census.tsv" +out="$(bash "$d/CHECK" 2>&1)"; rc=$? +cell title-moved 1 "$rc" "$(printf '%s' "$out" | grep -m1 '^FAIL')" + +# 3 one Q cell moved (same row, position 1) +d="$(fresh c-q)"; sed -i '2s/^1\t/199\t/' "$d/workqueue-census.tsv" +out="$(bash "$d/CHECK" 2>&1)"; rc=$? +cell q-moved 1 "$rc" "$(printf '%s' "$out" | grep -m1 '^FAIL')" + +# 4 manifest digest corrupted +d="$(fresh c-digest)"; sed -i 's/"source_sha256": ".*"/"source_sha256": "'"$(printf 'a%.0s' $(seq 64))"'"/' "$d/extract_manifest.json" +out="$(bash "$d/CHECK" 2>&1)"; rc=$? +cell digest-corrupt 1 "$rc" "$(printf '%s' "$out" | grep -m1 '^FAIL')" + +# 5 pin repointed at a rev that does not hold that blob +OLD="$(git -C "$WT" rev-list HEAD -- WORK-QUEUE.md | tail -n 1)" +d="$(fresh c-rev)"; sed -i 's/"source_rev": ".*"/"source_rev": "'"$OLD"'"/' "$d/extract_manifest.json" +out="$(bash "$d/CHECK" 2>&1)"; rc=$? +cell pin-rev-moved 1 "$rc" "$(printf '%s' "$out" | grep -m1 '^FAIL *pin-matches-rev')" + +# 6 pinned object absent -> cannot grade, never a pass +d="$(fresh c-absent)"; sed -i 's/"source_blob_sha": ".*"/"source_blob_sha": "'"$(printf '0%.0s' $(seq 40))"'"/' "$d/extract_manifest.json" +out="$(bash "$d/CHECK" 2>&1)"; rc=$? +cell pin-absent 2 "$rc" "$(printf '%s' "$out" | head -n 1)" + +# 7 artifact deleted -> cannot grade +d="$(fresh c-notsv)"; mv "$d/workqueue-census.tsv" "$d/gone.tsv" +out="$(bash "$d/CHECK" 2>&1)"; rc=$? +cell tsv-absent 2 "$rc" "$(printf '%s' "$out" | grep -m1 'CANNOT GRADE')" + +# 8 grader absent -> the wrapper refuses instead of passing +d="$(fresh c-nograder)"; mv "$d/grade_census.py" "$d/gone.py" +out="$(bash "$d/CHECK" 2>&1)"; rc=$? +cell grader-absent 2 "$rc" "$(printf '%s' "$out" | head -n 1)" + +# 9 the queue grows under a pinned artifact -> still green, and says so +printf '\n## Q199 — probe append the pin must absorb\n\n**Status: OPEN.**\n' >> "$WT/WORK-QUEUE.md" +out="$(bash "$DIR/CHECK" 2>&1)"; rc=$? +cell drift-absorbed 0 "$rc" "$(printf '%s' "$out" | grep -m1 '^ADVISORY')" + +# 10 ...and the same append makes the extractor refuse to pin it +out="$(cd "$WT" && python3 "$DIR/extract_workqueue_census.py" 2>&1)"; rc=$? +cell extract-refuses 1 "$rc" "$(printf '%s' "$out" | head -n 1)" + +# 11 --allow-dirty writes, and the unpinned manifest is ungradable (rc 2) +out="$(cd "$WT" && python3 "$DIR/extract_workqueue_census.py" --allow-dirty 2>&1)"; rc=$? +cell allow-dirty 0 "$rc" "$(printf '%s' "$out" | grep -m1 '^pin:')" +out="$(bash "$DIR/CHECK" 2>&1)"; rc=$? +cell unpinned-ungradable 2 "$rc" "$(printf '%s' "$out" | head -n 1)" + +# restore the pinned artifact and re-read green (the last cell is a control) +cp "$SRC_DIR/extract_manifest.json" "$SRC_DIR/workqueue-census.tsv" "$DIR/" +out="$(bash "$DIR/CHECK" 2>&1)"; rc=$? +cell restore-green 0 "$rc" "$(printf '%s' "$out" | tail -n 1)" + +echo +echo "probe_census: $cells cell(s), $faults unexpected" +[ "$faults" -eq 0 ] || exit 1 +exit 0 diff --git a/wizard-work/volt/q137-open-set/open_set.py b/wizard-work/volt/q137-open-set/open_set.py index 5639544..dff3083 100644 --- a/wizard-work/volt/q137-open-set/open_set.py +++ b/wizard-work/volt/q137-open-set/open_set.py @@ -532,8 +532,14 @@ PIN_OPENED = [51, 52, 53, 65, 100, 101, 102, 103, 104, 105, 106, 107, 109, # ids 143 -> 144; record_only stays 55 and open / opened stay 0 / 26 (same-tick # closure, no probe; CHECK-q153 is its guard). Measured after the append, not # predicted. -PIN_COUNTS = {"headings": 101, "heading_ids": 89, "records": 115, - "record_ids": 81, "ids": 144, "open": 0, "opened": 26, +# Q155 (2026-11-02): the same move again -- one heading (## Q155 closure) and +# one record (**Q155 — OPENED and REPAIRED ...) for a new id, so headings +# 101 -> 102, heading_ids 89 -> 90, records 115 -> 116, record_ids 81 -> 82, +# ids 144 -> 145; record_only stays 55 and open / opened stay 0 / 26 (same-tick +# closure, no probe; CHECK-q155 is its guard). Measured after the append by +# `open_set.py --check`, which read exactly these five moves and no others. +PIN_COUNTS = {"headings": 102, "heading_ids": 90, "records": 116, + "record_ids": 82, "ids": 145, "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 cdf1fd5..812abaa 100644 --- a/wizard-work/volt/q143-check-sweep/check_entry_baseline.tsv +++ b/wizard-work/volt/q143-check-sweep/check_entry_baseline.tsv @@ -152,3 +152,7 @@ wizard-work/ledger/CHECK-2026-11-01-posts-census 0 VERDICT=PASS posts-census-202 CHECK-q152 0 q152: 4 leg(s), all passed # rows signed (q148 via retake.py, 2026-11-02): 1 entry point(s) measured, --timeout 120 --jobs 4, at HEAD 0467528 CHECK-q153 0 q153: 2 leg(s), all passed +# rows signed (q148 via retake.py, 2026-11-02): 1 entry point(s) measured, --timeout 120 --jobs 4, at HEAD 0ec1c64 +wizard-work/ledger/2026-11-02-workqueue-census/CHECK 0 ALL CHECKS PASSED (88 rows, 85 distinct q-numbers, pin a7f7165@0ec1c64) +# rows signed (q148 via retake.py, 2026-11-02): 1 entry point(s) measured, --timeout 120 --jobs 4, at HEAD 0ec1c64 +CHECK-q155 0 q155: 3 leg(s), all passed