#!/bin/bash
# A3 stopped cell — runs at A3b state: hand rule spt-w2-F PRESENT (admitting),
# listener DOWN, product pair present-but-non-admitting beside it.
# Labelled THROUGH THE HAND RULE: witnesses the product's REFUSAL semantics only.
source "$HOME/.cargo/env" 2>/dev/null
D=~/lane-asm/w2-field
cd ~/spt-core-hertz-linux || exit 9
F='binary(twohost_bootstrap) & test(bootstrap_stopped_from_second_machine)'
export SPT_TWO_HOST=1 SPT_TWO_HOST_ROLE=a \
       SPT_TWO_HOST_PEER_IP=192.168.1.81 \
       SPT_TWO_HOST_BOOTSTRAP_PORT=29470 \
       SPT_TWO_HOST_BOOTSTRAP_ARM=stopped \
       SPT_TWO_HOST_BOOTSTRAP_TRIPLE=x86_64-pc-windows-msvc \
       SPT_TWO_HOST_BOOTSTRAP_SHA=1e29d549d69c34e3fc452212406b7fe513935632816a4021cf7b94a29dc25137

echo "== blob under test (must be 49102e395c3778a8378f3cc5ed06b95ac5a00bbe) =="
git hash-object crates/spt-daemon/tests/twohost_bootstrap.rs

echo "== pre-run list under the run filter (must be 1) =="
cargo nextest list -E "$F" > $D/a3-prelist.log 2>&1
echo "PRELIST_EXIT=$? count=$(grep -cE ' bootstrap_[a-z_]+$' $D/a3-prelist.log)"
grep -E ' bootstrap_[a-z_]+$' $D/a3-prelist.log
echo "-- negative control on the SAME log (must be 0) --"
grep -cE ' bootstrap_zzz_not_a_cell$' $D/a3-prelist.log

echo "== A3 RUN, start $(date -u +%FT%TZ) =="
cargo nextest run -p spt-daemon -E "$F" --success-output immediate --no-fail-fast > $D/a3-run.log 2>&1
echo "A3_EXIT=$?"
echo "== A3 RUN, end   $(date -u +%FT%TZ) =="
cat $D/a3-run.log
echo DONE_A3
