Skip to content

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

Merged
t3dotgg merged 4 commits into
mainfrom
t3/takeover-pr-17044
Oct 8, 2026
Merged

t3dotgg merged 4 commits into
mainfrom
t3/takeover-pr-17044

Conversation

@t3dotgg

@t3dotgg t3dotgg commented Oct 8, 2026

Copy link
Copy Markdown
Member

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

SunkenInTime and others added 4 commits October 8, 2026 02:09
The HTTP and WebSocket shell loaders kept the shared SQLite connection in a
transaction while they decoded every thread row, so auth checks, thread
subscribes and background sweeps queued behind the conversion.

ProjectionStore.readShellSnapshot now runs the reads and returns a decode
step. loadActiveShellSnapshot (used by both loaders) and the archived shell
read threads, projects and sequence in one transaction, then decode after it
commits.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
…d step

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
… loader

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@github-actions github-actions Bot added vouch:trusted PR author is trusted by repo permissions or the VOUCHED list. size:L 100-499 changed lines (additions + deletions). labels Oct 8, 2026
@juliusmarminge juliusmarminge added the macroscope-review Opt PRs made by unvouched contributors in for Macroscope review. Vouched contributors auto-reviews label Oct 8, 2026
@macroscopeapp

macroscopeapp Bot commented Oct 8, 2026

Copy link
Copy Markdown
Contributor

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.

@t3dotgg
t3dotgg merged commit 1f31906 into main Oct 8, 2026
32 of 33 checks passed
@t3dotgg
t3dotgg deleted the t3/takeover-pr-17044 branch October 8, 2026 09:19
@github-actions

github-actions Bot commented Oct 8, 2026

Copy link
Copy Markdown
Contributor

Thread transfer impact

✅ Thread transfer remains within every enforced ceiling.

Provider Metric Main baseline This PR Impact PR ceiling
Codex Total thread wire 4.9 KiB 4.9 KiB 0 B (0.0%) 6.8 KiB ✅
Codex Thread snapshot wire 3.8 KiB 3.8 KiB 0 B (0.0%) 4.9 KiB ✅
Codex Live turn WebSocket wire 1.2 KiB 1.2 KiB 0 B (0.0%) 2.0 KiB ✅
Codex Live turn WebSocket decoded 20.8 KiB 20.8 KiB 0 B (0.0%) 29.3 KiB ✅
Codex Live turn messages 1 1 0 (0.0%) 8 ✅
Claude Total thread wire 5.0 KiB 5.0 KiB 0 B (0.0%) 6.8 KiB ✅
Claude Thread snapshot wire 3.8 KiB 3.8 KiB 0 B (0.0%) 4.9 KiB ✅
Claude Live turn WebSocket wire 1.2 KiB 1.2 KiB 0 B (0.0%) 2.0 KiB ✅
Claude Live turn WebSocket decoded 21.2 KiB 21.2 KiB 0 B (0.0%) 29.3 KiB ✅
Claude Live turn messages 1 1 0 (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.

github-actions Bot added a commit to omarcresp/t3code-flake that referenced this pull request Oct 8, 2026
## What's Changed
* feat(providers): run Muse Code as a native provider by @t3dotgg in pingdotgg/t3code#17082
* feat(web): compact-before-send is a chip that shows the token count by @t3dotgg in pingdotgg/t3code#17127
* fix(clients): copy button is back in its old spot, before fork by @t3dotgg in pingdotgg/t3code#17137
* fix(usage): repeat usage scans no longer decode unchanged Antigravity databases by @t3dotgg in pingdotgg/t3code#17139
* fix(server): shell snapshots no longer block other database reads while decoding by @t3dotgg in pingdotgg/t3code#17141
* perf(server): ACP tool updates no longer persist a snapshot per streamed chunk by @darjss in pingdotgg/t3code#16682
* feat(web): filter the Usage page to just the providers you want by @t3dotgg in pingdotgg/t3code#16970
* fix(usage): Cursor account history loads about 4x faster by @t3dotgg in pingdotgg/t3code#17140
* fix(server): threads settle as soon as branch status sees their PR merge by @t3dotgg in pingdotgg/t3code#17148
* perf(usage): the Usage page shows numbers in under a second and dims only what is still loading by @t3dotgg in pingdotgg/t3code#17147
* fix(server): an agent can settle its own thread when its turn ends by @t3dotgg in pingdotgg/t3code#17145
* feat(web): Add provider button sits with the provider list by @t3dotgg in pingdotgg/t3code#17152

## New Contributors
* @darjss made their first contribution in pingdotgg/t3code#16682

**Full Changelog**: pingdotgg/t3code@v0.0.46-nightly.20261008.2813...v0.0.46-nightly.20261008.2819

Upstream release: https://github.com/pingdotgg/t3code/releases/tag/v0.0.46-nightly.20261008.2819
github-actions Bot added a commit to davidvanderklay/t3code-flake that referenced this pull request Oct 8, 2026
## What's Changed
* feat(providers): run Muse Code as a native provider by @t3dotgg in pingdotgg/t3code#17082
* feat(web): compact-before-send is a chip that shows the token count by @t3dotgg in pingdotgg/t3code#17127
* fix(clients): copy button is back in its old spot, before fork by @t3dotgg in pingdotgg/t3code#17137
* fix(usage): repeat usage scans no longer decode unchanged Antigravity databases by @t3dotgg in pingdotgg/t3code#17139
* fix(server): shell snapshots no longer block other database reads while decoding by @t3dotgg in pingdotgg/t3code#17141
* perf(server): ACP tool updates no longer persist a snapshot per streamed chunk by @darjss in pingdotgg/t3code#16682
* feat(web): filter the Usage page to just the providers you want by @t3dotgg in pingdotgg/t3code#16970
* fix(usage): Cursor account history loads about 4x faster by @t3dotgg in pingdotgg/t3code#17140
* fix(server): threads settle as soon as branch status sees their PR merge by @t3dotgg in pingdotgg/t3code#17148
* perf(usage): the Usage page shows numbers in under a second and dims only what is still loading by @t3dotgg in pingdotgg/t3code#17147
* fix(server): an agent can settle its own thread when its turn ends by @t3dotgg in pingdotgg/t3code#17145
* feat(web): Add provider button sits with the provider list by @t3dotgg in pingdotgg/t3code#17152

## New Contributors
* @darjss made their first contribution in pingdotgg/t3code#16682

**Full Changelog**: pingdotgg/t3code@v0.0.46-nightly.20261008.2813...v0.0.46-nightly.20261008.2819

Upstream release: https://github.com/pingdotgg/t3code/releases/tag/v0.0.46-nightly.20261008.2819
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

macroscope-review Opt PRs made by unvouched contributors in for Macroscope review. Vouched contributors auto-reviews size:L 100-499 changed lines (additions + deletions). vouch:trusted PR author is trusted by repo permissions or the VOUCHED list.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants