Skip to main content

Module array

Module array 

Source
Expand description

Array CRDT synchronization for NodeDB-Lite.

This module implements the embedded side of the sparse N-dimensional array sync protocol. The design has three independent paths:

  1. Outbound — local writes call ArrayOutbound, which appends the op to a durable KV-backed KvOpLogStore and enqueues it on PendingQueue for the transport layer to drain. The send path is fire-and-forget from the engine’s perspective.

  2. Inbound — wire messages from Origin enter ArrayInbound, which deduplicates by HLC against the local op-log, applies the op via LiteApplyEngine, and persists the resulting state. The receive path deliberately does not re-trigger outbound hooks, preventing echo loops by construction.

  3. Catch-up — CatchupTracker persists the highest applied HLC per array so that, on reconnect, the transport can request only the ops it missed.

Cross-cutting state:

  • ReplicaState — stable replica identity + monotonic HLC generator.
  • SchemaRegistry — per-array [SchemaDoc] snapshots, persisted as Loro documents.

Backpressure is enforced at the PendingQueue (100k-op cap); overflow surfaces as crate::error::LiteError::Backpressure.

Transport wiring (WebSocket dispatch into ArrayInbound and the push loop that drains PendingQueue) lives in crate::sync::transport. This module is transport-agnostic. reject_policy decides what happens to a local op Origin refuses.

Re-exports§

pub use ack_sender::spawn as spawn_ack_sender;
pub use catchup::CatchupTracker;
pub use inbound::ArrayInbound;
pub use inbound::InboundOutcome;
pub use inbound::LiteApplyEngine;
pub use op_log_store::KvOpLogStore;
pub use outbound::ArrayOutbound;
pub use pending::PendingArrayOp;
pub use pending::PendingQueue;
pub use reject_policy::RejectDisposition;
pub use reject_policy::reject_disposition;
pub use replica_state::ReplicaState;
pub use schema_registry::SchemaRegistry;

Modules§

ack_sender
[ArrayAckSender] — periodic ack sender from Lite to Origin.
catchup
Catchup-request helper: tracks the last-seen inbound HLC per array and builds ArrayCatchupRequestMsg messages for the transport layer.
inbound
Inbound array CRDT message handler for NodeDB-Lite.
op_log_store
Storage-backed OpLog implementation for the array CRDT sync subsystem.
outbound
High-level emitter for array CRDT ops on the send path.
pending
Durable FIFO queue of outbound array ops waiting for transport to Origin.
reject_policy
What Lite does with a locally-originated op Origin refuses.
replica_state
Persistent replica identity and HLC generator for the array CRDT sync subsystem.
schema_registry
Per-array SchemaDoc registry with durable cold-start snapshots.