Diffing workbooks¶
marinade diff compares two extracted IR databases — the SQLite output of
marinade extract — not two raw workbook files directly. Extract each version of
the workbook first, then diff the two databases:
marinade extract before.xlsx -o a.db
marinade extract after.xlsx -o b.db
marinade diff a.db b.db
This is deterministic and network-free: the same pair of databases always produces the same changelist.
Why compare databases, not files¶
Comparing raw formula text between two workbook versions is noisy: inserting a
row shifts every absolute reference below it, so a plain text diff reports
hundreds of "changes" for a single row insertion. marinade diff first matches
sheets and rows/columns between the two versions and re-expresses version A's
addresses in version B's coordinate space, so a row insertion is reported once —
as a row insertion — instead of as a formula change on every cell it shifted.
The changelist¶
The output is a JSON object with these top-level keys:
| Key | Contents |
|---|---|
version |
The changelist format version (currently "1.0"), not a workbook version. |
schema_version_a / schema_version_b |
The IR schema version each input database was extracted with. |
workbook_sha256_a / workbook_sha256_b |
The provenance hash of each source workbook, carried over from extraction. |
root_a / root_b |
The extraction root (sheet + range), if either database was a rooted extraction; null for a full-workbook extraction. |
summary |
Counts of changes by category — bindings added/removed/moved/resized/formula-changed, cell value/format/dtype changes, sheet and row/column edits, VBA modules and procedures, and more (see below). |
binding_map |
A flat list mapping every binding in A to its match in B (or null if added/removed), each with a diff_state of unchanged, modified, moved, removed, or added, and shifted (true when only an inserted or deleted row/column changed its address). |
changes |
The ordered list of individual changes that make up the diff. |
Each entry in changes is {"seq": <position>, "type": <change type>, ...},
where the remaining fields depend on the change type (e.g. a formula change
carries old_formula and new_formula; a resize carries old and new shapes).
Workbook edits vs. IR inference¶
Not every entry in changes represents something a person edited in the
workbook. Some of extraction's output is inferred — table-candidate
detection, binding-label evidence, binding metadata, and time-axis annotations
are all derived by the extractor's semantic layer, and can shift between two
extractions even when the cells they name were not touched. Every entry
carries a "layer": "workbook" for an edit, "ir_inference" for inference.
The inference layer is rolled up separately in summary.ir_inference_changes,
so a consumer that only cares about actual workbook edits can filter it out
rather than mistaking it for a genuine change.
Edge changes are classified per change. An edge that appeared or disappeared
because its cell's formula changed is part of that edit ("workbook"). An
edge out of a cell whose formula is unchanged is "ir_inference": nothing
edited that formula, so the extractor re-resolved it against something else
that did change. The common case is a lookup — INDEX/MATCH or VLOOKUP
resolved to the row its key currently selects — whose key changed value. The
key's own VALUE_CHANGED is the edit; the lookup's moved edges are its
consequence.
VBA changes¶
For a macro-enabled workbook, the diff also compares the VBA recorded in
vba_modules and vba_procedures. These entries are workbook edits
("layer": "workbook") and come after every other change:
| Type | Meaning |
|---|---|
VBA_MODULE_ADDED / VBA_MODULE_REMOVED |
A module (module, e.g. BatchRunner.bas) exists in only one version. Its procedures are also reported as added/removed. |
VBA_PROCEDURE_ADDED / VBA_PROCEDURE_REMOVED |
A procedure exists in only one version. A removal with "ambiguous_rename": true had several equally likely rename targets, each reported as added. |
VBA_PROCEDURE_LOGIC_CHANGED |
The body changed beyond comments, whitespace and case. |
VBA_PROCEDURE_SIGNATURE_CHANGED |
As above, and the declaration line changed (signature_a / signature_b). |
VBA_PROCEDURE_RENAMED / VBA_PROCEDURE_RENAMED_AND_MODIFIED |
The same procedure under a new name in the same module (procedure_a → procedure_b), with or without a body edit. |
VBA_PROCEDURE_COSMETIC_CHANGED |
Only comments, whitespace, case or line continuations changed. |
VBA_DECLARATIONS_CHANGED |
Module code outside every procedure changed: Option statements, Declares, module-level variables and constants. |
VBA_DECLARATIONS_COSMETIC_CHANGED |
Only comments, whitespace or Attribute lines outside procedures changed. |
Procedure entries carry module, procedure, kind, compile_branch and
the line range (lines, or lines_a / lines_b for a matched pair; 1-based and inclusive) to look the
bodies up in vba_procedures. Two branches of an #If block that define the
same procedure are compared branch to branch. summary counts them as
vba_modules_added, vba_modules_removed, vba_procedures_added,
vba_procedures_removed, vba_procedures_renamed,
vba_procedures_logic_changed, vba_declarations_changed and
vba_cosmetic_changes.
Each database records whether its VBA was read in ir_metadata key
vba_extraction (see VBA extraction). Trust the VBA_* entries
only when both sides are extracted or no_vba_project. A database extracted
by 0.5.0–0.6.x without the [vba] extra (skipped_no_oletools) has no VBA,
so diffing it against one that does reports every module as added or removed:
re-extract it first. When the key differs between the two
databases, the changelist also carries an IR_METADATA_CHANGED entry for it.
Inserted and deleted rows and columns¶
Rows and columns are aligned per sheet before anything else is compared, so an insertion or deletion is reported once, where it happened, rather than as edits to everything after it:
ROWS_INSERTED/ROWS_DELETED/COLS_INSERTED/COLS_DELETEDcarrysheet,at_roworat_col(in B's coordinates for an insertion, A's for a deletion) andcount, the number of contiguous occupied rows or columns in that block.summary.rows_inserted,rows_deleted,cols_insertedandcols_deletedcount rows and columns, not events.- A binding that lay entirely in deleted rows or columns is reported as
BINDING_REMOVEDwith"with_axis_deletion": true, and appears inbinding_mapasremoved. - A binding that only shifted because of the edit is
unchangedinbinding_map, with"shifted": true. Itsaddress_aandaddress_bdiffer by the shift; the axis event explains it. Everybinding_maprow carriesshifted, so filtering ondiff_statestill yields only what was edited, and filtering onshiftedlists what the edit pushed along. A binding that moved on its own ismoved, notshifted. - Formulas are compared as Excel rewrites them: a relative reference that
spans the inserted or deleted rows or columns is adjusted before
comparison, and so are defined names whose range shifted. What remains is
the edit's real consequences, such as a formula that read a deleted column
and now holds
#REF!.
Alignment uses each row's or column's full contents first. Where that leaves a stretch unmatched, it retries with reference offsets ignored, then with only the header labels and constants. A row or column whose contents and label both changed can still be paired with whatever sits at the same position inside the unmatched stretch.
Reference shift vs. logic change¶
A formula change (BINDING_FORMULA_CHANGED) carries a modification_kind of
either:
reference_shift— only the absolute row/column targets moved (typically because rows or columns were inserted elsewhere in the sheet); the underlying logic is identical.logic_change— the formula's actual logic changed.
This distinction matters for review: a wall of reference_shift entries after a
row insertion is expected noise, while a logic_change on a binding you didn't
touch is worth a second look.
Quoting-insensitive formula comparison¶
Excel sometimes stores the same cross-sheet reference with or without
single-quotes around the sheet name ('Sheet1'!A1 vs Sheet1!A1) depending on
how the workbook was last saved, even though nothing about the reference changed.
The diff normalizes this away before comparing formulas, so re-saving a workbook
in a different Excel build doesn't manufacture spurious formula-changed entries.
Next¶
- How extraction works — what gets diffed.
- Bindings & the graph — the unit
binding_mapand mostchangesentries are expressed in terms of. - Quickstart — the extract → document → diff walkthrough.
- CLI reference — the
marinade diffflag reference.