# fix\(server\): run windowed snapshots on the SQLite reader · PR \#21869 · pingdotgg/t3code

[View on GitCafe](https://git.cafe/pingdotgg/t3code/pull/21869)

Repository: [pingdotgg/t3code](https://git.cafe/pingdotgg/t3code)

Visibility: public

State: open

Source repository: Unavailable fork

Source branch: fix/21840-snapshot-reader

Target branch: main

Head commit: b16843cb8db770b43717e3717afd8677ca11ac4a

[Discussion and reviews](https://git.cafe/pingdotgg/t3code/pull/21869)

[Commits](https://git.cafe/pingdotgg/t3code/pull/21869/commits?format=markdown)

[Files changed](https://git.cafe/pingdotgg/t3code/pull/21869/diffs?format=markdown)

## Description

---

## Problem

Opening a thread reads its bounded snapshot inside a writer transaction, so a long snapshot blocks thread creation, message dispatch, and other database writes. A file-backed WAL reproduction fails on main when another connection holds the writer.

## Change

Route the entire bounded snapshot transaction through the existing SQLite reader helper. Anchor lookup, fork-parent projections, and snapshot sequence stay in one consistent transaction. Preserve the contributor’s implementation and regression test from this PR; the updated branch also includes current main.

## Scope and approval

Fixes #21840
GitCafe: https://git.cafe/pingdotgg/t3code/issues/21840
Triaged bug via the automated issue flow. [Accepted bug](https://github.com/pingdotgg/t3code/issues/21840#issuecomment-6274030066). Scope is bounded snapshot reader routing; query indexing and other projection reads are separate work.

## Verification

- Red at [9f597f2058](https://github.com/pingdotgg/t3code/commit/9f597f2058): `windowed snapshots return committed data while the writer is held` fails with “snapshot must return while another connection holds the writer”; the cause is SQLite writer lock contention.
- Green at [247703a96b](https://github.com/pingdotgg/t3code/commit/247703a96b): server `vp test run src/orchestration-v2/ProjectionStore.test.ts src/orchestration-v2/ThreadSearch.test.ts` passes 37 tests; shared `vp test run src/nodeSqliteClient.test.ts` passes 16 tests.
- Both focused commands rerun after merging the contributor commit and main at [b16843cb8d](https://github.com/pingdotgg/t3code/commit/b16843cb8d): 53 tests pass. Its tree equals the green-tested tree.
- Scoped format, lint, and server typecheck pass. Two independent reviewers report no findings.
- [Before/after runtime transcript](https://gh-file-drop-api-prod-mi5fy3sowv63ufte.pinglabs.workers.dev/f/8d92c4280f19ab8c/runtime.txt): isolated Linux dev server, real browser, same seeded stopped threads; authenticated bounded snapshot returns HTTP 200 on both revisions. The snapshot transaction changes from `writer` on main to `reader` with the fix.

Runtime excerpt (both enclosing bounded requests succeeded):

```text
before 8d3b061121: sql.transaction db.connection=writer durationMs=13.297433 exit=Success
after  b16843cb8d: sql.transaction db.connection=reader durationMs=32.628450 exit=Success
```

This server-only change has an empty visual fixture matrix. No render paths or wire contracts changed. The reporter’s 10 GB cold-cache latency was not reproduced; no latency improvement is claimed.

Model: GPT-6.1-Sol and Claude Opus 5.5. Harness: Codex and Claude Code.

