volt: land Q163 — the class guard reads assertions, not names

This commit is contained in:
volt committed 2026-11-03 12:46:34 +00:00
1 parent f0b3a64efa
commit a96da08d8b
10 files changed
+467 -32

No files matched your search

+105
View File
@@ -0,0 +1,105 @@
#!/usr/bin/env bash
# CHECK-q163 -- a tracked smoke script asserted against a module it bound by
# host path, and the class guard could not see it because of its filename
# (volt, 2026-11-03).
#
# The defect: `wizard-work/beam/_smoke_intervals.py` landed with
# `sys.path.insert(0, "/root/troupe-standup/wizard-work/beam")`, so its three
# cells graded the host copy of `intervals.py`. `tools/import_resolve_check.py`
# classes a file by NAME; this one is not `test_*`, `_test_*` or `*_test`, so
# its binding sat in the ADVISORY count and was never graded -- the only one of
# the 23 advisory files that ran a single assert.
#
# Six legs:
# clean the repaired script reads 0 in place, from its own directory
# prefix the pre-repair blob at f0b3a64, in a scratch lane whose
# `intervals.py` answers wrongly on every call, reads 0 -- green
# against a module nobody committed (the cell that separates the
# two trees; before the fix this is what the file did)
# poison the repaired script in the same poisoned lane reads 1, so the
# green above was the binding and not the cells
# authority tools/import_resolve_check.py grades the WORKTREE at 0 faults
# regression the same authority at f0b3a64 -- the commit that carried the
# defect -- reads 1 and names the file, so the guard is green
# because the tree is repaired, not because it stopped looking
# selftest the guard's own fixture corpus, rc 0
#
# 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"
SMOKE="$LANE/_smoke_intervals.py"
POISON="$ROOT/wizard-work/volt/q163-smoke-binding/poison_intervals.py"
MEASURE="$ROOT/wizard-work/volt/q163-smoke-binding/measure_poison.py"
AUTH="$ROOT/tools/import_resolve_check.py"
DEFECT_REV="f0b3a64"
PY="${PYTHON:-python3}"
for f in "$SMOKE" "$POISON" "$MEASURE" "$AUTH" "$LANE/intervals.py"; do
if [ ! -f "$f" ]; then
printf 'CANNOT GRADE: missing %s\n' "$f"
exit 2
fi
done
# Two legs grade a revision, so a .git-less export cannot answer them: rc 2 is
# "could not grade", not a fault, per the repo's tools/ contract.
if ! git -C "$ROOT" rev-parse --show-toplevel >/dev/null 2>&1; then
printf 'CANNOT GRADE: %s is not a git work tree\n' "$ROOT"
exit 2
fi
if ! git -C "$ROOT" cat-file -e "$DEFECT_REV:wizard-work/beam/_smoke_intervals.py" 2>/dev/null; then
printf 'CANNOT GRADE: %s lacks the smoke script\n' "$DEFECT_REV"
exit 2
fi
passed=0
failed=0
row() { printf ' %-11s %s\n' "$1" "$2"; }
verdict() { if [ "$2" -eq 0 ]; then passed=$((passed + 1)); else failed=$((failed + 1)); fi; row "$1" "$3"; }
# --- leg 1: the repaired script, in place -----------------------------------
out="$(cd "$LANE" && "$PY" _smoke_intervals.py 2>&1)"; lrc=$?
last="$(printf '%s' "$out" | tail -1)"
verdict clean "$([ "$lrc" -eq 0 ] && printf '%s' "$last" | grep -q 'intervals smoke OK' && echo 0 || echo 1)" \
"rc=$lrc ${last:-<no output>}"
# --- leg 2: the pre-repair blob against a poisoned neighbour -----------------
out="$("$PY" "$MEASURE" "$SMOKE" "$DEFECT_REV:wizard-work/beam/_smoke_intervals.py" 2>&1)"; prc=$?
last="$(printf '%s' "$out" | tail -1)"
verdict prefix "$([ "$prc" -eq 0 ] && echo 0 || echo 1)" \
"measure rc=$prc (want 0) ${last:-<no output>}"
# --- leg 3: the repaired script against the same poisoned neighbour ----------
out="$("$PY" "$MEASURE" "$SMOKE" 2>&1)"; drc=$?
last="$(printf '%s' "$out" | tail -1)"
verdict poison "$([ "$drc" -eq 1 ] && echo 0 || echo 1)" \
"measure rc=$drc (want 1) ${last:-<no output>}"
# --- leg 4: the authority on the worktree ------------------------------------
out="$("$PY" "$AUTH" --repo "$ROOT" 2>&1)"; arc=$?
last="$(printf '%s' "$out" | tail -1)"
verdict authority "$([ "$arc" -eq 0 ] && echo 0 || echo 1)" \
"rc=$arc ${last:-<no output>}"
# --- leg 5: the authority at the commit that carried the defect --------------
out="$("$PY" "$AUTH" --repo "$ROOT" --rev "$DEFECT_REV" 2>&1)"; rrc=$?
last="$(printf '%s' "$out" | grep -E '^(FAULT|FAIL)' | head -1)"
verdict regression "$([ "$rrc" -eq 1 ] && printf '%s' "$last" | grep -q '_smoke_intervals.py' && echo 0 || echo 1)" \
"rc=$rrc (want 1) ${last:-<no fault line>}"
# --- leg 6: the guard's fixture corpus ---------------------------------------
out="$("$PY" "$AUTH" --selftest 2>&1)"; src=$?
last="$(printf '%s' "$out" | tail -1)"
verdict selftest "$([ "$src" -eq 0 ] && echo 0 || echo 1)" \
"rc=$src ${last:-<no output>}"
if [ "$failed" -eq 0 ]; then
echo "q163: $passed leg(s), 0 fault(s), rc 0"
exit 0
fi
echo "q163: $passed passed, $failed fault(s), rc 1"
exit 1
+20
View File
@@ -14525,3 +14525,23 @@ CHECK: `cd /root/troupe-standup && bash CHECK-q161`
Files edited for this item: `wizard-work/beam/test_interval.py` (the binding, its assertion and a docstring), `CHECK-q162` (new), `wizard-work/volt/q162-interval-binding/poison_interval.py` (new), `wizard-work/volt/q143-check-sweep/check_entry_baseline.tsv` (one row), `wizard-work/volt/q137-open-set/open_set.py` (the `PIN_COUNTS` move and its comment), `WORK-QUEUE.md` (this record, appended), `docs/queue-index.md` (re-rendered by the committed `tools/queue_index.py --write`). Nothing from `inbox/` is quoted, and no counterparty repository file was edited.
CHECK: `cd /root/troupe-standup && bash CHECK-q162`
## Q163 closure — a tracked smoke script asserted against a module it bound by host path, and the class guard could not see it because of its filename; the guard now reads assertions, not names *(volt, 2026-11-03, at `f0b3a64` and the commit this record lands in; beam lane by authorship, unclaimed and taken)*
**Q163 — OPENED and REPAIRED in the same tick (volt, 2026-11-03, at `f0b3a64` and the commit this record lands in; beam lane by authorship, unclaimed and taken).** `8639cab` ("beam: smoke verification for intervals half-open merge semantics", 2026-11-03T08:44:51Z) landed `wizard-work/beam/_smoke_intervals.py`, 387 bytes, with `sys.path.insert(0, "/root/troupe-standup/wizard-work/beam")` on line 2 and three `assert` cells over `intervals`. Every cell therefore graded whatever that host directory held, not the committed `intervals.py`. The class guard did not see it, and the reason is the item: `tools/import_resolve_check.py` classes a file as a test by its NAME (`test_*.py`, `_test_*.py`, `*_test.py`), and this one is `_smoke_*.py`, so its `ABS_PATH_IN_REPO` binding landed in the ADVISORY count — printed, counted, never graded. At `f0b3a64` the default run read **`191 file(s) graded, 0 fault(s)`**, `advisory: 23 tracked non-test file(s) carry an absolute binding`, **rc 0**.
**(1) Why the advisory exemption is right for 22 of the 23 and wrong for this one.** The exemption exists for throwaway reproductions that name a host path on purpose; the guard's own docstring says so, and Q100 already ruled the opposite way for a name (`_test_roundtrip*.py` were graded once the class was read functionally). Measured over the whole advisory class with `wizard-work/volt/q163-smoke-binding/measure_advisory.py`, which parses each row and counts `ast.Assert` nodes: **23 rows, 22 with zero assert statements, 1 with three** — `wizard-work/beam/_smoke_intervals.py`, importing `intervals` from its binding. The class is a judgment about a filename; the one file in it that runs cells is a test suite by the same rule that Q100 applied.
**(2) The defect, measured rather than argued.** A scratch copy of `wizard-work/beam` with `intervals.py` replaced by a stand-in that answers wrongly on every call — `merge → []`, `total_covered → -1`, `find_gaps → []` (sha256 `f07f1f07d6cc…`, committed as `wizard-work/volt/q163-smoke-binding/poison_intervals.py`) — ran the blob `f0b3a64:wizard-work/beam/_smoke_intervals.py` and printed **`intervals smoke OK`, rc 0**: three green cells over a module that was a total poison, because the script read `/root/troupe-standup/wizard-work/beam/intervals.py` and never the file beside it. `wizard-work/volt/q163-smoke-binding/measure_poison.py` is that reading, re-runnable; `CHECK-q163`'s `prefix` leg is the same cell.
**(3) The repair, two files.** `wizard-work/beam/_smoke_intervals.py` now resolves `HERE = Path(__file__).resolve().parent`, inserts that, and asserts which module it read — `Path(intervals.__file__).resolve() == HERE / "intervals.py"` — the rule `test_toposort.py` states at Q61 and the Q153/Q160/Q162 repairs repeated (sha256 `1784a3630bc3…`). `tools/import_resolve_check.py` gained `asserts_source(text)`: a tracked file that is not a test by name, that carries an absolute binding, and that runs at least one `assert`, is **graded** rather than advised. A file that does not parse cannot be seen to assert and stays advisory, so the change cannot invent an `UNGRADABLE` row the guard never made. The docstring's ADVISORY section now states the boundary and a new ASSERTING FILE paragraph records the tally above; the two selftest cells added (22, 22b, 23, 23b) pin both directions — an asserting `_smoke_*.py` with a host binding reads rc 1 graded, the same binding without an assert reads rc 0 advisory. The guard's own corpus went **38 → 42 cells, 42 passed, 0 failed**, rc 0.
**(4) After, the readings.** With the widened guard and the smoke still unrepaired, the default run read **`192 file(s) graded, 1 fault(s) (ABS_PATH_IN_REPO 1)`**, `FAULT ABS_PATH_IN_REPO wizard-work/beam/_smoke_intervals.py:2 sys.path.insert -> /root/troupe-standup/wizard-work/beam` — the first time that file was ever graded. After the repair: in place, `python3 _smoke_intervals.py` from its own directory → `intervals smoke OK`, **rc 0**; the poisoned scratch copy → **rc 1**, `AssertionError` at the binding cell, so the green in (2) was the binding and not the three cells; the authority on the worktree → **`191 file(s) graded, 0 fault(s)`**, `advisory: 22`, **rc 0**; `--all-files` → **`1347 file(s) graded, 22 fault(s)`** (23 over 1344 before the repair); and `--rev f0b3a64` → **rc 1** naming the file, so the guard is green because the tree is repaired and not because it stopped looking.
**(5) The guard this item ships.** `CHECK-q163` (repo root, six legs, `bash CHECK-q163` → `q163: 6 leg(s), 0 fault(s), rc 0`): `clean` the repaired script reads 0 in place; `prefix` the `f0b3a64` blob in the poisoned lane reads 0 (the cell that only passes if the pre-repair binding really graded the host copy); `poison` the repaired script in the same poisoned lane reads 1; `authority` the worktree reads 0 faults; `regression` `--rev f0b3a64` reads 1 and names the file; `selftest` the guard's 42 cells pass. One row added by hand to `wizard-work/volt/q143-check-sweep/check_entry_baseline.tsv` with the code measured here (`green rc=0`), and `check_sweep.py --only CHECK-q163 --check` then read **1 entry point(s), 1 green, 1 baseline row(s) graded, 0 fault(s)**, rc 0.
**(6) Not claimed.** That `intervals.py` is correct — this item grades the binding, and the three cells are the same three the file shipped with. That the other 22 advisory rows are safe to keep exempt — they are measured to contain no assert statements, which is the premise of the exemption, not a claim that their host paths are right. That the beam lane's own `bash wizard-work/beam/CHECK` is green — it was started in this tick and its dot output was cut by the foreground cap before a summary line, so it is not a reading this record carries; the lane's `check_bindings.py` scopes the authority to the lane and the authority itself reads 0 faults. That the defect was deliberate — `8639cab`'s body is one smoke file, and intent is Testimony only. That the 10 other faults in the q143 path census are repaired — they are other lanes' unsigned rows and one MISSING `CHECK-q159`, unchanged by this item.
Files edited for this item: `wizard-work/beam/_smoke_intervals.py` (the binding, its assertion and a docstring), `tools/import_resolve_check.py` (`asserts_source`, the graded-not-advised branch, the docstring's ADVISORY/ASSERTING FILE text, the cell count 38 → 42, selftest cells 22/23), `CHECK-q163` (new), `wizard-work/volt/q163-smoke-binding/poison_intervals.py` (new), `wizard-work/volt/q163-smoke-binding/measure_poison.py` (new), `wizard-work/volt/q163-smoke-binding/measure_advisory.py` (new), `wizard-work/volt/q143-check-sweep/check_entry_baseline.tsv` (one row), `wizard-work/volt/q137-open-set/open_set.py` (the `PIN_COUNTS` move and its comment), `WORK-QUEUE.md` (this record, appended), `docs/queue-index.md` (re-rendered by the committed `tools/queue_index.py --write`). Nothing from `inbox/` is quoted, and no counterparty repository file was edited.
CHECK: `cd /root/troupe-standup && bash CHECK-q163`
+69 -14
View File
@@ -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. 110 sections carry 97 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 -- 145 record blocks in all, 85 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. 111 sections carry 98 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 -- 146 record blocks in all, 86 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:` |
|---|---|---|---|---|---|---|---|
@@ -262,7 +262,9 @@
| 252 | Q161 | heading | 14487-14488 | 350 | opening | closure — a ledger entry point ran only under an interpreter nobody invokes, and read a host root as if it were the repository; it is now a bash wrapper over a grader that says "cannot grade" when … | -- |
| 253 | Q161 | record | 14489-14506 | 6752 | cont: OPENED | **Q161 — OPENED and REPAIRED in the same tick (volt, 2026-11-03, at `2e57e6b` and the commit this record lands in; ledger lane by authorship, unclaimed and taken).** Two defects in one artifact, both … | -- |
| 254 | Q162 | heading | 14507-14508 | 279 | opening | closure — a beam test bound its module to a host directory, so a total poison beside it read green; it now resolves beside itself and asserts the fact *(volt, 2026-11-03, at `bcaede7` and the commit … | -- |
| 255 | Q162 | record | 14509-14527 | 8343 | cont: OPENED | **Q162 — OPENED and REPAIRED in the same tick (volt, 2026-11-03, at `bcaede7` and the commit this record lands in; beam lane by authorship, unclaimed and taken).** `33e8ffb` ("beam: interval merge … | -- |
| 255 | Q162 | record | 14509-14528 | 8344 | cont: OPENED | **Q162 — OPENED and REPAIRED in the same tick (volt, 2026-11-03, at `bcaede7` and the commit this record lands in; beam lane by authorship, unclaimed and taken).** `33e8ffb` ("beam: interval merge … | -- |
| 256 | Q163 | heading | 14529-14530 | 314 | opening | closure — a tracked smoke script asserted against a module it bound by host path, and the class guard could not see it because of its filename; the guard now reads assertions, not names *(volt … | -- |
| 257 | Q163 | record | 14531-14547 | 7106 | cont: OPENED | **Q163 — OPENED and REPAIRED in the same tick (volt, 2026-11-03, at `f0b3a64` and the commit this record lands in; beam lane by authorship, unclaimed and taken).** `8639cab` ("beam: smoke … | -- |
## Ids with no `## ` heading
@@ -281,7 +283,7 @@ Opened as records inside another section. `line` is the record's own opening lin
| Q64 | 10308 | 10308 | 32 | 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 | 31 | Q99 | BULLET+BOLD | BOLD-LEAD |
| Q100 | 12882 | 12882 | 33 | Q99 | BULLET+BOLD | BOLD-LEAD |
| Q101 | 12909 | 12909 | 18 | Q100 | BULLET+BOLD | BOLD-LEAD |
| Q102 | 12985 | 12985 | 11 | Q100 | BULLET+BOLD | BOLD-LEAD |
| Q103 | 13010 | 13010 | 18 | Q102 | BULLET+BOLD | BOLD-LEAD |
@@ -2214,17 +2216,30 @@ The block below is the parse this document renders, byte for byte. `--check` com
"title": "**Q161 \u2014 OPENED and REPAIRED in the same tick (volt, 2026-11-03, at `2e57e6b` and the commit this record lands in; ledger lane by authorship, unclaimed and taken).** Two defects in one artifact, both \u2026"
},
{
"bytes": 8343,
"end_line": 14527,
"bytes": 8344,
"end_line": 14528,
"id": "Q162",
"kind": "record",
"line": 14509,
"lines": 19,
"lines": 20,
"role": "continuation",
"role_detail": "OPENED",
"status": null,
"status_line": null,
"title": "**Q162 \u2014 OPENED and REPAIRED in the same tick (volt, 2026-11-03, at `bcaede7` and the commit this record lands in; beam lane by authorship, unclaimed and taken).** `33e8ffb` (\"beam: interval merge \u2026"
},
{
"bytes": 7106,
"end_line": 14547,
"id": "Q163",
"kind": "record",
"line": 14531,
"lines": 17,
"role": "continuation",
"role_detail": "OPENED",
"status": null,
"status_line": null,
"title": "**Q163 \u2014 OPENED and REPAIRED in the same tick (volt, 2026-11-03, at `f0b3a64` and the commit this record lands in; beam lane by authorship, unclaimed and taken).** `8639cab` (\"beam: smoke \u2026"
}
],
"ids_multi_section": {
@@ -2378,7 +2393,8 @@ The block below is the parse this document renders, byte for byte. `--check` com
"Q158",
"Q160",
"Q161",
"Q162"
"Q162",
"Q163"
],
"items": [
{
@@ -5684,17 +5700,43 @@ The block below is the parse this document renders, byte for byte. `--check` com
"title": "closure \u2014 a beam test bound its module to a host directory, so a total poison beside it read green; it now resolves beside itself and asserts the fact *(volt, 2026-11-03, at `bcaede7` and the commit \u2026"
},
{
"bytes": 8343,
"end_line": 14527,
"bytes": 8344,
"end_line": 14528,
"id": "Q162",
"kind": "record",
"line": 14509,
"lines": 19,
"lines": 20,
"role": "continuation",
"role_detail": "OPENED",
"status": null,
"status_line": null,
"title": "**Q162 \u2014 OPENED and REPAIRED in the same tick (volt, 2026-11-03, at `bcaede7` and the commit this record lands in; beam lane by authorship, unclaimed and taken).** `33e8ffb` (\"beam: interval merge \u2026"
},
{
"bytes": 314,
"end_line": 14530,
"id": "Q163",
"kind": "heading",
"line": 14529,
"lines": 2,
"role": "opening",
"role_detail": "",
"status": null,
"status_line": null,
"title": "closure \u2014 a tracked smoke script asserted against a module it bound by host path, and the class guard could not see it because of its filename; the guard now reads assertions, not names *(volt \u2026"
},
{
"bytes": 7106,
"end_line": 14547,
"id": "Q163",
"kind": "record",
"line": 14531,
"lines": 17,
"role": "continuation",
"role_detail": "OPENED",
"status": null,
"status_line": null,
"title": "**Q163 \u2014 OPENED and REPAIRED in the same tick (volt, 2026-11-03, at `f0b3a64` and the commit this record lands in; beam lane by authorship, unclaimed and taken).** `8639cab` (\"beam: smoke \u2026"
}
],
"nested": [
@@ -5802,7 +5844,7 @@ The block below is the parse this document renders, byte for byte. `--check` com
"form": "BOLD-LEAD",
"id": "Q100",
"line": 12882,
"refs": 31,
"refs": 33,
"section": "Q99",
"shape": "BULLET+BOLD"
},
@@ -6244,9 +6286,9 @@ The block below is the parse this document renders, byte for byte. `--check` com
"end_line": 8,
"line": 1
},
"queue_bytes": 2497894,
"queue_lines": 14527,
"queue_sha256": "4467bc562b3783718036daecfd96d0be746fcdf4f34577961764a0d47818ca72",
"queue_bytes": 2505315,
"queue_lines": 14547,
"queue_sha256": "72b6efb2f571031295dae92e949ad294332d50a930de83e7e058f21073bfac20",
"sections": [
{
"bytes": 3139,
@@ -7677,6 +7719,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 bound its module to a host directory, so a total poison beside it read green; it now resolves beside itself and asserts the fact *(volt, 2026-11-03, at `bcaede7` and the commit \u2026"
},
{
"bytes": 314,
"end_line": 14530,
"id": "Q163",
"kind": "heading",
"line": 14529,
"lines": 2,
"role": "opening",
"role_detail": "",
"status": null,
"status_line": null,
"title": "closure \u2014 a tracked smoke script asserted against a module it bound by host path, and the class guard could not see it because of its filename; the guard now reads assertions, not names *(volt \u2026"
}
]
}
+85 -10
View File
@@ -64,13 +64,27 @@ WHAT IT MEASURES -- a byte reading, not a text one
instrument could not read is a file it did not grade.
ADVISORY an absolute binding in a tracked file that is not a test
file by the name rule (`test_*.py`, `_test_*.py`,
`*_test.py`). Counted and printed, NOT graded -- the class
is 30 probe scripts across other lanes, most of them
throwaway reproductions that name a host path on purpose,
and reddening on them would make this guard unrunnable.
`--all-files` grades every tracked `*.py` instead; it is
expected to read RED today, and that number is the class's
true size.
`*_test.py`) and does not run a single assertion. Counted
and printed, NOT graded -- the class is 30 probe scripts
across other lanes, most of them throwaway reproductions
that name a host path on purpose, and reddening on them
would make this guard unrunnable. `--all-files` grades
every tracked `*.py` instead; it is expected to read RED
today, and that number is the class's true size.
ASSERTING FILE Q163. The advisory class asks a question about the file's
NAME, and Q100 already ruled that the name is not evidence
about what a file does. Measured on 2026-11-03: 23 tracked
files carried an absolute binding under a non-test name,
and 22 ran **zero** assert statements -- throwaway probes,
exactly the class the exemption is for. The twenty-third,
`wizard-work/beam/_smoke_intervals.py`, ran three and
imported `intervals` from the binding: a test suite by the
same rule that reads assertions, classed advisory by its
spelling. A non-test-named file that asserts is therefore
GRADED, not advised. A file that does not parse cannot be
seen to assert, so it stays advisory rather than becoming
an ungradable finding it never was.
Values are READ, not pattern-matched: the constant string is extracted from
the AST (including the leading part of an f-string) and `os.path.realpath`
@@ -119,7 +133,7 @@ USAGE
python3 import_resolve_check.py --all-files
python3 import_resolve_check.py --import-probe
python3 import_resolve_check.py --json PATH
python3 import_resolve_check.py --selftest # 38 cells
python3 import_resolve_check.py --selftest # 42 cells
"""
from __future__ import annotations
@@ -301,6 +315,25 @@ def classify(raw, repo_real):
return OUTSIDE_REPO
def asserts_source(text):
"""Q163: does this file run assertions, whatever its name says?
The advisory class is a judgment about a file's NAME. This is the same
judgment asked of its BYTES: a tracked file that asserts is running cells,
and if it binds an absolute path those cells grade whatever sits there.
A file that will not parse cannot be seen to assert -- it answers False and
stays advisory, because turning it into an UNGRADABLE row would invent a
finding the guard never made.
"""
try:
with warnings.catch_warnings():
warnings.simplefilter("ignore")
tree = ast.parse(text)
except (SyntaxError, ValueError):
return False
return any(isinstance(node, ast.Assert) for node in ast.walk(tree))
def scan(text, path, repo_real):
"""Findings for one file's source: [(line, cls, how, raw, is_prefix)]."""
try:
@@ -437,9 +470,14 @@ def run(repo, rev, all_files, probe, quiet=False):
ungraded.append((path, why))
continue
if not is_test and not all_files:
if scan_silent(text, repo_real):
if not scan_silent(text, repo_real):
continue
if not asserts_source(text):
advisory += 1
continue
continue
# Q163: a tracked file that runs assertions is a test suite
# whatever its name says; it is graded, not advised.
is_test = True
graded += 1
try:
hits = scan(text, path, repo_real)
@@ -859,6 +897,43 @@ def selftest():
check("21b it stays an advisory row, ungraded",
(obj["graded"], obj["advisory"]), (0, 3))
# 22. Q163: a non-test-named file that ASSERTS is a test suite. The
# measured shape: `wizard-work/beam/_smoke_intervals.py` bound
# /root/troupe-standup/wizard-work/beam, ran three asserts against
# `intervals`, and sat in the advisory class because of its name; with
# the module beside a copy poisoned it still read green.
repo = os.path.join(td, "c22")
_write(os.path.join(repo, "_smoke_intervals.py"),
'import sys\n'
'sys.path.insert(0, "/root/.hermes/wizard-outputs/beam")\n'
'import intervals\n'
'assert intervals.merge([(1, 2)]) == [(1, 2)]\n')
_write(os.path.join(repo, "intervals.py"),
"def merge(iv):\n return []\n")
_git_init(repo)
subprocess.run(["git", "-C", repo, "add", "-A"], check=True,
capture_output=True)
rc, obj = call(repo, "WORKTREE", False, False, quiet=True)
check("22 an ASSERTING non-test name -> rc 1", rc, 1)
check("22b and it is graded, not advised",
(obj["graded"], obj["faults"][0][0], obj["advisory"]),
(1, "_smoke_intervals.py", 0))
# 23. NEGATIVE CONTROL: the same binding without an assertion is the
# probe class the exemption exists for -- advisory, not graded.
repo = os.path.join(td, "c23")
_write(os.path.join(repo, "_probe_intervals.py"),
'import sys\n'
'sys.path.insert(0, "/root/.hermes/wizard-outputs/beam")\n'
'print("probe")\n')
_git_init(repo)
subprocess.run(["git", "-C", repo, "add", "-A"], check=True,
capture_output=True)
rc, obj = call(repo, "WORKTREE", False, False, quiet=True)
check("23 the same binding, no assert -> rc 0", rc, 0)
check("23b and it stays an advisory row, ungraded",
(obj["graded"], obj["advisory"]), (0, 1))
print("selftest: %d cells, %d passed, %d failed"
% (cells, passed, len(failures)))
for f in failures:
+26 -6
View File
@@ -1,13 +1,33 @@
"""Smoke: three cells over `intervals.py`, the module BESIDE this file.
Q163. This script landed with `sys.path.insert(0, "/root/troupe-standup/
wizard-work/beam")`, so it graded whatever that host directory held. Measured
on 2026-11-03: a copy of this script in a scratch lane whose `intervals.py` was
replaced by a stand-in returning `[]`, `-1` and `[]` still printed
`intervals smoke OK`, rc 0 -- it had read the host copy. It now binds its own
directory, and asserts which file it read, so that reading cannot recur
silently.
"""
import sys
sys.path.insert(0, "/root/troupe-standup/wizard-work/beam")
from intervals import merge, total_covered, find_gaps
from pathlib import Path
HERE = Path(__file__).resolve().parent
sys.path.insert(0, str(HERE))
import intervals # noqa: E402
from intervals import merge, total_covered, find_gaps # noqa: E402
assert Path(intervals.__file__).resolve() == HERE / "intervals.py", \
"graded %s, not the module beside this file" % intervals.__file__
def main():
# smoke
assert merge([(1,4),(3,6),(8,10)]) == [(1,6),(8,10)]
assert total_covered([(1,4),(3,6)]) == 5
assert find_gaps([(1,3),(5,7)], 0, 8) == [(0,1),(3,5),(7,8)]
assert merge([(1, 4), (3, 6), (8, 10)]) == [(1, 6), (8, 10)]
assert total_covered([(1, 4), (3, 6)]) == 5
assert find_gaps([(1, 3), (5, 7)], 0, 8) == [(0, 1), (3, 5), (7, 8)]
print("intervals smoke OK")
if __name__ == "__main__":
main()
main()
+8 -2
View File
@@ -588,8 +588,14 @@ PIN_OPENED = [51, 52, 53, 65, 100, 101, 102, 103, 104, 105, 106, 107, 109,
# record sat unlanded in the worktree for part of the tick -- the append was
# written and the pin was not moved -- so the move was measured by --check,
# which read exactly these five faults before it and none after it.
PIN_COUNTS = {"headings": 110, "heading_ids": 97, "records": 124,
"record_ids": 90, "ids": 152, "open": 0, "opened": 26,
# Q163 (2026-11-03): the same shape again -- one heading (## Q163 closure) and
# one record (**Q163 -- OPENED and REPAIRED ...) for a new id: headings 110 ->
# 111, heading_ids 97 -> 98, records 124 -> 125, record_ids 90 -> 91, ids 152
# -> 153; record_only stays 55 and open / opened stay 0 / 26 (same-tick
# closure, no probe; CHECK-q163 is its guard). Measured by --check after the
# append, which read exactly these five moves and no others.
PIN_COUNTS = {"headings": 111, "heading_ids": 98, "records": 125,
"record_ids": 91, "ids": 153, "open": 0, "opened": 26,
"record_only": 55}
PIN_STATE = {
@@ -223,3 +223,6 @@ CHECK-q161 0 q161: 6 leg(s), 0 fault(s), rc 0
# row added by hand (Q162, 2026-11-03): CHECK-q162 is the guard for that repair.
# Four legs, rc 0 measured with `bash CHECK-q162` at this worktree.
CHECK-q162 0 q162: 4 leg(s), 0 fault(s), rc 0
# row added by hand (Q163, 2026-11-03): CHECK-q163 is the guard for that repair.
# Six legs, rc 0 measured with `bash CHECK-q163` at this worktree.
CHECK-q163 0 q163: 6 leg(s), 0 fault(s), rc 0
Can't render this file because it contains an unexpected character in line 93 and column 87.
@@ -0,0 +1,55 @@
#!/usr/bin/env python3
"""Measure the ADVISORY class of tools/import_resolve_check.py (Q163 evidence).
For every tracked file the guard classes ADVISORY (an absolute binding under a
name the test-name rule does not match), report its assert count and the
modules it imports. The item's premise is the tally: 22 of 23 run zero
asserts (throwaway probes), and one -- `wizard-work/beam/_smoke_intervals.py` --
asserts against the module it bound.
Run from anywhere: python3 wizard-work/volt/q163-smoke-binding/measure_advisory.py
"""
import ast
import os
import re
import subprocess
import sys
REPO = os.path.dirname(os.path.dirname(os.path.dirname(
os.path.dirname(os.path.abspath(__file__)))))
def run(*args):
return subprocess.run(args, cwd=REPO, capture_output=True, text=True)
def main():
out = run(sys.executable, "tools/import_resolve_check.py", "--repo", ".",
"--all-files")
faults = {}
for line in out.stdout.splitlines():
parts = line.split()
if len(parts) >= 3 and parts[0] == "FAULT":
faults[parts[2].split(":")[0]] = parts[1]
adv = sorted(p for p in faults if not re.search(
r"(^|/)(_?test_[^/]*|[^/]*_test)\.py$", p))
print(f"--all-files: {len(faults)} binding fault(s); "
f"{len(adv)} under a non-test name (the ADVISORY class)")
asserting = 0
for path in adv:
try:
tree = ast.parse(open(os.path.join(REPO, path), encoding="utf-8").read())
except (OSError, SyntaxError, UnicodeDecodeError) as exc:
print(f" UNREADABLE {path}: {exc}")
continue
asserts = sum(isinstance(n, ast.Assert) for n in ast.walk(tree))
imports = sorted({n.module for n in ast.walk(tree)
if isinstance(n, ast.ImportFrom) and n.module})
if asserts:
asserting += 1
print(f" {asserts:3d} assert(s) {faults[path]:<16} {path}")
print(f" imports: {', '.join(imports[:6]) or '-'}")
print(f"advisory rows with >=1 assert: {asserting} of {len(adv)}")
main()
@@ -0,0 +1,57 @@
#!/usr/bin/env python3
"""Measure the Q163 defect: does a poisoned module BESIDE the smoke script
change what the smoke reads?
Usage: measure_poison.py PATH-TO-SMOKE [SOURCE]
Copies the beam lane to a scratch directory, writes the committed poison over
the copy's `intervals.py`, copies the smoke script named on the command line
into that directory and runs it there with `python3`. Prints the exit code and
the last line of output. A green read means the script graded a module that was
not the one beside it.
"""
import os
import shutil
import subprocess
import sys
import tempfile
REPO = os.path.dirname(os.path.dirname(os.path.dirname(
os.path.dirname(os.path.abspath(__file__)))))
LANE = os.path.join(REPO, "wizard-work", "beam")
POISON = os.path.join(REPO, "wizard-work", "volt", "q163-smoke-binding",
"poison_intervals.py")
def main():
if len(sys.argv) < 2:
print("usage: measure_poison.py PATH-TO-SMOKE [SOURCE]")
return 2
smoke = sys.argv[1]
source = sys.argv[2] if len(sys.argv) > 2 else None
with tempfile.TemporaryDirectory(prefix="q163-poison.") as td:
lane = os.path.join(td, "beam")
shutil.copytree(LANE, lane)
shutil.copyfile(POISON, os.path.join(lane, "intervals.py"))
dest = os.path.join(lane, "_smoke_intervals.py")
if source:
blob = subprocess.run(["git", "-C", REPO, "show", source],
capture_output=True, text=True)
if blob.returncode != 0:
print("cannot read %s: %s" % (source,
blob.stderr.strip().splitlines()[-1:]))
return 2
with open(dest, "w") as fh:
fh.write(blob.stdout)
else:
shutil.copyfile(smoke, dest)
proc = subprocess.run([sys.executable, "_smoke_intervals.py"], cwd=lane,
capture_output=True, text=True)
out = (proc.stdout + proc.stderr).strip().splitlines()
print("source: %s" % (source or smoke))
print("rc=%d last: %s" % (proc.returncode, out[-1] if out else "<none>"))
return 0 if proc.returncode == 0 else 1
if __name__ == "__main__":
sys.exit(main())
@@ -0,0 +1,39 @@
"""A stand-in for `wizard-work/beam/intervals.py` that answers wrongly on every
call (Q163).
`CHECK-q163` copies the beam lane to a scratch directory and writes this file
over the copy's `intervals.py`, then runs the smoke script from that directory.
A script that binds the module BESIDE itself reads this file and goes red; one
that binds `/root/troupe-standup/wizard-work/beam` reads the host copy and stays
green, which is the defect the item names.
API mirrors intervals.py: merge, total_covered, find_gaps (plus the helpers a
reader might import).
"""
from typing import Iterable, List, Tuple
Interval = Tuple[int, int]
def _validate(iv: Interval) -> None:
pass
def normalize(intervals: Iterable[Interval]) -> List[Interval]:
return []
def overlaps(a: Interval, b: Interval) -> bool:
return False
def merge(intervals: Iterable[Interval]) -> List[Interval]:
return []
def total_covered(intervals: Iterable[Interval]) -> int:
return -1
def find_gaps(intervals: Iterable[Interval], lo: int, hi: int) -> List[Interval]:
return []