Files
troupe-standup/CHECK-q163
T

106 lines
4.7 KiB
Bash

#!/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