75 lines
3.2 KiB
Bash
Executable File
75 lines
3.2 KiB
Bash
Executable File
#!/usr/bin/env bash
|
|
# CHECK-q152 -- the 2026-11-01 posts census graded offline against its own
|
|
# snapshot, a mutant that proves the green is not the only thing it can print,
|
|
# and the scoped sweep that signs the entry point.
|
|
#
|
|
# WHAT WAS WRONG (measured at 76471ad, before this tick's edits)
|
|
# `wizard-work/ledger/CHECK-2026-11-01-posts-census` was a Python program
|
|
# under a `bash` invocation, so the documented run exited 2 on shell syntax
|
|
# before grading a cell; the artifact directory was the literal host path; the
|
|
# check re-derived from the live JSONPlaceholder API on every run; and the
|
|
# rc 2 it documented was unreachable code.
|
|
#
|
|
# WHAT THIS GRADES
|
|
# 1. the committed snapshot, offline: JSON self-consistency, CSV and MD
|
|
# byte-identical re-renderings of it (rc 0, verdict names the population);
|
|
# 2. a mutant of that snapshot in a COPY: one CSV cell moved must read rc 1,
|
|
# so the green above is a measurement and not a print;
|
|
# 3. `check_sweep.py --only <the entry point> --check` -> rc 0, the row the
|
|
# baseline signs (the scoped run grades only what it swept; before Q152's
|
|
# repair it graded 110 unswept rows as MISSING);
|
|
# 4. `check_sweep.py --selftest` -> 23 cells, 0 failed.
|
|
#
|
|
# --live is deliberately NOT a leg: it reaches JSONPlaceholder, and a gate
|
|
# that depends on the network's mood is not a gate.
|
|
#
|
|
# rc 0 every leg holds rc 1 a leg failed rc 2 could not grade
|
|
set -u
|
|
ROOT="$(git -C "$(dirname "$0")" rev-parse --show-toplevel 2>/dev/null)" || exit 2
|
|
[ -n "$ROOT" ] || exit 2
|
|
cd "$ROOT" || exit 2
|
|
|
|
ENTRY=wizard-work/ledger/CHECK-2026-11-01-posts-census
|
|
SWEEP=wizard-work/volt/q143-check-sweep/check_sweep.py
|
|
[ -f "$ENTRY" ] && [ -f "$SWEEP" ] || { echo "CANNOT GRADE: entry point or sweep missing"; exit 2; }
|
|
|
|
legs=0
|
|
faults=0
|
|
leg() { # leg <name> <rc> <detail>
|
|
legs=$((legs + 1))
|
|
if [ "$2" -eq 0 ]; then printf 'PASS %-22s %s\n' "$1" "$3"
|
|
else printf 'FAIL %-22s %s\n' "$1" "$3"; faults=$((faults + 1)); fi
|
|
}
|
|
|
|
out="$(bash "$ENTRY" 2>&1)"; rc=$?
|
|
leg snapshot "$rc" "$(printf '%s' "$out" | grep -m1 -E '^(VERDICT|FAIL|CANNOT)')"
|
|
|
|
tmp="$(mktemp -d "${TMPDIR:-/tmp}/q152-mut-XXXX")" || exit 2
|
|
trap 'rm -rf "$tmp"' EXIT
|
|
mkdir -p "$tmp/census" || exit 2
|
|
cp "$ENTRY" "$tmp/census/CHECK" && cp wizard-work/ledger/grade_posts_census.py "$tmp/census/" \
|
|
&& cp wizard-work/ledger/2026-11-01-posts-census.json \
|
|
wizard-work/ledger/2026-11-01-posts-census.csv \
|
|
wizard-work/ledger/2026-11-01-posts-census.md "$tmp/census/" \
|
|
|| { echo "CANNOT GRADE: cannot stage the mutant"; exit 2; }
|
|
sed -i '2s/,10$/,99/' "$tmp/census/2026-11-01-posts-census.csv"
|
|
mout="$(bash "$tmp/census/CHECK" 2>&1)"; mrc=$?
|
|
if [ "$mrc" -eq 1 ] && printf '%s' "$mout" | grep -q '^FAIL'; then
|
|
leg mutant 0 "a moved CSV cell reads rc 1: $(printf '%s' "$mout" | grep -m1 '^FAIL')"
|
|
else
|
|
leg mutant 1 "mutant did not red the snapshot (rc=$mrc)"
|
|
fi
|
|
|
|
out="$(python3 "$SWEEP" --repo "$ROOT" --only "$ENTRY" --check 2>&1)"; rc=$?
|
|
leg sweep-scoped "$rc" "$(printf '%s' "$out" | grep -m1 '^check-sweep:')"
|
|
|
|
out="$(python3 "$SWEEP" --selftest 2>&1)"; rc=$?
|
|
leg sweep-selftest "$rc" "$(printf '%s' "$out" | grep -m1 '^selftest:')"
|
|
|
|
if [ "$faults" -eq 0 ]; then
|
|
echo "q152: $legs leg(s), all passed"
|
|
exit 0
|
|
fi
|
|
echo "q152: $legs leg(s), $faults fault(s)"
|
|
exit 1
|