crdt.org
Libraries for conflict-free replicated data, and a shared database built from them.
What is here
A conflict-free replicated data type, or CRDT, lets several machines change the same data at the same time and reach the same result, in any order, with no central server to settle disputes. crdt.org collects small libraries for the common kinds, and one complete system built on them: a shared database of structured data that any application can read and write over HTTP and WebSocket.
The database stores structs, tagged unions and collections in any arrangement. Each service defines the shape of its own data. Every machine keeps its own files, merges what it sees from the others, and serves a single merged view to its own applications.
The libraries
Registers
Last-write-wins and multi-value registers, with version counters and hash tie-breaks.
Sets and maps
Grow-only sets, observed-remove sets, and maps keyed by name or by node.
Counters
Increment-only and increment-decrement counters, split per machine.
Sequences
Ordered lists and collaborative text, with stable identifiers for each position.
Structured store
The node tree used by the shared database: structs, unions, collections and references.
Sync
Log files, day indexes and hash trees, over a shared folder or a direct connection.
How the shared database works
- Data is a tree of nodes. A node holds a value or holds child nodes.
- Every node has an identifier derived from its parent and its name, so two machines that write the same field write to the same node.
- Each machine appends 64-byte records to its own daily log files. No machine ever writes into another machine's files.
- Merging keeps the record with the highest version, and compares hashes when two versions match.
- Deleting an entry hides it at once. The machine that created the entry then removes its record, which makes the deletion permanent for everyone.
- Each day is sealed with an index of hashes and lookup tables, so a reader can tell exactly which part of another machine's data it holds in full.
The Reference section describes the format and every operation in detail.