Skip to content

Moirai: An Extensible, Generic Operation-based CRDT Framework with Customizable Conflict Resolution

License

Notifications You must be signed in to change notification settings

CEA-LIST/Moirai

Repository files navigation

Moirai

GitHub stars License Rust Version Build Status

An Extensible Pure Operation-Based CRDT Framework for Building Collaborative Applications

FeaturesQuick StartArchitectureDocumentationPublications


⚠️ Work in Progress — In Development ⚠️

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.

Overview

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.

Features

Core CRDTs

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.

Quick Start

Installation

Add Moirai to your Cargo.toml:

[dependencies]
moirai = { git = "https://github.com/CEA-LIST/Moirai.git" }

Basic Example: Counter CRDT

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);

Architecture

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              │
└─────────────────────────────────────────────────┘

Publications

Moirai has been used in the following research:

License

This project is licensed under the Apache License 2.0. See LICENSE for details.


Acknowledgments

Developed at CEA LIST, the French Alternative Energies and Atomic Energy Commission.

Authors:


⬆ Back to Top

Made with ❤️ by the CEA LIST team

About

Moirai: An Extensible, Generic Operation-based CRDT Framework with Customizable Conflict Resolution

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Contributors 4

  •  
  •  
  •  
  •