Files
stack/agents/rocko/work/queue-56/byte-check.sh
T
jason.woltjeandClaude Opus 5.5 71d874764a feat(runs): read-only runs and releases reader module (#1545, row 56)
New packages/runs reads run records, result.json, the release pointer
and the activation log without writing, pruning or following a link out
of the data root. mosaic-task.mjs list and show use it, so a malformed
result.json or a run that is a regular file no longer crashes them.
Deliberate deltas are listed in the README.

Rocko built it. Round 1 (ed3c5392) was approved with notes by Darkwing
(27115) and Filbert (27116); round 2 (2727198f, tests and wording only)
was approved by Darkwing (27123) and Filbert (27124). Sage's gate on
c9a25a47 plus the candidate: runs 41/0, queue 148/0, webui 22/0,
conversation 182/0 (181/1 in the full run on the K12 cgroup timing
test under load, 182/0 alone), control-board 124/0, every
scripts/test-*.sh 0 failed (task 98/0 with Docker, 26/0 without).

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-10-10 12:22:37 -05:00

67 lines
2.5 KiB
Bash
Executable File

#!/usr/bin/env bash
# Row 56 byte-identity check. Runs `mosaic-task.mjs list` and `show` from a
# baseline tree and a candidate tree against the same seeded data roots and
# compares stdout, stderr and exit codes byte for byte. It also checks that
# neither tree changed the data root.
# Usage: byte-check.sh BASE_TREE CAND_TREE WORK_DIR (WORK_DIR must not exist)
set -euo pipefail
BASE="$(cd "$1" && pwd)"; CAND="$(cd "$2" && pwd)"; W="$3"
HERE="$(cd "$(dirname "$0")" && pwd)"
[ ! -e "$W" ] || { echo "byte-check: $W exists" >&2; exit 4; }
mkdir -p "$W/out"; W="$(cd "$W" && pwd)"
"$HERE/seed.sh" "$W/data"
mkdir -p "$W/empty"
conf() { printf '{"configVersion":1,"environment":"development","dataRoot":"%s","execution":{"backend":"docker","provider":"zai","model":"m"}}\n' "$2" > "$W/$1.json"; }
conf seeded "$W/data"; conf empty "$W/empty"; conf absent "$W/no-such-root"
snapshot() { (cd "$W/data" && find . -printf '%p %y %s %T@ %l\n' | sort && find . -type f -print0 | sort -z | xargs -0 sha256sum); }
snapshot > "$W/before.txt"
CASES=(
"seeded list"
"empty list"
"absent list"
"seeded show r-20260101T000000Z-aaaaaa"
"seeded show r-20260101T000100Z-bbbbbb"
"seeded show r-20260101T000200Z-cccccc"
"seeded show r-20260101T000300Z-dddddd"
"seeded show r-20260101T000400Z-eeeeee"
"seeded show r-20260101T000500Z-ffffff"
"seeded show r-20260101T000700Z-hhhhhh"
"seeded show r-20260101T000800Z-iiiiii"
"seeded show r-zz.weird_name-1"
"seeded show r-missing"
"seeded show ../escape"
"seeded show"
"absent show r-20260101T000000Z-aaaaaa"
)
for tree in base cand; do
root="$BASE"; [ "$tree" = cand ] && root="$CAND"
i=0
for c in "${CASES[@]}"; do
i=$((i + 1))
read -r cfg op arg <<<"$c"
o="$W/out/$tree/$(printf '%02d' "$i")"
mkdir -p "$o"
printf '%s\n' "$c" > "$o/case"
rc=0
(cd "$root" && env -u NODE_OPTIONS MOSAIC_CONFIG="$W/$cfg.json" node scripts/mosaic-task.mjs "$op" ${arg:+"$arg"} >"$o/stdout" 2>"$o/stderr") || rc=$?
printf '%s\n' "$rc" > "$o/exit"
[ -f "$o/stdout" ] && [ -f "$o/stderr" ] || { echo "byte-check: case $i ($c) left no output in $o" >&2; exit 4; }
done
done
snapshot > "$W/after.txt"
status=0
if diff -r "$W/out/base" "$W/out/cand" > "$W/diff.txt"; then
echo "byte-check: ${#CASES[@]} cases, stdout, stderr and exit identical"
else
echo "byte-check: DIFFERENCES (see $W/diff.txt)"; status=1
fi
if cmp -s "$W/before.txt" "$W/after.txt"; then
echo "byte-check: data root unchanged"
else
echo "byte-check: DATA ROOT CHANGED"; status=1
fi
exit "$status"