Skip to main content

CompareOptions

Reconstruction modes

The reconstruction mode controls how the atomizer engine builds the output document.xml.

'rebuild' (default)

Rebuilds document.xml from scratch using the comparison result. This mode is more stable for accept/reject workflows because the output XML is structurally clean. It is the recommended mode for production use. When using the MCP save tool, the fail_on_rebuild_fallback parameter has no effect when 'rebuild' is the requested mode — fallback only occurs when 'inplace' is requested and cannot be satisfied.

'inplace'

Modifies the revised document AST in place, inserting tracked-change wrappers around diffed atoms. This mode preserves more of the original XML structure (hyperlinks, SDTs, table structure) but is more experimental. If the safety checks fail, the atomizer falls back to 'rebuild' and reports fallbackReason and fallbackDiagnostics in the result.

Fallback behavior

When 'inplace' is requested but the round-trip safety checks fail, the atomizer automatically falls back to 'rebuild'. You can detect this:
To treat a fallback as a hard error, check explicitly and throw:
The MCP save tool exposes this as fail_on_rebuild_fallback: true.

ReconstructionFallbackDiagnostics

fallbackDiagnostics is populated only when the atomizer falls back. It records every inplace reconstruction pass that was attempted and the specific safety checks that prevented it from being used.

Safety checks

The atomizer runs these checks on its inplace reconstruction passes before committing the output:
A check failure means the reconstructed output could not be safely accept/rejected in Word, so the atomizer falls back.

CompareStats

CompareResult