# Card dispatch performance proof

Compared [base 63bf014dc3](https://github.com/pingdotgg/t3code/commit/63bf014dc3fb35e76c32d4ca23ed0485cd5d47f7) with [head 982b5610bf](https://github.com/pingdotgg/t3code/commit/982b5610bf977cd642db1ca5d2e8cf455f6673ed) for [#38890](https://github.com/pingdotgg/t3code/pull/38890).

Linux x86_64, Node 26.13.1, same VM, sequential real development servers. No unit tests or mocked orchestrator were used. Scenario documentation excludes timing/performance proof, so this uses the server path.

## Run

Install dependencies with `vp i` in each checkout first. Run each side sequentially, with unused ports. Use a fresh checkout: the scratch hook is installed once.

```sh
python3 setup-hook.py "$HEAD_CHECKOUT"
python3 setup-hook.py "$BASE_CHECKOUT"
python3 drive.py "$HEAD_CHECKOUT" "$OUTPUT_DIRECTORY" head 19110
python3 drive.py "$BASE_CHECKOUT" "$OUTPUT_DIRECTORY" base 19111
python3 summarize.py "$HEAD_RUN_DIRECTORY" head "$OUTPUT_DIRECTORY/head-capture.json"
python3 summarize.py "$BASE_RUN_DIRECTORY" base "$OUTPUT_DIRECTORY/base-capture.json"
python3 render-evidence.py "$OUTPUT_DIRECTORY"
```

`drive.py` prints each timestamped run directory. It creates a fresh T3 home there and starts the real app with `dev:server --no-seed`, also setting `T3CODE_DEV_SEED=0`. It adds a project and completes a real replay-agent turn through the normal CLI. Before each measurement it stops the server, inserts synthetic settled history, then restarts the same server. Each older run has a distinct attempt, root node and provider turn; identifiers and payload references are rewritten consistently. At the largest phase there are 15,001 runs, 15,001 attempts, 15,002 nodes (the replay turn has an extra node) and 15,001 provider turns.

The identical, temporary `setup-hook.py` fixture on both commits adds one HTTP route that issues a normal MCP credential for the replay-owned thread and reactivates its current run. It does not change the production card handlers, their reads, lock, dispatch, or persistence. This replaces a live Claude invocation; the measured operations go through the real `/mcp` transport, tool services and orchestrator. The hook is local scratch instrumentation, not a proposed code change.

At 0, 2,000 and 15,000 older runs, the driver performs three batches of five `request_secret` calls with distinct client request IDs and 1,000 ms timeouts (pending, then cancelled), followed by five `t3_environment_link` calls (pending). Thus each phase captures 30 secret and 15 link dispatches, including the first call after restart. It reads the persisted cards and verifies their run, node, provider thread and provider turn associations. `summarize.py` also checks counts, contents and final statuses. The normalized card arrays were identical on both commits: 15/30/45 secret cards cancelled and 15/30/45 link cards pending after the respective phases.

## Metric

The primary measurement is the server's `orchestrationV2.dispatch.withReceipt` trace span, filtered to `secret_request.record` and `link_request.record`, including receipt and event commit. The JSON retains every measured duration, batch index, median, full range and three batch medians. It also retains handler-only durations and synthetic MCP responses. It contains no credentials, local paths, hostnames or real user data. The PNGs render this captured output; they are not client screenshots.

At 15,000 older runs, secret dispatch is 427.251 ms on base versus 5.770 ms on head (74.05x); link dispatch is 437.645 ms versus 5.822 ms (75.17x). Median reductions of 421.481/431.823 ms exceed the largest observed full ranges of 189.904/44.729 ms, respectively. The head's worst sample is below the base's best sample for each type.

This does not measure total tool latency (which includes secret timeout and other reads), returned SELECT row counts, browser rendering, or another command waiting behind the lock. Only synthetic long history was benchmarked.

Prepared by GPT-6.1 Sol through Codex. No commits or forge writes were made.
