# Queued-message dispatch runtime proof

This is an executable measurement of the real T3 Code server, not a test runner.
No product implementation changes or provider stand-ins are used.

## Reproduce

Create separate worktrees at base [758f73a710](https://github.com/pingdotgg/t3code/commit/758f73a7103c0efda3e9a4a333bde0c7a7119cce)
and head [c9f2872068](https://github.com/pingdotgg/t3code/commit/c9f28720685865462e4335bba82408e6f15f0420), and run `vp i` in each.
Put the scripts in one scratch directory. Run these sequentially on the same machine:

```sh
headless-desktop python3 record-proof.py /path/to/base-worktree base-memory
headless-desktop python3 record-proof.py /path/to/head-worktree head-memory
```

`run-proof.py` starts and waits for a production `apps/server/src/bin.ts serve`
process, with fresh synthetic state. `install-driver.py` adds the same scratch
startup hook to each checkout. The hook runs after the production orchestrator
has been constructed, before the effect worker starts. Production adapters and
policies are retained; no provider process is needed for command dispatch.
It selects the production in-memory SQLite layer to match the PR's stated
storage setup. The only source edits are the hook, the driver, and the selection
between existing SQLite layers; the orchestrator and projection implementations
are untouched. These scratch changes are never committed.

Timing uses `performance.now()` immediately around `orchestrator.dispatch`.
It excludes network/browser latency, provider execution, seeding, projection
inspection, and settling the synthetic run. This is the same timing boundary
as the report. It does not measure end-to-end provider response time.

Every completed history run is created by `message.dispatch`, marked completed
through the real projection store, and given one assistant reply plus one
`assistant_message` turn item. User messages are produced by dispatch itself.
For each explicit start or resume, the driver creates a user run, puts it into
the stopped/held queue state through the projection (`queued`, `queueHeld:true`,
`queuePosition:1`), then dispatches the action. This is the report's seed method.
Every measured action is inspected afterward: its run must have entered
`starting` or `preparing`, with the queue unheld, then it is settled completed.

Five rounds each use four warmup iterations and 24 measured samples per command.
Commands are interleaved: Send now, resume queue, ordinary send. The short control
uses a fresh thread with exactly four completed runs for every sample. The long
thread starts with 5,000 completed runs and gains 84 sample runs per round,
ending at 5,420. Both commits use the same sequence and counts. The reported
central value is the median of five round medians; spread is max minus min
of those round medians. Raw JSON retains all individual measured durations.

The same production process also captures 27 behavior decisions on persisted
synthetic states. It covers both explicit commands for latest usage limits,
session error overrides, stale limits after completion, limits on another
provider, a later generic failure, non-root errors, completed error items,
failed/interrupted worktree setup, older setup failure followed by completion,
and already-bound worktrees. Explicit start additionally covers a nonqueued
selection, missing user message, active run, notification, and delegated completion.
Refusals must leave the selected run's status and hold state unchanged.
These are T3's persisted-state validation decisions, not proof of a provider's
quota reporting, OAuth, reset timing, or actual worktree creation lifecycle.

The MP4s record live production-driver output in a terminal. The PNGs are
stable screenshots of that output (two frames 500 ms apart, zero differing
pixels). JSON is the authoritative per-sample and per-decision output.
No screenshot is presented as a web-client rendering change.
