mdcs_compaction/
lib.rs

1//! # mdcs-compaction
2//!
3//! Compaction and stability subsystem for the MDCS (Merkle-Delta CRDT Store).
4//!
5//! This crate provides:
6//! - Snapshotting: Serialize full CRDT state at stable frontiers
7//! - DAG pruning: Remove nodes older than the last snapshot
8//! - Stability monitoring: Track delivered and stable frontiers
9//! - Version vectors: Compact representation of causal context
10//!
11//! ## Architecture
12//!
13//! The compaction subsystem ensures bounded metadata growth by:
14//! 1. Tracking which updates have been durably replicated (stability)
15//! 2. Creating periodic snapshots at stable points
16//! 3. Pruning DAG history before the snapshot root
17//! 4. Preventing resurrection of deleted items
18//!
19//! ## Example
20//!
21//! ```rust,ignore
22//! use mdcs_compaction::{StabilityMonitor, SnapshotManager, PruningPolicy};
23//!
24//! // Create a stability monitor
25//! let mut monitor = StabilityMonitor::new("replica_1");
26//!
27//! // Track frontier updates from peers
28//! monitor.update_peer_frontier("replica_2", frontier_2);
29//! monitor.update_peer_frontier("replica_3", frontier_3);
30//!
31//! // Check if a node is stable (delivered to all tracked peers)
32//! if monitor.is_stable(&node_cid) {
33//!     // Safe to compact
34//! }
35//! ```
36
37mod compactor;
38mod pruning;
39mod snapshot;
40mod stability;
41mod version_vector;
42
43pub use compactor::{CompactionConfig, CompactionError, CompactionStats, Compactor};
44pub use pruning::{PrunableStore, Pruner, PruningPolicy, PruningResult, PruningVerifier};
45pub use snapshot::{Snapshot, SnapshotError, SnapshotManager};
46pub use stability::{FrontierUpdate, StabilityConfig, StabilityMonitor, StabilityState};
47pub use version_vector::{VectorEntry, VersionVector};