Repository navigation
Cache prepared statements for thread lifecycle state - #8368
Merged
Merged
Conversation
Co-Authored-By: Claude Opus 5.5 <[email protected]>
scowalt
pushed a commit
to scowalt/bb
that referenced
this pull request
Dec 1, 2026
🚨 **SLOP COP** 🚨 · `new-issue-autopilot` ## Human comments ## What was wrong Fixed lifecycle-state reads and cleanup queries rebuilt their SQL and prepared fresh SQLite statements on every invocation. A warm-path regression against real migrated databases records 48 SQL compilations and 48 SQLite preparations across four cycles, including separate transactions and two thread IDs. This failure repeats in a second clean trusted-main checkout. Report: https://get-bb.github.io/reports/issues/8364.html ## What changed - Cache the two run-state reads, thread-start existence check, and two cleanup DELETE statements per connection with bound identifiers. - Reuse the existing cached `getThread` lookup in the lifecycle writer. - Add `readThreadRunState` and `hasThreadStartTurnRequest` to the existing warm-lookup table in `prepared-queries.test.ts`; both rows fail on main and pass here. - Keep inserts, status updates, recovery scans, public APIs, schemas, stored data, and protocols unchanged. Changed-line count from `git diff --numstat origin/main`: **201 total text lines** — 166 additions and 35 deletions across two files, entirely in `packages/db`. No binary changes or new dependencies. ## How you verified - Before the production fix: the authored regression fails on trusted main in both clean checkouts with `{ compilations: 48, preparations: 48 }`, expected zero. - After the fix: focused regression, prepared-query, thread-lifecycle, and thread tests pass — **54 tests in 4 files**. - `pnpm exec turbo run test typecheck lint --filter=@bb/db` passes — **763 database tests in 73 files**, with typecheck. - `pnpm exec turbo run lint:type-aware --filter=@bb/db` passes with zero warnings and errors. - `pnpm exec turbo run build` passes — **74 successful tasks**, after building missing local Plugin SDK artifacts with `pnpm exec turbo run build build:types --filter=@get-bb/plugin-sdk`. - `git diff --check origin/main` passes; numstat confirms two text files and the 201-line limit. The original report's precise timing multiplier is not claimed by this fix; the deterministic repeated-compilation failure is reproduced and repaired. Fixes get-bb#8364 > AGENT GENERATED <!-- slopcop:rule=new-issue-autopilot run=run_si418rigmx27hldk sha=issue-8364 kind=summary --> --------- Co-authored-by: SawyerHood <[email protected]> Co-authored-by: Michael Yong <[email protected]> Co-authored-by: Claude Opus 5.5 <[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
Fixed lifecycle-state reads and cleanup queries rebuilt their SQL and prepared fresh SQLite statements on every invocation. A warm-path regression against real migrated databases records 48 SQL compilations and 48 SQLite preparations across four cycles, including separate transactions and two thread IDs. This failure repeats in a second clean trusted-main checkout.
Report: https://get-bb.github.io/reports/issues/8364.html
What changed
getThreadlookup in the lifecycle writer.readThreadRunStateandhasThreadStartTurnRequestto the existing warm-lookup table inprepared-queries.test.ts; both rows fail on main and pass here.Changed-line count from
git diff --numstat origin/main: 201 total text lines — 166 additions and 35 deletions across two files, entirely inpackages/db. No binary changes or new dependencies.How you verified
{ compilations: 48, preparations: 48 }, expected zero.pnpm exec turbo run test typecheck lint --filter=@bb/dbpasses — 763 database tests in 73 files, with typecheck.pnpm exec turbo run lint:type-aware --filter=@bb/dbpasses with zero warnings and errors.pnpm exec turbo run buildpasses — 74 successful tasks, after building missing local Plugin SDK artifacts withpnpm exec turbo run build build:types --filter=@get-bb/plugin-sdk.git diff --check origin/mainpasses; numstat confirms two text files and the 201-line limit.The original report's precise timing multiplier is not claimed by this fix; the deterministic repeated-compilation failure is reproduced and repaired.
Fixes #8364