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.
