106 lines
4.8 KiB
Bash
106 lines
4.8 KiB
Bash
#!/usr/bin/env bash
|
|
# probe_census.sh -- prove the 2026-11-02 workqueue-census gate can fail.
|
|
#
|
|
# Every cell copies the census directory into a detached worktree of HEAD (the
|
|
# pin resolves there, because a worktree shares the repository's objects),
|
|
# mutates exactly one thing, and runs the entry point the tree invokes --
|
|
# `bash CHECK`. A gate whose only measured state is green is a print, not a
|
|
# check: these cells are the red and ungradable readings.
|
|
#
|
|
# rc 0 every cell read the code it must read; rc 1 a cell read something else.
|
|
set -u
|
|
ROOT="$(git -C "$(dirname "${BASH_SOURCE[0]}")" rev-parse --show-toplevel)" || exit 1
|
|
SRC_DIR="$ROOT/wizard-work/ledger/2026-11-02-workqueue-census"
|
|
WT="$(mktemp -d "${TMPDIR:-/tmp}/census-probe.XXXXXX")/wt"
|
|
git -C "$ROOT" worktree add --detach "$WT" HEAD >/dev/null 2>&1 || {
|
|
echo "CANNOT PROBE: git worktree add failed"; exit 1; }
|
|
trap 'git -C "$ROOT" worktree remove --force "$WT" >/dev/null 2>&1' EXIT
|
|
|
|
DIR="$WT/wizard-work/ledger/2026-11-02-workqueue-census"
|
|
for f in CHECK grade_census.py extract_workqueue_census.py extract_manifest.json workqueue-census.tsv; do
|
|
cp "$SRC_DIR/$f" "$DIR/$f"
|
|
done
|
|
|
|
cells=0
|
|
faults=0
|
|
cell() { # cell <name> <want-rc> <got-rc> <detail>
|
|
cells=$((cells + 1))
|
|
if [ "$2" -eq "$3" ]; then
|
|
printf 'ok %-22s rc=%s %s\n' "$1" "$3" "$4"
|
|
else
|
|
printf 'FAIL %-22s want rc=%s got rc=%s %s\n' "$1" "$2" "$3" "$4"
|
|
faults=$((faults + 1))
|
|
fi
|
|
}
|
|
fresh() { # fresh <name> -> a private copy at the same depth inside the worktree
|
|
# the depth matters: grade_census.py resolves the repo from its own path, so a
|
|
# copy outside wizard-work/ledger/ would grade a directory that is not a repo
|
|
cp -a "$DIR" "$WT/wizard-work/ledger/$1"
|
|
printf '%s\n' "$WT/wizard-work/ledger/$1"
|
|
}
|
|
|
|
# 1 baseline
|
|
out="$(bash "$DIR/CHECK" 2>&1)"; rc=$?
|
|
cell baseline 0 "$rc" "$(printf '%s' "$out" | tail -n 1)"
|
|
|
|
# 2 one title cell moved
|
|
d="$(fresh c-title)"; sed -i '2s/\tRecover the fifteen silent rooms\t/\tMUTANT TITLE\t/' "$d/workqueue-census.tsv"
|
|
out="$(bash "$d/CHECK" 2>&1)"; rc=$?
|
|
cell title-moved 1 "$rc" "$(printf '%s' "$out" | grep -m1 '^FAIL')"
|
|
|
|
# 3 one Q cell moved (same row, position 1)
|
|
d="$(fresh c-q)"; sed -i '2s/^1\t/199\t/' "$d/workqueue-census.tsv"
|
|
out="$(bash "$d/CHECK" 2>&1)"; rc=$?
|
|
cell q-moved 1 "$rc" "$(printf '%s' "$out" | grep -m1 '^FAIL')"
|
|
|
|
# 4 manifest digest corrupted
|
|
d="$(fresh c-digest)"; sed -i 's/"source_sha256": ".*"/"source_sha256": "'"$(printf 'a%.0s' $(seq 64))"'"/' "$d/extract_manifest.json"
|
|
out="$(bash "$d/CHECK" 2>&1)"; rc=$?
|
|
cell digest-corrupt 1 "$rc" "$(printf '%s' "$out" | grep -m1 '^FAIL')"
|
|
|
|
# 5 pin repointed at a rev that does not hold that blob
|
|
OLD="$(git -C "$WT" rev-list HEAD -- WORK-QUEUE.md | tail -n 1)"
|
|
d="$(fresh c-rev)"; sed -i 's/"source_rev": ".*"/"source_rev": "'"$OLD"'"/' "$d/extract_manifest.json"
|
|
out="$(bash "$d/CHECK" 2>&1)"; rc=$?
|
|
cell pin-rev-moved 1 "$rc" "$(printf '%s' "$out" | grep -m1 '^FAIL *pin-matches-rev')"
|
|
|
|
# 6 pinned object absent -> cannot grade, never a pass
|
|
d="$(fresh c-absent)"; sed -i 's/"source_blob_sha": ".*"/"source_blob_sha": "'"$(printf '0%.0s' $(seq 40))"'"/' "$d/extract_manifest.json"
|
|
out="$(bash "$d/CHECK" 2>&1)"; rc=$?
|
|
cell pin-absent 2 "$rc" "$(printf '%s' "$out" | head -n 1)"
|
|
|
|
# 7 artifact deleted -> cannot grade
|
|
d="$(fresh c-notsv)"; mv "$d/workqueue-census.tsv" "$d/gone.tsv"
|
|
out="$(bash "$d/CHECK" 2>&1)"; rc=$?
|
|
cell tsv-absent 2 "$rc" "$(printf '%s' "$out" | grep -m1 'CANNOT GRADE')"
|
|
|
|
# 8 grader absent -> the wrapper refuses instead of passing
|
|
d="$(fresh c-nograder)"; mv "$d/grade_census.py" "$d/gone.py"
|
|
out="$(bash "$d/CHECK" 2>&1)"; rc=$?
|
|
cell grader-absent 2 "$rc" "$(printf '%s' "$out" | head -n 1)"
|
|
|
|
# 9 the queue grows under a pinned artifact -> still green, and says so
|
|
printf '\n## Q199 — probe append the pin must absorb\n\n**Status: OPEN.**\n' >> "$WT/WORK-QUEUE.md"
|
|
out="$(bash "$DIR/CHECK" 2>&1)"; rc=$?
|
|
cell drift-absorbed 0 "$rc" "$(printf '%s' "$out" | grep -m1 '^ADVISORY')"
|
|
|
|
# 10 ...and the same append makes the extractor refuse to pin it
|
|
out="$(cd "$WT" && python3 "$DIR/extract_workqueue_census.py" 2>&1)"; rc=$?
|
|
cell extract-refuses 1 "$rc" "$(printf '%s' "$out" | head -n 1)"
|
|
|
|
# 11 --allow-dirty writes, and the unpinned manifest is ungradable (rc 2)
|
|
out="$(cd "$WT" && python3 "$DIR/extract_workqueue_census.py" --allow-dirty 2>&1)"; rc=$?
|
|
cell allow-dirty 0 "$rc" "$(printf '%s' "$out" | grep -m1 '^pin:')"
|
|
out="$(bash "$DIR/CHECK" 2>&1)"; rc=$?
|
|
cell unpinned-ungradable 2 "$rc" "$(printf '%s' "$out" | head -n 1)"
|
|
|
|
# restore the pinned artifact and re-read green (the last cell is a control)
|
|
cp "$SRC_DIR/extract_manifest.json" "$SRC_DIR/workqueue-census.tsv" "$DIR/"
|
|
out="$(bash "$DIR/CHECK" 2>&1)"; rc=$?
|
|
cell restore-green 0 "$rc" "$(printf '%s' "$out" | tail -n 1)"
|
|
|
|
echo
|
|
echo "probe_census: $cells cell(s), $faults unexpected"
|
|
[ "$faults" -eq 0 ] || exit 1
|
|
exit 0
|