# Turn-start lookup measurement

This is a manual **real server / CLI** capture, not a unit test or a web scenario. The scenario runner documentation explicitly excludes performance regressions.

## Procedure

Run the uploaded Python driver with a clean checkout and an output directory as its two positional arguments. Each invocation starts a new development server, using its own fresh home and `T3CODE_DEV_SEED=0`, and stops its entire spawned process group in `finally`. Run sequentially on base and head, on the same Linux x86_64 machine. Install dependencies with `vp i` first. The driver restores the original service source in `finally` and commits nothing.

For each history size (2,000, 10,000, 25,000):

1. Add a synthetic workspace through the real project CLI. Start a real replay `multi-turn` thread and await its first completed reply.
2. Send a second message through the real thread CLI. Temporary instrumentation inside `ProviderTurnStartService.start` writes synthetic history through the real EventSink (no direct SQL writes or copied databases), then reloads it through the normal `getTurnStartContext` query.
3. Every tenth historical run is failed/interrupted/cancelled, with two attempts; others have one. Each attempt has one provider turn. Only `a10-steered`, `a20`, and `a21` project as running. The bootstrap record is retained as historical run zero. The current run has ordinal n+1 and is also present, with its current attempt; thus the loaded projection has n+1 runs, 1.1n+1 attempts, and 1.1n provider turns.
4. At the real abandoned-turn lookup site, perform 3 warmups and 15 timed evaluations on the same loaded projection. The base's source-exact inline lookup body is copied into a local closure for repetition; the head invokes its exported helper. Timing excludes seeding, projection loading, Proxy counting, and provider execution. One extra evaluation wraps the records in Proxies and counts property reads. The original service lookup/recovery then runs normally.
5. Capture every duration and ordered pair. Await the real turn's completion and reply. Read only the fresh server's own database to capture persisted provider-turn statuses: `t-a10-steered` and `t-a20` must be interrupted, while `t-a21` stays running. This read is verification, not seeding.

The synthetic historical records clone the bootstrap's schema-valid records and reuse its node/checkpoint references. This isolates the changed lookup; it does not reconstruct 25,000 independent workspaces/checkpoints or simulate a provider that ignores Stop. The real replay session is idle when recovery requests its interrupt, which the real adapter treats as already interrupted.

## Interpretation

Use the per-process medians and their spread to assess repeatability; raw samples are included. The formatted PNGs render the captured measurement output and are not screenshots of the web client. Read counts differ slightly from the PR's standalone projection because an actual turn start includes the current run and attempt: at 25k, +5,001 reads on base and +2 on head.

The result proves the synchronous lookup's performance and selected recovery behavior in a running server. It does not measure total user-perceived message-to-first-token latency, and the temporary repeated evaluations deliberately add overhead to the instrumented turn.
