đź“–Melda: a general purpose delta state JSON CRDT

authors
Brocco, Amos
year
2022
url
https://doi.org/10.1145/3517209.3524039
  • designed for offline-first collaboration

  • Each object version is a revision. When multiple revisions are submitted concurrently they are called “conflicting revisions”. Only one of conflicting revisions is chosen as a “winning” revision (more or less arbitrarily using longest edit sequence and highest hash) and the rest are “discarded.” However, conflicting revisions are still accessible to application and it may “re-elect” another winner.

    • (I think this should work even better with Hybrid Logical Clock, so latest changes usually win regardless of how long edit sequence was. This works better if a node can be offline for prolonged period.)

    • each revision references its parent, so all revisions of an object form a revision tree

  • data is split between delta block and data pack. Delta block stores revision tree updates (revision ids and their parents) and data pack stores object map (map from content hash to content).

I think Melda more or less boils down to treating each object as a last-write-wins or rather a multi-value register with arbitrary conflict resolution (+ auto-flattening nested objects).

It does, however, have a custom resolution for merging arrays, though only for building a view (i.e., the underlying data still stores conflicts).

Brocco2025 adds another view-only extension for moving objects while avoiding duplication.

Backlinks