Crate mdcs_compaction

Crate mdcs_compaction 

Source
Expand description

§mdcs-compaction

Compaction and stability subsystem for the MDCS (Merkle-Delta CRDT Store).

This crate provides:

  • Snapshotting: Serialize full CRDT state at stable frontiers
  • DAG pruning: Remove nodes older than the last snapshot
  • Stability monitoring: Track delivered and stable frontiers
  • Version vectors: Compact representation of causal context

§Architecture

The compaction subsystem ensures bounded metadata growth by:

  1. Tracking which updates have been durably replicated (stability)
  2. Creating periodic snapshots at stable points
  3. Pruning DAG history before the snapshot root
  4. Preventing resurrection of deleted items

§Example

use mdcs_compaction::{StabilityMonitor, SnapshotManager, PruningPolicy};

// Create a stability monitor
let mut monitor = StabilityMonitor::new("replica_1");

// Track frontier updates from peers
monitor.update_peer_frontier("replica_2", frontier_2);
monitor.update_peer_frontier("replica_3", frontier_3);

// Check if a node is stable (delivered to all tracked peers)
if monitor.is_stable(&node_cid) {
    // Safe to compact
}

Modules§

compactor 🔒
High-level compaction orchestrator.
pruning 🔒
DAG pruning for bounded history growth.
snapshot 🔒
Snapshot management for CRDT state persistence.
stability 🔒
Stability monitoring for safe compaction.
version_vector 🔒
Version vector for compact causal context representation.

Structs§

CompactionConfig
Configuration for the compactor.
CompactionStats
Statistics about compaction operations.
Compactor
High-level compactor that orchestrates all compaction operations.
FrontierUpdate
Update about a peer’s frontier.
Pruner
Pruner for removing old DAG nodes.
PruningPolicy
Policy for DAG pruning decisions.
PruningResult
Result of a pruning operation.
PruningVerifier
Verification utilities for pruning safety.
Snapshot
A snapshot of CRDT state at a specific point in causal history.
SnapshotManager
Manages snapshot creation and retrieval.
StabilityConfig
Configuration for stability monitoring.
StabilityMonitor
Monitors stability across replicas for safe compaction decisions.
VectorEntry
A single entry in a version vector.
VersionVector
A version vector tracking the frontier of seen updates per replica.

Enums§

CompactionError
Errors that can occur during compaction.
SnapshotError
Errors that can occur during snapshot operations.
StabilityState
State of stability tracking for a single item.

Traits§

PrunableStore
Extension trait for stores that support node removal.