#!/usr/bin/env bash
# Run once per side, with a different fresh fixture directory.
set -euo pipefail
fixture=${1:?pass a fresh fixture directory}
mkdir -p "$fixture"
git init "$fixture/repo"
git -C "$fixture/repo" -c user.name=Evidence -c user.email=evidence@example.com commit --allow-empty -m init
git -C "$fixture/repo" worktree add "$fixture/feature" -b feature
cd "$fixture/feature"
codex exec --json 'Remember this first code word: PINEAPPLE. Just reply OK.' > "$fixture/first.jsonl"
thread=$(python3 -c 'import json,sys; print(json.loads(open(sys.argv[1]).readline())["thread_id"])' "$fixture/first.jsonl")
codex exec resume "$thread" --json 'Remember this second code word: MANGO. Just reply OK.' > "$fixture/second.jsonl"
printf 'Native thread: %s\n' "$thread"
# In the real app, import only this repository through /welcome > Review all.
# Open its imported thread and submit:
# Create a file named t3.txt containing the single line: from t3. Then reply DONE.
# After DONE, run native-history.py with the native thread ID, retaining its output.
# Inject the restoration failure:
# touch "$(git rev-parse --git-path index.lock)"
# Hover the T3 message, click Edit from here > Revert files too.
# Wait for five provider-thread.rollback attempts and the locked-index error.
# Run native-history.py again BEFORE removing the lock or sending a turn.
# Remove only this fixture's index.lock, then submit in the same app thread:
# Without using any tools: what were the two code words I asked you to remember earlier in this conversation? If you don't see them, say NONE.
