Repository navigation
Conversation
214378b to
1f46348
Compare
|
@slopcop The PR description has been rewritten to lead with the user-facing benefits and benchmark results, with the detailed lifecycle, validation, and raw artifacts kept in expandable sections. |
|
🚨 SLOP COP 🚨 · I am the Slop Cop, and I am reviewing this change now. I will check security, code quality, performance, architecture, and the main user flow. |
| runEventLoopWorkSync("sweep:retained-event-output-expiry:delete", () => | ||
| deleteExpiredRetainedEventOutputs(deps.db, { | ||
| expiredAtOrBefore: now, | ||
| limit: RETAINED_EVENT_OUTPUT_EXPIRY_BATCH_SIZE, |
There was a problem hiding this comment.
🚨 slopcop/review — The expiry worker removes only one full output each ten-second sweep.
That permits 8,640 removals each day. A faster write rate creates an endless backlog. Expired outputs can remain as plaintext past seven days. Please use a bounded row or time budget, and yield between delete groups.
There was a problem hiding this comment.
Fixed in 28f2efe. The 10-second expiry sweep now performs up to 256 one-row deletes, yielding with setImmediate after every successful delete and stopping early when empty. The regression seeds two expired sidecars and observes both deletion plus the intermediate one-row state between yields; it failed before this fix and now passes.
| }); | ||
| const hydratedEventRows = | ||
| detailsInlineOutputLimit === null | ||
| ? hydrateRetainedEventOutputRows(db, eventRowsWithBackgroundTaskState) |
There was a problem hiding this comment.
🚨 slopcop/review — This byte check occurs after the code loads every full sidecar.
The earlier floor sees only previews. One large result can cause an unlimited database read, JSON parse, and JSON write before fallback. Please query lengths first, then hydrate only values that fit the 4 MiB budget.
There was a problem hiding this comment.
Fixed in 28f2efe. Bounded timeline detail hydration now preflights sidecar byte metadata before selecting values. If raw bytes already exceed the 4 MiB budget it returns previews without materializing the full strings; otherwise it checks JSON-escaped size and hydrates only when the completed response fits. The new 5 MiB regression stays previewed at a 4 MiB budget and hydrates exactly at 8 MiB.
| json_type(data, ?) = 'text' | ||
| AND json_type(data, ?) IS NULL | ||
| AND json_extract(data, ?) = ? | ||
| AND length(json_extract(data, ?)) > ? |
There was a problem hiding this comment.
🚨 slopcop/review — This migration size check does not match the new-write size check.
SQLite counts Unicode code points. JavaScript counts UTF-16 units. Thus, 20,000 emoji count as 20,000 here and 40,000 in JavaScript. New writes retain this output, but the legacy migration skips it forever. Please use one unit and add an astral Unicode test.
There was a problem hiding this comment.
Fixed in 28f2efe. The SQL predicate is now only a cheap UTF-8-byte candidate filter; prepareCompletedEventOutputData remains the canonical JavaScript UTF-16 threshold check. False-positive multibyte candidates advance the cursor safely. A 20,000-emoji value (40,000 JS UTF-16 units) now migrates and hydrates byte-identically.
| let migratedBytes = 0; | ||
| let migratedRows = 0; | ||
| const startedAt = performance.now(); | ||
| while (migratedRows < expectedRows) { |
There was a problem hiding this comment.
🚨 slopcop/review — This loop measures continuous advances, not the production drain time.
Production stops after 64 advances and waits for the next ten-second sweep. Therefore, 4,000 rows need at least 63 sweeps, or approximately 10.5 minutes. The PR reports 4.6–5.5 seconds. Please benchmark the real schedule or correct the stated drain time.
There was a problem hiding this comment.
Fixed in 28f2efe. The harness now reports both continuous active work and a production projection using the actual 10-second cadence, one foundation call versus at most 64 bounded advances per sweep. It also adds four 4 MiB single-row paths. For 4,000 rows / 147 MB, bounded migration uses about 5.1 s active work but about 630 s from startup; standard idle p95 occupancy is 69.779 -> 0.378 ms and the 4 MiB-row p95 is 23.347 -> 4.308 ms. Raw artifacts and the corrected comparison are linked in the PR.
| return { inserted: false }; | ||
| } | ||
| if (prepared.retainedOutput !== null) { | ||
| insertPreparedRetainedEventOutput(db, { |
There was a problem hiding this comment.
🚨 slopcop/review — This helper can save the preview without the retained full output.
insertEvents accepts a plain connection. If this second write fails, the preview remains. A retry ignores the existing event and never restores the sidecar. Please make both writes atomic, or require a transaction. Add a failure test for the sidecar write.
There was a problem hiding this comment.
Fixed in 28f2efe. insertEvents now accepts DbConnection and wraps the complete event batch plus retained-sidecar inserts in one immediate transaction; notification happens only after commit. The regression installs a real SQLite BEFORE INSERT trigger that rejects the sidecar insert and verifies that no preview event is left behind. It failed before the transaction and passes now.
There was a problem hiding this comment.
🚨 SLOP COP 🚨 · review
Plain English summary: This PR moves large completed outputs into a side table for seven days. Normal timeline reads receive small previews. Explicit reads can still receive the full output. A background job converts old rows in small steps.
I found five material issues.
- High — Expiry cannot keep pace. The worker removes one output every ten seconds. It can remove only 8,640 rows each day. A faster write rate keeps plaintext outputs past seven days and grows the database.
- High — The 4 MiB guard runs too late. Detail reads load and rebuild all full values before the size check. One very large result can block the server or exhaust memory.
- Medium — Unicode size rules differ. SQLite counts code points, but JavaScript counts UTF-16 units. The migration can skip legacy emoji-heavy outputs that new writes retain.
- Medium — The drain benchmark does not model production. It runs advances continuously. Production runs 64 advances every ten seconds. A 4,000-row backlog needs at least 10.5 minutes, not 4.6–5.5 seconds. The 36 KiB fixture also does not test a very large single row.
- Medium — One exported write path is not atomic.
insertEventscan save a preview before a sidecar write fails. A retry ignores the event and cannot restore the full output.
The architecture scan found a smaller maintenance issue. The output paths exist in both retained-event-outputs.ts and event-output-truncation.ts. The retention module and sweep module also import each other. Move the policy constants and target contract into retained-event-output.ts. Derive both path lists from that contract.
Verification completed:
- The full
@bb/dbsuite passed: 455 tests. - The five focused server files passed: 55 tests.
- The
@bb/dband@bb/serverTurbo typechecks passed. - The local app loaded through doobie. The project view and prompt interface worked without console errors.
- The current GitHub checks are green.
The core design is useful, but these limits need correction before the retention promise is reliable.
|
🚨 SLOP COP 🚨 · I am the Slop Cop. I am reviewing this pull request for security, code quality, performance, architecture, and end-to-end behavior. |
28f2efe to
193561b
Compare
|
@slopcop Follow-up: current |
| if (cursor.lastCreatedAt === 0 && cursor.lastEventId === "") { | ||
| return emptyCompletedEventOutputMigrationResult("idle", 0); | ||
| } | ||
| advanceCompletedEventOutputMigrationCursor(db, { |
There was a problem hiding this comment.
🚨 slopcop/review — A completed migration restarts forever.
This reset makes the next 10-second sweep scan from the first event again.
After migration completes, each sweep can still run 64 scans of 250 rows and evaluate JSON conditions.
Please store a completed-pass state and reduce later scans.
Reset that state after an import or a policy change.
There was a problem hiding this comment.
Fixed in b73deba. A full cursor pass now persists an explicit completed state; ordinary 10-second sweeps then return with zero scanned rows. A bounded daily wrap catches out-of-band/imported legacy rows inserted behind the cursor, and a cursor-version change restarts immediately. The regression covers completion, a no-scan follow-up, and discovery of a behind-cursor row after the rescan interval.
|
|
||
| const expiresAt = args.createdAt + COMPLETED_EVENT_OUTPUT_RETENTION_MS; | ||
| const truncation = isJsonObject(existingTruncation) ? existingTruncation : {}; | ||
| item[target.outputPath] = truncateOutput(value); |
There was a problem hiding this comment.
🚨 slopcop/review — The output size becomes incorrect for retained values.
This assignment replaces a 50,000-character output with a 4,173-character storage preview.
The timeline preview then uses row.output.length as outputPreview.totalChars.
The UI can report 4,173 characters while the retained detail contains 50,000 characters.
Please carry truncation.originalLength into the timeline row and use it for totalChars.
There was a problem hiding this comment.
Fixed in b73deba. Timeline projection now derives the authoritative original output length from the completed-event truncation metadata and preserves it when applying an additional timeline preview. The normal and detail timeline regressions use a 5 MiB retained value and assert bounded preview text plus the full original totalChars.
| } | ||
| const remainingDataBytes = maxDataBytes - storedDataBytes; | ||
| if ( | ||
| retainedOutputSizeTotal(rawSizes, rowCountsByEventId) > remainingDataBytes |
There was a problem hiding this comment.
🚨 slopcop/review — The byte check rejects retained output that fits the limit.
The check adds the retained value size to storedDataBytes.
It does not subtract the storage preview that hydration replaces.
I reproduced this with a 40,000-character retained value.
The hydrated rows used 45,489 bytes, but this function returned the 9,805-byte previews at that exact limit.
Please calculate the projected hydrated JSON size before the decision.
There was a problem hiding this comment.
Fixed in b73deba. The preflight now computes the exact projected serialized JSON byte count: it removes the stored preview and truncation metadata from the small event template, then adds SQLite octet_length(json_quote(value)) metadata for the retained string. It still does not select/materialize the full value before acceptance. The regression proves an exact-limit response hydrates and a limit one byte smaller stays a preview.
| if (!result.threadId) { | ||
| throw new Error("Migrated completed output has no thread"); | ||
| } | ||
| deps.hub.notifyThread(result.threadId, ["history-rewritten"]); |
There was a problem hiding this comment.
🚨 slopcop/review — The migration can cause repeated client refreshes.
Each migrated row sends an immediate history-rewritten message.
A sweep can send 64 messages, and one thread can receive many messages.
The client handles this change immediately and invalidates several queries.
Please collect changed thread IDs and send one message for each thread after the sweep.
There was a problem hiding this comment.
Fixed in b73deba. The periodic sweep now collects affected thread IDs in a Set and emits cache/history invalidation once per thread in finally, so a later advance failure cannot lose invalidation. The regression migrates two rows belonging to one thread and now expects exactly one history-rewritten notification.
There was a problem hiding this comment.
🚨 SLOP COP 🚨 · review
This PR moves large completed outputs into a second database table. Normal reads keep a short preview. Detail reads keep full text for seven days. A background job converts old rows in small steps.
I found four medium issues:
- The timeline can report the storage preview length as the full output length.
- The detail byte check can reject a full output that fits its limit.
- The migration restarts a complete scan every ten seconds forever.
- The migration can send many immediate refresh messages for one thread.
I left line comments with the evidence and proposed corrections.
The security review found no access, privacy, retention, or transaction defect. The central target list also removes path duplication cleanly. I found no other required architecture refactor.
The database suite passed 458 tests. The focused server suites passed 36 tests. The security checks passed 13 focused database tests.
I also tested the real application with Doobie. A 40,000-character command stored a 4.8 KB preview and a full retained value. The detail view restored all 40,000 characters.
GitHub currently reports a merge conflict with main.
|
🚨 SLOP COP 🚨 · I am the SlopCop. I am reviewing this pull request for security, code quality, performance, architecture, and end-to-end behavior. |
| types: args.types, | ||
| }); | ||
| return rows.map((row) => parseStoredEventRow(row)); | ||
| return hydrateRetainedEventOutputRows(db, rows).map((row) => |
There was a problem hiding this comment.
🚨 slopcop/review — This raw read has no output byte limit.
The route accepts any numeric row limit. This line loads every full sidecar before JSON serialization.
Twenty 1 MiB outputs took 286 ms locally. One request can use unbounded time and memory.
Please set a row limit and a total-byte limit, or stream bounded pages.
There was a problem hiding this comment.
Fixed in 6aba4c1. The raw event-list route now clamps pages to 100 rows and performs the exact projected hydrated-data byte preflight before selecting any full sidecar value. Pages over 8 MiB return 413; callers can use the existing sequence/limit pagination, and a smaller page still returns the byte-identical retained value. The same byte guard protects /events/wait. The in-memory integration regressions cover a requested 1,000-row page being capped at 100 and a 9 MiB retained page returning 413 while a one-row page hydrates exactly; both failed before this fix and now pass.
193561b to
b73deba
Compare
There was a problem hiding this comment.
🚨 SLOP COP 🚨 · review
Plain-English summary
This change moves large completed outputs into a separate database table for seven days.
Normal timeline pages keep small previews. A background job converts old database rows in small steps.
Findings
I found five medium issues. I added one new inline comment and did not repeat four open comments.
- Raw event reads can load unlimited full outputs into memory.
- Timeline previews report the storage preview length instead of the full output length.
- The detail byte check rejects some full outputs that fit the response limit.
- The migration cursor restarts after each complete pass and scans all completed history forever.
- Migration notices can cause 64 immediate client refreshes for one thread in one sweep.
I found no security defect. The central output-target contract also removes the old path-list duplication.
Verification
- The database suite passed all 460 tests.
- The database and server typechecks passed.
- All current GitHub checks passed.
- A browser check returned the exact 50,026-character retained output without storage-only truncation data.
git diff --checkpassed.
Please address the five findings before merge.
|
@slopcop The four follow-up findings are addressed on |
b73deba to
6aba4c1
Compare
|
@slopcop The additional raw-read finding is now addressed on |
|
|
||
| function truncateOutput(value: string): string { | ||
| return ( | ||
| value.slice(0, COMPLETED_EVENT_OUTPUT_RETAINED_HEAD_CHARS) + |
There was a problem hiding this comment.
🚨 slopcop/review — Preserve Unicode characters at both preview boundaries
slice() works on UTF-16 code units. A boundary can divide an emoji or another astral character. The stored preview then contains an unpaired surrogate. After retention expires, UTF-8 output replaces that character with U+FFFD permanently. I reproduced this with 2,047 ASCII characters followed by 😀; value.slice(0, 2048).isWellFormed() returned false.
Please move each boundary when it falls between a high and low surrogate. Add tests for both the head and tail boundaries.
There was a problem hiding this comment.
Fixed in 9e58d94. The retained preview now detects a head or tail boundary between a UTF-16 high/low surrogate pair and moves that boundary inward, so the preview never introduces an unpaired surrogate. The in-memory SQLite regression places an emoji across each boundary and verifies both stored previews remain well formed after round-tripping through SQLite; it failed before this fix and passes now.
There was a problem hiding this comment.
🚨 SLOP COP 🚨 · review
Plain-English summary: this PR keeps large command, tool, search, fetch, and generated-image results available without making every timeline response carry the full payload. It moves those large values into a seven-day retention table, sends small previews for normal timeline rendering, hydrates full values only for detail/raw reads within byte limits, migrates old rows in the background, and adds a compact generated-image row.
I found two medium-severity issues:
- Raw CLI pagination can collapse into one HTTP request per event. The new 413 backoff halves the page size but never grows it after the large-output region passes. A couple of dense events can therefore make a long ordinary tail take roughly one request per row. I left a line comment with a concrete regression case and recovery suggestion.
- Mounted command/tool rows can retain stale full output after expiry. The memo signatures still omit retained-output availability, so the server's same-identity upsert on migration or seven-day expiry may not rerender the row. The existing discussion is still current on this head; I replied there with the remaining gap.
Security review found no material issue: retained values stay thread-scoped, SQL values are parameterized, response hydration is preflight-bounded, generated-image payloads are omitted from the DOM, and retention cleanup preserves the intended foreign-key lifecycle.
Architecture is generally cohesive: the sidecar table, shared truncation strategy, bounded hydration, and incremental migration are sensible boundaries. One non-blocking cleanup would be to centralize the exact legacy image-generation envelope parser, which is currently duplicated between the DB migration and thread-view lifecycle projection. The migration benchmark also defaults to a 250-row scan while production now uses 25, so its default should be aligned or made explicit. I did not find another material duplicate or refactor that should hold this PR.
Verification on f8542b2997:
- CI is green (14 successful checks; two intentionally skipped matrix jobs), and GitHub reports the PR merge state as clean.
- Local Turbo suites passed: client-core 253 tests, DB 471 tests, CLI 532 tests, and server 2,218 tests (one server test file skipped).
- Live dev-app/doobie QA passed. A seeded 4 MiB legacy generated-image event was migrated from a 4,194,740-byte event row to a 4,722-byte preview row with 4,194,328 bytes retained in the side table. The timeline rendered “Generated image” and the base64 payload was absent from the DOM.
These two medium issues should be addressed before merge; I have left this as a comment review, per policy.
7ccb072 to
c4c12b7
Compare
c4c12b7 to
4760dc1
Compare
## Human comments ## What was wrong The provider-installation deadline regression combined three independent layers in one 5-second test body: a full server route harness, provider registry setup, and retryable host RPC timers. It scheduled every stalled wire attempt with fake `setTimeout`, then advanced the entire harness clock by 150 seconds even though the aggregate policy only needs to model three concurrent provider requests across a 70-second budget. Under normal server-shard CPU contention, processing that avoidable timer/lifecycle work could consume the test's real 5-second ceiling. This recurred on current main at `cb3aaf57ddf46ec9cd27e18fc4d99084fb75917e` ([run 34277635721](https://github.com/get-bb/bb/actions/runs/34277635721), [job 102235437825](https://github.com/get-bb/bb/actions/runs/34277635721/job/102235437825)) and on unrelated PR #2920 ([run 34277790348](https://github.com/get-bb/bb/actions/runs/34277790348), [job 102234989200](https://github.com/get-bb/bb/actions/runs/34277790348/job/102234989200)). Retryable RPC attempt budgeting is already covered by `online-rpc.test.ts`, so replaying both attempts for every provider here duplicated coverage while making the aggregation regression timing-sensitive. ## What changed - Extracted the existing provider aggregation policy into `aggregateProviderInstallations`: it preserves three-way concurrency and registry order, prepares each provider request, applies the remaining aggregate budget, omits providers after the deadline, and assembles the response. - Kept `getProviderInstallations` responsible for provider discovery, bridge resolution, host RPC dispatch, error classification, and logging. Its 70-second production deadline and 30-second command ceiling are unchanged. - Reworked the deadline regression to drive the production aggregation helper through observable batches of three deferred provider requests. The test advances an injected logical clock once per concurrent batch, resolves every deferred request, and still proves an empty result, nine provider requests, a shortened final request budget, completion at 70 seconds before the SDK's 75-second deadline, and omission of providers 10 and 11. - No host-daemon wire, SDK, CLI, route, request deadline, retry budget, or test timeout changed. ## How you verified - Current-main red: the exact test failed at 5,063ms under a bounded 48-hog profile on an 8-logical-CPU Intel host (at least 50 runnable compute processes, 6.25x oversubscription). Five unloaded current-main runs took 695-1,157ms in the test body. - Matched green: the rewritten test passed in 13ms under the same 48-hog profile and in 5ms without generated load. Every load/test harness had a hard deadline and process-group cleanup; survivor checks were empty. - `pnpm exec turbo run test --filter=@bb/server -- test/public/public-provider-installations.test.ts` passed: 1 file, 6 tests. - `pnpm exec turbo run typecheck build --filter=@bb/server` passed both server tasks. - A serial one-worker rerun passed `online-rpc.test.ts` (9 tests), `plugin-update.test.ts` (27), `timeline-in-turn-window.test.ts` (28), and `timeline-perf.test.ts` (1); one unrelated macOS launch-agent test timed out while the Intel host's virtualization workload remained elevated. - Three broader server runs all passed `public-provider-installations.test.ts` (6 tests). The full shards did not go green on this host: depending on worker count and concurrent virtualization load, unrelated install/plugin/timeline tests hit their existing 5-second ceilings (best run: 4 failed files, 18 failed and 2,310 passed tests). The server package itself used seven Vitest workers plus one coordinator on eight logical CPUs, so it did not oversubscribe the host by itself. - `pnpm exec prettier --check apps/server/src/services/system/provider-installations.ts apps/server/test/public/public-provider-installations.test.ts` and `git diff --check` passed. > AGENT GENERATED
## Human comments ## What was wrong A real Codex image-generation request could fail at several points: Account Pool returned 404 for native image requests, BB rejected Codex's current image event format, and saved generated-image rows had neither an expansion control nor a rendered body. Older successful or failed attempts could also disappear on reload because the history filter required a marker added only when large results were migrated. This completes the image support introduced in #2920 and the pooled Codex transport introduced in #3056. ## What changed - Render generated images through the existing image preview and full-size viewer, with readable fallback bodies for failures or unavailable files. - Preserve older image completions with small, empty, missing, or null results, while retaining the existing large-result migration behavior. Accept the nullable background flag in retained native attempts as well. - Accept native `in_progress` status and nullable `transparentBackground` while preserving the existing normalized event contract. - Forward image generation and editing through Account Pool's existing authenticated Codex handler, preserving account selection and credential replacement. Update configuration, CLI guide, and skill documentation. No server/daemon wire fields change. Native web-search routing is outside this change. ## How you verified - Regression coverage in existing Codex and Account Pool tests fails before the fixes and passes afterward, including image-route authentication, upstream credentials, and unchanged request/response bodies. - `pnpm exec turbo run test typecheck --filter=bb-plugin-account-pool --filter=bb-plugin-provider-codex`: 531 tests passed and both typechecks passed. - Added history regression coverage for short, threshold-sized, Unicode, empty, missing, and null image results across repeated SQLite migration sweeps. All 31 focused server timeline tests and 475 database tests and 201 domain tests passed through Turbo; domain, database, and server typechecks passed. - After rebasing, `pnpm exec turbo run typecheck --filter=@bb/app --filter=@bb/client-core --filter=bb-plugin-provider-codex --filter=bb-plugin-account-pool` passed. - Generated a real 1254×1254 PNG using native Codex through the patched dev Account Pool. Verified the saved-path preview and full-size viewer on desktop 1440×900 and compact 390×844 with a coarse pointer. The isolated QA pool threshold was set to 1 to allow the account's remaining quota; production settings were unchanged. - Reloaded the earlier real failed Codex request and verified its previously hidden empty-result image attempt now appears and expands to a readable failure body. - [Live verification thread](https://ymichael--13158.getbb.app/projects/proj_jpr2jadhnc/threads/thr_hw4knk4a8g): expand **Worked for 57s → Explored 1 file, generated 1 image → Generated image**, then click the image. The successful turn follows an initial quota-threshold failure. > AGENT GENERATED
Human comments
What was wrong
Large completed outputs were stored directly in
events.data. Ordinary timeline reads therefore loaded and parsed megabytes that the UI did not need. Image-generation completions were also left in large provider envelopes, so an otherwise useful generated-image event could exceed the timeline response limit and appear as an unexplained placeholder.Existing databases had a second problem: old inline outputs were truncated in a bulk synchronous sweep. Large backlogs could block the Node event loop long enough to make the server visibly unresponsive.
What changed
In simple terms
resultpayload is not needed to render it.Output lifecycle and contract
The authoritative retained-output pairs are:
commandExecution.aggregatedOutputimageGeneration.resulttoolCall.resultwebFetch.resultTextwebSearch.resultTextFor a supported completed output above 32,768 JavaScript characters:
events.datareceives a Unicode-safe 2 KiB head + marker + 2 KiB tail payload preview.retained_event_outputsstores the exact JSON-encoded string withevent_id,output_path, andexpires_at.event.createdAt + 7 days; the payload preview then becomes authoritative.The actual generated-image preview is not truncated by this policy. The UI loads the saved image file from
savedPath;imageGeneration.resultis the large encoded provider payload. Existing command/tool/fetch/search retention behavior is unchanged apart from moving the exact value into the sidecar during the retention window. Image generation is the new fifth target.Public event pages accept at most 100 rows. A hydrated raw response above 8 MiB returns HTTP 413 so callers can reduce their page size. The CLI does this automatically and grows its page size again after a dense output region.
Existing databases
events_completed_item_truncation_idxand scan 25 indexed rows per window.events.idprimary-key index in 250-row windows. This bounds total rows examined, not merely matching rows, and needs no new index over the existing events table.Drizzle migration
0113_solid_night_thrasher.sqlcreates only the sidecar table and its empty expiry index. It does not scan or rewriteeventsduring startup.Generated-image boundary
The Codex provider plugin translates new image-generation items into the provider-neutral bridge delta union. The assembler persists canonical
imageGenerationitems. Oldprovider/unhandledimage completions are recognized through one shared strict parser; migration preserves their original envelope and sidecarizes only the nestedresult.The provider-bridge grammar remains v2 because image generation is additive vocabulary. The host-daemon protocol is bumped from current-main 180 to 181 because that new delta shape can cross the server/daemon wire; this forces already-enrolled daemons to self-update.
Measurements
Normal reads and new writes
BEFORE is inline baseline
eeaaa3e8db7b3aeb3c4ab46873816c84cb6ea513; AFTER is sidecar runtimeb78bf6038f15c081c8274f3e8141ccc6afa8f5b2. Same harness, Apple M4 Max, Node v22.23.1, 12 read warmups + 60 iterations and 8 write warmups + 40 iterations.Foundation artifacts: comparison, inline JSON, sidecar JSON, harness, checksums.
Legacy completed-output responsiveness
BEFORE is foundation
259f937f7b327ea73f56b69ace6ed35645c8045e; AFTER is bounded migration runtimef89baf1d0384d3f59cba5e655a1a65d083160a51. The later fixes do not change these four standard target advances. Same harness, 2 warmups + 10 iterations, with one busy child in CPU runs.Every 4,000-row drain migrated 147,456,000 bytes. Persisted windows reduced fetched scan rows from 875,500 to 4,000. Expected, hydrated, and raw-event hashes match. A 4,000-row backlog projects to about 10.5 minutes at the production cadence, trading total drain time for responsiveness.
Migration artifacts: comparison, BEFORE idle, AFTER idle, BEFORE CPU, AFTER CPU, checksums.
Production-shaped existing-database upgrade
Exact HEAD
e1d7c0f054012b8b4126134d58bbadddad4bc91d, sanitized database with all 1,490 threads and all 1,659,038 events (3.68 GiB), 2 warmups + 10 measured fresh-clone upgrades per load:The removed index-building migration measured 8,164.99 ms p50 and 8,886.13 ms p95/max idle. The new pending-upgrade p50 is about 516× lower. The new schema adds 12,288 bytes instead of 425,984 bytes.
The exact-HEAD primary-key image scan covered all 1,659,038 events in 6,678 yielded advances:
Both passes migrated all 40 eligible legacy image rows and 99,775,504 output bytes, scanned exactly 1,659,038 rows, and executed about 33,425 measured statements. Every retained raw event hydrated to its byte-identical pre-migration SHA-256. A legacy-only production-scheduled pass projects to about 17.4 minutes after other targets are exhausted.
Exact-HEAD follow-up artifacts: report, upgrade JSON, scan JSON, upgrade harness, scan harness, checksums.
Earlier full production-copy stress run
The earlier all-target stress pass used the same complete sanitized 1.66-million-event population. It migrated 2,989 rows and 457,525,580 source bytes with four forced reopens and identical idle/CPU totals and hashes. The standard target behavior remains unchanged; the exact-HEAD follow-up above replaces its legacy-image index scan and separately measures that new pass.
Artifacts: QA report, idle JSON, CPU JSON, snapshot validation.
Exact combined file list (73 files)
Residual tradeoffs
How you verified
All database regressions use real in-memory SQLite without mocks. Coverage includes byte-identical raw/detail hydration, copy and expiry, malformed and extension events, UTF-16 boundaries, 8 MiB guards, query plans, cursor windows, restart/completion, cache invalidation, CLI 413 pagination recovery, canonical and legacy image envelopes, and yielded scheduler behavior.
Latest focused validation:
@bb/dbTurbo typecheck/build/test: 474/474 tests passed.@bb/serverTurbo typecheck/build/test: 2,239/2,239 tests passed across 230 passing files; 1 file skipped.@bb/host-daemon-contractand@bb/host-daemonTurbo typecheck/build/test: 51/51 contract tests and 572/572 daemon tests passed.origin/main...HEADcontains the complete sidecar, image rendering, incremental migration, and protocol-version changes with no worker or unrelated feature work.Fixes: no linked issue.