-
Notifications
You must be signed in to change notification settings - Fork 2
Description
Summary
The inplace modifier produces incorrect tracked changes for documents containing tables with merged cells (w:vMerge/w:gridSpan). The round-trip safety check correctly catches this — after rejecting all changes, the text doesn't match the original document. Paragraphs get shuffled (e.g., "Party Name: Acme Corp" ends up where "Signature:" should be).
This causes a fallback to rebuild mode, which prior to the scaffold fix (#64) destroyed all table structure.
Reproduction
cd ~/Projects/open-agreements
node bin/open-agreements.js fill bonterms-mutual-nda \
-d <(echo '{"party_1_name":"Acme Corp","party_2_name":"Globex Industries","effective_date":"January 15, 2026","purpose":"Evaluating a potential business relationship","nda_term":"1 year","confidentiality_period":"1 year","governing_law":"Delaware","courts":"courts located in New Castle County, Delaware"}') \
-o /tmp/NDA-A.docx
node bin/open-agreements.js fill bonterms-mutual-nda \
-d <(echo '{"party_1_name":"Meridian Ventures LLC","party_2_name":"Atlas Biotech Inc.","effective_date":"March 1, 2026","purpose":"Joint development of diagnostic platform technology","nda_term":"18 months","confidentiality_period":"3 years","governing_law":"California","courts":"courts located in San Francisco County, California"}') \
-o /tmp/NDA-B.docxThen compare with reconstructionMode: 'inplace'. All 4 adaptive passes fail rejectText.
Diagnostic Detail
Pass: inplace_word_split
Failed check: rejectText
Expected paragraph 25: "Party Name: Acme Corp"
Actual paragraph 25: "Signature: "
First difference at position 896
Pass: inplace_run_level
Failed check: rejectText
Expected paragraph 16: "courts located in New Castle County, Delaware"
Actual paragraph 16: "Additional Terms"
First difference at position 599
Root Cause Hypothesis
The Bonterms NDA template has 5 merged cell indicators (w:vMerge/w:gridSpan). The Common Paper Mutual NDA has 0 merged cells and succeeds with inplace. The inplace modifier's content insertion/deletion logic likely misplaces content when operating on paragraphs inside merged table cells.
Template Comparison
| Template | Tables | Cell Paras | Merged Cells | Inplace Result |
|---|---|---|---|---|
| Common Paper NDA | 3 | 50 | 0 | ✅ inplace succeeds |
| Bonterms NDA | 4 | 49 | 5 | ❌ rebuild fallback |
Impact
With the scaffold fix, rebuild mode now preserves table structure, so the visual output is correct. But the tracked changes are split into separate paragraphs (whole-paragraph del/ins encoding) rather than inline changes within the same paragraph. Fixing this would eliminate the rebuild fallback entirely for Bonterms templates, producing inline tracked changes via inplace mode.