Skip to content

A DOCX document's headings sit under its Title paragraph - #295

Merged
zlareb1 merged 7 commits into
mainfrom
dp-docx-title
Nov 6, 2026
Merged

zlareb1 merged 7 commits into
mainfrom
dp-docx-title

Conversation

@zlareb1

@zlareb1 zlareb1 commented Nov 6, 2026 •

Copy link
Copy Markdown
Member

Related: #289

Changelog category (leave one):

  • Improvement

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):

In a DOCX with a Title paragraph, the reference extractor puts the document's headings under the title, so section paths and heading levels follow the document's outline.

Why

A Title paragraph and a Heading 1 both read as depth 1, so each Heading 1 closed the title's section: the title stood alone and the sections were siblings of it rather than inside it. On the document-parsing bench (#289) heading level accuracy on DOCX was 0.10 on both splits.

Scope and risk

extractor/loom_extractor/docxfile.py (PARSER_VERSION 3), its test and the DOCX paragraph of docs/architecture/document-extraction.md. Once a Title paragraph is read as a heading, it is depth 1 (whatever outline level it carries) and every other heading after it one level under its own (Heading 1 at depth 2, an outline level 0 at depth 2), and a later title is depth 1 again; a document with no title heading (none, an empty one, one set to body text) is read as before, and a heading before the title keeps its level. Headings past depth 9 stay well under the contract's 64 section entries.

Compatibility, rollout and rollback

  • Wire: none; a DOCX artifact's heading depths and section paths change for titled documents.
  • Operator steps: none. A DOCX keeps its artifact until it is ingested again.
  • Rollback: reverting restores the flat levels on the next ingest.

Tests

test_a_docx_title_paragraph_holds_the_headings_under_it: Title, Heading 1, Heading 2 read at depths 1, 2, 3 with the section path through all three; an outline level 0 after a title reads at depth 2; a title with an outline level of its own is depth 1; a heading before the title keeps depth 1; with no title, an empty title paragraph or one set to body text, the levels stay 1, 2; two titles read 1, 2, 1, 2, the second section under the second title. The DOCX tests pass.

Document-parsing bench, DOCX files (python -m bench.docparse run on each build, score ... --split dev|heldout): heading level accuracy 0.111 → 1.000 on dev and 0.101 → 1.000 on held-out; text, headings and table cells unchanged at 1.000.

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 checked the depths against the bench's DOCX gold and the existing DOCX 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 typecheck and make test-unit pass; the integration suite passes if server behaviour changed.
  • Generated files are regenerated in this PR, not by hand: the SDK op tables, docs/reference/configuration.md and the docs/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).
  • A new migration is additive and numbered after the latest on main; no merged migration is edited.
  • A behaviour change to any file a plugin ships (hooks/, lib/, bin/, skills/, .mcp.json, the Codex plugin-defaults.json) bumps both plugin manifests' version, and no other open PR uses that version.
  • The frontend builds (npm --prefix frontend run build) and its tests pass, if frontend/ changed.
  • Docs under docs/ describe the system as it now is, and this description names any operator steps and wire changes.
  • Repository text has no dates, people, host names, internal namespaces, ticket or decision numbers; the history goes in this description (tests/unit/test_public_copy.py).
  • Commits are signed off (git commit -s), as CONTRIBUTING.md asks.

🤖 Generated with Claude Code

zlareb1 and others added 7 commits November 6, 2026 16:01
…act holds

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: zlareb1 <[email protected]>
…s before and around it

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]>
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