{"operations":["base: text notes insert 0 \"Agenda:\"","A: map meta set title \"Q3 planning\"","B: map meta set title \"Q3 review\"","A: text notes insert 7 \" budget\"","B: text notes insert 7 \" hiring\""],"sample":true,"base":{"meta":{},"notes":"Agenda:"},"replicas":[{"label":"A","clientId":1,"updates":[{"operation":"map meta set title \"Q3 planning\"","bytes":32},{"operation":"text notes insert 7 \" budget\"","bytes":17}],"before":{"meta":{"title":"Q3 planning"},"notes":"Agenda: budget"},"deltaBytes":44},{"label":"B","clientId":2,"updates":[{"operation":"map meta set title \"Q3 review\"","bytes":30},{"operation":"text notes insert 7 \" hiring\"","bytes":17}],"before":{"meta":{"title":"Q3 review"},"notes":"Agenda: hiring"},"deltaBytes":42}],"converged":true,"schedules":3,"merged":{"meta":{"title":"Q3 review"},"notes":"Agenda: budget hiring"},"mergedBytes":95,"decisions":[{"target":"map 'meta', key 'title'","replicas":["A","B"],"outcome":"one value wins","detail":"A set it to \"Q3 planning\" and B set it to \"Q3 review\" while apart. One value wins: \"Q3 review\" (B's write) - every replica now holds that, and A's write is gone. A map key holds one value, picked deterministically but arbitrarily - by client id here, by random session ids in an app - and never by time. If both edits must survive, make the value a nested BcrdtText (or map) created once before people edit it, or give each writer a key of its own."},{"target":"text 'notes'","replicas":["A","B"],"outcome":"both survive","detail":"A inserted \" budget\" at 7 and B inserted \" hiring\" at 7 while apart. Every insertion survives, each as one contiguous run: every replica now reads \"Agenda: budget hiring\". Insertions at the same index are ordered by client id, the same way on every replica."}],"notes":["No operations were passed, so this ran a sample. One operation per line (or separated by ';'), as '<replica>: <type> <name> <action> <arguments>' with values in JSON - text <name> insert <index> \"text\" [{attributes}] | delete <index> <length> | format <index> <length> {attributes}; map <name> set <key> <value> | delete <key>; array <name> insert <index> <value>... | push <value>... | delete <index> [<length>] | move <from> <to>; set <name> add <value> | remove <value>. Replicas are any labels (A, B, ...), two to four of them; 'base:' lines build the state every replica starts from. A name 'root/key' is the type nested at that key of the root map 'root', created there if it is not one yet. A JSON object { \"base\": [...], \"A\": [...], \"B\": [...] } of operation lists works too.","Each replica made its edits with no connection to the others - one transaction, and so one update, per line - and then received every other replica's updates. 3 delivery orders were tried: every order the replicas could be heard in, and every update newest first, which leaves updates waiting in the pending queue for the ones they depend on. Every replica ended identical under every one of them: replicas that have seen the same updates hold the same document, whatever the order.","The replicas were given client ids 1 (A), 2 (B) so the run is repeatable. An application's are random per session, so which concurrent write wins varies between sessions - treat it as arbitrary, never as \"the last one\".","BcrdtMap: a key written concurrently keeps one value and loses the other. Fields a person types prose into belong in a nested BcrdtText - created once, before people edit it - where both edits merge.","BcrdtText: every concurrent insertion survives, each author's run contiguous. Write an input's new value with BcrdtTextSynchronizer.Apply (BcrdtTextArea does), never by replacing the whole text, or every concurrent edit is lost.","deltaBytes is what each replica sends a peer holding only the starting state - its whole session as one delta, however many updates it made; mergedBytes is the whole document encoded, what a new peer is sent. Decode any update with InspectBcrdtUpdate."]}