Skip to content

Guard timeline migration and byte preflight - #1982

Merged
ymichael merged 1 commit into
mainfrom
bb/review-slop-cop-comments-thr_gyrubrb35r
Aug 20, 2026
Merged

ymichael merged 1 commit into
mainfrom
bb/review-slop-cop-comments-thr_gyrubrb35r

Conversation

@ymichael

Copy link
Copy Markdown
Collaborator

What was wrong

The parent-tool-call backfill added in #1976 evaluated json_extract for any historic event payload containing the parent key text, so malformed stored JSON aborted migration 0103 and prevented server startup. The byte-budget optimization from the same PR also aggregated every matching payload in a client-selected turn-details range before its early-stopping iterator ran, allowing a very wide range to add one or two unbounded synchronous scans.

What changed

  • Guard migration 0103 with json_valid(data) so malformed historic payloads remain unbackfilled instead of aborting the upgrade.
  • Accept the original merged 0103 hash so development databases that already applied it continue to pass migration-history validation.
  • Limit the scalar byte-total preflight to 2,001 matching events, which keeps the aggregate fast path for normal event-budgeted timeline windows and falls back to the existing exact, early-stopping iterator for unusually long ranges.
  • Add regressions for malformed matching JSON, the historical migration hash, and a wide byte range whose older payload must not be visited by the aggregate.

This is a database/server implementation fix only. There is no server/host-daemon wire change, so HOST_DAEMON_PROTOCOL_VERSION is unchanged.

How you verified

  • pnpm exec turbo run typecheck --filter=@bb/db --force
  • pnpm exec turbo run test --filter=@bb/db --force — 29 files, 406 tests passed
  • pnpm exec prettier --check packages/db/src/data/events.ts packages/db/src/migration-history.ts packages/db/test/data/events.test.ts packages/db/test/migrate.test.ts
  • git diff --check

Follow-up to #1976 and its migration finding and range-scan finding.

AGENT GENERATED: by GPT-5

@ymichael
ymichael force-pushed the bb/review-slop-cop-comments-thr_gyrubrb35r branch from 372c23d to 383a7e2 Compare August 20, 2026 03:36
@ymichael
ymichael merged commit 10e86a9 into main Aug 20, 2026
12 checks passed
@ymichael
ymichael deleted the bb/review-slop-cop-comments-thr_gyrubrb35r branch August 20, 2026 03:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant