-
Notifications
You must be signed in to change notification settings - Fork 2
Open
Labels
bugSomething isn't workingSomething isn't working
Description
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
- Baseline timing is NOT the cause: Codex verified that premerge does NOT change extracted text — pre-premerge and post-premerge text are identical.
- Bug Collapsed-field multi-run replay broken in Deleted/MovedSource inplace paths #34 (collapsed field packing) does NOT resolve this: after fixing Collapsed-field multi-run replay broken in Deleted/MovedSource inplace paths #34, the premerge safety check still fails.
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
- Fixes Collapsed-field multi-run replay broken in Deleted/MovedSource inplace paths #34 (collapsed field multi-run replay) — confirmed this fix alone does not resolve the premerge issue
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
bugSomething isn't workingSomething isn't working