Files
troupe-standup/CHECK-q164
T

123 lines
5.5 KiB
Bash
Executable File

#!/usr/bin/env bash
# CHECK-q164 -- the beam coverage census graded the directory instead of the
# tree, so a scratch file on this host moved its verdict (volt, 2026-11-03).
#
# The defect: `check_coverage.py` listed the lane with
# `glob(lane/*.py)`. At `a96da08` the worktree read 125 module(s) / 3 fault(s)
# and a `git archive HEAD` export of the SAME COMMIT read 124 / 2 -- the
# difference was `_run_regex.py`, untracked, which no clone of that commit
# contains. Same class as Q140/Q141 (a census that describes its host).
#
# Six legs:
# tree the census reads the tree: rc 0, 124 modules, and the untracked
# scratch file is named in a note rather than graded
# scratch a new untracked *.py dropped into the lane does NOT move the
# verdict (rc 0), which is the item: the reading is of the tree
# dir --enumerate dir on the same directory DOES grade it (rc 1), so
# the green above is the source of the list, not a lost tooth
# export a `git archive HEAD` export of the same commit reads rc 0 with
# the same module count: no clone can disagree with this worktree
# smoke the lane gate executes Q163's smoke cells (grep the CHECK line,
# run it, and read its coverage row as covered-gate)
# selftest the census's own fixture corpus, 17 cells, 0 failed
#
# 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"
CENSUS="$LANE/check_coverage.py"
GATE="$LANE/CHECK"
SMOKE="$LANE/_smoke_intervals.py"
PROBE="$LANE/zz_q164_scratch_probe.py"
PY="${PYTHON:-python3}"
for f in "$CENSUS" "$GATE" "$SMOKE"; do
if [ ! -f "$f" ]; then
printf 'CANNOT GRADE: missing %s\n' "$f"
exit 2
fi
done
# Two legs grade the tree and one grades a revision, so a .git-less export
# cannot answer them: rc 2 is "could not grade", not a fault.
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
WORK="$(mktemp -d "${TMPDIR:-/tmp}/check-q164.XXXXXX")" || exit 2
trap 'rm -f "$PROBE"; rm -rf "$WORK"' EXIT
passed=0
failed=0
row() { printf ' %-10s %s\n' "$1" "$2"; }
verdict() { if [ "$2" -eq 0 ]; then passed=$((passed + 1)); else failed=$((failed + 1)); fi; row "$1" "$3"; }
# --- leg 1: the census reads the tree ---------------------------------------
out="$("$PY" "$CENSUS" 2>&1)"; trc=$?
last="$(printf '%s' "$out" | grep '^coverage: [0-9]' | tail -1)"
note="$(printf '%s' "$out" | grep 'untracked, not graded' | head -1)"
verdict tree \
"$([ "$trc" -eq 0 ] && printf '%s' "$last" | grep -q '124 module(s)' \
&& printf '%s' "$last" | grep -q '0 fault(s)' \
&& printf '%s' "$note" | grep -q '_run_regex' && echo 0 || echo 1)" \
"rc=$trc ${last:-<no summary>} ${note:-<no untracked note>}"
# --- leg 2: a host artifact cannot move the verdict -------------------------
printf 'print("scratch probe, never committed")\n' > "$PROBE"
out="$("$PY" "$CENSUS" 2>&1)"; src=$?
last="$(printf '%s' "$out" | grep '^coverage: [0-9]' | tail -1)"
note="$(printf '%s' "$out" | grep 'untracked, not graded: zz_q164_scratch_probe' | head -1)"
verdict scratch \
"$([ "$src" -eq 0 ] && printf '%s' "$last" | grep -q '0 fault(s)' \
&& printf '%s' "$last" | grep -q '124 module(s)' \
&& [ -n "$note" ] && echo 0 || echo 1)" \
"rc=$src ${last:-<no summary>} ${note:-<probe not named>}"
# --- leg 3: the directory reading still has teeth ---------------------------
out="$("$PY" "$CENSUS" --enumerate dir 2>&1)"; drc=$?
faultline="$(printf '%s' "$out" | grep 'UNCOVERED' | tr '\n' ';')"
verdict dir \
"$([ "$drc" -eq 1 ] && printf '%s' "$faultline" | grep -q 'zz_q164_scratch_probe' && echo 0 || echo 1)" \
"rc=$drc (want 1) ${faultline:-<no fault row>}"
rm -f "$PROBE"
# --- leg 4: the same commit, read from a clean export -----------------------
if git -C "$ROOT" archive HEAD 2>/dev/null | tar -x -C "$WORK" 2>/dev/null; then
out="$("$PY" "$WORK/wizard-work/beam/check_coverage.py" 2>&1)"; erc=$?
last="$(printf '%s' "$out" | grep '^coverage: [0-9]' | tail -1)"
verdict export \
"$([ "$erc" -eq 0 ] && printf '%s' "$last" | grep -q '124 module(s)' \
&& printf '%s' "$last" | grep -q '0 fault(s)' && echo 0 || echo 1)" \
"rc=$erc ${last:-<no summary>}"
else
verdict export 1 "git archive HEAD would not export -- cannot read the commit"
fi
# --- leg 5: the lane gate runs the smoke ------------------------------------
line="$(grep -c '^python3 _smoke_intervals\.py$' "$GATE")"
out="$(cd "$LANE" && "$PY" _smoke_intervals.py 2>&1)"; mrc=$?
last="$(printf '%s' "$out" | tail -1)"
rowline="$("$PY" "$CENSUS" --list 2>&1 | grep 'covered-gate * _smoke_intervals' | head -1)"
verdict smoke \
"$([ "$line" -eq 1 ] && [ "$mrc" -eq 0 ] && printf '%s' "$last" | grep -q 'intervals smoke OK' \
&& [ -n "$rowline" ] && echo 0 || echo 1)" \
"check-line=$line rc=$mrc ${last:-<no output>} ${rowline:-<not covered-gate>}"
# --- leg 6: the census's fixture corpus -------------------------------------
out="$("$PY" "$CENSUS" --selftest 2>&1)"; crc=$?
last="$(printf '%s' "$out" | tail -1)"
verdict selftest \
"$([ "$crc" -eq 0 ] && printf '%s' "$last" | grep -q '17 cell(s), 0 failed' && echo 0 || echo 1)" \
"rc=$crc ${last:-<no output>}"
if [ "$failed" -eq 0 ]; then
echo "q164: $passed leg(s), 0 fault(s), rc 0"
exit 0
fi
echo "q164: $passed passed, $failed fault(s), rc 1"
exit 1