1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
//! MenteDB Storage Engine: page-based storage with WAL and buffer pool.
//!
//! This crate implements the low-level storage engine:
//! - **Page manager**: file-backed 64KB pages with free-list allocation
//! - **Write-ahead log (WAL)**: append-only, CRC-checked, LZ4-compressed entries
//! - **Buffer pool**: fixed-capacity page cache with CLOCK eviction
//! - **Storage engine**: unified facade for memory node persistence
//!
//! # Concurrency
//!
//! Multiple processes can open the same database directory simultaneously.
//! Writes are serialized via `flock(2)` on the WAL file; reads are lock-free.
//! In-memory state (page count, LSN counter) is refreshed from disk under the
//! flock so no process acts on stale data.
//!
//! # Example
//!
//! ```no_run
//! use mentedb_storage::StorageEngine;
//! use mentedb_core::{MemoryNode, memory::MemoryType, types::AgentId};
//!
//! let engine = StorageEngine::open("/tmp/mentedb-data".as_ref())?;
//!
//! let node = MemoryNode::new(
//! AgentId::new(),
//! MemoryType::Episodic,
//! "The user prefers Rust".to_string(),
//! vec![0.1, 0.2, 0.3],
//! );
//!
//! let page_id = engine.store_memory(&node)?;
//! let loaded = engine.load_memory(page_id)?;
//! assert_eq!(loaded.content, "The user prefers Rust");
//!
//! engine.checkpoint()?;
//! engine.close()?;
//! # Ok::<(), mentedb_core::error::MenteError>(())
//! ```
/// Snapshot backup utilities.
/// Fixed capacity page cache with CLOCK eviction.
/// Unified storage facade for memory persistence.
/// File backed 16KB page manager with free list allocation.
/// Append only write ahead log with CRC checks and LZ4 compression.
// Re-export key types at crate root for convenience.
pub use BufferPool;
pub use StorageEngine;
pub use ;
pub use ;