#!/usr/bin/env bash
set -euo pipefail
# Run from each checked-out commit after vp i. Supply an empty scratch directory.
: "${PROOF_SCRATCH:?Set a scratch directory}"
mkdir -p "$PROOF_SCRATCH/codex-home" "$PROOF_SCRATCH/repro"
# Keep authentication and the configured API endpoint; intentionally omit all rules.
python3 - "$PROOF_SCRATCH" <<'PYTHON'
import os, pathlib, shutil, sys, tomllib, json
root=pathlib.Path(sys.argv[1]); source=pathlib.Path.home()/'.codex'
shutil.copyfile(source/'auth.json', root/'codex-home/auth.json')
config=tomllib.loads((source/'config.toml').read_text())
endpoint=config.get('openai_base_url')
if endpoint:
 (root/'codex-home/config.toml').write_text('openai_base_url = '+json.dumps(endpoint)+'\n')
PYTHON
git init "$PROOF_SCRATCH/repro"
export CODEX_HOME="$PROOF_SCRATCH/codex-home" T3CODE_DEV_SEED=0
# Start in a retained terminal: vp run dev
# Pair the browser using that server's startup URL.
node apps/server/src/bin.ts project add --base-dir .t3 --title 'Approval reproduction' "$PROOF_SCRATCH/repro"
for title in 'Full access direct' 'Full access delegated'; do
 node apps/server/src/bin.ts thread start --base-dir .t3 --provider codex --model gpt-6.1-sol --title "$title" "$PROOF_SCRATCH/repro" 'Reply READY. Do not run tools yet.'
done
# CLI-created threads default to Full access; confirm with thread show --json.
# Browser: light theme, 1280x800. Open each thread using its link.
# Hide sidebar and thread details to exclude private environment labels.
# Start recording before submitting each prompt; leave approval cards unanswered.
# Direct prompt:
# Execute exactly this command: touch t3-repro.txt && rm -f t3-repro.txt. Do not change the command.
# Delegated prompt:
# Use T3's delegate_task tool to create one Codex child in this project, model gpt-6.1-sol, runtimeMode full-access, isolation shared. Tell the child: Execute exactly this command: touch t3-repro.txt && rm -f t3-repro.txt. Do not change the command. Do not execute the command yourself. Wait for the child result.
