set -u
[ -f ~/.cargo/env ] && . ~/.cargo/env
REPO=/home/reavus/projects/spt-core/spt-core; RIG=$REPO/.worktrees/hertz-w7-order; SHA=$1
cd $REPO || exit 9
echo "START $(date -u +%T) writers $(ps -eo comm= | grep -cE '^(cargo|rustc|cargo-nextest|Runner.Worker)$')"
git fetch -q /tmp/hertz-w7o.bundle hertz/w7-336-rig-order:refs/heads/hertz/w7-336-rig-order || exit 2
git worktree add -q $RIG hertz/w7-336-rig-order || exit 3
cd $RIG; [ "$(git rev-parse HEAD)" = "$SHA" ] || { echo SHA_MISMATCH; exit 4; }
cargo run -q -p xtask -- pool-claim --pool $RIG/target --label hertz-w7-order; echo claim_rc=$?
t0=$(date +%s); cargo test -q -p spt --test auto_apply_e2e --no-run > /tmp/hertz-w7o-build.log 2>&1; echo "build_rc=$? ($(( $(date +%s)-t0 ))s)"
grep -E "^(warning|error)" /tmp/hertz-w7o-build.log | sort | uniq -c | head
t0=$(date +%s); cargo clippy -q -p spt --test auto_apply_e2e -- -D warnings > /tmp/hertz-w7o-clippy.log 2>&1; echo "clippy_rc=$? ($(( $(date +%s)-t0 ))s)"
grep -E "^(warning|error)" /tmp/hertz-w7o-clippy.log | head
echo "END $(date -u +%T)"
