Skip to content

Conflict lab

The other pages show collaboration working. This one is for disbelieving it: each scenario gives two replicas the same starting point, takes them both offline, makes a specific pair of conflicting edits - the exact cases that break naïve synchronization, on a text, a list, a map and a set - and reconnects them, so you can watch what the merge actually does.

Eight scenarios

Every scenario states its expectation before you run it. The point is not that something happens, but that the stated thing happens, on both replicas, every time.

Pressing Run this scenario does five things, and the log below the tiles records each one:

  1. Seed. With both replicas connected, Replica A writes the shared starting point - a seed text, a seed list item and a seed tag - if it is not there already, and waits until B holds it too. A starting point written by each replica separately would be two look-alike values, not one shared one.
  2. Isolate. Both replicas disconnect, so neither can see what the other is about to do.
  3. Edit both. A makes its edit, then B makes the conflicting one. Without the disconnect, B's edit would come after A's rather than at the same time, which is not a conflict at all.
  4. Reconnect. The synchronization handshake sends each replica what the other is missing.
  5. Compare. The page waits until both replicas project identical state (or two seconds pass) and reports what each one holds.

Opening two replicas…

The rule behind each outcome

No scenario's result is chosen by this page: each is the merge rule of the type it edits, applied the same way on every replica, whichever order the updates arrive in.

TypeConcurrent editsWhy
BcrdtText, BcrdtArray Every insertion survives, each run in one piece, in one agreed order. A deletion removes only what its author could see. Every character or element is a block with a unique identity and the identity of what it was inserted next to, so a position is never "index 7" but "after that block".
BcrdtMap Different keys never conflict; one key keeps one value, the same one everywhere. A key holds one value. Which of two concurrent writes wins follows the order the engine integrates them in - the same on every replica, but unrelated to which was typed last.
BcrdtSet Equal values are one member; an add wins over a concurrent remove - if the add created a member. A member is keyed by its value, and a removal deletes the member it observed rather than the value for ever.

To see what a merge of your own would decide before you build on it, ask the MCP server's InspectBcrdtMerge: it runs the real engine on any set of concurrent edits by two to four replicas, in every delivery order - try one in the browser.

An unhandled error has occurred. Reload 🗙