Summary
When premergeRuns: true (now the default), the ILPA corpus comparison with reconstructionMode: 'inplace' fails the round-trip safety check (rejectText mismatch) and falls back to rebuild mode.
Reproduction
npx tsx -e "
import { compareDocuments } from './packages/docx-core/src/index.js';
import { readFile } from 'fs/promises';
const [orig, rev] = await Promise.all([
readFile('tests/test_documents/redline/ILPA-Model-Limited-Partnership-Agreement-WOF_v2.docx'),
readFile('tests/test_documents/redline/ILPA-Model-Limited-Parnership-Agreement-Deal-By-Deal_v1.docx'),
]);
const result = await compareDocuments(orig, rev, {
engine: 'atomizer',
reconstructionMode: 'inplace',
// premergeRuns defaults to true
});
console.log(result.reconstructionModeUsed); // 'rebuild'
console.log(result.fallbackReason); // 'round_trip_safety_check_failed'
"
What was ruled out
Likely root cause
The safety check failure occurs because inplace reconstruction produces incorrect output when operating on premerged run topology. Premerge changes atom boundaries (larger merged runs → different atoms), which causes the inplace modifier's run-splitting/placement logic to reconstruct differently, producing text that doesn't match the original on reject-all.
Investigation direction
- Run per-pass reject-text diagnostics to identify the exact paragraph/run where the mismatch occurs
- Trace through the inplace modifier's run-splitting/placement logic for that specific case
- The pipeline baseline extraction at line 496 is correct and should NOT be moved
Current workaround
Tests that need inplace mode for ILPA have been updated to expect rebuild fallback rather than passing premergeRuns: false.
Related
Summary
When
premergeRuns: true(now the default), the ILPA corpus comparison withreconstructionMode: 'inplace'fails the round-trip safety check (rejectTextmismatch) and falls back to rebuild mode.Reproduction
What was ruled out
Likely root cause
The safety check failure occurs because inplace reconstruction produces incorrect output when operating on premerged run topology. Premerge changes atom boundaries (larger merged runs → different atoms), which causes the inplace modifier's run-splitting/placement logic to reconstruct differently, producing text that doesn't match the original on reject-all.
Investigation direction
Current workaround
Tests that need inplace mode for ILPA have been updated to expect
rebuildfallback rather than passingpremergeRuns: false.Related