From 1c338ef53decb0a3eda9a2a4deebfe9da010f746 Mon Sep 17 00:00:00 2001 From: tv Date: Sun, 29 Nov 2026 04:44:24 +0000 Subject: document.md: the kinds to come: merged state, ordered by clocks, a set of events --- docs/document.md | 583 ++++++++++++++++++++++++++++++++++++++++++++++++++++--- 1 file changed, 560 insertions(+), 23 deletions(-) (limited to 'docs/document.md') diff --git a/docs/document.md b/docs/document.md index addc396..65206bd 100644 --- a/docs/document.md +++ b/docs/document.md @@ -232,16 +232,34 @@ named where nodes meet, and nodes of different kinds refuse each other saying so * **Automerge**, as now: every change kept, values merged within (lists, text, counters), a history to list and read at, and remakes to shed it. -* **Merged state, without a history**: at each place its value, or the several written - at once, each write named by its writer and that writer's count; a document knows - per writer the count it has seen up to, and a write replaces what its writer had - seen. Its size is by what it holds, not by how often it was written; a slow link - skips to the newest; nothing needs remaking. Of writes at once to one place none is - chosen by a clock or by its writer's ID: all are kept and shown, and a reader wanting - one gets the one whose write has the lowest hash, till a write that saw them all. A - writer is the node, not one run of it. Lists and text are whole values at first. -* **A set of events**: bytes by their hash, added and never removed, which is what a - federation's store asks. +* **Merged state, without a history** ([below](#merged-state-without-a-history)): at + each place its value, or the several written at once, each write named by its writer + and that writer's count, and replacing what its writer had seen. Of writes at once to + one place none is chosen, by a clock, a writer's ID or anything else: all are kept, + and a reader gets them all, till a write that saw them all. A writer is the node, not + one run of it. Lists and text are whole values. +* **Ordered by clocks** ([below](#ordered-by-clocks)): at each place its newest write, + by a stamp of its node's clock; no conflicts, nothing kept per writer. +* **A set of events** ([below](#a-set-of-events)): bytes by their hash, added, and all + but what a checkpoint keeps dropped when the fold moves to one + ([`store.md`](store.md)), which is what a federation's store asks. + +What each is for: + +| | Automerge | Merged | By clocks | Events | +|---|---|---|---|---| +| Nodes | honest, or judged by a policy | honest, or judged by a policy | honest, clocks about right | parties that don't trust each other | +| Writes at once to one place | merged within, or one chosen | all kept, the reader decides | the later wins, the other gone | the fold's rule | +| Written often | no: every write is history | yes | yes | no: every write is an event | +| Its size | grows, shed by a remake | what it holds, a count per member | what it holds | grows, shed by a checkpoint | +| Deleted for good | yes | yes, among members | within the time markers are kept | the fold's | +| A history to read | yes | no | no | back to its checkpoint | +| Needs | a majority, to remake | nothing | clocks | the fold's votes, to move | + +Merged state and the one ordered by clocks name a write by its writer's word, a count +or a stamp, which a node that lies can use twice +([What others do](#what-others-do)): they are for swarms whose nodes are honest. The +set of events names by hash, and is for those whose aren't. ## Passing on @@ -322,15 +340,532 @@ and sync nothing. To see that what is asked isn't Automerge's in other words: -* **A stamp**: a digest of the count seen up to per writer. -* **A unit**: one writer's writes from one count to another, signed by it: its name the - hash of that. -* **A session**: the counts the peer has seen up to, as it said when the session began - and as what was sent since adds. The next message is what the document holds beyond - those counts, as it holds it now: a place written ten times since is sent once. A - message lost is nothing to repair: what the peer has is learned again from its counts. +* **A stamp**: a fingerprint of all it holds, the same on two nodes where they hold the + same. +* **A unit**: a write, its name the hash of its writer and count. +* **A session**: which ranges of places the two have found the same, and which they are + still narrowing down. The next message is fingerprints of ranges, or the writes of a + small one, as the document holds them now: a place written ten times since is sent + once. A message lost is nothing to repair: the range is compared again. * **In bulk**: all it holds, for a node that has nothing. -* **Units since a stamp**: by writer, the counts beyond it. +* **Units since a stamp**: what was taken since, kept in the order it came for as long + as a neighbour may ask. + +## Merged state, without a history + +Not built: the second kind, `merged`. A design to be gone over before it is. + +It is a kind for any swarm, not for one use: what it gives and what it doesn't is said +here for everything a swarm can be asked to do, a policy and a strict one among it. A +kind differs from another by what it guarantees, not by what is built on it. + +### What it holds + +* **Writes.** A write is a value at a place, by a writer, with that writer's count: the + node's ID and a number it raises by one with every write, so that the pair names the + write for good. A value is any JSON but a map: a map is the places under it. A write + of nothing is a deletion (below). +* **At each place**, the writes that count there: one, where one writer writes or each + saw the last; several, where writers wrote at once. +* **Per member, the count seen up to**: every write of that writer up to it has been + taken, or replaced by one that has. An entry per member, however much was written; + a member forgotten (`swarm::peer::forget`) is forgotten here too, once markers of its + time are ([Deleting](#deleting), below). + +Nothing else: no write that was replaced, no order of what came when. Its size is by +what it holds and how many members there are, not by how often they wrote, nor by who +ever did. + +### A write, and what it replaces + +A write says what its writer had seen where it writes: for each writer that had written +at or under the place, the count seen there. It replaces those writes, every node alike, +whatever of them a node holds: + +* a writer's later write at a place replaces its earlier ones there, also those a node + never got: so a place written a hundred times a second is passed on as its newest + write alone, and a slow link skips the rest; +* a write by another that saw it replaces it; one that didn't stays beside it, and both + count (a conflict, below); +* a write at a place replaces what its writer saw under it: writing a value where a map + was, or deleting a map, takes what was in it, and keeps what was written in it at once + by someone who hadn't seen; +* and a value its writer saw above it: writing under a place that held a value makes a + map of it. + +What a write saw at its place it has from the writes it replaces, with what they saw: +so what was seen at a place is not forgotten as its writes are replaced, and stays as +small as the number of those who ever wrote there. + +### Deleting + +A deletion is a write of nothing: it replaces what its writer saw, and stays, as a +marker that the place was emptied. A node keeps a marker for a day since it took +it, by its own clock (as long as it keeps a peer that is no member), and then drops it: +nobody is asked whether they have seen it, and nothing is written to find out. Waiting +for every member to have seen it would keep markers for as long as one member is +silent ([What others do](#what-others-do)). + +A marker is what tells a node that is behind a little, as a slow link makes it all the +time, what went, with the write that says so. It isn't what keeps a deletion true: the +counts are. + +### Seen, and gone + +A node that has seen a write and holds it no more never takes it again, whoever offers +it, marker or none: its count for the writer covers the write. And of two nodes +comparing what they hold ([Passing on, and catching up](#passing-on-and-catching-up), +below): + +* a write one holds that the other has seen and holds no more is gone, replaced or + deleted: the one drops it; +* a write one holds that the other hasn't seen is a write like any other, however old: + passed on, replacing what it saw, and beside whatever was written at its place + meanwhile (a conflict, as below). + +So nothing deleted comes back and nothing written is lost, however long a node was +away, with markers or without, for as long as the writer is a member. The counts of a +forgotten member go, a day after it was forgotten: what it wrote and nobody replaced +stays where it is; what of it was deleted, and a node away since before brings again, +is back. Forgetting a member is saying it wrote its last. + +### Reading + +A place with one write reads as its value; a map, as its places that hold something. +With several writes at once at a place, the document chooses none: a reader gets them +all, each with its writer and count, and decides. The next write by one who saw them +all replaces them all: through the API, a write at the place replaces all its node +holds there. + +So a read of such a place answers its values, not a value, and says so (`300`); a read +of a tree with such a place in it leaves the place out and says that it did, and +`?conflicts=true` lists them. What the node itself reads, a rule's who may write where +among it, takes such a place for holding nothing: the same on every node holding the +same writes, and giving no right that only one of the writes gives. + +A value where a map also holds something (one wrote a value there as another wrote +under it, neither seeing the other) is such a conflict too. + +Lists and text are values: written whole, and two edits at once conflict as two values. +Counters are not this kind's: a count is a value, written whole. + +### Passing on, and catching up + +* **A unit is a write**: taken or refused by itself. +* **Signed where the swarm asks for it**, as a change is today + ([`api.md`](api.md), [Signed changes](api.md#signed-changes)): by its writer's node, + where it writes a place the swarm lists as signed, or protocol data, so that whoever + passes it on can't change it and whoever takes it knows whose it is. Elsewhere a write + goes unsigned, taken on the word of the neighbour bringing it: in a swarm of one + operator's nodes a signature on every write buys nothing, and a pointer written a + hundred times a second pays 64 bytes and a check for each. Unlike a change, an + unsigned write is vouched for by no later one: there is no history a signature could + cover. +* **As written**, a write goes to the writer's neighbours along its tree and on, as a + change does now. +* **Where it stands**, a node says by a fingerprint of all it holds: the sum of a hash + of each write's name. Two that say the same hold the same. +* **Behind**, or ahead, or both: the two say their counts, and compare what they hold + by ranges of places ([What others do](#what-others-do)). One sends the fingerprint + of a range; where the other's is the same, the range is done; where not, it answers + with the fingerprints of the range's parts, or with the writes themselves where they + are few. A number of rounds by the logarithm of what they hold, bytes by how much + they differ; nothing kept per neighbour, nothing to know of each other before. Once + through, each has what the other held, and takes the other's counts for seen. No log + is kept to answer from, and nothing is sent twice for having been written twice. +* **A node with nothing** is behind on everything, and gets it in bulk. + +What can't be had so: a writer's counts must not have holes a peer can't account for. A +node counts on from what its document file holds, which it writes ahead of the writes +it lets out; one that lost its file takes its own count from its peers before it writes +again (writes are held till then, as a kept writer's are now). + +### Partitions + +Each side reads and writes on, as long as it lasts: nothing waits for a majority, and +no side is the one that counts. When the sides meet again, each sends what the other +lacks, and at each place: + +* written on one side only: that write, as if there had been no partition; +* written on both: both writes count, a conflict, and a reader gets both, until someone + who saw both writes again; +* deleted on one side, written on the other by one who hadn't seen the deletion: the + write stays. A deletion takes what its writer saw, no more; +* deleted on one side, untouched on the other: deleted; +* a value on one side, a map written under it on the other: a conflict too. + +A partition longer than markers are kept ends no differently +([Seen, and gone](#seen-and-gone)): the sides come out the same. + +### Judging + +A swarm of this kind says what its members are trusted with in the same three steps as +any ([`trust.md`](trust.md), [What members are trusted +with](trust.md#what-members-are-trusted-with)), by the same rules +([`access.md`](access.md), [Changes judged on every +node](access.md#changes-judged-on-every-node)): who wrote, for which user, what, where. +What differs is one thing. The rules read who may write where *as the document stood +when a change was written*, and this document holds no past. + +What decides who may write where is itself written in the document: a user's entry, a +member's, a ban, the policy, the entries of `_continuum/access`. Call a write at one of +those a write of rights. What stands in for the past: + +* **A write of rights says all its writer had seen**: of every writer, the count seen up + to. (Any other write says that only of its place.) And it is kept, a deletion too, for + as long as nothing replaces it: no marker of rights is dropped after a day. +* **A write is judged by the rights as they are**, whenever it comes. Where they refuse + it, it still stands if what refuses it had seen it: the entry that no longer gives the + right, the ban, the member's entry gone, each had seen that writer up to a count, and + the writer's writes up to that count were written before it. +* **So taking a right away holds for every write the one taking it hadn't seen**, and + what it had seen stays. Every node holding the same writes judges alike, in whatever + order they came; one that took a write before what refuses it came drops it then (as a + node drops what it took unjudged now). + +No rule does better: that nobody writes once its right is gone, and that a write made +without knowing stays, can't both hold where nodes write without asking each other +([What others do](#what-others-do)). A swarm chooses: without a policy, the node a +write is made through checks it and the others take it; with one, the cut above. + +Against a document read as it was, that is the same wherever one write came after the +other. It differs for writes made at once: + +* a write made without having seen its right taken away, on the other side of a + partition say, is refused. Read as it was, it stands: and so does everything its + writer makes later at a history from before, as far as it likes, which a document + with a history ends only by a remake + ([`access.md`](access.md), [Values signed by their + users](access.md#values-signed-by-their-users)). Here nothing is to end: a writer + can't write before a count others have seen; +* a write made before its right was given is taken once the right is there. Its writer + could write it again then anyway. + +A write refused so is out of the document, not lost: the node that made it keeps it +aside (`GET /admin/quarantine`, as a node does today with its own writes among what it +drops), for a user who may write there to put again or discard. Nobody can show that a +write was made without having seen its right taken away, the writer's word apart; so +the document doesn't take it, and a person may. + +The three steps, then: + +* **Without a policy**, nothing is judged: any member writes anywhere, a write is taken + on the word of the neighbour bringing it, signed or not. +* **With a policy**, every node judges every write as above: a member writes its own + entry; the rest as the registry lets the user the write names; a banned node nothing; + one that is no member only its own entry. With signatures required, every write is + signed by its node, and two different writes of one name prove their writer made both. +* **Strict**, the values at the places that decide who may do what, and at the paths the + swarm lists, are envelopes their users signed, as now: each names its path, its user, + the one it replaces and its number, so it needs no history to be checked, and of + several at a place the highest number counts, before anything that isn't one. That is + the one conflict the document decides, by what the users signed. The signer's key and + right are judged as above. + +What every member is trusted with whatever the step stays: reading everything, and what +it says of itself. What needed a majority of members only because of remakes (votes, the +electorate, a coordinator) isn't there: nothing in this kind waits for a majority. + +A swarm turns strict at its start. Turning a running one strict, which a remake does +for a document with a history, would be one write of rights here, signed by a key every +node was given (`--strict-keys`), naming what is kept at the signed places: it had seen +what it keeps, and what it hadn't seen is judged strictly. + +### What it doesn't do + +No history to list, no reading as it was, no change taken back but by writing again; +lists and text not merged within; no remake, as nothing gathers that one would shed. +Replacing all it holds and restoring a backup are writes. Asked for what it doesn't do, +it says so. + +### Open + +* **A tree with a conflict in it**, as under Reading: left out and said, or the whole + read refused. +* **Rights taken away**, as under Judging: that it holds for whatever the one taking it + hadn't seen, a write made at once on the other side of a partition among it. +* **Turning a running swarm strict** by one write, as under Judging, or at a start only. +* **What only grows** under a policy: the rights taken away that nothing replaced, each + with all its writer had seen. By how many users and members there ever were, not by + writes or time; and nothing sheds them yet. + +## Ordered by clocks + +Not built: a kind, `clocked`, for swarms whose nodes are honest and whose clocks are +about right. Beside `merged`, not instead: it decides what `merged` shows. + +* **A stamp on every write**: the later of its node's time and the highest stamp the + node has seen, and one more (a hybrid logical clock), then the writer's node ID. The + node's time is its clock set right by what it measures of its peers' + ([`measurements.md`](measurements.md), [Clocks](measurements.md#clocks)). So a write + made having seen another is after it, whatever the clocks say; of two made at once, + the later by the clocks is, as far as they agree; and the node ID parts only two of + one stamp. +* **At each place the newest write**, and nothing else: a write at a place replaces + what is older at it, under it, and a value above it. No conflicts, no choice left to a + reader, and of two writes at once one is gone without a word. +* **Nothing per writer, nothing per neighbour.** A write goes to the neighbours as it + is made. Where a node stands is a fingerprint of all it holds, the sum of a hash of + each place with its stamp; two nodes that differ compare ranges of places by their + fingerprints, as `merged` does + ([Passing on, and catching up](#passing-on-and-catching-up)), and each takes the + newer of what differs. +* **A deletion's marker is kept for a set time**, long (a month, say), then dropped. + After a partition longer than that, a value one side holds and the other doesn't is + kept: something deleted may be back, and nothing written is lost. +* **A write stamped further ahead** than clocks may differ is refused, saying so; one + from a node long away is as old as it is, and loses to what was written since. + +Its size is by what it holds and the markers of that time: nothing in it only grows. + +What is written often and matters only as it is now, where a pointer is, where a node +is reached, is what it is for: other systems keep such apart from their documents +([What others do](#what-others-do)). A write made at once with another and lost to it +is lost without a trace; where that matters, `merged`. And a stamp is its node's word: +among nodes that don't trust each other, no cut by time holds. + +## A set of events + +Not built: a kind, `events`, for a swarm holding a store ([`store.md`](store.md)). The +store asks nothing of what carries its events, and what makes an Automerge document +carry them is most of what a swarm holding a store has to get right +([On Automerge](store.md#on-automerge)): the changes that may write an event, the +changes that found a swarm built byte for byte, events put again where a document +lacks them, remakes and the epochs they part, a writer's two changes of one number, +the Automerge version every node must share. This kind is the store's own home, and +has none of it. + +### What it holds + +* **The store's checkpoint, the events it keeps, and the events above its heads**, each + as its bytes, named by its ID. A swarm's ID is its root's, as now. +* **Each member's entry**, written by that member alone, the one with its highest count + kept, signed with its node key: where it is reached, its group, what it speaks. An + entry of a node the fold doesn't name a member is held by nobody. +* **For a while, what its checkpoint forgot** (below). + +And nothing else: no users, no bans, no tokens of other nodes, no topology written +down, as a swarm holding a store has none today; no epochs, no records of remakes, no +acks. + +### What is taken + +An event is taken into the document where its bytes hash to its name, are no more than +the fold allows, name what they build on as the fold reads it, and all it builds on is +held; and where the fold takes it at its history, which every node judges alike. One +the fold refuses there is held by nobody. One whose history takes it and that the node +itself refuses or doesn't read (a node's own: what it took before, its operator's +drops, where it stopped) is held and passed on all the same, as the document holds it +today: so that what one node doesn't read still reaches the nodes that do. + +Who brought an event, and who put it, is nothing: no node signs for an event, and +nothing is judged by a writer. An event that waits for what it builds on waits a +bounded while, among a bounded number. + +### Passing on + +* **A unit is an event**, its name its ID; or a member's entry. +* **A stamp**: the checkpoint's ID and a digest of the heads. +* **Behind**, a node says its checkpoint and its heads: the same heads, the same + events, exactly. Heads the peer holds, it answers with what builds on them. Else the + two find what differs by ranges of the events' names and their fingerprints, as + `merged` does ([Passing on, and catching up](#passing-on-and-catching-up)), the + fingerprint a hash of the names' sum and their number + ([What others do](#what-others-do)): nothing kept per peer, and nothing a party can + make slow by the names it mints. Where the heads still differ after that, someone + made fingerprints collide, and the node asks by name, from the heads it lacks back to + what both hold. Whatever a peer answers, a node takes only events whose history it + holds whole, each after what it builds on: a peer that lies withholds, and adds + nothing. +* **Across a move to a checkpoint**: a node keeps what its checkpoint forgot for a set + time after moving, and gives it to one that is still before it, which then builds the + checkpoint itself, as every node does. After that time, a node still before it takes + the checkpoint where its operator pins it, as today after a remake + ([Pinned checkpoints](store.md#pinned-checkpoints)). +* **A node with nothing** starts from the root its operator names, or a checkpoint its + operator pins. + +### What bounds it + +Checkpoints, which the fold moves to (the federation: by a version its parties pass, +which nodes voting by themselves propose and back). What a checkpoint forgot goes after +the set time; what was refused is remembered by name only until the store moves; what +waits is bounded. Without checkpoints passed it grows, as the store does anywhere: that +is the fold's to see to, and the federation's limits on what a party writes are still +to come ([`federation.md`](federation.md)). + +### What goes with Automerge + +| Today, on Automerge | In this kind | +|---|---| +| A change judged by what it writes (`access::holding`), signed by its node | an event taken by its bytes | +| The genesis change and a fork's founding changes, byte for byte (`document::events`) | the root, and the events it keeps, as they are | +| Events put again (a change refused, a switch, a rejoin) | nothing takes an event away | +| Remakes, acks, epochs, of two epochs the lower | none: checkpoints bound it | +| A writer's two changes of one number parting documents | no writers | +| Every writer's cost in memory, a fresh one each start | no writers | +| One Automerge version for all, its bytes pinned (`federation::vectors`) | none | +| A snapshot holding the store at a base | the checkpoint is the document's | + +What the store promises ([What is promised](store.md#what-is-promised)) it promises as +now; "nothing underneath adds an event or takes one away" is then true by what the +document is, not by what is put again. + +### From an Automerge document to this + +A store is its root and its events, whatever carries them: a node of this kind reads +the same state from the same events, and builds the same checkpoints. So a swarm moves +without a new federation and without a vote. Two ways: + +* **A node of both for a while**: a release whose node can hold the store in both kinds + at once, a member of both, and takes into each what the other holds, as it puts events + again today. Operators move their nodes one at a time; once none is of the old kind, + the next release drops it for a swarm holding a store. +* **A day**: every operator starts its nodes anew in this kind, from what their + documents hold. Nodes not yet moved hear nothing until they are. + +### Open + +* How long a node keeps what its checkpoint forgot. +* Which of the two ways to move. +* Whether a swarm holding a store may still be started on Automerge once this is built. + +## What others do + +What the three kinds take from what is published, and where they part from it. + +### Naming by hash, for nodes that lie + +Kleppmann, *Making CRDTs Byzantine Fault Tolerant* (PaPoC 2022, +[doi:10.1145/3517209.3524042](https://doi.org/10.1145/3517209.3524042)), and Kleppmann +and Howard, *Byzantine Eventual Consistency and the Fundamental Limits of Peer-to-Peer +Databases* ([arXiv:2012.00472](https://arxiv.org/abs/2012.00472)): + +* An update named by the hash of its bytes, naming those it builds on, applied after + them, and judged by them alone, is taken or refused by every correct node alike, + however many nodes lie. That is an event of the store, judged at its history. +* A name made of a node and a count is the node's word: one that lies gives two updates + one name, and two correct nodes whose counts are the same hold different things, + signed or not. So `merged` and `clocked` are for honest nodes. +* Catching up: heads, then asking back by name; and a Bloom filter of what came since + the last time with that peer, which brought their measure to 1.03 round trips. + `events` keeps the heads and the asking back, and finds what differs by ranges + instead (below): a filter is state per peer, and one who mints names can fill it. +* What can be kept without nodes agreeing, however many lie, is what two writes that + each keep it also keep together. That a name is given once, that a balance stays + above nothing, and that nobody writes once its right is gone, are not: they need + agreement, which is the federation's votes, or a cut one side loses by. +* History may go where every node of a known set has delivered what follows it. They + say nothing of a node that never says so; the store's checkpoint is voted instead. + +Brocco, *Decoupling Trust in Byzantine CRDTs* +([arXiv:2606.31759](https://arxiv.org/abs/2606.31759)), on a key that was honest and +then leaked: shutting out the identity takes what it wrote before with it, and what +others built on that; a cut by time needs a clock all trust; so what was taken before +stays, named by its content, and what comes after is judged anew. How nodes come to +the same judgement it leaves open. The store has both halves: what a node took it +holds, an operator's drops and a party's keys changed by votes apart +([`store.md`](store.md), [A node's own](store.md#a-nodes-own)). + +### Until every node has seen it + +Olivier, Bauwens, Didonet Del Fabro and Gérard, *The Cost of Purity: Scalability +Challenges in the Pure Operation-based CRDT Framework* (ICSOFT 2026, +[cea-05739385](https://cea.hal.science/cea-05739385)), of a document that is a log of +operations, pruned of what later ones make redundant and compacted once every node has +delivered: + +* One silent node holds that off for good: "we do not recommend relying on causal + stability" where nodes crash. So markers are kept for a time, members are forgotten, + and a store moves by its fold's votes. +* What is pruned from the document still waits to be sent to whoever hasn't + acknowledged it, unless the one sent in its place says what it stands for: `merged`'s + write saying what it saw. +* A stamp of one entry per node on every operation, and a matrix of them to find what + all have seen. `clocked` has neither; a `merged` write names those who wrote at its + place. +* A graph of operations by hash can't be pruned: what is gone leaves holes in what the + rest builds on. A kind keeps a history or it doesn't. + +### Catching up, knowing nothing of each other + +Auvolat and Taïani, *Merkle Search Trees: Efficient State-Based CRDTs in Open Networks* +(SRDS 2019, [hal-02303490](https://inria.hal.science/hal-02303490)): a map as a search +tree whose shape its keys' hashes fix, each block named by its hash, so that two nodes +compare roots and fetch the blocks that differ, at a cost by the difference and not by +how many nodes there are or ever were. Against vector clocks it wins where writes are +rare and loses where they are many, and suggests sending each write as it is made with +the tree as the repair: push along trees, and compare when behind. It says nothing of +nodes that lie, nor of dropping the markers of what was deleted. + +Meyer, *Range-Based Set Reconciliation* +([arXiv:2212.13567](https://arxiv.org/abs/2212.13567), a draft): the same end without a +tree the two must share. Items in one order; a range's fingerprint sent; the same, +done; else the range's parts, or its items where few. Rounds by the logarithm of what +is held in the worst case, where a tree's depth is its keys' to decide. Fingerprints +that add up come from any sorted structure; a sum of hashes can be made to collide by +one who chooses the items, which honest nodes don't. `merged` and `clocked` catch up +so. + +Hoyte, *Range-Based Set Reconciliation* ([logperiodic.com/rbsr.html](https://logperiodic.com/rbsr.html)), +and Negentropy, which Nostr relays run over tens of millions of items: items by a +timestamp and a 32-byte name; a range split in 16, so three round trips for a million; +the fingerprint the names added up modulo 2^256, their number appended, hashed, 16 +bytes of it; no state on either side between messages, as the ranges are each node's +to choose. On fingerprints: XOR collides in seconds, a plain sum in about a day of +eight cores, a multiset hash on an elliptic curve not at all but slowly; the number of +items in the fingerprint and boundaries chosen at random are what it takes instead. +On the rest: a Bloom filter leaves what it wrongly takes for held, and can be filled +on purpose (shown against Automerge's sync); a tree whose shape the items fix can be +made to send everything. `events` takes that fingerprint, with the heads to tell when +it was fooled. + +### Newest wins, in each writer's own space + +Willow ([willowprotocol.org](https://willowprotocol.org): its data model, Meadowcap, +its reconciliation, and *Timestamps, really?*): an entry is a namespace, a subspace (a +writer's key), a path, a timestamp its writer claims, and the length and digest of a +payload. Of two entries of one subspace, the newer at a path removes the older at it +and under it (of one timestamp, the greater digest): the newer one stays, standing for +all it removed, and nothing else marks a deletion. Who may write where is a capability +(Meadowcap): a namespace is anyone's to write in, each in its own subspace, or one +key's, which hands out parts of it, a subspace, a path, a span of time. Nothing takes +one back: it runs out, or the owner writes over what was written with a stamp later +than the capability reaches. Nodes catch up by ranges in three dimensions, with a +fingerprint that must hold against items made to collide. + +Of its timestamps it says what holds for `clocked`: a system that relies on them being +right "is a centralised system in disguise"; this one doesn't, as any stamps give one +state on every node, and right ones give the state people expect. Exact order would +cost space by how much is written at once, and still leave a winner to pick; and any +rule that picks one can be gamed, a lowest hash by trying until one is low. What it +warns of is a stamp far ahead by mistake: it removes what is right, and nothing right +can be written under it until that time comes; so a node refuses entries stamped more +than some ten minutes ahead. `clocked` refuses alike, and its stamps follow the +highest seen, so that whoever has seen a write can always write after it. + +It is `clocked` with one thing more: a stamp competes only with its own writer's, so a +clock that lies harms its own places and no others. `clocked` has that wherever a place +is one node's to write, as in a mesh each node's is. + +For a federation it is no home. Its authority is one key or none, where a federation's +is two thirds of its parties; it has no history, so nothing is judged by the version +current when it was written, and a key that was taken away writes on with a later +stamp; votes, versions and forks would have to stand beside it, which is the fold. + +### Libraries + +Read as they stand on crates.io, none built on: + +| Crate | What it is | For us | +|---|---|---| +| `crdts` 7.3 | maps of values that merge, a clock per map and per entry, removal without markers by "the other has seen it and holds it no more", writes at once kept | `merged`'s shape, and what to test it against; its clocks never forget a writer, an operation can't be skipped, and nothing is between sending all and sending each | +| `crdt-kit` 0.5 | a last-writer-wins map by a hybrid clock | `clocked`'s shape; its stamps name a node by 16 bits, so two nodes can stamp alike, and its markers stay | +| `merkle-search-tree` 0.8 | the tree of that paper, over keys and hashes of values | a reference; it doesn't remove, and hashes weakly unless told | +| `loro` 1.19 | a document of maps, lists, text, trees, with its history | where Automerge stands, not another kind: a history, a clock entry per peer, last writer wins in maps, nothing named by hash; its trimmed snapshots shut out whoever is behind. It keeps presence apart from the document, as `clocked` is apart here | +| `diamond-types` 1.0 | text | not ours | +| `negentropy` 0.5 | Negentropy's protocol, 1 800 lines, no dependency, over a sorted list | a reference for catching up by ranges; its items are a timestamp and a name, ours a place or a name | +| `willow25` 0.7 | Willow: entries, capabilities, stores, reconciliation | a reference for `clocked`; no home for a federation | ## Stages @@ -344,8 +879,10 @@ To see that what is asked isn't Automerge's in other words: become something a kind can do. Each step leaves the tests as they are. 3. **The kind named** where nodes meet, with one kind to name: built, with the wire version (`HelloRequest::kind`). -4. **Merged state without a history**, as a second kind, with what is written often as - its test. -5. **A WireGuard mesh** as its first use: each node's key and where it is reached, - written by itself. -6. **The federation on a set of events**, where that proves the better home. +4. **A second kind**: the set of events, or merged state, or the one ordered by clocks, + with what is written often as + the test of the latter two. +5. **A WireGuard mesh** built on one of those two, as any application is on a swarm: each + node's key + and where it is reached, written by itself. +6. **The federation on a set of events** ([above](#a-set-of-events)). -- cgit v1.3.1