Files
wizwar6e/deploy/verify-ledgers.sh
T

22 lines
794 B
Bash
Executable File

#!/bin/bash
# Pre-deploy determinism check: fetch every production ledger and strictly
# replay it against the LOCAL engine. Any refused command is a hard failure.
# Run from the repo root before deploying any engine change.
set -euo pipefail
HOST="${1:-159.203.115.252}"
TMP=$(mktemp -d)
trap 'rm -rf "$TMP"' EXIT
scp -q "root@$HOST:/var/lib/wizwar/rooms/*.jsonl" "$TMP/"
fails=0
for f in "$TMP"/*.jsonl; do
# `|| true`: a failing replay must feed the tally, not abort the loop.
out=$(npx tsx deploy/replay-verify.mjs "$f" 2>&1 | tail -1) || true
case "$out" in
OK*) ;;
*) echo "${out:-$(basename "$f"): replay crashed with no output}"; fails=$((fails+1));;
esac
done
count=$(ls "$TMP" | wc -l | tr -d ' ')
echo "--- $count ledgers checked, $fails failures"
[ "$fails" -eq 0 ]