Repository navigation
Conversation
9 tasks done
… process A page with no text, and a picture covering a fifth of a page or slide, are read with Tesseract through ctypes (no program started), their words laid out like a page's own; a scanned table's grid is found, taken out before OCR and read as the page's rules. Without OCR such a page or slide is not complete. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: zlareb1 <[email protected]>
…le or a heading Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: zlareb1 <[email protected]>
…r reads a page's text twice A picture the page's own text fills is not read; an image's failure of any kind leaves its page partial; a scan's OCR lines survive a layout fallback; strokes come off only words beside a rule; raw images convert without per-pixel loops; deck pictures inflate within their own bound; the engine loads at the first picture; a missing model it was set to stops the service. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: zlareb1 <[email protected]>
… picture once a page Only thin strokes are rules; a page reads at most 50 pictures; an image counts against the bound only when the engine reads it; a slide is complete without text only when OCR read all its pictures and it has no chart; the reasons an image-only page names say what happened. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: zlareb1 <[email protected]>
…, and decodes nothing past its bound A stroke in or beside a dark region is no rule; a page of small icons stays complete; an image drawn again is collected once; a slide counts its pictures and charts; the 1-bit image is computed once. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: zlareb1 <[email protected]>
…whose pictures are not all collected is partial The dark-image mask is made from the turned gray image; a failed region mask refuses the image rather than painting its letters out. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: zlareb1 <[email protected]>
…shown screenshot at its own size A page with no image is never partial for its drawing's bound; the drawing's own reason follows OCR's; a band mask is freed when the next one fails. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: zlareb1 <[email protected]>
…d measures a turned image along its own axis A picture shown under a point wide is refused; a page whose pictures are known skips the image search; the drawing's bounds say which costs what. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: zlareb1 <[email protected]>
… points compare at a tenth; turned images are tested Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: zlareb1 <[email protected]>
…tep; a slide skips a sub-point picture Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: zlareb1 <[email protected]>
…nts are one class; the slide filter that could not fire is gone Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: zlareb1 <[email protected]>
Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: zlareb1 <[email protected]>
…refused by its header's size, and a large linked picture leaves its slide partial Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: zlareb1 <[email protected]>
…e is read from its own first bytes Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: zlareb1 <[email protected]>
…e inline scan is complete, and a GIF counts every frame Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: zlareb1 <[email protected]>
…r is no picture, and a text page whose drawing fails beside an image is partial Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: zlareb1 <[email protected]>
… page whose drawing names one is partial Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: zlareb1 <[email protected]>
…out-error paths and the dangling reasons are tested Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: zlareb1 <[email protected]>
…s, and an image in the deepest form is read Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: zlareb1 <[email protected]>
…t form's image and the nested reasons are tested Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: zlareb1 <[email protected]>
…e comment sits over its condition Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: zlareb1 <[email protected]>
Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: zlareb1 <[email protected]>
… when the page may hold an image Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: zlareb1 <[email protected]>
…lide, and an undecodable image costs no OCR read Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: zlareb1 <[email protected]>
… layouts are read once a deck, and a decode that read its header is charged Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: zlareb1 <[email protected]>
…ach layout's relationships are read once Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: zlareb1 <[email protected]>
…de's picture is its size or its placeholder Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: zlareb1 <[email protected]>
…ide that asks for it Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: zlareb1 <[email protected]>
…ide failures name an unreadable layout Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: zlareb1 <[email protected]>
… a slide that cannot read them keeps its text Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: zlareb1 <[email protected]>
…says what its parts replace Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: zlareb1 <[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.
Related: #289, #292
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):
The reference extractor reads scanned PDF pages, and pictures that cover a fifth of a page or slide, with OCR: a scan's headings, tables and text are cited by page like any page's, and a diagram's labels are searchable. Without OCR (
LOOM_EXTRACTOR_OCR=off, or an image built withOCR=off) such a page or slide is reported not complete instead of read as if it held nothing.Why
A scanned PDF failed every page as needing OCR, and the text in a picture (a whiteboard photo on a slide, a screenshot in a runbook) was not read at all, while the slide or page reported itself complete: a silent loss. On the document-parsing bench (#289) the held-out split's scans scored 0 on everything, and slides and decks lost 5 to 6% of their words with the file complete.
Design
extractor/loom_extractor/ocr.pybindslibtesseract.so.5andlibleptonica.so.6through ctypes, in the extraction child's own process: the child may start no program (its seccomp filter refuses a new process), so notesseractbinary is run. One engine per child, loaded at the first picture to read (a file with none never loads the model); its threads are capped byOMP_THREAD_LIMIT=1, set with the child's other native limits.timeout = 30,__init__).attrs.ocr, never a table or a heading. A diagram's boxes and labels laid out in rows would otherwise read as a table, and its large labels as headings.bytes.translaterather than a loop per pixel; JBIG2 is refused (it would need a program). Pastocr.MAX_PIXELSan image is refused, from its own header before it is decoded (a GIF's by walking its blocks for its screen and every frame, as Leptonica decodes a GIF whole to give its header and decodes each frame at its own size), the clean-up's morphology uses composite bricks with its sizes those of 600 pixels an inch at most (a 4000 by 5000 scan in a one-inch box reads in 0.56 s, not 4.3; a 2x screenshot shown at 720 pixels an inch is read at its own size, exactly), and a recognition past 20 seconds (Tesseract's monitor deadline) leaves its page partial. A page whose drawing is too large to collect every picture from (past 1,000 images or the operators' bound) is partial rather than complete.attrs.ocr, the artifactattrs.ocr_pages, andparser_versionnames the Tesseract version.Package.media), so reading them never costs the deck's text parts their room.LOOM_EXTRACTOR_OCR(on/off),LOOM_EXTRACTOR_OCR_LANGUAGES(eng; Tesseract model names joined by+; a language set whose model is not installed stops the service at start) andLOOM_EXTRACTOR_OCR_MAX_IMAGES(30 a file), passed to the child with its limits. An image without the libraries logs once at start that such pages are reported not complete.Alternatives: running the
tesseractprogram is refused by the child's sandbox; a model-based OCR or layout stack would add hundreds of megabytes, a GPU-shaped runtime and non-determinism to the reference extractor.Scope and risk
extractor/loom_extractor/(ocr.py; the PDF parser,PARSER_VERSION3; the PPTX parser,PARSER_VERSION3;ooxml.Package.media; the service and child limits),extractor/Dockerfile,extractor/README.md, docs, tests.libtesseract5andtesseract-ocr-eng, about 44 MB unpacked (12.5 MB compressed; 511 MB against 467 MB);docker build --build-arg OCR=offleaves them out, and that build reads no image and reports such pages not complete.Compatibility, rollout and rollback
attrs.ocr,attrs.ocr_pagesare attrs).LOOM_EXTRACTOR_OCR=offor builds withOCR=off; existing documents keep their artifact until they are ingested or synced again.Tests
tests/unit/test_document_extraction_ocr.py, with a fake engine: an image-only page is read and cited by page; OCR words land where the picture is drawn; a large picture on a text page is read and a small one is not; a text layer drawn over a page's image is read once, not again with OCR; a diagram's labels in columns on a text page are paragraphs, not a table or a heading; an image drawn on many pages, or shown on several slides, is read and counted once; an image drawn again on its page is read once there, a page past its picture bound is partial, and a text page of many small icons is complete; an image past the file's bound is not decoded; an image-only page names why its image was not read (inline, not drawn, drawing unreadable); an image that fails to decode with any error leaves its page partial and its text read; a scan whose layout is not trusted keeps its OCR text, and an image-only page whose layout fails says so; a negative 8-bit image is turned back; without OCR a large picture leaves its page partial and an image-only page failed; past the image bound a page is partial; a JBIG2 image is refused and says so; raw samples become a PNM Leptonica reads and a JPEG is passed as it is; a stroke is taken off a word only beside a rule; a table's strokes are taken off OCR's words; a deck's picture reads leave its text parts their room; an inline scan in a form beside a spacer still fails its page, a text page's large inline picture leaves it partial unless the page's text fills it, an inline scan beside a readable logo is not complete, and an inline icon drawn many times takes no room from the pictures OCR reads; a GIF's pixels count its screen and every frame; a header past the pixel bound is refused before decoding (real engine); a slide's large linked picture leaves it partial; a slide whose relationships cannot be read keeps its text and fails once, and a slide whose master cannot be read keeps its title; a slide's large picture is read into a block of its own, a small one is not, without OCR a large one fails its slide, a slide with a chart beside a picture OCR read is not complete, whether or not OCR found text; a picture in a placeholder is sized by its layout's placeholder of the same index (else type), or, when that one is unsized, by the master's placeholder its type inherits from (content takes the body's), or as the slide when none states it, and each layout, its relationships and each master are read once a deck, however many layouts share it; a grouped picture is sized on its slide, and a deck with no slide size has the default; an image whose header Leptonica cannot read leaves the file's image bound, and one whose decode fails after its header was read uses it; the service refuses a missing model it was set to and warns without OCR, and loads the engine once. An image turned a quarter is measured along its own width; a spacer under a point wide is not read, alone on a page or beside a scan, and the page stays complete; sizes under 6 points compare at a tenth. With the libraries installed (the extractor image), the real engine reads a ruled image end to end through ctypes, finds no rule in a dark band or between the light letters a dark band holds (skipped without them; run in the image, the last fails on the previous head); in the image, light text on a dark band (Release checklist for the queue) reads exactly, where it read as noise before the band was kept. The PDF and PPTX tests run with OCR off.Document-parsing bench, held-out split (27 files): this branch in its image (OCR on) against
mainwithout OCR (python -m bench.docparse run --out ...on each, thenscore main=... ocr=... --split heldout), paired difference with a 95% bootstrap interval:The two silent losses left are OCR misreads on pages that read complete: a YAML code block on a scanned page, and one label of a blurred whiteboard photo on a slide. Scanned headings stay weak: OCR's point size separates a title from the text but not one heading level from the next. The OCR choices (gray input, rule sizes, bands kept) were made on the dev split, which moved the same way (text 0.926 → 0.999, headings 0.926 → 0.996, tables 0.917 → 0.992, locators 0.917 → 0.998, silent loss 0 → 0). Time 0.14 → 0.45 s and peak memory 37 → 66 MB a file; a scanned page about 2 s.
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. I tuned OCR on the dev split only, checked the sandboxed service container reads scans end to end, and checked the bounds against hostile images in the tests.
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