#!/bin/bash
# W1 #235 gate — kitsubito arm. Usage: w1_gate_linux.sh <sha>
set -u
SHA="$1"
export PATH="$HOME/.cargo/bin:$PATH"
cd "$HOME/gate-242-w1" || exit 9
run() { name=$1; shift; echo "=== $name: $*" >> GATE_driver.log; "$@" > "GATE_${name}.raw" 2>&1; echo $? > "GATE_${name}.exit"; }
# env assert: the wake cells' seams must NOT be exported here (vacuous-green hazard)
env | grep -E 'SPT_SPAWN_STRETCH_MS|SPT_WAKE_WEDGE_CEILING_MS' > GATE_envassert.raw 2>&1
echo $? > GATE_envassert.exit   # exit 1 (no match) is the PASS for this leg
git fetch origin feat/w1-235-spawn-liveness >> GATE_driver.log 2>&1
git checkout -q "$SHA" || { echo "checkout failed" >> GATE_driver.log; exit 8; }
git log --oneline -1 >> GATE_driver.log
run fixtures cargo build -p mock-adapter --bins
run clippy cargo clippy --workspace --all-targets -- -D warnings
run clippy_release cargo clippy --release -p spt-daemon --all-targets -- -D warnings
run nextest_daemon cargo nextest run -p spt-daemon
run wake_rig cargo nextest run -p spt-daemon --test wake_single_flight
echo DONE >> GATE_driver.log
