reddb_server/storage/mod.rs
1// reddb persistent storage core
2//
3// This module exposes the unified RedDB storage engine for tables, documents,
4// graphs, and vectors with a single API surface.
5
6// Low-level primitives (bloom filters, encoding, mmap, serialization)
7pub mod primitives;
8
9// Cross-structure index abstraction (trait + bloom segment helper)
10pub mod index;
11
12// RedDB Storage Engine (page-based, B-tree indexed)
13pub mod engine;
14
15// B+ Tree with MVCC (Concurrent Storage)
16pub mod btree;
17
18// Transaction Management (ACID)
19pub mod transaction;
20
21// Page Cache (SIEVE Algorithm)
22pub mod cache;
23
24// Foreign Data Wrappers (Phase 3.2 PG parity)
25pub mod fdw;
26
27// SQLite Import/Compatibility Layer
28pub mod import;
29
30// Write-ahead log - serializer is now integrated into storage primitives
31
32// Write-Ahead Log (Durability)
33pub mod wal;
34
35// Encryption Layer (Security)
36pub mod encryption;
37
38// Remote Storage Backend Abstraction (S3, R2, GCS, Turso, D1)
39pub mod backend;
40
41// Keyring integration for secure password storage
42pub mod keyring;
43
44// Schema System (Types, Tables, Registry)
45pub mod schema;
46
47// Time-Series Storage
48pub mod timeseries;
49
50// Queue / Deque Storage
51pub mod queue;
52
53// Vector storage stable contract surface (introspection, etc.) — issue #743.
54pub mod vector;
55
56// Graph storage stable contract surface (viewport, etc.) — issue #744.
57pub mod graph;
58
59// Machine Learning registry + async job queue (ML Sprint 1 — scaffold).
60// Feature 5 (classifier), Feature 6 (symbolic regression), and the other
61// five ML capabilities all publish models/versions and submit training
62// jobs through this module.
63pub mod ml;
64
65// Query Engine (Filters, Sorting, Similarity Search)
66pub mod query;
67
68// Unified Storage Layer (Tables + Graphs + Vectors)
69pub(crate) mod unified;
70
71// Per-collection disk usage accounting for runtime catalog views.
72pub(crate) mod disk_accountant;
73
74// Pure tiered storage layout derivation.
75pub mod layout;
76
77// Storage/deploy profile selection contract.
78pub mod profile;
79
80// Boot-time memory budget resolver (ADR 0073 §1). Resolves the single
81// process-wide budget from operator config, the deployment-profile default,
82// the cgroup limit, or a conservative fraction of physical RAM. Pool sizing
83// and admission enforcement are downstream slices consuming the number.
84pub mod memory_budget;
85
86// Budget shares over one shared accounting pool (ADR 0073 §2). Divides the
87// resolved budget among the big memory consumers by a single allocation
88// policy, and owns the one pool they report live usage into. Sizing and
89// accounting only — admission enforcement is the downstream slice.
90pub mod memory_pools;
91
92#[cfg(test)]
93mod no_malloc_hot_paths;
94
95// Embedded single-file `.rdb` artifact skeleton.
96pub mod embedded;
97
98pub(crate) mod operational_manifest;
99
100// Blockchain collection kind: pure logic for hash-chained append-only rows.
101// Storage/wire integration tracked in issue #521.
102pub mod blockchain;
103
104// Signed Writes: ed25519 signer registry + insert verification logic
105// for `CREATE COLLECTION ... SIGNED_BY (...)` (issues #520, #522).
106// Runtime wiring (insert path, reserved-column injection, REST error
107// codes) lands in follow-up slices; this module ships the pure
108// primitives the wiring will call into.
109pub mod signed_writes;
110
111// Columnar analytics projection (ADR 0069, #1766): the derived, disposable
112// columnar representation of an append-only collection. Emitted on the
113// checkpoint path, sealed under the crypto page envelope, and read via the
114// LSN-pinned analytical scan (columnar segments + un-materialized row tail
115// under one pinned snapshot). Runtime wiring into `SegmentManager` checkpoint
116// and the query executor lands in follow-up slices.
117pub mod columnar_projection;
118
119// Public surface re-used by the rest of the codebase.
120pub use backend::{BackendError, LocalBackend, RemoteBackend};
121pub use embedded::{
122 EmbeddedRdbArtifact, EmbeddedRdbManifest, EmbeddedRdbOpen, EmbeddedRdbSuperblock,
123 EMBEDDED_RDB_MANIFEST_0_OFFSET, EMBEDDED_RDB_MANIFEST_1_OFFSET,
124 EMBEDDED_RDB_MANIFEST_SLOT_SIZE, EMBEDDED_RDB_MANIFEST_ZONE_END,
125 EMBEDDED_RDB_SUPERBLOCK_0_OFFSET, EMBEDDED_RDB_SUPERBLOCK_1_OFFSET,
126 EMBEDDED_RDB_SUPERBLOCK_SIZE,
127};
128pub use keyring::{
129 clear_keyring, has_keyring_password, resolve_password, save_to_keyring, PasswordSource,
130};
131pub use layout::{
132 LayoutOverrides, LayoutToggles, LogDestination, LogRoutingOverrides, StorageLayout,
133 TieredLayoutPaths,
134};
135pub use memory_budget::{
136 InvalidMemoryBudget, MemoryBudget, MemoryBudgetInputs, MemoryBudgetSource,
137};
138pub use memory_pools::{
139 BudgetSharePolicy, BudgetShares, MemoryAccounting, MemoryPool, PoolUsage, MEMORY_POOLS,
140 MEMORY_POOL_COUNT,
141};
142pub use profile::{DeployProfile, StorageDeployPreset, StoragePackaging, StorageProfileSelection};
143pub use unified::RedDB;
144
145// =============================================================================
146// UNIFIED STORAGE INTERFACE (PRIMARY API)
147// =============================================================================
148//
149// The unified storage layer is THE primary interface for all storage operations.
150// Use `storage::Store` and `storage::Query` for all new code.
151//
152// Use `storage::Store` and `storage::Query` for all new code.
153
154pub use unified::{
155 AdjacencyEntry,
156 CrossRef,
157 DslFilter,
158 DslQueryResult as QueryResult,
159 EdgeData,
160 EdgeDirection,
161 EmbeddingSlot,
162 EntityData,
163 // Entity types - Universal data model
164 EntityId,
165 EntityKind,
166 FilterOp,
167 FilterValue,
168 // Graph adjacency index
169 GraphAdjacencyIndex,
170 GraphQueryBuilder,
171 HybridQueryBuilder,
172 IndexEvent,
173 IndexEventKind,
174
175 IndexStats,
176 IndexStatus,
177 // Index lifecycle management
178 IndexType,
179 IntegratedIndexConfig as IndexConfig,
180 IntegratedIndexConfig,
181
182 // Index Manager - Unified indexing (HNSW + Inverted + B-tree + Graph)
183 IntegratedIndexManager as IndexManager,
184 IntegratedIndexManager,
185 InvertedIndex,
186 LifecycleEvent,
187
188 ManagerConfig,
189 ManagerStats,
190 MatchComponents,
191
192 // Metadata
193 Metadata,
194 MetadataQueryFilter,
195 MetadataStorage,
196 MetadataType,
197
198 MetadataValue,
199 // =========================================================================
200 // PRIMARY INTERFACE - Use these for all new code
201 // =========================================================================
202 NativeHeaderRepairPolicy,
203 NodeData,
204 QueryResultItem,
205 RefQueryBuilder,
206 RefType,
207
208 RowData,
209 ScanQueryBuilder,
210 ScoredMatch,
211 SegmentConfig as UnifiedSegmentConfig,
212 SegmentError,
213
214 SegmentId as UnifiedSegmentId,
215 // Manager
216 SegmentManager,
217 SegmentState,
218 SegmentStats,
219 SimilarResult,
220 SortOrder,
221 SparseVector,
222 StoreError,
223
224 StoreStats,
225 TableQueryBuilder,
226 TextSearchBuilder,
227 TextSearchResult,
228 TimeSeriesData,
229 TimeSeriesPointKind,
230 TraversalDirection,
231 UnifiedEntity,
232 UnifiedEntity as Entity,
233 UnifiedMetadataFilter,
234 // Segments
235 UnifiedSegment,
236 // Store - THE primary storage interface
237 UnifiedStore,
238 UnifiedStore as Store,
239 UnifiedStoreConfig,
240 VectorData,
241 // Query builders (for advanced use)
242 VectorQueryBuilder,
243 VectorSearchResult,
244 WhereClause,
245 FIRST_USER_ENTITY_ID,
246 // Query DSL - Entry point for all queries
247 Q as Query,
248};