Follow-up to #37. The starter set (GCounter, PNCounter, GSet, ORSet, LWWRegister) covers the canonical scenarios. Akka's `ddata` ships several more that pull their weight in real workloads — same-shape merge functions, just composed differently.
To add:
- LWWMap<K, V> — map of LWWRegisters; each value carries its own `(timestamp, replicaId)`. Pattern: per-key feature flags, per-user settings.
- ORMap<K, V extends Crdt> — map of CRDTs; per-key add-wins semantics. Pattern: shopping carts where each cart is itself an ORSet of items.
- MVRegister — multi-value register that retains every concurrent assignment instead of arbitrating. Reader sees the set of "currently competing" values and decides resolution at read-time (e.g. show user a conflict UI).
- GCounterMap — per-key grow-only counter. Pattern: per-tag event counts, per-route hit counter.
Components:
| File |
Task |
| `src/crdt/{LWWMap,ORMap,MVRegister,GCounterMap}.ts` (new) |
Each implements `Crdt` with toJSON / fromJSON. |
| `src/crdt/index.ts` |
Re-export the four new types + JSON shapes. |
| `src/crdt/DistributedData.ts` |
`decodeCrdt` switch needs four more cases. |
| `tests/unit/crdt/CrdtProperties.test.ts` |
Property tests for each new type (idempotent / commutative / associative). |
| `tests/unit/crdt/Maps.test.ts` (new) |
Hand-rolled scenarios — concurrent put on different keys, concurrent put on same key, ORMap with nested ORSet. |
Estimate: 3-4 days.
Verification:
- Each CRDT passes the same three property tests as the existing five.
- Multi-node convergence tests in `tests/multi-node/distributed-data.test.ts` extended to cover at least `LWWMap` + `ORMap`.
Out of scope:
- RGA / Treedoc (collaborative text) — niche, separate issue if demand surfaces.
- Delta-CRDTs — deferred globally.
Follow-up to #37. The starter set (GCounter, PNCounter, GSet, ORSet, LWWRegister) covers the canonical scenarios. Akka's `ddata` ships several more that pull their weight in real workloads — same-shape merge functions, just composed differently.
To add:
Components:
Estimate: 3-4 days.
Verification:
Out of scope: