#!/usr/bin/env bash
# IR-155 A/B on hfenduleam (doyle GO YWO2F4PF). Arm U (unfixed helper) FIRST, then arm F (fix).
# Each arm writes its own file; the verdict is read from the files afterwards, never through a pipe.
set -u
WT=/c/Users/decid/Documents/projects/spt-core/.worktrees/hertz-ir155
OUT=/c/Users/decid/Documents/projects/spt-core/.spt/preserved/331/hertz/ir155
FIX=866f75c8
cd "$WT" || exit 9
[ "$(git rev-parse --short=8 HEAD)" = "$FIX" ] || { echo "HEAD not $FIX"; exit 4; }
[ -z "$(git status --porcelain)" ] || { echo DIRTY; exit 5; }
date -u +%T > "$OUT/start.txt"
cargo run -q -p xtask -- pool-claim --pool "$WT/target" --label hertz-ir155 > "$OUT/claim.txt" 2>&1; echo "claim_rc=$?" >> "$OUT/claim.txt"
# Arm U: the helper as it was before the fix (FIX~1), in the working tree only.
git checkout -q "$FIX~1" -- crates/spt-daemon/src/brainproc.rs
git diff --stat > "$OUT/armU-diff.txt"
cargo nextest run -p spt-daemon --lib brainproc::tests --no-fail-fast > "$OUT/armU.nextest.txt" 2>&1; echo $? > "$OUT/armU.exit"
# Arm F: restore the fix.
git checkout -q "$FIX" -- crates/spt-daemon/src/brainproc.rs
[ -z "$(git status --porcelain)" ] || { echo "RESTORE FAILED" > "$OUT/armF.exit"; exit 6; }
cargo nextest run -p spt-daemon --lib brainproc::tests --no-fail-fast > "$OUT/armF.nextest.txt" 2>&1; echo $? > "$OUT/armF.exit"
date -u +%T > "$OUT/end.txt"
