Skip to main content

Crate nodedb_crdt

Crate nodedb_crdt 

Source
Expand description

§nodedb-crdt

CRDT engine with SQL constraint validation for NodeDB.

§The CRDT / SQL Paradox

CRDTs are AP (Available + Partition-tolerant): agents compute optimistic deltas offline and sync later. SQL constraints are CP (Consistent + Partition-tolerant): UNIQUE indexes, foreign keys, etc. must hold globally.

This crate bridges the gap:

  1. Optimistic local writes — agents apply deltas to their local LoroDoc without constraint checks (AP behavior for availability).
  2. Constraint validation at commit — when deltas sync to the leader, constraints are validated against the committed state.
  3. Dead-letter queue — rejected deltas are routed to a DLQ with compensation hints so the application can recover gracefully.
  4. Pre-validation — optional fast-reject against the leader’s state before the full Raft round-trip, reducing wasted consensus bandwidth.

Re-exports§

pub use constraint::Constraint;
pub use constraint::ConstraintKind;
pub use constraint::ConstraintSet;
pub use dead_letter::CompensationHint;
pub use dead_letter::DeadLetterQueue;
pub use deferred::DeferredQueue;
pub use error::CrdtError;
pub use error::Result;
pub use policy::CollectionPolicy;
pub use policy::ConflictPolicy;
pub use policy::PolicyRegistry;
pub use policy::PolicyResolution;
pub use policy::ResolvedAction;
pub use signing::DeltaSigner;
pub use signing::DeviceRegistry;
pub use state::CrdtState;
pub use validator::ValidationOutcome;
pub use validator::Validator;

Modules§

constraint
SQL constraint definitions for CRDT collections.
constraint_checks
Constraint-checking methods for the Validator.
dead_letter
Dead-letter queue for rejected CRDT deltas.
deferred
Deferred retry queue for CASCADE_DEFER policy.
error
Error types for the CRDT engine.
list_ops
LoroMovableList operations for block document model.
policy
Declarative conflict resolution policies for CRDT constraint violations.
pre_validate
Pre-validation: fast-reject before Raft round-trip.
signing
Delta signing and verification using HMAC-SHA256 with replay protection.
state
CRDT state management backed by loro.
validator
Constraint validator — checks deltas against committed state.

Structs§

CrdtAuthContext
Authentication context threaded through CRDT validation.