An Extensible Pure Operation-Based CRDT Framework for Building Collaborative Applications
Features • Quick Start • Architecture • Documentation • Publications
This project is under active development. This project is currently under active development. The API and features are subject to change as we refine the framework.
Moirai is a Rust-based framework for building pure operation-based Conflict-free Replicated Data Types (CRDTs). It provides a flexible, extensible architecture that enables developers to create custom CRDTs with sophisticated conflict resolution semantics, making it ideal for distributed collaborative applications.
Moirai provides a comprehensive library of CRDT implementations:
| Category | Types | Description |
|---|---|---|
| Counters | Counter, ResettableCounter |
Increment/decrement with optional reset |
| Flags | EWFlag, DWFlag |
Enable/disable boolean flags. |
| Registers | MVRegister, TORegister, PORegister, Last-Writer-Wins Register, Fair Register |
Multi-value, semantically data-driven totally ordered and partially ordered registers, unfair and fair to process single value registers. |
| Collections | AWSet, RWSet |
Add-wins and remove-wins sets |
| Maps | UWMap |
Update-wins map with nested CRDT values |
| Graphs | UWMultiDigraph |
Directed multi-graphs with CRDT nodes and edges |
| Lists | List (EG-walker), NestedList |
Collaborative text editing with nested structures |
| Composite | Union, Record |
Sum types and product types CRDTs |
| Document | JSON |
CRDT for JSON-like hierarchical documents with rich data types |
Most of these CRDTs implementations are based on specifications that have been formally verified using VeriFX.
Add Moirai to your Cargo.toml:
[dependencies]
moirai = { git = "https://github.com/CEA-LIST/Moirai.git" }use moirai::{
crdt::counter::simple_counter::Counter,
protocol::{
crdt::query::Read,
replica::IsReplica,
state::po_log::VecLog,
broadcast::tcsb::Tcsb,
},
};
// Create two replicas
let (mut replica_a, mut replica_b) =
moirai::crdt::test_util::twins::<VecLog<Counter<i32>>, Tcsb<Counter<i32>>>();
// Replica A increments
let event = replica_a.send(Counter::Inc(5)).unwrap();
replica_b.receive(event);
// Replica B increments
let event = replica_b.send(Counter::Inc(3)).unwrap();
replica_a.receive(event);
// Both replicas converge to the same value
assert_eq!(replica_a.query(Read::new()), 8);
assert_eq!(replica_b.query(Read::new()), 8);Moirai's architecture separates concerns into distinct layers:
┌─────────────────────────────────────────────────┐
│ Application Layer │
│ (Your collaborative application logic) │
└─────────────────────────────────────────────────┘
▼
┌─────────────────────────────────────────────────┐
│ CRDT Layer (IsLog + PureCRDT) │
│ Counter │ Map │ Set │ List │ Graph │ ... │
└─────────────────────────────────────────────────┘
▼
┌─────────────────────────────────────────────────┐
│ State Management (EventGraph/POLog) │
│ Causal tracking │ Operation storage │
└─────────────────────────────────────────────────┘
▼
┌─────────────────────────────────────────────────┐
│ Protocol Layer (Replica + Broadcast) │
│ Version vectors │ Causal delivery │
└─────────────────────────────────────────────────┘
Moirai has been used in the following research:
- Léo Olivier, Kirollos Morcos, Marcos Didonet del Fabro, Sebastien Gerard.
A Local-First Collaborative Modeling Approach with Replicated Data Types.
CoPaMo'25 - International Workshop on Collaborative and Participatory Modeling, October 2025, Grand Rapids, United States.
This project is licensed under the Apache License 2.0. See LICENSE for details.
Developed at CEA LIST, the French Alternative Energies and Atomic Energy Commission.
Authors:
- Léo Olivier (@leo-olivier)
- Kirollos Morcos (@KirollosMorcos)
Made with ❤️ by the CEA LIST team