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
Approvability#
Verdict: Approved at
6972436Macroscope'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).