Repository navigation
The reference extractor parses PDF, DOCX and PPTX - #257
Merged
Merged
Conversation
zlareb1
force-pushed
the
feat/extractor-office
branch
6 times, most recently
from
November 4, 2026 13:30
523e5f1 to
0b63eeb
Compare
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]>
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]>
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]>
Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: zlareb1 <[email protected]>
zlareb1
force-pushed
the
feat/extractor-office
branch
from
November 4, 2026 14:02
0b63eeb to
50cff69
Compare
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]>
Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: zlareb1 <[email protected]>
8 of 9 tasks
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: #157
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 parses PDF, DOCX and PPTX files:
knowledge.ingestpublishes them, a PDF page or a deck slide cited by its page span (locator.page_start/page_end), and the document-source sync converts the PDFs and decks its folders hold.Why
The issue asks for office documents and PDFs to be ingested server side and cited back to their place in the original. Before this change the reference extractor recognised these formats and refused them as
format_unavailable. This PR adds the parsers inside the extractor service. The Loom server still parses nothing: it only reads the artifact and its new locator fields.Design
page_start/page_end.allow_partial.unsupported_format.cryptographyis added so that a PDF encrypted with AES under an owner password alone (a common case) opens.zipfileand expat, not python-docx or python-pptx.corrupt. The check runs in expat's handler, so it holds for UTF-16 parts too, and no entity is ever expanded.Heading N/Titlestyles, or from an outline level set on the paragraph or found along its style'sbasedOnchain.List-style paragraphs become one list block per run.attrs.notes) are blocks.attrs.hidden.|, andattrs.tablecarries its shape. The contract's typedTableand the typed snapshots belong to the datasets work (XLSX, CSV, Parquet), so this PR adds no new block type.page_start/page_end(1-based, both 0 or a range) is added to the extractor's and the server'sLocator. The server validates it as a range, and a chunk cut from several blocks spans their pages.tableblock type: rejected, because a server one build older refuses a block type it does not know.Scope and risk
extractor/loom_extractor/:pdffile.py,docxfile.py,pptxfile.pyandooxml.py, the package reader;source.pyroutes the three formats and refuses anencodingfor them (invalid_option);service.pydeclares them with no options;child.pyquiets pypdf's repair warnings;text.pytoartifact.py(Blocks), so the new parsers share it; it gains heading attrs (a hidden slide's title) andclose_sections(a slide with no title).server/knowledge/domain/extract/:Locator.page_start/page_end, validated invalidate.pyand merged instructural.py. No server module imports pypdf,zipfileorxmlin the knowledge plane (tests/unit/test_package_contracts.py).pypdf>=6.21,<7andcryptography>=50,<51inextractor/pyproject.tomland in the rootextractorextra, with both locks at one version of each package (the root lock keeps its format revision; the CI and image uv versions accept both).docs/architecture/document-extraction.md(the formats table, the PDF and DOCX/PPTX sections, the locator, the dependencies),docs/reference/extractor-contract.md(locator fields, coverage units),docs/features/knowledge.md,extractor/README.md.Compatibility, rollout and rollback
page_start/page_endfields it does not know, as the contract allows. It therefore publishes a new extractor's PDF and PPTX artifacts without page spans.locatormay now carrypage_start/page_end; theknowledge.searchhit field comment, the assistant toolset's description and the feature page name them.Tests
altChunkis a failed unit, as is a document of pictures with no text, and a slide whose charts, diagrams or embedded objects carry everything it shows.tests/unit/test_document_extraction_office.py. Files are built byte by byte: the PDFs intests/fixtures/office_files.py(shared with the integration test), the DOCX and PPTX packages in the test file itself. The cases:basedOn), lists, tracked changes (a move read once; a deleted run's hyphen and tab, a deleted row and a deleted cell not read), a deleted picture not counted, a content control, alternate content, a table and footnotes, in order;unsupported_format, a broken onecorrupt;altChunk, a pictures-only document, a picture beside text (no failure), a non-decimal outline level and one of 5,000 digits (no heading, nothing else lost), and outline level 9 (body text) overriding a heading style on a style and on a paragraph;extractors.available_formats), and the mislabelled upload expectsformat_mismatchexactly when one declares pdf. The inspect test's and thenamespace.tunedocument test's unavailable-format cases use.xlsx, which the reference extractor still does not parse; its job is run by itself, as the ingest tests' are.pdfas a format the reference does not take now usecsv(a truncated PDF is nowcorrupt). The capabilities test and the quickstart smoke (scripts/gates/docker_extractor_smoke.py) list the three formats. The pin test covers every parser dependency.tests/integration/test_knowledge_ingest_live.py.incomplete_extraction, then publishespartialwithallow_partial, its chunk citing page 1 under its outline heading..pdfupload now failsformat_mismatch, because the reference extractor reads the bytes; with no extractor routed for pdf it failsformat_unavailable.-k "knowledge or document or extract or source or tune", with structural search merged: 96 passed, 53 skipped;test_capabilities_nested_too_deep_are_unavailable_and_declare_nothing, which fails on main too under Python 3.14 (its JSON decoder reports deep nesting differently); CI runs 3.12.PDF headings and table cells, and OCR, are what an optional layout-aware extractor would add.
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 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/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