#!/usr/bin/env bash
# Run once per checkout (base, then head) against a fresh isolated T3 home.
# Load the Azure test environment before invoking this script.
set -eu
checkout=$1
proof_root=$2
side=$3
cd "$checkout"
# Seed once before the base run: python3 seed.py "$proof_root"
# Abandon the base PR before the head run; keep the same pushed feature branch.
T3CODE_DEV_SEED=0 vp run dev > "$proof_root/$side-server.log" 2>&1 &
server_pid=$!
trap 'kill "$server_pid"' EXIT
# Once the server is listening, enable OpenCode in this isolated home's settings:
# {"providerInstances":{"opencode":{"driver":"opencode","enabled":true,"config":{}}}}
# Then run the following observer and CLI interaction.
python3 host-observer.py "$proof_root/$side-observer.jsonl" "$proof_root/repository.json" &
observer_pid=$!
node apps/server/src/bin.ts project add "$proof_root/repo" --base-dir .t3
node apps/server/src/bin.ts thread start "$proof_root/repo" \
 'Call pull_request_create exactly once with draft: true, base: proof39732-r4-main, title: "Draft creation proof 39732", body: "Synthetic verification". Do not create or modify files or call another tool. Report the result.' \
 --provider opencode --model opencode/big-pickle --wait --json --base-dir .t3
kill "$observer_pid"
# Stop the dev process tree through the shell harness after recording the trace.
