#!/usr/bin/env bash
# Run from either checkout after vp i. Pass an empty fixture directory as $1.
set -eu
fixture=$(realpath "$1")
mkdir -p "$fixture/claude"
# Start gateway.mjs in another terminal (port 18991).
export T3CODE_DEV_SEED=0
export CLAUDE_CONFIG_DIR="$fixture/claude"
export ANTHROPIC_BASE_URL=http://127.0.0.1:18991
export CLAUDE_CODE_OAUTH_TOKEN=synthetic-evidence-token
# Run this in one terminal, retaining its process tree:
vp run dev
# In a second terminal in the same checkout:
# node apps/server/src/bin.ts project add --base-dir .t3 --title 'Gateway cooldown proof' "$fixture"
# node apps/server/src/bin.ts thread start --base-dir .t3 --provider claudeAgent --model claude-opus-5-5 --title 'Claude gateway cooldown proof' --wait --json <project-id> 'Reply with OK.'
# Open the startup pairing URL, then /<environment-id>/<thread-id>.
# Hide thread details (machine-local information). Observe the usage-limit banner.
# Base: Reset time unavailable; retry manually.
# Head: Resets <time>, Resume at reset. Click Resume at reset to schedule recovery.
# Supplement: restart the same fake gateway with GATEWAY_COOLDOWN=17s.
# Start a fresh thread titled 'Short cooldown recovery' on each checkout with
# the same provider, model and prompt. Wait for the usage-limit banner.
# Base still has no reset / scheduling control. On head click 'Resume at reset'.
# After 17 seconds, head should start another run without a user message.
# The gateway always rejects, so stop the automatically resumed run afterward.
