Table of Contents
Fetching ...

The Art of the Fugue: Minimizing Interleaving in Collaborative Text Editing

Matthew Weidner, Martin Kleppmann

TL;DR

The paper tackles the pervasive problem of interleaving in collaborative text editing using replicated lists by introducing maximal non-interleaving, a practical correctness criterion. It presents two CRDTs, Fugue and FugueMax, with FugueMax proven to satisfy maximal non-interleaving, and provides an optimized implementation whose performance rivals state-of-the-art libraries such as Yjs. The core idea relies on a tree-based representation where list order follows a depth-first in-order traversal, and insertions are anchored by leftOrigin and rightOrigin relations; FugueMax further strengthens guarantees by reversing the ordering among certain right-origin siblings. Empirically, the authors demonstrate that Fugue achieves competitive throughput and memory usage on realistic traces, supporting its practicality for real-world collaborative editors. The work also establishes a formal framework for maximal non-interleaving and discusses implications for related CRDTs and OT, outlining future work to analyze other algorithms under this stronger correctness lens.

Abstract

Most existing algorithms for replicated lists, which are widely used in collaborative text editors, suffer from a problem: when two users concurrently insert text at the same position in the document, the merged outcome may interleave the inserted text passages, resulting in corrupted and potentially unreadable text. The problem has gone unnoticed for decades, and it affects both CRDTs and Operational Transformation. This paper defines maximal non-interleaving, our new correctness property for replicated lists. We introduce two related CRDT algorithms, Fugue and FugueMax, and prove that FugueMax satisfies maximal non-interleaving. We also implement our algorithms and demonstrate that Fugue offers performance comparable to state-of-the-art CRDT libraries for text editing.

The Art of the Fugue: Minimizing Interleaving in Collaborative Text Editing

TL;DR

The paper tackles the pervasive problem of interleaving in collaborative text editing using replicated lists by introducing maximal non-interleaving, a practical correctness criterion. It presents two CRDTs, Fugue and FugueMax, with FugueMax proven to satisfy maximal non-interleaving, and provides an optimized implementation whose performance rivals state-of-the-art libraries such as Yjs. The core idea relies on a tree-based representation where list order follows a depth-first in-order traversal, and insertions are anchored by leftOrigin and rightOrigin relations; FugueMax further strengthens guarantees by reversing the ordering among certain right-origin siblings. Empirically, the authors demonstrate that Fugue achieves competitive throughput and memory usage on realistic traces, supporting its practicality for real-world collaborative editors. The work also establishes a formal framework for maximal non-interleaving and discusses implications for related CRDTs and OT, outlining future work to analyze other algorithms under this stronger correctness lens.

Abstract

Most existing algorithms for replicated lists, which are widely used in collaborative text editors, suffer from a problem: when two users concurrently insert text at the same position in the document, the merged outcome may interleave the inserted text passages, resulting in corrupted and potentially unreadable text. The problem has gone unnoticed for decades, and it affects both CRDTs and Operational Transformation. This paper defines maximal non-interleaving, our new correctness property for replicated lists. We introduce two related CRDT algorithms, Fugue and FugueMax, and prove that FugueMax satisfies maximal non-interleaving. We also implement our algorithms and demonstrate that Fugue offers performance comparable to state-of-the-art CRDT libraries for text editing.
Paper Structure (31 sections, 7 theorems, 4 equations, 10 figures, 4 tables)

This paper contains 31 sections, 7 theorems, 4 equations, 10 figures, 4 tables.

Key Result

Theorem 1

alg:tree_fugue satisfies the strong list specification of Attiya et al. attiya.

Figures (10)

  • Figure 1: Possible interleaving in a collaborative text editor.
  • Figure 2: Each user prepends items to their shopping list. When the edits are merged in an algorithm that allows interleaving of backward insertions, the result may place the items in an illogical order, such as listing bread in the fruit category.
  • Figure 3: One possible Fugue structure for the list abcdef. Observe that a and b are both left children of c; they are sorted lexicographically by their elements' IDs.
  • Figure 4: (a) Inserting a new element g between a and b. When a has no right children, making g a right child of a places it immediately after a in the traversal. (b) Inserting a second new element h between a and g. When g is a descendant of a, we make h a left child of g.
  • Figure 5: Fugue tree after executing the editing history in \ref{['fig:backward-interleaving']}. Since the two users' insertions are in separate subtrees, a depth-first traversal does not interleave them.
  • ...and 5 more figures

Theorems & Definitions (10)

  • Theorem 1
  • Definition 2
  • Lemma 3
  • Definition 4
  • Lemma 5
  • Definition 6
  • Lemma 7
  • Lemma 8
  • Theorem 9
  • Theorem 10