test(server): measure shell, second client, and reconnect transfer #9157
main fromrefs/pull/9157/head·merged by t3dotgg(GitHub profile, opens in a new tab) View on GitHubThe transfer budget measured one thread subscription during one turn. Real clients also hold the sidebar (shell) subscription, users often have a desktop and a phone connected at once, and clients reconnect. Nobody had measured those, and the larger perf proposals (sharing the sidebar projector across clients, sharing git services across connections, incremental history) are gated on knowing whether they matter.
This PR measures them in the same test and prints them next to the existing capped rows. The single-thread measurement and its caps are unchanged.
What it adds:
- A shell-only socket and a second client socket holding both the thread and shell subscriptions during the measured turn. The report shows per-socket wire bytes, decoded bytes, message counts, and total server egress.
- A reconnect after the turn. The second client disconnects and resubscribes each subscription from the cursor it held before the turn. The report shows catch-up bytes and whether the server chose replay or a snapshot reset.
- A SQL statement count from
sql.executespans. A counting tracer is installed on the harness runtime and the HTTP/WS app so reactor writes and subscription reads land in one total. No new instrumentation insrc/. openMeasuredWsClientopens each RPC socket on its own child scope so clients disconnect independently.
The new rows have no caps. The shell stream coalesces on a 50 ms window, so the second client's message count moved between 9 and 10 across runs and its wire bytes between 6.7 and 7.1 KiB. SQL statement counts moved between 1096 and 1167 for the same reason. The capped thread rows stayed within a few bytes.
Measured (local, one run):
| Provider | Phase | Metric | Observed | Budget | Result |
|---|---|---|---|---|---|
| codex | thread snapshot | HTTP wire | 6.9 KiB (7,049 B) | 7.3 KiB (7,500 B) | PASS |
| codex | measured turn | WebSocket wire | 6.3 KiB (6,401 B) | 7.8 KiB (8,000 B) | PASS |
| codex | measured turn | WebSocket decoded | 54.7 KiB (55,974 B) | 66.4 KiB (68,000 B) | PASS |
| codex | measured turn | WebSocket messages | 8 | 21 | PASS |
| codex | shell snapshot | HTTP wire | 829 B | none | INFO |
| codex | measured turn, shell | WebSocket wire | 628 B | none | INFO |
| codex | measured turn, shell | WebSocket decoded | 3.7 KiB (3,793 B) | none | INFO |
| codex | measured turn, shell | WebSocket messages | 3 | none | INFO |
| codex | measured turn, second client | WebSocket wire | 7.0 KiB (7,144 B) | none | INFO |
| codex | measured turn, second client | WebSocket decoded | 58.3 KiB (59,723 B) | none | INFO |
| codex | measured turn, second client | WebSocket messages | 10 | none | INFO |
| codex | measured turn | server egress wire | 13.8 KiB (14,173 B) | none | INFO |
| codex | measured turn | SQL statements | 1096 | none | INFO |
| codex | reconnect, thread (replay) | WebSocket wire | 6.2 KiB (6,325 B) | none | INFO |
| codex | reconnect, thread (replay) | WebSocket decoded | 54.4 KiB (55,707 B) | none | INFO |
| codex | reconnect, thread (replay) | WebSocket messages | 2 | none | INFO |
| codex | reconnect, shell (replay) | WebSocket wire | 386 B | none | INFO |
| codex | reconnect, shell (replay) | WebSocket decoded | 1.3 KiB (1,355 B) | none | INFO |
| codex | reconnect, shell (replay) | WebSocket messages | 2 | none | INFO |
| codex | reconnect | SQL statements | 10 | none | INFO |
| claudeAgent | thread snapshot | HTTP wire | 6.9 KiB (7,059 B) | 7.3 KiB (7,500 B) | PASS |
| claudeAgent | measured turn | WebSocket wire | 6.3 KiB (6,409 B) | 7.8 KiB (8,000 B) | PASS |
| claudeAgent | measured turn | WebSocket decoded | 55.5 KiB (56,806 B) | 66.4 KiB (68,000 B) | PASS |
| claudeAgent | measured turn | WebSocket messages | 8 | 21 | PASS |
| claudeAgent | shell snapshot | HTTP wire | 829 B | none | INFO |
| claudeAgent | measured turn, shell | WebSocket wire | 626 B | none | INFO |
| claudeAgent | measured turn, shell | WebSocket decoded | 3.8 KiB (3,877 B) | none | INFO |
| claudeAgent | measured turn, shell | WebSocket messages | 3 | none | INFO |
| claudeAgent | measured turn, second client | WebSocket wire | 7.0 KiB (7,161 B) | none | INFO |
| claudeAgent | measured turn, second client | WebSocket decoded | 59.2 KiB (60,602 B) | none | INFO |
| claudeAgent | measured turn, second client | WebSocket messages | 10 | none | INFO |
| claudeAgent | measured turn | server egress wire | 13.9 KiB (14,196 B) | none | INFO |
| claudeAgent | measured turn | SQL statements | 1096 | none | INFO |
| claudeAgent | reconnect, thread (replay) | WebSocket wire | 6.2 KiB (6,342 B) | none | INFO |
| claudeAgent | reconnect, thread (replay) | WebSocket decoded | 55.2 KiB (56,539 B) | none | INFO |
| claudeAgent | reconnect, thread (replay) | WebSocket messages | 2 | none | INFO |
| claudeAgent | reconnect, shell (replay) | WebSocket wire | 379 B | none | INFO |
| claudeAgent | reconnect, shell (replay) | WebSocket decoded | 1.4 KiB (1,383 B) | none | INFO |
| claudeAgent | reconnect, shell (replay) | WebSocket messages | 2 | none | INFO |
| claudeAgent | reconnect | SQL statements | 10 | none | INFO |
Reading the numbers:
- The sidebar costs about 630 B wire and 3 messages per turn, about 10% of the thread stream. A second device costs one more thread stream plus one more shell stream, about 7 KiB. Egress scales linearly with connected clients and there is no hidden multiplier.
- Reconnecting from the pre-turn cursor replays about the same bytes as live delivery (6.3 KiB thread, 380 B shell) in 2 messages each and 10 SQL statements total. Replay was chosen every time at this gap size. Snapshot fallback did not trigger.
- This fixture mocks git, so it says nothing about sharing git services across connections.
Change authored by Claude Fable 5.1 running in Claude Code.
Note
Low Risk Changes are confined to integration tests and reporting helpers; production server code is not modified.
Overview Extends the thread transfer budget integration test so CI reports more than a single thread WebSocket during one turn. Existing capped thread snapshot and measured-turn rows are unchanged.
The scenario now opens three measured WebSocket clients (thread-only, shell-only, and a second device with both subscriptions), records shell HTTP snapshot size, and sums server egress across the three sockets. After the turn, the second client closes and resubscribes from its pre-turn cursors; the report records catch-up wire/decoded/message totals and whether catch-up used replay or snapshot.
Test harness plumbing adds openMeasuredWsClient (per-client forked scope + close), WebSocket recorder improvements (awaitOpen, wire totals after close), shared SQL statement counting via a counting Tracer on the orchestration harness and HTTP/WS app (sql.execute spans), and helpers moved into TransferBudgetScenario for thread/shell subscribe and sync detection. New report fields are INFO-only (no new budgets).
Note
Expand transfer-budget test to measure shell, second client, and reconnect transfer#
- Reworks the live transfer-budget integration test in server.test.ts to open three concurrent measured clients (thread-only, shell-only, second-client), capture per-socket WebSocket transfer and server-wide
sql.executedeltas, then close and reconnect the second client to measure replay-or-snapshot catch-up - Adds
openMeasuredWsClient, a factory that forks a per-client child scope, builds a counting WebSocket protocol, waits for open (10s timeout defect), and returns an explicit close effect - Updates
makeWebSocketTransferRecorderto retain the underlying transport at open time so wire-byte totals remain readable after socket closure - Adds
makeSqlStatementCounter, a tracer that increments a counter for spans named exactlysql.executewhile returning native spans for all operations - Extends
formatTransferBudgetReportwith informational (uncapped) rows for shell snapshot, shell-only and second-client WebSocket diagnostics, aggregate server egress, SQL counts, and reconnect catch-up modes alongside existing capped thread rows - Adds subscription helpers
subscribeThreadItems,subscribeShellItems, andawaitSubscriptionSynchronizedin TransferBudgetScenario.integration.ts that run scoped subscriptions and classify initial catch-up as replay or snapshot - Risk:
makeWebSocketTransferRecorderopen wait fails with a timeout defect after 10 seconds;awaitSubscriptionSynchronizedsimilarly defects after 10 seconds if the synchronization marker never arrives
- 1
github-actions[bot](GitHub profile, opens in a new tab) added labelsvouch:trusted
github-actions[bot](GitHub profile, opens in a new tab) added labelssize:L
Approvability#
Verdict: Approved at
7aff2b1Macroscope's review found this PR approvable — This PR expands a server integration test to measure shell traffic, multiple clients, reconnects, and SQL activity. All changes are confined to test and reporting infrastructure, with no shipped production behavior or product-default changes.
Notes:
- No code objects were reviewed. Approvability was decided on eligibility alone.
macroscopeapp[bot](GitHub profile, opens in a new tab) approved these changes
t3dotgg(GitHub profile, opens in a new tab) closed this
Sign in to join this conversation.
Thread transfer impact#
✅ Thread transfer remains within every enforced ceiling.
Baseline:
80c708a· PR result:7aff2b1· Source CI: successScenario and decoded snapshot size
10 historical turns, 5 command tools per turn, 878.9 KiB retained MCP result per historical turn, and a 1.05 MiB retained result in the measured turn.
Updated in place by a trusted workflow. PR artifacts are strictly validated and never executed.