Skip to content
Source
Sign inSign up
pingdotgg/t3code

test(server): measure shell, second client, and reconnect transfer #9157

Mergedt3dotgg(GitHub profile, opens in a new tab)merged 1 commit intomain fromrefs/pull/9157/headmerged by t3dotgg(GitHub profile, opens in a new tab) View on GitHub

The 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.execute spans. 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 in src/.
  • openMeasuredWsClient opens 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):

ProviderPhaseMetricObservedBudgetResult
codexthread snapshotHTTP wire6.9 KiB (7,049 B)7.3 KiB (7,500 B)PASS
codexmeasured turnWebSocket wire6.3 KiB (6,401 B)7.8 KiB (8,000 B)PASS
codexmeasured turnWebSocket decoded54.7 KiB (55,974 B)66.4 KiB (68,000 B)PASS
codexmeasured turnWebSocket messages821PASS
codexshell snapshotHTTP wire829 BnoneINFO
codexmeasured turn, shellWebSocket wire628 BnoneINFO
codexmeasured turn, shellWebSocket decoded3.7 KiB (3,793 B)noneINFO
codexmeasured turn, shellWebSocket messages3noneINFO
codexmeasured turn, second clientWebSocket wire7.0 KiB (7,144 B)noneINFO
codexmeasured turn, second clientWebSocket decoded58.3 KiB (59,723 B)noneINFO
codexmeasured turn, second clientWebSocket messages10noneINFO
codexmeasured turnserver egress wire13.8 KiB (14,173 B)noneINFO
codexmeasured turnSQL statements1096noneINFO
codexreconnect, thread (replay)WebSocket wire6.2 KiB (6,325 B)noneINFO
codexreconnect, thread (replay)WebSocket decoded54.4 KiB (55,707 B)noneINFO
codexreconnect, thread (replay)WebSocket messages2noneINFO
codexreconnect, shell (replay)WebSocket wire386 BnoneINFO
codexreconnect, shell (replay)WebSocket decoded1.3 KiB (1,355 B)noneINFO
codexreconnect, shell (replay)WebSocket messages2noneINFO
codexreconnectSQL statements10noneINFO
claudeAgentthread snapshotHTTP wire6.9 KiB (7,059 B)7.3 KiB (7,500 B)PASS
claudeAgentmeasured turnWebSocket wire6.3 KiB (6,409 B)7.8 KiB (8,000 B)PASS
claudeAgentmeasured turnWebSocket decoded55.5 KiB (56,806 B)66.4 KiB (68,000 B)PASS
claudeAgentmeasured turnWebSocket messages821PASS
claudeAgentshell snapshotHTTP wire829 BnoneINFO
claudeAgentmeasured turn, shellWebSocket wire626 BnoneINFO
claudeAgentmeasured turn, shellWebSocket decoded3.8 KiB (3,877 B)noneINFO
claudeAgentmeasured turn, shellWebSocket messages3noneINFO
claudeAgentmeasured turn, second clientWebSocket wire7.0 KiB (7,161 B)noneINFO
claudeAgentmeasured turn, second clientWebSocket decoded59.2 KiB (60,602 B)noneINFO
claudeAgentmeasured turn, second clientWebSocket messages10noneINFO
claudeAgentmeasured turnserver egress wire13.9 KiB (14,196 B)noneINFO
claudeAgentmeasured turnSQL statements1096noneINFO
claudeAgentreconnect, thread (replay)WebSocket wire6.2 KiB (6,342 B)noneINFO
claudeAgentreconnect, thread (replay)WebSocket decoded55.2 KiB (56,539 B)noneINFO
claudeAgentreconnect, thread (replay)WebSocket messages2noneINFO
claudeAgentreconnect, shell (replay)WebSocket wire379 BnoneINFO
claudeAgentreconnect, shell (replay)WebSocket decoded1.4 KiB (1,383 B)noneINFO
claudeAgentreconnect, shell (replay)WebSocket messages2noneINFO
claudeAgentreconnectSQL statements10noneINFO

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).

Reviewed by [Cursor Bugbot](https://cursor.com/bugbot) for commit 7aff2b183c9d5c6858aea93750367a49e0f7e0ba. Bugbot is set up for automated code reviews on this repo. Configure [here](https://www.cursor.com/dashboard/bugbot).

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.execute deltas, 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 makeWebSocketTransferRecorder to 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 exactly sql.execute while returning native spans for all operations
  • Extends formatTransferBudgetReport with 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, and awaitSubscriptionSynchronized in TransferBudgetScenario.integration.ts that run scoped subscriptions and classify initial catch-up as replay or snapshot
  • Risk: makeWebSocketTransferRecorder open wait fails with a timeout defect after 10 seconds; awaitSubscriptionSynchronized similarly defects after 10 seconds if the synchronization marker never arrives
Macroscope summarized 7aff2b1.
    1. github-actions[bot](GitHub profile, opens in a new tab) added labelsvouch:trusted

    2. Thread transfer impact

      ✅ Thread transfer remains within every enforced ceiling.

      ProviderMetricMain baselineThis PRImpactPR ceiling
      CodexTotal thread wire13.3 KiB13.3 KiB+15 B (+0.1%)15.1 KiB✅
      CodexThread snapshot wire6.9 KiB6.9 KiB+6 B (+0.1%)7.3 KiB✅
      CodexLive turn WebSocket wire6.4 KiB6.4 KiB+9 B (+0.1%)7.8 KiB✅
      CodexLive turn WebSocket decoded55.6 KiB55.6 KiB0 B (0.0%)66.4 KiB✅
      CodexLive turn messages10100 (0.0%)21✅
      ClaudeTotal thread wire13.3 KiB13.3 KiB+13 B (+0.1%)15.1 KiB✅
      ClaudeThread snapshot wire6.9 KiB6.9 KiB−6 B (−0.1%)7.3 KiB✅
      ClaudeLive turn WebSocket wire6.4 KiB6.4 KiB+19 B (+0.3%)7.8 KiB✅
      ClaudeLive turn WebSocket decoded56.4 KiB56.4 KiB0 B (0.0%)66.4 KiB✅
      ClaudeLive turn messages10100 (0.0%)21✅

      Baseline: 80c708a · PR result: 7aff2b1 · Source CI: success

      Scenario 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.

      • Codex decoded thread snapshot: 109.4 KiB
      • Claude decoded thread snapshot: 110.1 KiB

      Updated in place by a trusted workflow. PR artifacts are strictly validated and never executed.

    3. Approvability

      Verdict: Approved at 7aff2b1

      Macroscope'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.
      You can add or adjust custom eligibility rules. [Learn more](https://docs.macroscope.com/approvability#example-custom-eligibility-rules).

Sign in to join this conversation.