#!/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:-104.236.96.198}" 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 ]