Example conversation

A real conversation in which several AI assistants discuss one question with each other.

Conversation topic Two users edit the same text document, each one offline, and then they sync. How should conflicts between their edits be resolved? Compare the two common approaches (operational transformation and CRDTs) for a small web app, say which one you would choose and why, and write short pseudocode for the core merge step. Cassiopeia Altair Polaris Vega Orion Lyra Atlas Sirius Nova Round 1 Cassiopeia Round 1

For a small web app where both users edit offline, the decisive constraint is the length of the offline window and the absence of a reliable sequencer. Operational Transformation assumes a central server holds the canonical order of operations; long offline periods produce large pending-operation buffers that must be transformed against every missed remote change, and the transformation functions for rich text have many edge cases. CRDTs encode merge rules into the data structure itself, so each offline replica can merge in any order without coordination and converge. 1 5

I would choose a text CRDT (Yjs) for this case. The cost is metadata overhead per character, typically 16–32 bytes for tombstones and identifiers. For a small document that is acceptable; for a large long-lived wiki, tombstone garbage collection becomes a real maintenance concern. 6 13

Core merge step with Yjs:

// each client holds a Y.Doc replica
function merge(localDoc, remoteUpdate):
    Y.applyUpdate(localDoc, remoteUpdate)
    // commutative, associative, idempotent
    return localDoc

// sync: exchange state vectors, send only missing updates
diff = Y.encodeStateAsUpdate(localDoc, remoteStateVector)

The merge is one function call because convergence is a property of the data type, not of a server-side transform pipeline. 7 11

Altair Round 1

For a small web app with two offline editors, I would pick CRDTs.

Operational Transformation (OT) requires a central server to order and transform every operation against concurrent ones; the transformation functions are notoriously hard to get right for arbitrary edits (the classic Jupiter/Wave model assumes a single authority). A CRDT (e.g., Logoot, RGA, or Yjs-style sequences) merges locally: each character gets a unique, stable identifier, and concurrent insertions converge to the same order on all replicas without any server in the loop. Deletions become tombstones, so deleting and editing the same character resolve deterministically. Libraries (Yjs, Automerge) make the cost small; building OT from scratch for a small app is disproportionate.

Tradeoffs: CRDTs carry metadata per character (memory grows if the doc keeps churning), while OT keeps the doc compact but depends on stable connectivity.

Core merge step (insert-only sequence CRDT, RaW):

# each op: {site, lamport, pos: [path of (site, t noc) ids]}
function merge(remoteOp, doc):
    remoteOp.lamport = max(remoteOp.lamport, doc.clock) + 1
    // find insertion index among existing char ids
    i = lowerBound(doc.chars, remoteOp.pos)
    if duplicate(remoteOp.id, doc.chars): return   // idempotent
    doc.chars.insert(i, remoteOp)
    doc.clock = remoteOp.lamport

Deletion adds: mark tombstone, keep the character for ordering. Tiebreak on identical lamport by site id, so both replicas never diverge. No server transform needed.

Polaris Round 1

For a small web app where users edit offline and sync, Conflict-free Replicated Data Types (CRDTs) are preferable to Operational Transformation (OT).

FeatureOperational Transformation (OT)CRDTs
ArchitectureRequires a central server to sequence and transform operations.Peer-to-peer or server-relayed; no central sequencing needed.
Offline SupportComplex; requires queuing and replaying operations through the server.Native; states merge commutatively regardless of arrival order.
ComplexityHigh; transformation functions are historically error-prone.Moderate; relies on unique identifiers and deterministic sorting.

I would choose CRDTs. They eliminate the need for a central coordinating server, making them ideal for a lightweight, offline-first web app. Each edit is tagged with a unique identifier (e.g., site_id and sequence_number), allowing deterministic merging without complex transformation logic.

Core merge step pseudocode (Sequence CRDT):

text123456789function merge(local_state, remote_state):  // Combine all characters from both states  combined_set = local_state UNION remote_state    // Sort deterministically by unique identifier to establish   // a consistent total order across all replicas  sorted_document = sort(combined_set, key=(char.site_id, char.sequence_number))    return sorted_document

This ensures that regardless of the order in which offline edits are synced, all replicas converge to the exact same document state.

Vega Round 1

For a small web app with offline edits and later sync, I would pick a CRDT (specifically, I would not write one from scratch — I'd use Yjs or Automerge). The reason is structural, not just convenience: OT requires every concurrent operation to be transformed against every other concurrent one in a globally consistent order, and getting the transformation functions right (the TP1/TP2 properties) is famously bug-prone. CRDTs move that burden into the data type itself — operations are commutative by construction, so any arrival order converges, and no central server is strictly required, which fits offline-first peer sync.

The tradeoff is overhead: CRDTs carry per-character IDs and tombstones, so memory is higher than a naive OT. For a small app that is acceptable; correctness and the lack of a coordination server win.

Quick comparison:

AspectOTCRDT
ConvergenceRequires correct transform + total orderGuaranteed by construction
ServerPractically requiredOptional, peer-to-peer works
Implementation costHigh (TP1/TP2)High from scratch, low with library
MemoryLeanTombstones/IDs overhead
Used byGoogle Docs, EtherpadYjs, Automerge, Notion

Core merge step (sequence CRDT, RGA-style), pseudocode:

text

# op: {type:'insert'|'delete', id:(clientId,seq), after:id|None, ch:char}
# doc: ordered list of {id, after, ch, tomb:bool}; applied: set of op ids

def merge(incoming, doc):
    for op in incoming:
        if op.id in doc.applied: continue
        if op.type == 'insert':
            pos = anchor(doc, op.after) + 1
            # skip siblings with same parent that sort before op.id
            while pos < len(doc) and doc[pos].after == op.after and doc[pos].id < op.id:
                pos += 1
            doc.list.insert(pos, {id:op.id, after:op.after, ch:op.ch, tomb:False})
        elif op.type == 'delete':
            mark(doc, op.id).tomb = True   # tombstone, never reorder
        doc.applied.add(op.id)
    render(doc)   # drop tombstoned chars for display only

The key property: each character has a stable unique id and a parent anchor, so insertion order is fixed by id comparison, independent of which replica received which op first. Delete is idempotent (tombstone), so duplicate delivery is harmless.

Orion Round 1

For a small web app that allows two users to edit the same document offline and synchronize later, I would choose a CRDT, specifically a sequence-based CRDT designed for text.

The key challenge is that both users may modify the same logical position while disconnected. The merge must preserve both edits, converge to the same document on both clients, and avoid requiring a central server to decide which edit wins.

Operational Transformation (OT) and CRDTs differ mainly in how they handle concurrent operations:

  • OT: Transforms one operation against another so that its meaning remains valid after concurrent changes. It is powerful for real-time collaboration but requires careful transformation logic and coordination around operation history.
  • CRDT: Assigns stable identities and ordering information to inserted elements. Concurrent insertions can coexist, and replicas deterministically converge when they receive the same operations.

For an offline-first application, CRDTs make reconnection and synchronization easier to reason about.

A simplified character-based CRDT:

Plain text

insert(id, after, char) delete(id) merge(local, remote): operations = union(local.operations, remote.operations) operations = deduplicate_by_id(operations) return rebuild_document_deterministically(operations)

Each inserted character has a unique ID and an anchor (after). Concurrent insertions after the same anchor are ordered deterministically by ID. Deletions are represented as tombstones rather than immediately removing the element.

The important caveat: this is conceptual pseudocode, not a complete text CRDT. A real implementation must handle anchor ordering, nested insertions, deletion of concurrent inserts, and compaction.

For a small app, I would use an existing CRDT library rather than invent the merge algorithm. The real advantage is reducing the number of subtle synchronization bugs that must be solved and tested.

Lyra Round 1

For a small web app where two users edit offline and then sync, I would choose a CRDT, specifically a sequence CRDT such as Yjs or Automerge, rather than operational transformation.

OT. Each edit is an operation such as insert(pos, char). When concurrent operations meet, one is transformed against the other so positions still make sense. It works well with a central server that imposes a single order. Offline editing is its weak point. Long divergent histories need many transformations, and the transformation functions are famously hard to get right. Without a central server, correctness proofs get difficult.

CRDT. Each character gets a unique, immutable ID, and edits refer to IDs, not positions. Merge is commutative, associative and idempotent, so replicas converge in any sync order, with no server arbitration needed. The costs are metadata overhead (IDs and tombstones for deleted text) and a need for garbage collection or compaction.

Why CRDT for a small app. Mature libraries exist, so you avoid writing the hard part yourself. Offline-first and peer-to-peer sync work naturally. Any server can be a dumb relay. Memory overhead is rarely a problem for documents of ordinary size.

Core merge step (RGA-style):

// each element: {id: (counter, siteId), value, deleted, origin}
function integrate(doc, newElem):
    i = indexOf(doc, newElem.origin)      // element it was inserted after
    i = i + 1
    // skip over concurrent inserts with a higher id
    while i < len(doc) and doc[i].id > newElem.id:
        i = i + 1
    doc.insert(i, newElem)

function mergeDelete(doc, id):
    find element by id
    element.deleted = true                // tombstone

function sync(localDoc, remoteOps):
    for op in remoteOps:
        if alreadyApplied(op.id): continue   // idempotent
        if op.type == "insert": integrate(localDoc, op.elem)
        if op.type == "delete": mergeDelete(localDoc, op.targetId)

The ordering rule (higher ID goes first among concurrent inserts at the same spot) is deterministic, so both users end up with identical text.

Limit and way forward. Plain-text CRDTs do not understand intent: two users rewriting the same sentence produce an interleaved result, not a “smart” merge. To handle that, show a change-history or review view, which needs only UI work on top of the stored operations.

Atlas Round 1

For offline text editing that syncs later, conflict resolution should preserve user intent and converge deterministically without losing characters.

AspectOperational Transformation (OT)CRDTs (Sequence / RGA)
CoordinationOften relies on a central server to order opsPeer-friendly and naturally offline-first
ComplexityTransformation functions get tricky across concurrent editsState/op math is clean, though tombstones add metadata

For a small web app supporting offline edits, I would choose a sequence CRDT because disconnected clients can apply local changes immediately and merge out-of-order syncs without central coordination bottlenecks.

function mergeState(localDoc, remoteDoc):
  for each item in remoteDoc.entries:
    if item.id not in localDoc.byId:
      localDoc.byId[item.id] = item
  sort localDoc.entries by (positionIndex, actorId, seq)
  return renderVisibleText(localDoc.entries)

For overlapping edits on the exact same word or sentence, deterministic merging still needs a clear UX policy—such as keeping both insertions adjacent rather than silently dropping one—so neither user feels their offline work vanished.

Sirius Round 1

Conflicts in offline-then-sync text editing are resolved by producing a single convergent document that preserves the intent of both users’ operations as far as possible, without requiring one edit to simply overwrite the other.

Operational Transformation (OT) rewrites concurrent operations against each other so that applying them in any order yields the same result. It needs carefully designed transformation functions and usually a central authority that sequences the ops. CRDTs embed enough metadata (unique identifiers, causal history, tombstones) that any two replicas can be merged by a deterministic, commutative function; no central sequencer is required.

For a small web app I would choose CRDTs. Offline support is native, the merge is local and simple to implement with mature libraries (Yjs, Automerge), and there is no need to maintain a transformation table or a single source of truth. The main cost—extra metadata—is acceptable at small scale.

Core merge step (character-level CRDT sketch):

function merge(docA, docB):
  result = empty document
  for each unique char id in union(docA.ids, docB.ids):
    if present and not deleted in either:
      insert at causal position given by the id’s left/right neighbors
    else if deleted in either:
      mark tombstone
  return result sorted by causal order
Nova Round 1

For a small web app with offline editing and later sync, I would choose a CRDT, preferably an existing text-CRDT library such as Automerge or Yjs. It merges independent offline edits deterministically without a central server ordering operations, while OT normally relies on transforming operations against concurrent edits and is simpler to reason about when a server serializes them. arxiv+2

OT versus CRDT

AspectOperational transformation (OT)CRDT
Core ideaTransform an incoming operation so it remains valid after concurrent operations. arxivGive edits stable identities and merge them in any order to the same state. automerge+1
Typical architectureUsually a central server defines operation order. offlineprotocol+1Can sync peer-to-peer or through a passive relay/server. automerge+1
Offline behaviorRequires careful operation history and transformation logic.Natural fit: edit locally, merge when connectivity returns. automerge+1
Text conflictsCan preserve editing intent, but transformation rules are subtle. arxivConcurrent inserts are preserved and deterministically ordered; concurrent deletes can remove inserted text. automerge
Small-app complexityLower if using a mature OT server/library; higher if implementing it.Lower if using a mature CRDT library; merge logic is built in. cloud.r-project+1

Choice

I would use a CRDT because the stated scenario is explicitly offline-first: two users edit separate copies and sync later. A CRDT avoids a coordination server for conflict resolution and converges once the edits are exchanged; Automerge, for example, preserves concurrent insertions and deletions in text and determines a consistent order for concurrent inserts. automerge+1

The trade-off is that a CRDT does not make every outcome intuitive: if one user deletes a sentence while another inserts into it, the insertion may remain even though its surrounding text was deleted. For a small app, expose that behavior in the UI rather than trying to build a custom semantic merge. automerge

Core merge pseudocode

# Each local edit is recorded as:
# { id, actorId, clock, type: "insert" | "delete",
#   targetId, position, character }

function apply_local_edit(doc, edit):
    doc.operations.append(edit)
    doc.text = render_visible_characters(doc.operations)
    return doc

function merge(local_doc, remote_doc):
    merged_ops = union(local_doc.operations, remote_doc.operations)

    # Remove duplicates by operation id.
    merged_ops = unique_by_id(merged_ops)

    # Apply operations in a deterministic causal order.
    ordered_ops = sort_by(merged_ops, [clock, actorId, id])

    for op in ordered_ops:
        if op.type == "insert":
            insert_character(op.character, after=op.targetId)
        if op.type == "delete":
            mark_character_deleted(op.targetId)

    merged_doc.operations = ordered_ops
    merged_doc.text = render_visible_characters(ordered_ops)
    return merged_doc

The essential property is that both clients run the same deterministic ordering and rendering over the same operation set, so their documents converge. Automerge documents that concurrent text insertions and deletions are retained, with concurrent insertions placed in the same order on every replica. automerge+1

The user replied

Test case for everyone: the starting text is "abc". User A deletes "b". User B inserts "X" between "a" and "b". What should the final text be, and why? Show how your chosen approach gets there.

Round 2 Cassiopeia Round 2

The test case exposes a real difference, and several participants' pseudocode would get it wrong.

Correct answer for the sequence CRDT: final text is "aXc". A deletes "b" by tombstoning it; B inserts X with anchor "a" (i.e. after a, before b). Merge keeps X alive and b tombstoned, and rendering drops tombstones. Both replicas converge on "aXc".

Two problems in the replies above. First, Polaris sorts all characters by (site_id, sequence_number) as a global order. That destroys positional anchors: insertion order would depend on client IDs, so "abc" and a later insert could reorder unrelated characters, not just concurrent ones. It converges, but it is not a text CRDT; it is an unordered set with a cosmetic sort. Second, Nova's merge sorts operations by (clock, actorId, id) and then inserts at position — a raw integer index. Integer positions are exactly what go stale under concurrent edits; that is OT's problem imported into a CRDT. If B's position is the index after "a" computed locally as 2 (before b), replaying after A's delete removes b and the index drifts.

Vega's and Lyra's anchor-based integrate is closer, but note the tiebreak direction must be fixed: among concurrent inserts sharing the same anchor, order by ID — and if A's delete of b and B's insert both concern that gap, the delete must reference b's ID, not an offset, or the case above still breaks.

The human-visible rule: deletions never resurrect, and an insert into deleted text survives. If the product wants "insert into a deleted sentence vanishes too", that is a separate intentional-removal feature (Yjs's delete-set semantics), not something plain RGA gives.

Altair Round 2

The test case resolves cleanly in my chosen approach. Both operations are independent element-level facts: A's delete marks the element with id of "b" as a tombstone; B's insert creates a new element X anchored after the element "a". Neither op transforms the other, so nothing is lost. Rendering skips tombstones, giving "aXc" on both replicas, and that is exactly what OT-based systems would also produce here: the insert at position 1 transformed against the delete at position 1 stays at position 1, and the delete loses its target's visible effect. The conflict in this case is nominal, not real, because the two edits touch different elements.

The interesting limit is the next step: if B had inserted X inside the string A deleted (say "bc"), a plain sequence CRDT still keeps X ("aXc" again, X surviving its deleted context). Some consider that a bug in intent terms; others consider it correct, since A deleted characters, not future neighbors' content. Automerge's docs describe this behavior for concurrent insert-and-delete. So my answer: "aXc", convergence guaranteed, and the only genuine design decision is whether resurrections of this kind are acceptable UX or need a review view (as I noted in round 1, that is a UI-layer fix on top of the same op log).

Polaris Round 2

Test Case Resolution: "abc" → A deletes "b", B inserts "X" between "a" and "b" Final text: "aXc". Why: In a sequence CRDT like Yjs, every character is assigned a stable, unique ID (e.g., id_a, id_b, id_c). User B’s insertion is anchored to the left neighbor, id_a (insert after id_a). User A’s deletion targets id_b. During the merge, the CRDT evaluates the causal structure: id_a is present, id_X is deterministically placed after id_a, and id_b is marked as a tombstone. The tombstone does not invalidate id_a as an anchor. Therefore, the visible sequence resolves to a, X, c. The deletion of b does not retroactively swallow X because X’s existence is tied to the persistent identity of a, not to a mutable numerical index.

Deepening Nova’s Observation on Semantic Intent Nova correctly noted that if one user deletes a sentence while another inserts into it, the insertion may remain. This is not a flaw; it is the fundamental guarantee of structural convergence. However, this must be deepened: structural convergence does not equal semantic correctness. For a small web app, the correct architectural response is not to hack the CRDT with heuristic "smart merge" rules (which breaks commutativity and idempotency), but to handle the gap at the UI or schema layer. Options include:

  1. Exposing the interleaved state via a conflict-resolution UI (e.g., a "review changes" modal showing the tombstoned context).
  2. Using block-level or paragraph-level CRDTs instead of character-level ones, so the unit of conflict is larger and easier for a user to resolve manually.

Refining Altair and Lyra’s Point on Tombstones Altair and Lyra accurately identified tombstones as a memory tradeoff. I will refine this by emphasizing that tombstones are not merely a cost; they are the structural mechanism that makes the test case work without central coordination. If id_b were physically removed from the data structure, any operation anchored to id_b (e.g., inserting before b) would lose its reference, leading to divergence or complex fallback logic. Therefore, garbage collection (GC) in Yjs must be handled with extreme caution: enabling GC prematurely breaks the ability to sync with offline clients that still reference those tombstones in their pending state vectors. For a small app, the 16–32 bytes per character is a mathematically necessary price for guaranteed offline sync, not just an implementation detail.

Addressing Vega’s TP1/TP2 Complexity Point Vega highlighted the difficulty of getting OT transformation functions (TP1/TP2 properties) right. I will add that this complexity compounds exponentially in offline-first scenarios. In OT, an offline client must replay its entire operation history against every single remote operation received upon reconnection, requiring a persistent, ordered history buffer on the client. CRDTs bypass this entirely: the Y.applyUpdate function is strictly O(N)O(N)O(N) relative to the size of the incoming delta, regardless of how long the offline window was, because the merge logic is encapsulated in the data type’s identity rules, not in a historical transformation pipeline.

Vega Round 2

Test case: final text is "aXc", and my round-1 pseudocode produces exactly that.

Walking through it. Characters carry IDs, say a=(A,1), b=(A,2), c=(A,3). User A emits delete(targetId=(A,2)). User B emits insert(id=(B,1), after=(A,1), ch='X'). On merge, the insert runs first: anchor(doc, (A,1)) returns index 0, so pos starts at 1; no sibling of 'a' with id < (B,1) exists, so X lands at index 1 — doc is a, X, b, c. The delete then tombstones b. render() drops tombstoned chars → "aXc".

Why this is the right answer: X is anchored to 'a', which still exists, so X keeps its intended place. The delete of 'b' cannot retroactively move or kill X. This is also the CRDT footgun Lyra and Nova flagged — if X had been anchored after 'b' instead of after 'a', X would survive but sit stranded next to the deleted word, which is correct by the rules but unintuitive to users. The test case is the benign variant of that problem.

One real disagreement. Polaris's merge that sorts the whole character set globally by (site_id, sequence_number) is not a valid sequence CRDT — it destroys causal structure. Two insertions at totally different anchors would be ordered purely by id, not by where the user put them. Every real text CRDT (RGA, Logoot, LSEQ) orders by anchor plus a tiebreak on id, never by a global id sort. That is the whole point of the after field in my pseudocode.

For completeness: OT also yields "aXc" here, but only because the transform function explicitly shifts the delete index past the concurrent insert. Same outcome, earned by code rather than by the data type.

Orion Round 2

The test case exposes an important distinction that several of the pseudocode sketches obscure: a deterministic merge is not necessarily a semantically correct merge. In particular, sorting all characters globally by (site_id, sequence_number) or (clock, actorId) is insufficient to reconstruct text order. A sequence CRDT needs positional relationships, causal context, and a well-defined rule for ordering concurrent siblings and descendants.

For abc:

  • A deletes b.
  • B inserts X between a and b.

In an RGA-style CRDT, B's insertion is anchored to a (or to the left neighbor), and A's deletion targets the stable ID of b. The insertion and deletion affect different element IDs, so the deletion does not erase X.

Using a two-sided positional reference (between a and b), the intended merged result is:

Plain text

aXc

  • b remains as a deleted structural element (tombstone).
  • X survives because it is a separate insertion.
  • c survives and retains its original relative order.
  • Both replicas converge after exchanging updates.

However, the exact placement of X relative to c depends on the CRDT's sibling-ordering and anchor semantics. A CRDT guarantees convergence, not necessarily the intuitively preferred result. That is why this test is useful for checking the actual library behavior, not just the theoretical merge.

Lyra Round 2

Test case result. The final text is “aXc”, because A’s deletion targets the character with ID b and B’s insertion is anchored to the character with ID a. The two edits touch different elements, so they do not conflict.

Trace in the RGA-style CRDT from my first answer:

initial:   a(1,s0)  b(2,s0)  c(3,s0)

A (offline): mergeDelete(b)        -> a  b[tomb]  c
B (offline): insert X(1,sB) origin=a
             i = indexOf(a)+1 = 1
             doc[1] is b, b.id (2,s0) > X.id (1,sB)? yes, so skip
             -> insert X after b
             -> a  b  X  c

This surfaces a problem in my first-round code. The skip loop must only skip siblings, meaning elements whose origin is also a. Element b does have origin a, so skipping it is correct here, and X lands after b. Because the tie-break depends on the ID order, a different ID assignment could put X before b. Either way the visible result is the same once b is a tombstone.

sync at A: integrate X (origin a) -> a  b[tomb]  X  c
sync at B: mergeDelete(b)         -> a  b[tomb]  X  c
visible text on both: "aXc"

Both replicas end with the same element list, so they converge. The order of syncing does not matter.

Why not “ac” or “abc”? OT reaches the same answer only if it transforms B’s insert position. B’s insert(1, X) must be shifted against A’s delete(1) so it stays at position 1, giving “aXc”. A CRDT gets there without any transformation because IDs never shift.

Problems in other replies.

Polaris and Atlas sort the union by (site_id, sequence_number) or by a position index. That does not preserve document order. It would place all of one user’s characters before the other’s, so “aXbc” could become scrambled text. A sequence CRDT needs an origin or anchor per element, as Vega and I used.

Nova sorts by clock, which breaks causality: an insert anchored to a character could be processed before that character exists.

Yjs’s actual rule is similar to what Cassiopeia described, with origin and right-origin, which also prevents interleaving of concurrent runs.

Atlas Round 2

For the human operator's test case, the final text should be "aXc". Both actions target different elements—User A removes "b", while User B inserts "X" relative to "a"—so preserving both intentions yields "aXc".

In a sequence CRDT (like the RGA-style structures described by Vega and Lyra), each initial character has a stable ID: a (id:1), b (id:2), c (id:3).

  • User A marks id:2 ("b") with deleted = true (a tombstone).
  • User B inserts "X" (id:4) with after = id:1 ("a").
  • When merging, id:4 anchors right after id:1, and id:2 remains in the internal list as a tombstone for structural anchoring, yielding [a, X, (b-tombstone), c]. Rendering visible characters gives "aXc".

Notice a key distinction across Round 1's pseudocode: Polaris and my initial snippet sorted solely by global ID/position tuples, which fails to preserve relative adjacency when inserts happen after specific characters. Anchoring each insert to a predecessor ID (after/origin), as Vega and Lyra showed, is essential so "X" stays anchored after "a" even when "b" becomes a tombstone. Meanwhile, as Nova noted, if User B had anchored relative to "b" instead of "a", "X" would still survive next to the tombstoned "b" rather than vanishing.

Sirius Round 2

The test case yields "aXc". In a sequence CRDT the original characters carry stable IDs. User A’s delete places a tombstone on b’s ID; User B’s insert creates a new character X whose origin/anchor is a (or the position between a and b). On merge the union of operations is taken, duplicates are discarded by ID, and the deterministic total order (causal parents plus ID tie-break) places X immediately after a while the tombstone hides b, producing "aXc". Both replicas reach the identical visible string without a server deciding a winner.

Most participants correctly favour CRDTs and libraries; the simplistic total-order-by-(site,seq) shown by Polaris is insufficient. Pure site/sequence sorting can violate causality when inserts nest or when a later insert references an earlier concurrent one. Anchor-based placement (RGA/Yjs style) or fractional indices plus causal history are required for the merge to remain intention-preserving under arbitrary offline interleaving.

The same mechanism also explains why concurrent rewrite of a whole sentence often interleaves rather than “smart-merges”: the CRDT only guarantees convergence, not semantic intent.

Nova Round 2

The final text should be aX.

User A’s delete targets the existing character b; User B’s insert creates a new character X anchored after a. These are independent operations: A never deletes X, and B never reinserts b. A sequence CRDT therefore keeps X and marks b as deleted.

Initial: a b

A: delete(id_b)          -> b becomes a tombstone
B: insert(id_X, after=a) -> X is added after a

Merge operations:
[a, X, b(tombstoned)]

Render visible characters:
aX

This matches the CRDT rule several participants described: deletion is a tombstone on a stable character ID, while insertion is tied to an anchor, not a numeric offset. The result is deterministic regardless of sync order: if A receives B’s insert first, b is still deleted; if B receives A’s delete first, X is still inserted after a.

I would add one qualification to Polaris’s and Atlas’s pseudocode: sorting all characters simply by (site_id, sequence_number) is not sufficient. The sort must respect the insertion ancestry/anchor first, then use a deterministic tie-breaker among concurrent insertions sharing the same anchor. Otherwise, characters inserted at different times and places could be reordered incorrectly.

The important UX point is that aX is correct convergence, but it may surprise a user: B inserted “between a and b,” and after A deleted b, the phrase is now simply “between a and X.” The system should show that b was deleted concurrently rather than presenting the merge as an ordinary sequential edit.

Round 3 Cassiopeia Round 3

Two points still open. First, Nova's answer "aX" drops the "c" — the starting text is "abc", and c is untouched by either edit. The correct result is "aXc". This is not a tiebreak dispute; it is a trace that lost an element, which is exactly the kind of error a test case is meant to catch.

Second, Lyra's trace exposes a real subtlety rather than a bug. When B inserts X anchored after a, the skip loop passes over b because b's origin is also a and b.id sorts before X.id. Whether X lands before or after b is an ID-order decision with no visible consequence here, since b is tombstoned either way. That is the correct reading: sibling ordering only matters among surviving concurrent inserts, and the visible result is invariant under it as long as tombstones render hidden.

The remaining design question is not convergence — every anchor-based scheme above converges — but what "preserve intent" means when the anchor survives and the anchor's right neighbor is deleted. Altair framed it as a UX choice; I'd sharpen it: the CRDT must never decide, because any rule that makes X vanish when its right neighbor dies requires X's existence to depend on a mutable fact, which reintroduces the coordination the CRDT was chosen to remove. So "aXc" is not merely convergent, it is the only result consistent with choosing a CRDT at all. If the product wants "X disappears with the deleted b", that must be an explicit delete-set or block-replace operation recorded in the log, not an emergent merge rule.

Altair Round 3

Nova's answer contains a slip worth flagging before the summary: he starts from "abc" but his trace, his internal list, and his final render all show only "a and b". The "c" vanishes without any operation touching it. The correct merge result is "aXc", not "aX": if a replica returned "aX" here, that would be a convergence or render bug, since no op deleted c. His structural logic (X anchored to a, b tombstoned) is otherwise right.

On the remaining point of contention, the internal placement of X: Lyra's trace lets X land after the still-present b (giving a, b[tomb], X, c), while Vega's give says a, X, b[tomb], c. Both render "aXc", so the test case hides the difference, but the difference is real and worth specifying: in genuine RGA, X's origin is a and b's origin is also a, so the sibling rule decides, and a fixed tiebreak such as comparing (counter, siteId) must be stated, not left implicit. Yjs uses origin plus right-origin plus client-id ordering, which also prevents the interleaving failure mode (one user's "hello" and the other's "world" producing "hwoerllod") that naive per-character CRDTs suffer. That interleaving guarantee, not the abc toy case, is the actual acceptance test a small app should run before shipping.

Polaris Round 3 No response in this round. Vega Round 3

Two corrections and one pushback.

Nova's "aX" drops 'c' from the document. The initial state was "abc" — three characters, not two. 'c' is untouched by either edit (A deletes b, B inserts X after a), so it must appear in the result. The correct visible text is "aXc", as every other participant concluded. This is not a CRDT question; it is reading the test case.

On Lyra's tiebreak concern: yes, the internal placement of X relative to tombstoned b depends on the ID scheme. With site-prefixed Lamport IDs, b=(A,2) typically sorts before X=(B,1), so internally you get a-b-X-c; with a different scheme X could land before b. But this ambiguity is invisible to the user — once b is tombstoned, both placements render as "aXc". The visible output is invariant under ID-scheme choice for this case, which is exactly what convergence should mean. Lyra flagged the right subtlety but understated the payoff: the tiebreak direction matters for the internal list, not for the rendered text, as long as the tombstone rule is consistent.

One pushback to Cassiopeia. Yjs does not have "delete-set semantics" that swallow concurrent inserts anchored to deleted text. Yjs's delete set is simply the set of tombstoned character IDs — semantically identical to plain RGA. If you want "insert into a deleted sentence vanishes too", you must build that at the application layer (for example, a delete-range op that re-deletes concurrent children on sync, or a UI review step). Neither Yjs nor Automerge cascades deletes to anchored inserts natively, so framing it as a built-in Yjs feature overstates what the library gives you.

Orion Round 3

The remaining disagreement about the test result is between Nova's aX and everyone else's aXc. Nova appears to have accidentally omitted c from the initial document in its trace. The stated starting document is abc, and neither operation targets c, so c must survive. The correct result is aXc, not aX.

There is also a subtle issue in Lyra's trace worth correcting. She demonstrates X being placed after the tombstoned b, then says the visible result is aXc. That outcome is possible, but her pseudocode's sibling ordering is insufficient to guarantee it for arbitrary insertion patterns. RGA ordering involves recursively traversing insertion descendants; simply skipping siblings in a flat list can place later insertions incorrectly.

The general lesson from this test is that we should separate three properties:

  1. Convergence: replicas eventually hold the same state.
  2. Preservation: concurrent edits aren't silently lost.
  3. Placement semantics: inserted text appears in the intended logical location.

A CRDT library can guarantee the first two while the third still depends on its specific sequence-ordering algorithm. That distinction is critical when choosing a library for real text editing.

Lyra Round 3

Correction to my round 2 trace. I gave X the ID (1, sB), which is lower than b’s (2, s0). That is not realistic. In RGA and Yjs, each replica’s logical clock advances past every ID it has seen. B saw a, b and c, so X gets a counter of at least 4, higher than b’s. The skip loop therefore does not skip b, and X lands directly after a:

B local:   a  X(4,sB)  b(2)  c(3)
A local:   a  b[tomb]  c
sync A:    integrate X origin=a -> i=1, doc[1]=b has id 2 < 4, stop
           -> a  X  b[tomb]  c
sync B:    delete b -> a  X  b[tomb]  c
visible:   "aXc" on both

The visible result is unchanged, but the internal order is now the one B intended: X between a and b. Vega’s walkthrough was already right on this.

Remaining disagreement.

Nova’s “aX” is wrong. The starting text was “abc”, and nothing in either edit touches c. Nova’s own rule (deletes tombstone only the targeted ID) gives “aXc”. The error is in the initial state “a b”, not in the CRDT.

Orion hedges that X’s placement relative to c depends on sibling semantics. It does not here. X’s anchor is a, and c’s anchor is b, so X cannot sort after c. Sibling tiebreaks matter only when two inserts share the same anchor.

Polaris’s claim that garbage collection breaks offline clients is correct. Safe collection needs every replica to confirm it has seen the delete. For a small app, I would simply keep tombstones until a snapshot-and-compact step, and not enable early GC.

Atlas Round 3

Two distinct issues remain in Round 2 that need correction before summarizing:

  1. Nova's omitted character: Nova traced the initial text as "a b" and concluded "aX", inadvertently dropping the trailing "c" from the operator's "abc" prompt. With "c" included, all models converge on "aXc".
  2. Yjs/YATA two-sided anchoring vs. RGA single-anchor: While Vega and Lyra highlighted left-anchoring (after/origin), Cassiopeia and Lyra rightly alluded to Yjs's dual-origin model (origin and rightOrigin). In a real sequence CRDT like Yjs (YATA), inserting "X" between "a" and "b" records both leftOrigin = id_a and rightOrigin = id_b. Using both bounds prevents character interleaving when two users type multi-character words simultaneously at the exact same gap—a classic failure mode of pure single-anchor RGA where concurrent words can weave together like hweolrllod.

Finally, as Polaris noted, tombstones cannot be safely garbage-collected until all offline peers have synced past that state vector—meaning a small web app must either avoid aggressive GC or force a full state reset if a client stays offline beyond a retention window.

Sirius Round 3

The remaining disagreement is not the visible string—“aXc” is settled—but what the CRDT is allowed to do with an insert whose surrounding context was concurrently deleted. Plain RGA/Yjs-style structures keep the insert; they treat the anchor’s survival as sufficient. Cassiopeia’s observation is exact: suppressing that insert requires an extra intentional-removal layer (delete-set or context-tracking) that is no longer a pure CRDT merge. Adding it risks breaking commutativity unless the extra metadata itself forms another CRDT.

For a small web app the practical decision is therefore library choice, not hand-written merge rules. Yjs keeps the insert by default and exposes the tombstone set for UI review; Automerge does the same. Either lets the product surface “X was inserted into text that was deleted offline” without altering the core merge. Global site/sequence sorting (still visible in some earlier sketches) remains incorrect because it discards those anchors; any remaining disagreement on that point is settled by the requirement for causal parent pointers.

Thus the core merge stays the simple apply-update; the only open design question is the UI policy layered on top of the surviving insert.

Nova Round 3

Cassiopeia and Lyra are right about my round-1 merge: sorting operations by (clock, actorId, id) and inserting at integer positions is not a valid sequence-CRDT merge. It can process an insert before its anchor exists and can use a stale numeric index after a concurrent deletion. The correct core is anchor-based integration: an inserted element records its origin (and, in Yjs-like designs, a right origin), while deletion targets a stable element ID.

For the test case, the corrected result is aXc:

a=(A,1), b=(A,2), c=(A,3)

A: delete(target=(A,2))              -> tombstone b
B: insert(id=(B,1), origin=(A,1))    -> X after a

Integrated structure:
a, X, b[tombstone], c

Visible text:
aXc

The disagreement is now narrower: not whether the answer is aXc, but what a minimal correct merge must contain. It needs at least:

  • Stable IDs for inserted characters.
  • A left anchor/origin, not a numeric index.
  • A deterministic rule for concurrent siblings at the same anchor.
  • Tombstones retained long enough for late-arriving operations to resolve.
  • Rendering that hides tombstones rather than physically removing them.

I would also distinguish the two “delete” cases that Cassiopeia raised. Deleting b while B inserts after a is benign. But if B inserts immediately after b, plain RGA semantics leave X alive beside the tombstone. That is not a convergence failure; it is a product decision. A small app can either accept it, show a review surface, or adopt a higher-level deletion model that explicitly marks a deleted range and applies a policy to later insertions within it.

Round 4: Final summaries Cassiopeia Round 4

Position: for a small offline-first web app, use a sequence CRDT through a mature library (Yjs or Automerge), not OT and not a hand-written merge. My reasoning stands: anchor-based CRDT convergence needs no central sequencer, and OT's transformation functions plus client-side replay history are the wrong burden at this scale.

It was agreed that the operator's test case resolves to "aXc": A tombstones b by its stable ID, B's X is anchored after a, and rendering hides the tombstone. Nova's "aX" was corrected by Nova itself as a trace error that dropped c. It was agreed that sorting characters globally by (site_id, sequence_number) or replaying integer positions is not a valid sequence-CRDT merge, because it discards causal anchors; anchor plus a deterministic sibling tiebreak (Yjs uses origin, right-origin and client ID) is required. It was agreed tombstones must be retained for unsynced offline peers, so garbage collection waits on full state-vector acknowledgement or a snapshot step.

Remaining difference is scope, not convergence: whether an insert anchored to concurrently deleted text should survive. Plain RGA/Yjs keeps it; suppressing it needs an explicit removal layer, which is a product decision on top of the merge.

Information not provided (estimated for the analysis): none — all requested information was provided.

Altair Round 4

Final summary:

My position is unchanged: for a small offline-first web app, choose an existing CRDT library (Yjs or Automerge) over OT. It was agreed across all participants that OT needs a central sequencer and transform functions that are hard to get right, while CRDTs converge from any merge order without coordination; the agreed cost is per-character metadata and tombstones, which for small documents is acceptable. On the operator's test case it was agreed the correct result is "aXc": A's delete tombstones b by stable ID, B's insert is anchored to a, c survives untouched, and any replica returning "aX" has a trace or render bug. It was also agreed that global sorting by (site_id, sequence_number) or by numeric positions is not a valid sequence CRDT, because it discards anchors and causality.

Disagreements raised and resolved: Lyra corrected her skip-loop trace after noting realistic Lamport clocks; Nova corrected his merge to anchor-based integration, so the earlier round-2 divergence (his "aX") is settled. One point was raised only late and stands unrefuted: it was disputed whether Yjs's delete-set semantics can make an insert vanish with deleted context; Vega argued they cannot, that this requires an application-layer removal op, and no participant contested that. The surviving open design question is UI policy for inserts stranded inside deleted text, not the merge itself.

Information not provided (estimated for the analysis): all the requested information was provided.

Polaris Round 4

It was agreed that the correct result for the test case is "aXc". Nova’s initial "aX" conclusion was corrected as a trace error that inadvertently omitted the untouched "c".

It was agreed that sequence CRDTs (like Yjs or Automerge) are the optimal choice for offline-first small web apps, as they guarantee convergence without a central sequencer, unlike Operational Transformation. The core merge mechanism must rely on stable unique IDs, anchor-based insertion, deterministic sibling tiebreaking, and tombstones for deletions.

I updated my position to explicitly favor Yjs’s dual-origin (YATA) model over pure single-anchor RGA, as highlighted by Cassiopeia and Atlas, because tracking both left and right origins prevents multi-character interleaving failures during concurrent edits.

It was agreed that tombstone garbage collection is hazardous for offline clients and should be avoided or strictly gated in small applications to prevent sync divergence.

The only remaining nuance is semantic intent: concurrent inserts natively survive if their surrounding context is deleted. It was agreed this is not a CRDT flaw, but a product-level concern to be resolved via UI review surfaces or higher-level block operations, rather than altering the foundational merge logic.

Information not provided (estimated for the analysis): All requested information was provided.

Vega Round 4

Final position. For a small offline-first web app where two users edit offline and sync later, choose a CRDT (Yjs or Automerge) over Operational Transformation. OT's transform functions and reliance on a central sequencer are disproportionate for peer sync; CRDTs make convergence a property of the data type. The tradeoff — per-character metadata and tombstone retention — is acceptable at small scale.

Agreed across the discussion:

  • All nine participants converged on CRDT over OT for this scenario.
  • The test case ("abc", A deletes b, B inserts X between a and b) yields "aXc". Nova's initial "aX" omitted c from the initial state; Nova corrected this in round 3.
  • Global sort by (site_id, sequence_number) is not a valid sequence CRDT; anchor-based ordering is required. Polaris and Atlas conceded their round-1 snippets on this point.
  • Insertions anchored to a surviving character survive even if their right neighbor is concurrently deleted. Suppressing them requires application-layer intent tracking, not native CRDT behavior. Cassiopeia's framing of "Yjs delete-set semantics" as a built-in feature was corrected — Yjs's delete set is tombstone tracking, semantically identical to plain RGA.
  • Tombstones cannot be garbage-collected until all replicas confirm receipt; small apps should defer GC or snapshot-and-compact.
  • Yjs's dual-origin (origin + rightOrigin) prevents character interleaving in concurrent multi-character runs — the real acceptance test beyond toy cases.

Disagreement remaining. Effectively none on substance. ID-scheme details (Lamport vs site-prefixed) affect the internal placement of X relative to tombstoned b but not the visible result, as Lyra's round-3 correction confirmed; my round-2 trace reached the same visible outcome via a slightly different ID assumption.

Information not provided (estimated for the analysis): all the requested information was provided.

Orion Round 4

Final summary

My position remains that a sequence CRDT, using a mature library such as Yjs or Automerge, is the best choice for a small offline-first web application with two editors. It supports disconnected editing, deterministic convergence, and synchronization without requiring a central operation sequencer.

Agreements reached:

  • CRDT is the preferred approach for this scenario.
  • Stable element IDs and positional anchors are essential; global sorting by site ID or numeric position alone is incorrect.
  • Concurrent insertions must be deterministically ordered.
  • Deletions should target stable IDs, and tombstones preserve structural references.
  • Convergence does not guarantee semantic intent; UX may need conflict review.

Test case outcome: Starting with abc, A deletes b while B inserts X between a and b. The correct visible result is aXc. Nova's aX was a trace error because c was omitted.

Remaining nuance: The internal placement of X around the deleted b depends on the CRDT's ordering rules. The visible result is the same here, but more complex concurrent insertions require testing sibling ordering and multi-character runs.

Information not provided (estimated for the analysis): No additional information was requested from the human operator.

Lyra Round 4

Final summary (Lyra).

Position. For a small offline-first web app I would use an existing sequence CRDT library (Yjs or Automerge) and would not hand-write the merge. I did not change this position during the discussion.

Agreed.

  • It was agreed that the test case (“abc”, A deletes b, B inserts X after a) yields “aXc” on both replicas.
  • It was agreed that Nova’s round-2 “aX” dropped the untouched c, and Nova corrected it in round 3.
  • It was agreed that sorting all characters globally by (site, sequence) or (clock, actor), as in Polaris’s, Atlas’s and Nova’s first sketches, is not a valid sequence CRDT. A correct merge needs stable IDs, a left anchor (origin) rather than an integer index, a deterministic tiebreak among siblings at the same anchor, and tombstones that stay hidden at render time.
  • It was agreed that OT reaches “aXc” only by explicitly shifting positions, while the CRDT gets there through immutable IDs.
  • It was agreed that tombstones cannot be garbage-collected until all offline peers have synced past them.

Corrections I made. In round 3 I fixed my own trace. X receives a counter above every ID its replica has seen, so X lands directly after a. The visible text is the same either way.

Remaining disagreement.

  • Orion argued that a flat sibling-skip loop like mine is not a full RGA, which needs a tree traversal over descendants. Polaris described the same tree structure. This was not resolved, and my pseudocode is a sketch.
  • Atlas and Altair favor Yjs-style dual origins (left and right) to prevent interleaving of concurrent multi-character runs. Others discussed only a single anchor.
  • It was not resolved whether suppressing an insert into concurrently deleted text belongs in the library or in a UI or application layer. Vega noted that neither Yjs nor Automerge cascades deletes natively.

Information not provided (estimated for the analysis): all requested information was provided, since no questions were asked of the human operator.

Atlas Round 4

Position For a small offline-first web app, a mature sequence CRDT library (such as Yjs or Automerge) is preferable to Operational Transformation (OT) because it enables deterministic, server-free convergence via stable element IDs, causal anchors, and tombstones. Based on the discussion, I updated my initial naive sorting pseudocode to anchor insertions to predecessor/successor element IDs rather than sorting solely by global position/ID tuples.

Agreements

  • Technology choice: Sequence CRDTs outperform OT for offline-first small apps because OT requires central sequencing and complex transformation functions (TP1/TP2) across long offline buffers, whereas CRDT merges are commutative and idempotent.
  • Data model & GC: Valid sequence CRDTs require causal anchors (origin/rightOrigin), deterministic sibling tie-breaking, and retained tombstones (with deferred garbage collection until all offline peers sync).
  • Test case: Starting from "abc", deleting "b" and inserting "X" between "a" and "b" converges on "aXc" (Nova corrected their earlier "aX" slip).

Remaining Disagreements

  • Intent vs. structural convergence: Whether surviving insertions inside concurrently deleted regions should be handled purely at the UI layer (review views) or via higher-level range-deletion rules—and whether Yjs natively provides cascading delete-set semantics (disputed between Cassiopeia and Vega).

Information not provided (estimated for the analysis): all the requested information was provided.

Sirius Round 4

Final position remains unchanged: for a small offline-first web app, choose an existing sequence CRDT (Yjs or Automerge). OT’s transformation pipeline and central sequencing are disproportionate and fragile under long offline windows. The core merge is simply applying the remote update; convergence is a property of the data type.

It was agreed that the human operator’s test case (“abc”, A deletes “b”, B inserts “X” between “a” and “b”) yields the visible string “aXc”. Anchors plus tombstones produce this result deterministically; pure global sorts by (site, sequence) or integer positions do not. Concurrent inserts whose context is later deleted survive by design; any policy that suppresses them must be an explicit higher-level operation or UI review layer, not part of the CRDT merge itself.

What remains is only implementation detail: the exact internal ordering of a surviving insert relative to a concurrent tombstone (invisible after rendering), and the retention window before tombstone garbage collection. Both are settled by the chosen library’s documented rules rather than by further debate.

Information not provided (estimated for the analysis): all the requested information was provided.

Nova Round 4

My position: for a small offline-first web app, use a mature sequence CRDT library such as Yjs or Automerge rather than implementing OT. The discussion corrected my round-1 pseudocode: a merge must use stable IDs and causal anchors, not integer positions or a global (site, sequence) sort. The correct result for the test case is aXc, not aX; I omitted the untouched c in my trace.

It was agreed that:

  • OT transforms concurrent operations and commonly relies on a central sequencer; CRDTs merge replicas deterministically without that coordination.
  • For abc, A’s deletion of b and B’s insertion of X after a affect different elements, so both survive: b becomes a tombstone and the visible result is aXc.
  • A valid text CRDT needs stable element IDs, left-origin anchoring, deterministic sibling ordering, and tombstones retained until safe compaction.
  • CRDT convergence does not guarantee semantic intent: an insertion into concurrently deleted context normally survives.
  • A product that wants such insertions to disappear needs an explicit application-level delete-range or review mechanism, not an implicit CRDT rule.

Remaining disagreement concerns implementation details rather than the outcome: whether a single left anchor suffices or Yjs-style left and right origins are preferable, and how aggressively tombstones may be garbage-collected. I would use Yjs-style two-sided anchoring and conservative compaction.

Information not provided (estimated for the analysis): the app’s document size, expected offline duration, number of concurrent users, and whether semantic conflict review is required.

The discussion ended (all rounds completed). Asking Rigel for a summary. Conversation stopped
Back to the example conversations