Files
wordcraft/corpus/docx

DOCX corpus (local only)

This directory is where a local, real-world DOCX corpus can live for the opt-in cargo xtask docx-corpus harness. The corpus is never committed. /corpus is git-ignored; only this README is tracked. Never commit Word-produced files, documents you do not have the right to redistribute, or any proprietary template, theme, font or image. Word-produced documents are useful locally, including ones you made yourself, but they must stay untracked.

Populate it

Put .docx files anywhere under this directory (subfolders are walked, symlinks are skipped):

mkdir -p corpus/docx/mine
cp ~/Documents/report.docx corpus/docx/mine/

Useful sources for a local corpus:

  • documents you wrote yourself, exported from Word, Google Docs, LibreOffice or Pages;
  • public-domain or openly licensed DOCX samples whose licence allows local testing;
  • synthetic files generated by WordCraft (wordcraft-cli run --template sample --save …);
  • deliberately broken files for the failure path (a text file renamed .docx, a truncated ZIP, a package missing word/document.xml).

Keep a note of where each file came from. If a corpus must be shared, share the manifest and the harness report, not the documents.

Run it

# The runner builds wordcraft-cli before every run (a no-op when it is current).
cargo xtask docx-corpus --dir corpus/docx
cargo xtask docx-corpus --dir corpus/docx --out target/docx-corpus/report.json
cargo xtask docx-corpus --dir corpus/docx --all-pages
cargo xtask docx-corpus --dir corpus/docx --timeout 120 --cli target/debug/wordcraft-cli

Options:

Option Meaning
--dir <path> corpus directory (required)
--out <path> JSON report path (default target/docx-corpus/report.json); the Markdown summary is written beside it with an .md extension
--all-pages render every page instead of only page 1 (capped at 2,000 pages per file)
--timeout <secs> per-child-process timeout, default 60, maximum 3,600
--cli <path> use a specific wordcraft-cli binary
-h, --help usage

A missing or empty corpus directory is not an error: the command explains what is missing and exits successfully.

What each file goes through

Every .docx is handled in child wordcraft-cli processes, each with the timeout above, so one hostile or hanging file cannot stop the run:

  1. Open + inspect — wordcraft-cli info gives page and word counts; wordcraft-cli text gives the plain text baseline.
  2. Render — page 1 to PNG (--all-pages renders every page). Images go to <report-stem>-artifacts/<index>-<file>/page-NNNN.png beside the report.
  3. Save — wordcraft-cli convert writes a temporary .docx copy under the system temporary directory.
  4. Reopen + compare — the copy is opened again for page count and plain text. The temporary copy is then deleted.

The report records file name, bytes, open time, page count, word count, render time, round-trip time, rendered images, and every failure. Failures are classified as:

Kind Meaning
open the file could not be opened or inspected (invalid package, encrypted, timeout, oversized, …)
render page rendering failed
save saving the temporary copy failed
reopen the saved copy could not be opened or its text read
text_mismatch reopened plain text differs from the original
page_count_delta reopened page count differs from the original

The JSON report is deterministic for the same corpus and arguments apart from the timing fields: files are sorted by relative path, failure counts are always present, and there is no timestamp. The Markdown summary is a short human-readable table.

Limits

  • This harness measures open/render/save/reopen and text/page stability. It does not compare with Word's own rendering or page count, and it does not fix document bugs. A Word-vs-WordCraft visual comparison is a separate task.
  • PNG rendering is a smoke test that the page can be produced, not a fidelity score.
  • Files are treated as hostile: recursion depth, file count, file size, render pages and child output are capped, and symlinks are skipped. The caps are deliberately generous for normal documents; a file above them is reported as a failure rather than skipped silently.
  • The corpus and its reports stay local. target/ is git-ignored too, so reports do not enter commits.