#!/usr/bin/env bash
# W10 rerun: each e2e alone with a census of processes running from THIS pool after it.
cd /c/Users/decid/Documents/projects/spt-core/.worktrees/w10-busy || exit 9
S="C:/Users/decid/AppData/Local/Temp/claude/C--Users-decid-Documents-projects-spt-core/cf4213ed-2bda-42a2-a018-1a54d595cb80/scratchpad"
census() {
  powershell -NoProfile -Command "(Get-CimInstance Win32_Process | Where-Object { \$_.ExecutablePath -like '*w10-busy\\target*' } | ForEach-Object { \$_.ProcessId.ToString() + ' ' + \$_.CommandLine }) -join ' | '"
}
run_leg() {  # name, test
  local f="$S/w10-$1.log"
  { date -u +%FT%TZ; git rev-parse HEAD; } > "$f"
  cargo nextest run -p spt --no-fail-fast --test "$2" --no-capture >> "$f" 2>&1
  echo "EXIT=$?" >> "$f"
  date -u +%FT%TZ >> "$f"
  sleep 3
  echo "POOL_PROCS_AFTER: [$(census)]" >> "$f"
}
run_leg green busy_window_axis_e2e
run_leg relay active_only_never_relay_e2e
python "$S/mutate_w10.py" apply > "$S/w10-control2.log"
run_leg control2b busy_window_axis_e2e
python "$S/mutate_w10.py" restore >> "$S/w10-control2b.log" 2>&1
git status --short crates/spt/src/api/delivery.rs >> "$S/w10-control2b.log"
