Repository navigation
feat(core): store session media in a content-addressed media_blob table - #56991
Draft
kitlangton wants to merge 7 commits into
Draft
kitlangton wants to merge 7 commits into
kitlangton wants to merge 7 commits into
Conversation
kitlangton
force-pushed
the
media-blob-table
branch
from
October 23, 2026 20:37
737f859 to
c7f0e04
Compare
kitlangton
force-pushed
the
attachment-hydration
branch
from
October 23, 2026 22:42
31876e3 to
976943f
Compare
This was referenced Oct 24, 2026
Merged
This branch has not been deployed
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.
Stacked on #57729 (
attachment-hydration). Retarget tobetaafter it merges.What it does. Session images live as base64 inside
session_message.data, so 85% of a 15 GBopencode.dbis image bytes and 19% of those bytes are exact duplicates. This moves media of 1 KiB or more into a content-addressedmedia_blobtable and leaves ablob:sha256:<hash>reference in the row.How it works.
SessionProjectorinsert/update callsSessionMediaBlob.externalizeinside the projection transaction. User filedataand tool file URIs that are exactlydata:<mime>;base64,…become refs; identical bytes share one row (INSERT … ON CONFLICT DO NOTHING).SessionHistory.decodeMessageRows): model context,store.message, inlinestore.messages(export, revert), inbox redelivery, title generation and the output-limit check. Fork copies refs as-is.store.messages(feat(app): hydrate user attachments on demand #57729) swaps user attachments foropencode-attachment:placeholders before hydration, so it never reads their blobs.packages/core/script/migrate-media-blobs.tsis an offline, re-runnable backfill (server stopped) with optionalVACUUM INTO.Risk. Server data layer.
blob:sha256:<existing hash>would be hydrated. User files can't hit this (base64 schema rejects:).node:cryptocreateHash; the workerd bundle probe passes, but it isn't exercised under workerd at runtime.Proof. Copy of a 22k-row session (
store.messages, 40 rows, warm, median of 7):bun test test/session-projector.test.ts test/session-store.test.ts test/session-title.test.ts test/session-runner-message.test.ts test/session-prompt.test.ts test/database-migration.test.tsinpackages/core: pass. Includes a test that dropsmedia_bloband checks reference-mode lists still load, and that inbox redelivery,store.messageand inline lists return the original bytes.bun test test/message.test.tsinpackages/server: pass.bun run check(lint + typecheck, 36 packages): pass.bun run probe:workerd: pass.