Skip to content

feat(document): DOCX adapter with flow projection and export - #50

Merged
1wgrumph merged 5 commits into
mainfrom
feat/21-docx-adapter
Sep 30, 2026
Merged

1wgrumph merged 5 commits into
mainfrom
feat/21-docx-adapter

Conversation

@1wgrumph

Copy link
Copy Markdown
Contributor

Summary

DOCX adapter for enterprise-document evidence (#21), registered in the #25 conformance harness alongside the XLSX and PDF adapters.

  • Import: maps WordprocessingML to a flow projection. It covers:

    • section and paragraph order, headings, lists, runs, and the styles needed to read structure;
    • tables, captions, hyperlinks (targets recorded, never fetched) and bookmarks;
    • footnotes and endnotes, and comments;
    • tracked changes, kept as tracked (never accepted or rejected);
    • images as content-addressed assets;
    • stable citation locators.

    Namespace prefixes resolve through in-scope bindings. Unsupported or normalized features appear in a fidelity receipt.

  • Safety: external relationships are never resolved, and VBA, fields, OLE and embedded content are never executed. mc:AlternateContent compatibility branches are refused with a typed result rather than imported twice. Metadata expansion is bounded.

  • Export: a deterministic DOCX with a fidelity receipt, which the importer accepts back (compression included). DLP and public-boundary checks run first. Attribute whitespace round-trips exactly.

Closes #21

Verification

  • ./tools/ci/check.sh --fast and --full pass on the branch merged with current main, with all DOCX, XLSX and PDF conformance rows executable. No new dependencies.
  • Readers: python-docx 1.2.0 and LibreOffice 26.2 open the exports (opt-in reader test).
  • Independent review (Codex GPT-6.1 Sol xhigh) returned REPAIR_REQUIRED with five findings, all fixed in 61f1c8b with tests that failed first:
    • unbounded metadata replication aborted import;
    • export produced packages the importer refused;
    • namespace identity was read from written prefixes;
    • compatibility branches became duplicate content;
    • attribute escaping changed tracked-change metadata.

Not covered: Word itself was not available to test. Query/packet selection of document evidence is tracked in #46.

🤖 Generated with Claude Code

https://claude.ai/code/session_01GXsmZAgLAftTb8E5oswz82

Claude Code and others added 5 commits September 30, 2026 01:02
Map WordprocessingML on top of the shared package intake into a flow
model: sections, headings, lists, tables with spans and merges, runs,
hyperlinks, bookmarks, captions, footnotes, endnotes, comments, tracked
changes kept as tracked changes, and content-addressed images. Every
normalized or skipped feature is recorded as a feature:status receipt
code. Fields are never evaluated and hyperlinks never fetched.

Export writes the model as a deterministic DOCX with a canonical JSON
fidelity receipt. DLP and public-boundary findings refuse before any
bytes are built, and export_file writes through the shared no-overwrite
gate. Import, export, and import again keep the model and anchors.

Register the adapter, so every package row runs through it, and make the
three DOCX adapter rows executable in the shared corpus.

Refs #21
Describe the DOCX content model, citation anchors, fidelity vocabulary,
export receipt, and the opt-in two-reader check with its recorded
LibreOffice and python-docx results. Fill the DOCX column of the shared
compatibility table and mark the DOCX adapter rows executable.

Closes #21
The shared XML reader now keeps attribute prefixes, so the adapter reads
w:val, r:id, and r:embed instead of stripped local names. A part that
binds the WordprocessingML or relationships namespace to another prefix,
or w or r to another namespace, is refused as unsupported-container
rather than misread. Record the corpus runtime with the nine new rows.

Refs #21
# Conflicts:
#	crates/bran-document/src/conformance.rs
#	crates/bran-document/tests/conformance.rs
#	docs/enterprise-document-conformance.md
@1wgrumph
1wgrumph merged commit bc851e1 into main Sep 30, 2026
5 checks passed
@1wgrumph
1wgrumph deleted the feat/21-docx-adapter branch September 30, 2026 12:43
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.

DOCX adapter: preserve Word structure, review state, and citation anchors

1 participant