Skip to content
Source
Sign inSign up
pingdotgg/t3code

fix(server): shell snapshots no longer block other database reads while decoding #17141

Mergedt3dotgg(GitHub profile, opens in a new tab)merged 4 commits intomain fromrefs/pull/17141/headmerged by t3dotgg(GitHub profile, opens in a new tab) View on GitHub

Loading the shell snapshot held the server's only SQLite connection while it decoded every thread row, not just while it read them. Auth checks, thread subscribes, and background sweeps all waited behind it. On real data, cheap queries waited from 100 ms to several seconds (#14701).

The shell reads still run in one transaction, so threads, projects, and the sequence agree. The decode now runs after the transaction commits. ProjectionStore.readShellSnapshot does the SQL reads and returns the decode step. The active HTTP, active WebSocket, and archived shell loaders share loadShellSnapshotParts. getShellSnapshot decodes after its own transaction too.

This continues #17044 by @SunkenInTime (Dara Adedeji), who wrote the fix, the tests, and the measurements. See that PR for the full write-up. Changes in this takeover:

  • Rebased onto current main. The only conflict was an import in http.ts.
  • The archived WebSocket loader now uses the same helper, so the code has no second hand-written copy of the transaction.

Verification:

  • On a copy of real data with 1,605 threads, a concurrent SELECT 1 waited a median of 43 ms with decode inside the transaction and 0.11 ms with this change.
  • apps/server typecheck is clean, and the focused tests pass: ShellStream, ProjectionStore, ws, AgentAwarenessRelay, ProviderTurnControlService, ProjectionSettlement, and transferBudgetV2.

Original work by Dara Adedeji with Claude Opus 5.5 in Claude Code. Takeover by Claude Opus 5.5 in Claude Code, running inside T3 Code.

🤖 Generated with Claude Code

    1. github-actions[bot](GitHub profile, opens in a new tab) added labelsvouch:trusted

    2. juliusmarminge added labelsmacroscope-review

    3. Approvability

      Verdict: Approved at 6972436

      Macroscope's review found this PR approvable — This is a focused server-side concurrency fix that keeps shell snapshot reads consistent while releasing the shared SQLite connection before expensive decoding. The shared loader and targeted tests cover the active and archived snapshot paths without changing schemas, defaults, or deployment behavior.

      You can add or adjust custom eligibility rules. [Learn more](https://docs.macroscope.com/approvability#example-custom-eligibility-rules).
    4. Thread transfer impact

      ✅ Thread transfer remains within every enforced ceiling.

      ProviderMetricMain baselineThis PRImpactPR ceiling
      CodexTotal thread wire4.9 KiB4.9 KiB0 B (0.0%)6.8 KiB✅
      CodexThread snapshot wire3.8 KiB3.8 KiB0 B (0.0%)4.9 KiB✅
      CodexLive turn WebSocket wire1.2 KiB1.2 KiB0 B (0.0%)2.0 KiB✅
      CodexLive turn WebSocket decoded20.8 KiB20.8 KiB0 B (0.0%)29.3 KiB✅
      CodexLive turn messages110 (0.0%)8✅
      ClaudeTotal thread wire5.0 KiB5.0 KiB0 B (0.0%)6.8 KiB✅
      ClaudeThread snapshot wire3.8 KiB3.8 KiB0 B (0.0%)4.9 KiB✅
      ClaudeLive turn WebSocket wire1.2 KiB1.2 KiB0 B (0.0%)2.0 KiB✅
      ClaudeLive turn WebSocket decoded21.2 KiB21.2 KiB0 B (0.0%)29.3 KiB✅
      ClaudeLive turn messages110 (0.0%)8✅

      Baseline: 2ea7684 · PR result: 6972436 · 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: 108.5 KiB
      • Claude decoded thread snapshot: 108.8 KiB

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

Sign in to join this conversation.