constraint-crdt
CRDT-backed constraint states for distributed fleet consensus.
Core insight
CRDTs satisfy three algebraic laws (commutative, associative, idempotent). Constraint satisfaction requires closure under lattice operations. These are the same algebraic structure — a semilattice.
This crate extracts the CRDT merge protocol from SmartCRDT and fuses it with constraint-theory-core semantics.
What you get
| Type | Description |
|---|---|
Merge trait |
Semilattice join (C/A/I laws verified) |
ConstraintGCounter |
Distributed satisfaction counting (per-node max merge) |
PNCounter |
Positive/negative counting (increment + decrement) |
ConstraintORSet |
Add-wins constraint tracking with tombstone GC |
EisensteinRegister |
Lattice positions as LWW registers (lower norm wins) |
FleetTile |
PLATO tiles as mergeable CRDTs with content integrity |
ConstraintState |
Composite: all sub-CRDTs in one mergeable unit |
VectorClock |
Causal ordering across fleet nodes |
DeltaTracker |
Send only changes, not full state |
PlatoClient |
HTTP client for PLATO tile server (plato feature) |
Usage
use ;
// Two fleet nodes, independent
let mut node_a = new;
node_a.add_constraint;
node_a.record_satisfied;
let mut node_b = new;
node_b.add_constraint;
node_b.record_satisfied;
// Merge without coordination — always consistent
let mut merged = node_a.merged;
assert_eq!;
// Vector clocks for causal ordering
let mut vc_a = new;
vc_a.increment;
let mut vc_b = vc_a.clone;
vc_b.increment;
assert!;
Delta-state CRDTs
Don't send full state on every heartbeat — send only what changed:
use DeltaTracker;
let mut tracker = new;
let delta = tracker.generate;
println!;
Tests
65 tests, all verifying CRDT algebraic laws (commutativity, associativity, idempotence) for every type. Vector clock causality tested across 1-3 node scenarios.
Features
default— core CRDT types (zero network deps)plato— addsPlatoClientfor HTTP integration with PLATO tile server
Origin
Extracted from SmartCRDT's OR-Set, G-Counter, PN-Counter, and Merge trait, specialized for the Cocapn fleet's constraint theory ecosystem.
Ecosystem
- constraint-theory-core — Rust library (184 tests)
- constraint-theory — Python bindings
- eisenstein-c — C library (integer overflow safe)
- flux-lucid — Unified constraint theory ecosystem
- holonomy-consensus — Distributed agreement protocol
License
MIT