Corpus checks

The unit tests pin behavior on small inputs; the corpus checks run a build over thousands of real files and count how many converge (ADR 0001): a round trip may normalize a file once, a second one must give the same result. Converging is not enough: a round trip can lose content once and then keep the loss, so they also count the files whose round trip kept their content. This page explains the scripts, the corpora, and the non-convergences left on purpose.

Scripts

All live in scripts/corpus/ and print counts only, never file contents; the diffs stay in the work directory, for reading locally.

Corpora

Corpus Files Trip
obs an Obsidian vault (local, private) md→org→md, --preset obsidian
lsq a Logseq org graph (local, private) org→md→org, --preset logseq
webmd the Rust book, GitHub's and MDN's docs md→org→md, --emphasis _
worg Worg, the org community's docs org→md→org, no flags

The web docs write emphasis _x_, which --emphasis _ keeps, so a file's identity diff shows what changed rather than every emphasis.

The local corpora never enter the repo, and neither do their file names: this page names files of the web corpora only. The web corpora are clones of upstream HEAD, so counts move as upstream does; compare a build against the baseline's run on the same clones, not against older counts.

Checking a change

Before committing a change that affects parsing or writing:

  1. npm run build, then scripts/corpus/all.sh.
  2. The baseline run (once per baseline, after setup.sh or moving /tmp/morg-base to a new main), of only the corpora the commits since the last one touch: all.sh records each run's commit in its directory's .ref, and compare.sh warns where the baseline's is not main.
  3. scripts/corpus/compare.sh: a file that converges on the baseline must converge on the change (no new non-convergences), a file identical there must stay identical, and a file that keeps its content there must keep it.

Status

As of 2026-10-07, branch fix/known-limits-0.11:

Corpus Converging Identical Same content
obs 24/24 0 23
lsq 407/407 321 407
webmd 1268/1268 384 1268
worg 285/293 0 293

The one Obsidian file whose content differs has a heading starting TODO: org reads it as the task keyword, which comes back as a todo:: TODO line below the heading (ADR 0002), gaining the word todo.

Worg files are identical in none: org→md→org writes org's canonical form (keyword values single-spaced, a list's blank lines dropped, a table's cells without padding, no blank line after an element but a paragraph), which hand-written org rarely is.

Known non-convergences

Each of the eight left in worg traces to a construct rare enough that a fix would cost more than it saves (special cases in shared code, a risk to files that converge now). Each converges in a later round or differs in whitespace only, unless noted.

Fixed-width lines in a list item also lose their trailing blanks once (org→md); the result is stable.