Files
troupe-standup/CHECK-quill-draft-compliance
volt 8216c2576e volt: CHECK leg 4 reads HEAD's archive, not the worktree (Q142)
Leg 4 built its copy from the worktree, so a dirty tree broke the leg that
exists to prove a copy grades itself. It now extracts wizard-work/quill from
HEAD with git archive; legs 2 and 3 remain the worktree readings, and the
script sets pipefail so a failed archive cannot read as an empty tarball.
2026-10-31 23:59:09 +00:00

104 lines
3.9 KiB
Bash
Executable File

#!/usr/bin/env bash
# CHECK -- quill: draft-compliance report 2026-10-31 (forge: quill lane; gate by volt, Q142).
#
# Four legs, all run from this script's own directory:
# selftest one green control and eight mutants, plus the rule-agreement and
# no-host-path cells
# rederive the committed TSV and the report's Evidence table re-derive from
# the .md drafts beside them
# regenerate the generator's output is byte-identical to the committed TSV
# copy-parity the same scripts run against a COPY of the lane grade the copy:
# clean copy rc 0, copy with one TSV row moved rc 1
#
# Exit codes: 0 all legs passed, 1 a leg failed, 2 a leg could not be graded.
set -u
set -o pipefail
cd "$(dirname "${BASH_SOURCE[0]}")" || exit 2
ROOT="$(pwd)"
LANE="$ROOT/wizard-work/quill"
WORK="$(mktemp -d "${TMPDIR:-/tmp}/check-quill.XXXXXX")" || exit 2
trap 'rm -rf "$WORK"' EXIT
passed=0
failed=0
row() { printf ' %-12s %s\n' "$1" "$2"; }
# --- leg 1: the verifier's own cells -----------------------------------------
if python3 "$LANE/verify_draft_compliance.py" --selftest >"$WORK/selftest.out" 2>&1; then
row selftest "PASS $(tail -n 1 "$WORK/selftest.out")"
passed=$((passed + 1))
else
row selftest "FAULT $(tail -n 1 "$WORK/selftest.out")"
cat "$WORK/selftest.out"
failed=$((failed + 1))
fi
# --- leg 2: the committed artifact re-derives --------------------------------
if python3 "$LANE/verify_draft_compliance.py" >"$WORK/rederive.out" 2>&1; then
row rederive "PASS $(head -n 1 "$WORK/rederive.out")"
passed=$((passed + 1))
else
rc=$?
row rederive "FAULT rc=$rc"
cat "$WORK/rederive.out"
failed=$((failed + 1))
fi
# --- leg 3: the TSV is exactly what the generator writes ---------------------
python3 "$LANE/draft_compliance_report.py" >"$WORK/regen.tsv" 2>"$WORK/regen.err"
gen_rc=$?
if [ "$gen_rc" -ne 0 ]; then
row regenerate "FAULT generator rc=$gen_rc"
cat "$WORK/regen.err"
failed=$((failed + 1))
elif cmp -s "$WORK/regen.tsv" "$LANE/draft-compliance-report-2026-10-31.tsv"; then
row regenerate "PASS bytes identical ($(wc -c <"$WORK/regen.tsv") B)"
passed=$((passed + 1))
else
row regenerate "FAULT committed TSV differs from a fresh derivation"
diff "$WORK/regen.tsv" "$LANE/draft-compliance-report-2026-10-31.tsv" | head -10
failed=$((failed + 1))
fi
# --- leg 4: the COMMITTED artifact grades a copy of itself -------------------
# The copy comes from HEAD (git archive), not from the worktree, so this leg is a
# reading of the committed bytes and is unaffected by an uncommitted edit that
# legs 2 and 3 already fault.
mkdir -p "$WORK/lane" || exit 2
if ! git -C "$ROOT" archive HEAD wizard-work/quill 2>"$WORK/archive.err" \
| tar -x -C "$WORK/lane" 2>>"$WORK/archive.err"; then
row copy-parity "FAULT cannot archive HEAD"
cat "$WORK/archive.err"
failed=$((failed + 1))
else
COPY="$WORK/lane/wizard-work/quill"
if python3 "$COPY/verify_draft_compliance.py" >"$WORK/copy-clean.out" 2>&1; then
clean_rc=0
else
clean_rc=$?
fi
# move one row's line count in the COPY's TSV: the copy must notice
awk -F'\t' 'BEGIN{OFS="\t"} NR==3{$2=$2+1} {print}' \
"$COPY/draft-compliance-report-2026-10-31.tsv" >"$WORK/mut.tsv" \
&& mv "$WORK/mut.tsv" "$COPY/draft-compliance-report-2026-10-31.tsv"
if python3 "$COPY/verify_draft_compliance.py" >"$WORK/copy-mut.out" 2>&1; then
mut_rc=0
else
mut_rc=$?
fi
if [ "$clean_rc" -eq 0 ] && [ "$mut_rc" -eq 1 ]; then
row copy-parity "PASS HEAD copy rc=0, mutated copy rc=1"
passed=$((passed + 1))
else
row copy-parity "FAULT clean copy rc=$clean_rc (want 0), mutated rc=$mut_rc (want 1)"
head -5 "$WORK/copy-clean.out" "$WORK/copy-mut.out"
failed=$((failed + 1))
fi
fi
echo
echo "CHECK-quill-draft-compliance: $passed leg(s) passed, $failed fault(s)"
[ "$failed" -eq 0 ] || exit 1
exit 0