Repository navigation
Cache prepared statements for thread indexing and startup reads - #8451
Merged
Merged
Conversation
scowalt
pushed a commit
to scowalt/bb
that referenced
this pull request
Dec 1, 2026
…bb#8451) 🚨 **SLOP COP** 🚨 · `new-issue-autopilot` ## Human comments ## What was wrong Four fixed-shape thread queries bypassed the existing connection-level prepared-statement cache. Search segment upserts/deletes, startup-context reads, and fork-history checks rebuilt SQL and prepared a SQLite statement on every invocation, including inside transactions. Report: https://get-bb.github.io/reports/issues/8438.html ## What changed - Reuse stable prepared builders with parameter bindings for the four queries in `packages/db/src/data/threads.ts`. - Extend the existing prepared-query contract tests for warm calls, changing bindings, connection isolation, direct/transactional writes, timestamps, and rollbacks. - Preserve search trimming/deletion behavior and lookup predicates. Leave batch indexing unchanged. - Change 215 total text lines across two files (174 additions, 41 deletions), all within the existing database subsystem. No dependency, generated-file, schema, migration, stored-data, protocol, public API, or CLI changes. ## How you verified - Added the focused regression before the production fix: four failures and eleven passes on unchanged trusted main. Repeated the final regression in two clean detached checkouts at `90ef6dc66ba20ce4d6b7db9d6b974d1e87e6a457`; both fail for the expected extra compilation/preparation calls. - Before: each warmed read performed ten compilations and ten prepares; each three-cycle write case performed twelve of each. After: zero warmed compiler/preparation calls. - `pnpm exec turbo run test --filter=@bb/db -- test/prepared-queries.test.ts test/data/thread-search.test.ts test/data/thread-search-ranking.test.ts test/data/events.test.ts test/data/threads.test.ts test/data/thread-lifecycle.test.ts`: 188 tests pass across six files. - Database typecheck and type-aware lint pass via `pnpm exec turbo run test typecheck lint:type-aware --filter=@bb/db`. - The broader database run has 785 passing assertions but two unrelated queue-suite query-plan guard failures. Both failures repeat against unchanged trusted production code (51 assertions pass); no queue code or allowlist is changed. - The baseline full-monorepo build stops because the unrelated GitHub plugin cannot find built Plugin SDK runtime entries. Scoped database test dependencies build successfully. - `git diff --check` passes; numstat confirms 215 changed text lines, two files, and no binaries. Fixes get-bb#8438 > AGENT GENERATED <!-- slopcop:rule=new-issue-autopilot run=run_cu8mm078mx45zxwl sha=issue-8438 kind=summary --> Co-authored-by: SawyerHood <[email protected]>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
🚨 SLOP COP 🚨 ·
new-issue-autopilotHuman comments
What was wrong
Four fixed-shape thread queries bypassed the existing connection-level prepared-statement cache. Search segment upserts/deletes, startup-context reads, and fork-history checks rebuilt SQL and prepared a SQLite statement on every invocation, including inside transactions.
Report: https://get-bb.github.io/reports/issues/8438.html
What changed
packages/db/src/data/threads.ts.How you verified
e611693952d5aa8e92162c68628cd3871e58249f; both fail for the expected extra compilation/preparation calls.pnpm exec turbo run test --filter=@bb/db -- test/prepared-queries.test.ts test/data/thread-search.test.ts test/data/thread-search-ranking.test.ts test/data/events.test.ts test/data/threads.test.ts test/data/thread-lifecycle.test.ts: 188 tests pass across six files.pnpm exec turbo run test typecheck lint:type-aware --filter=@bb/db.git diff --checkpasses; numstat confirms 215 changed text lines, two files, and no binaries.Fixes #8438