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