Repository navigation
A synced document's Markdown export drops its pictures' base64 and marks where they were - #312
Merged
Merged
Conversation
zlareb1
force-pushed
the
fix/gdrive-doc-inline-images
branch
from
November 7, 2026 08:28
ce61f58 to
e1183ce
Compare
…rks where they were Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: zlareb1 <[email protected]>
…d not fetched again; no space after an opening bracket Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: zlareb1 <[email protected]>
…nt hash is named for what it hashes Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: zlareb1 <[email protected]>
…a picture keeps its shape; stale records of unchanged copies go Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: zlareb1 <[email protected]>
…only at the stored address; patterns at module level Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: zlareb1 <[email protected]>
…hesised title tested; the code-sample test counts its exports Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: zlareb1 <[email protected]>
…cut write is mined again; readable record pruning Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: zlareb1 <[email protected]>
…nd a reconversion is only tried at the stored address Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: zlareb1 <[email protected]>
…matches the same way Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: zlareb1 <[email protected]>
…ed hash is read with prior narrowed Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: zlareb1 <[email protected]>
…icture-check record's pruning is tested on each listing Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: zlareb1 <[email protected]>
zlareb1
force-pushed
the
fix/gdrive-doc-inline-images
branch
from
November 7, 2026 12:02
86c68e7 to
5929c89
Compare
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.
Changelog category (leave one):
Changelog entry (one or two sentences a user of Loom can read without the diff; the release pull request collects these into the release notes):
A
gdrivesource no longer stores, chunks and embeds the base64 bytes of the pictures pasted into a document: a line of pictures becomes an[image-only: …]marker, as on a page store's page, and documents synced before this release are converted again once.Why
The store's Markdown export of a native document holds every pasted picture as a reference definition with an inline data URI (
[image1]: <data:image/png;base64,…>), referenced from the text as![][image1]. The sync wrote that export as it came, so the bytes of each screenshot and diagram became document text: windowed into chunks, embedded, indexed for BM25 and served as search hits and pack context.Measured on a private set of 44 real native documents (design documents, meeting notes, status reports and runbooks, 64 pasted pictures in 16 of them; 42 synced through the
gdrivesource, 2 kept in a folder the source is not given): 81% of the documents' characters were base64, and 4,768 of the namespace's 6,692 chunks were base64 windows with no text in them.The export conversion now drops definitions whose destination is a data URI and replaces each line (or run of lines) that only shows such pictures with the marker the page and slide conversions already use,
> [image-only: N pictures, rationale not extracted], followed by any alt text. A list item, quote line or heading that only shows pictures keeps its marker in place (* [image-only: 1 picture, …]), and a run of pictures indented under a list item gets a marker with that indentation. A picture inside a line of text is dropped and its alt text kept, with a space before the text that follows (so exactly one space stays between the neighbouring words, none inside brackets or emphasis and none before punctuation; a line of only a picture wrapped in emphasis is a picture line). Fenced code, at any indent and after list-item or quote marks (so a fence nested in a list item too), is left as it is, and only the blank lines the removed lines leave behind are dropped, so a document without pictures comes out byte for byte as it went in. Reference definitions to real links are left as they are. On the same set: 7.27M characters become 1.38M, no base64 is left, no line of text is lost, 59 markers.A document stored by an earlier build keeps its revision, so the sync would skip it forever. On a full listing (the only one that lists an unchanged file:
LOOM_KNOWLEDGE_SOURCE_SYNC_FULL_INTERVAL_SECONDS, a day by default, orloom knowledge sync --full), the stored-revision read also says whether a document's stored text still holds a picture definition with a data URI; such a native document is fetched and converted again at its same revision. A document without pictures is never fetched again, rewritten or re-embedded, and a converted document no longer matches, so no version stamp is needed. A document whose stored text only shows such a definition (in a code sample, which the conversion leaves as it is) still matches: it is exported once at its revision, compared with the stored copy, neither written nor mined, and recorded in the source's sync state (pictures_checked, file id to revision) so later listings skip it until its file changes; a record is dropped once its file is listed at another revision, or is missing from a trusted full listing. The check reads each document's text, so only full listings ask for it: on the real set's 63 synced files (42 native documents, 14 decks, 7 PDF and.pptxfiles; 1.6 MiB of live text, plus older versions not yet merged away), the stored-revision read went from 0.94 MiB to 9.4 MiB read, at 0.14-0.21 s either way (system.query_log, two runs each). The check stays on every full listing (daily by default) rather than ending once a listing finds no match: a build without this change, during a rolling upgrade or after a rollback, can store a raw export again, and only this read would find it. It is one read of the source's stored text per full listing (daily by default, and repeated each pass while a full listing stays incomplete, as when the pass bound spreads the reconversion over passes), bounded by the revisions limit; a later release can drop the check once no supported build stores raw exports.Scope and risk
docs) of agdrivesource. Decks, PDF/PPTX extraction, page stores, trackers and recordings are unchanged;knowledge.addandknowledge.ingeststore what their caller sent.LOOM_KNOWLEDGE_SOURCE_SYNC_DOCUMENTS_PER_PASS; its chunks are embedded again (far fewer, with the base64 gone). On the real set, 16 of 44 documents matched, the same 16 that had pictures.text_sha256, in which case by revision and hash (the page-store sync's mechanism). Every native-document write now stores the hash of its title and text, so a copy written again at the same revision with other text (a reconversion, or its redo after a write cut between its document row and its chunks) changes its mined key in the same row and is mined once more, including one given up on earlier as too large for a pass; a write that fails leaves the old copy and its old, already mined key. A document not rewritten keeps its revision-only key, and a rewrite at a new revision has a new key either way, so nothing already mined is mined again. Whether a reconversion changed anything is judged against the SHA-256 of the stored text that the full listing's read returns, so no second read of the document is needed.in stored text is converted when its file next changes. A flagged copy whose address moved at the same revision takes the ordinary path: written at the new address, the old one retired.unconverted: its stored copy is still served, and the waits decide when it is tried again. The skip-by-revision step takes an explicitrefetchfor this, rather than a blanked stored revision.Compatibility, rollout and rollback
docs/architecture/rolling-upgrades.md, rule 32): a build without this change skips a document at the revision it stored, so the two builds do not rewrite each other. A document N-1 writes moves the stamp past it, so N converts it again at the next full listing or when the file changes again. Both builds key mining by revision andtext_sha256when a document carries one, so a reconverted document is mined once whichever build mines it.loom knowledge sync --fullconverts the stored documents at once instead of at the next full listing.Tests
tests/unit/test_knowledge_source_sync.py: the conversion on a synthetic export (pictures alone on a line, a run of them, a list item, a quote line and a heading of only a picture, a run indented under a list item, one inside a list item's text, one between two words, one with a caption beside it, a fenced code block holding image syntax and blank lines, a fence nested in a list item, one opened on a list item's own line, one in a quote, a~~~fence, a line whose backtick info string opens no fence, inline data images alone and inside text, a definition with a quoted or parenthesised title, CRLF line endings left as they are, a line of prose that only starts like a definition (kept), emphasis around a picture with and without alt text, a reference to a real link, a document without pictures unchanged); a document stored with its pictures' bytes is converted again at its same revision, mined again and skipped on the next full listing; one stored without them is not fetched again; one whose code sample shows a definition is fetched once at its revision and neither written nor mined (and is written with the comparison removed); flagged-but-unchanged copies listed before a new file do not hold a full listing at the pass bound (and do with the record removed), and the record is dropped when its file is listed at another revision or missing from a full listing, and kept when an incremental turn does not list it; a failed reconverting write mines nothing until the new text is written, then mines it once; a turn cut after the reconverting write, or a write cut before its chunks, still mines the new text; a document given up on is not refetched and not counted unconverted at its address, and is counted unconverted when its address moved; a deck and an uploaded PDF are not fetched again.tests/unit/test_knowledge_source_revisions_sql.py(clickhouse-local, the realloom.documents): a full listing's read flags a definition, and returns the stored text's SHA-256 for a flagged copy only, with a data URI with or without angle brackets and indented, and not a link definition or one inside a line of text; without the flag it reads none (and fails with the pattern's multi-line mode removed).length(content)andcountSubstrings(content, 'base64,')inloom.documentsbefore and after one sync.make format lint typecheck,tests/analyzer, the doc-link and public-copy tests, and the unit suite.AI assistance in the code (leave one; writing this description with AI is fine):
AI-generated (an agent wrote most of the diff): Claude Code. The conversion was checked line by line against 44 real exports: every line of text that is not a picture is kept.
I can explain every line of this diff and how it interacts with the rest of Loom.
Checklist
make format-check,make lint,make typecheckandmake test-unitpass; the integration suite passes if server behaviour changed.docs/reference/configuration.mdand thedocs/reference/tables (python scripts/codegen/docs_reference.py), the reach manifest,schemas/schema.sql(make schema-dump) and the Codex plugin copies (python3 scripts/codegen/agent_plugin_sync.py).main; no merged migration is edited.hooks/,lib/,bin/,skills/,.mcp.json, the Codexplugin-defaults.json) bumps both plugin manifests' version, and no other open PR uses that version.npm --prefix frontend run build) and its tests pass, iffrontend/changed.docs/describe the system as it now is, and this description names any operator steps and wire changes.tests/unit/test_public_copy.py).git commit -s), as CONTRIBUTING.md asks.🤖 Generated with Claude Code