# Fresh-context background wake reproduction

Environment on both sides: Linux web dev client, Chromium preview browser,
1440 x 1000 CSS viewport (2x capture scale), dark theme, real Claude Haiku 5.5.
Each checkout ran T3CODE_DEV_SEED=0 vp run dev with its own fresh database.
The synthetic codeword-demo repository was shared, with no files written by agents.
Thread details were closed before recording to exclude the environment label.

The seed commands in reproduce.sh are the commands used, parameterized for a
scratch repository. Browser steps below were driven with preview_act, recording
the interaction using preview_recording_start/stop, identically on both sides.

1. Open the seeded thread by its environment/thread link. Confirm PELICAN ready
   and one pending background command (sleep 150; echo BG-DONE).
2. Submit: Run exactly `sleep 40; echo FOREGROUND-DONE` in Bash in the foreground
   with timeout 60000 and run_in_background=false. Wait for it and reply
   FOREGROUND-DONE. Do not write files.
3. The installed harness hook blocked the foreground sleep; let the agent finish.
   Type /clear, Enter, then submit: Remember the codeword ZEBRA for this
   conversation only. Reply ZEBRA remembered. Do not write files.
   Confirm the idle fresh-send refusal because background work is running.
4. Click Keep the current session, replace the retained draft with the same
   foreground-command prompt, Enter. Immediately (within one second, without
   waiting for the agent response) type /clear, Enter, type the same ZEBRA prompt,
   Enter. This is the queued fresh-context path; the command prompt remains running
   while the fresh send is accepted. Both databases recorded run 3 running and
   run 4 queued with freshContext=true. The foreground command remained blocked.
5. After ZEBRA remembered, send: Which codeword did I ask you to remember?
   Reply with only that codeword. Both sides answer ZEBRA on the new session.
6. Wait for the real background task to finish and its wake response to complete.
7. Send: Which codeword did I ask you to remember most recently? Reply with
   only that codeword.

Observed before: PELICAN. Observed after: ZEBRA.
The background wake is run 6 on the old session (first run 1) on both sides.
The final question is run 7: old session on base, fresh session (first run 4)
on head. audit.py reads only these isolated databases and exports the synthetic
routing and conversation transcript with machine-specific ids removed.

The foreground sleep itself was not executed because the harness blocked it.
The reproduction still exercised the reported queued fresh-session condition,
real old-session background completion and wake, and real follow-up routing.
No tests or mocked provider events were used as proof.
