Skip to main content

mongreldb_core/
lib.rs

1//! MongrelDB core — a log-structured columnar store with sub-ms writes, learned
2//! indexes over a shared row-id space, page-level native encryption, an
3//! MVCC-tagged content-addressed cache, and an AI-native access layer.
4//!
5//! The crate owns the WAL + memtable + Bε-tree write path, sorted-run container
6//! formats, MVCC snapshots, page cache, encryption, compaction, and indexes.
7
8#![allow(clippy::module_inception)]
9#![recursion_limit = "2048"]
10
11pub mod ai_generation;
12pub mod auth;
13pub mod auth_state;
14pub mod backup;
15pub mod be_tree;
16pub mod cache;
17pub mod catalog;
18pub mod catalog_cmds;
19pub mod certification;
20pub mod cluster_import;
21pub mod columnar;
22pub mod commit_log;
23pub mod compaction;
24pub mod constraint;
25pub mod core;
26pub mod cursor;
27pub mod database;
28pub mod durable_file;
29pub mod embedding;
30pub mod embedding_jobs;
31pub mod encryption;
32pub mod engine;
33pub mod epoch;
34pub mod error;
35pub mod execution;
36pub mod external_table;
37pub mod gc;
38pub mod global_idx;
39pub mod handle;
40pub mod index;
41pub mod jobs;
42pub mod locks;
43pub mod manager;
44pub mod manifest;
45pub mod memory;
46pub mod memtable;
47pub mod migrate_mysql;
48pub mod mutable_run;
49pub mod node_governor;
50pub mod ops_jobs;
51pub mod page;
52pub mod pitr;
53pub mod pma;
54pub mod procedure;
55pub mod query;
56pub mod replicated_apply;
57pub mod replication;
58pub mod reservoir;
59pub mod resource;
60pub mod result_cache;
61pub mod retention;
62pub(crate) mod row_id_set;
63pub mod rowid;
64pub mod run_lookup;
65pub mod scheduler;
66pub mod schema;
67pub mod security;
68pub mod security_hardening;
69pub mod service_principal;
70pub mod sorted_run;
71pub mod spill;
72pub mod storage_mode;
73pub mod trace;
74pub mod trigger;
75pub mod tsv;
76pub mod txn;
77pub mod wal;
78
79pub(crate) const MAX_READ_GENERATION_LAYERS: usize = 8;
80
81pub use crate::core::{DatabaseFileIdentity, LifecycleController, LifecycleState, OperationGuard};
82pub use ai_generation::{
83    evaluate_readiness, readiness_action, AiIndexGeneration, AiIndexGenerationRegistry, IndexId,
84    IndexReadinessError, ReadinessAction,
85};
86pub use auth::{
87    hash_password, verify_password, ColumnAccess, ColumnOperation, MysqlCachingSha2Verifier,
88    Permission, Principal, RoleEntry, UserEntry,
89};
90pub use backup::{verify_backup, BackupFile, BackupManifest, BackupReport};
91pub use be_tree::BeTree;
92pub use cache::PageCache;
93pub use catalog::{
94    IncrementalAggregateKind, IncrementalAggregateOutput, IncrementalAggregateView,
95    MaterializedViewEntry,
96};
97pub use catalog_cmds::{required_permission, CatalogCommand, CatalogCommandRecord, CatalogDelta};
98pub use certification::{
99    ArchitectureQualification, ArchitectureStage, ArchitectureStatus, CertificationManifest,
100    CertificationStatus, CertificationTest, EvidenceClass, MANDATORY_ARCHITECTURE_TASK_IDS,
101    RESIDUAL_ALIAS_TASK_IDS,
102};
103pub use cluster_import::{
104    cluster_import_prepare, hash_rows_canonical, ImportPlan, ImportTablePlan,
105};
106pub use columnar::{decode_column, encode_column};
107pub use cursor::{drain_cursor_to_columns, Cursor, MultiRunCursor, NativePageCursor};
108pub use database::{
109    lock_table_with_context, AuthorizedReadSnapshot, AuthorizedReadStamp, CdcBatch, ChangeEvent,
110    CheckIssue, Database, DatabaseCore, DatabaseOpenMetrics, ExternalTriggerBaseWrite,
111    ExternalTriggerBridge, ExternalTriggerWrite, ExternalTriggerWriteResult, OpenOptions,
112    ReadAuthorization, TableGenerationStats, TableGuard, TableHandle, TablePinsReport,
113    TableReadGeneration, DEFAULT_MEMORY_BUDGET_BYTES, DEFAULT_TEMP_DISK_BUDGET_BYTES,
114};
115pub use embedding::{
116    EmbeddingError, EmbeddingFailurePolicy, EmbeddingFuture, EmbeddingGenerationStatus,
117    EmbeddingLimits, EmbeddingModelMeta, EmbeddingNormalization, EmbeddingProvider,
118    EmbeddingProviderRef, EmbeddingProviderRegistry, EmbeddingRequest, EmbeddingResponse,
119    EmbeddingSource, FixedVectorProvider, GeneratedEmbeddingMetadata, GeneratedEmbeddingSpec,
120    GeneratedEmbeddingValue, ProviderExecutionMode, ProviderHealth, ProviderStatus,
121    TextRetrieveProvenance, TextRetrieveResult, TextSearchOptions,
122};
123pub use embedding_jobs::{
124    check_provider_readiness, embedding_status_is_ann_eligible, EmbeddingGenerationSlot,
125    EmbeddingJob, ProviderReadiness, ProviderReadinessEntry, ProviderReadinessReport,
126    ReEmbeddingCoordinator, ReEmbeddingJob, ReEmbeddingState,
127};
128pub use encryption::{Cipher, PlaintextCipher};
129pub use engine::{
130    AggState, ApproxAgg, ApproxResult, CachedAgg, ColumnStat, IncrementalAggResult,
131    IndexBuildPolicy, NativeAgg, NativeAggResult, ReadGeneration, Table, TableDeltas,
132};
133pub use epoch::{Epoch, EpochAuthority, EpochClock, GcFloor, MaintenanceReceipt, Snapshot};
134pub use error::{MongrelError, Result};
135pub use execution::{CancellationReason, ExecutionControl};
136pub use external_table::{
137    ExternalTableDefinition, ExternalTableEntry, ModuleArg, ModuleCapabilities,
138};
139pub use gc::{CheckReport, DoctorReport, GcReport, GcVersionsReport};
140pub use handle::{
141    AuthorizedMongrelSession, AuthorizedSession, AuthorizedTransaction, DatabaseHandle,
142    HandleAccess, HandleIdentity, OpenIdentity, SecretString,
143};
144pub use index::{
145    AnnDistance, AnnIndex, BitmapIndex, ColumnLearnedRange, FmIndex, HotIndex,
146    IndexFamilyGeneration, IndexGeneration, LearnedIndex, SparseIndex,
147};
148pub use jobs::{
149    CancellationToken, JobError, JobKind, JobProgress, JobRecord, JobRegistry, JobState, JobTarget,
150    JOBS_FILENAME,
151};
152pub use locks::{LockError, LockKey, LockManager, LockMode, LockRequest};
153pub use manager::DatabaseManager;
154pub use manifest::TtlPolicy;
155pub use memory::{
156    EscalationLevel, EscalationThresholds, GovernorConfig, GovernorStats, MemoryClass, MemoryError,
157    MemoryGovernor, Reclaimable, Reservation, SpillGrant,
158};
159pub use memtable::{Memtable, Row, Value};
160pub use migrate_mysql::{
161    dialect_matrix, map_mysql_type, plan_mysql_migration, run_migrate_pipeline,
162    run_migrate_pipeline_controlled, CdcOp, DialectFeature, DialectSupport, MemoryMigrateIo,
163    MigrateIo, MigrateRunReport, MigrateStage, MigrateTablePlan, MysqlMigratePlan,
164    MysqlWireRequest, SourceRow, TypeMapping, DEFAULT_COPY_BATCH, DUAL_WRITE_WARNING,
165};
166pub use mutable_run::MutableRun;
167pub use node_governor::{GovernorAction, NodeMemoryGovernor, NodePressureInputs};
168pub use ops_jobs::{OpsJob, OpsJobError, OpsJobKind, OpsJobState, OpsJobStore};
169pub use page::{CachedPage, Encoding, PageStat};
170pub use pitr::{
171    read_pitr_manifest, restore_pitr, PitrArchiveManifest, PitrArchiveReport, PitrChunkRef,
172    PitrCommitPoint, PitrCredentials, PitrTarget,
173};
174pub use procedure::{
175    ProcedureBody, ProcedureCallOutput, ProcedureCallResult, ProcedureCallRow, ProcedureCondition,
176    ProcedureEntry, ProcedureMode, ProcedureParam, ProcedureStep, ProcedureValue, StoredProcedure,
177};
178pub use security_hardening::{
179    node_cert_matches_id, redact_secrets, validate_jwt_claims, verify_jwt, IssuedServiceToken, Jwk,
180    JwksCache, JwksDocument, JwksFetch, JwksProvider, JwtAlgorithm, JwtClaims, JwtError,
181    JwtValidationConfig, KeyManagementError, KeyManagementHealth, KeyManagementProvider,
182    KeyRotationJournal, KeyRotationPhase, KeyRotationRecord, KmsDatabaseKeyEnvelope, KmsWrappedKey,
183    ScramChannelBindingPolicy, ScramClientSession, ScramServerSession, ScramVerifier,
184    SecurityHardeningError, ServiceToken, ServiceTokenRegistry, UnsupportedKeyManagementProvider,
185    VerifiedJwt,
186};
187
188#[derive(Debug, Clone, Copy, PartialEq, Eq, serde::Serialize)]
189pub struct BuildInfo {
190    pub artifact_version: &'static str,
191    pub engine_version: &'static str,
192    pub mongreldb_git_sha: &'static str,
193    pub target_triple: &'static str,
194    pub build_profile: &'static str,
195}
196
197pub fn build_info() -> BuildInfo {
198    BuildInfo {
199        artifact_version: env!("CARGO_PKG_VERSION"),
200        engine_version: env!("CARGO_PKG_VERSION"),
201        mongreldb_git_sha: env!("MONGRELDB_GIT_SHA"),
202        target_triple: env!("MONGRELDB_TARGET_TRIPLE"),
203        build_profile: env!("MONGRELDB_BUILD_PROFILE"),
204    }
205}
206pub use query::{Condition, Query};
207pub use replicated_apply::{
208    EngineSnapshot, EngineSnapshotFile, EngineSnapshotTable, ReplicatedTxnPayload,
209    COMMAND_TYPE_CATALOG_COMMAND, COMMAND_TYPE_MAINTENANCE, ENGINE_SNAPSHOT_FORMAT_VERSION,
210    REPLICATED_TXN_FORMAT_VERSION,
211};
212pub use replication::{
213    is_replica, replica_epoch, replica_source_id, write_replica_epoch, ReplicationBatch,
214    ReplicationSnapshot,
215};
216pub use reservoir::Reservoir;
217pub use resource::{ResourceError, ResourceGroup, ResourceGroupRegistry, WorkloadClass};
218pub use retention::{
219    OwnedSnapshotGuard, PinGuard, PinInfo, PinRegistry, PinSource, PinsReport, SnapshotGuard,
220    SnapshotRegistry,
221};
222pub use rowid::{RowId, RowIdAllocator};
223pub use scheduler::{
224    ClassConfig, ClassStats, HierarchicalScheduler, SchedulerError, SchedulerStats, TenantQuota,
225    WorkItem,
226};
227pub use schema::{
228    AlterColumn, ColumnDef, ColumnFlags, DefaultExpr, IndexDef, IndexKind, Schema, TypeId,
229};
230pub use security::{
231    ColumnMask, MaskStrategy, PolicyCommand, RowPolicy, SecurityCatalog, SecurityExpr,
232};
233pub use service_principal::{ServicePrincipalDefinition, ServicePrincipalStore};
234pub use sorted_run::{
235    read_column_dir, read_header, write_run, write_run_with, ColumnPayload, RunHeader, RunReader,
236    RunSpec, RunWriter,
237};
238pub use spill::{
239    SpillConfig, SpillError, SpillHandle, SpillManager, SpillReader, SpillSession, SpillStats,
240    SpillWriter,
241};
242pub use storage_mode::{StorageMode, StorageModeError, STORAGE_MODE_FILENAME};
243pub use trace::{IndexRebuild, QueryTrace, ScanMode};
244pub use trigger::{
245    StoredTrigger, TriggerCell, TriggerCondition, TriggerConfig, TriggerDefinition, TriggerEntry,
246    TriggerEvent, TriggerExpr, TriggerProgram, TriggerRaiseAction, TriggerStep, TriggerTarget,
247    TriggerTiming, TriggerValue,
248};
249pub use txn::{IsolationLevel, OwnedRow, PutResult, UpsertAction, UpsertActionKind, UpsertResult};
250pub use wal::{AddedRun, DdlOp, Op, Record, SharedWal, Wal, WalReader, SYSTEM_TXN_ID};
251
252pub use encryption::{AesCipher, ColumnKeyDescriptor, EncryptionDescriptor, Kek};
253pub use result_cache::{
254    decode_frame, decode_persisted_entry, decrypt_payload, encode_frame, encode_persisted_entry,
255    encrypt_payload, read_header_only, real_io_final_path, spawn_persistent_cache_worker,
256    CacheLoadRejection, CachePersistError, DrainOutcome, DrainedOp, IoError, IoErrorKind,
257    PersistContext, PersistableEntry, PersistedFrame, PersistedHeader, PersistenceDisabledReason,
258    PersistentCacheIdentity, PersistentCacheIo, PersistentPublicationState,
259    PersistentResultCacheWriter, RealPersistentCacheIo, StalenessGuard, WriterLimits,
260    WriterStalenessGuard, FRAME_FORMAT_VERSION, FRAME_MAGIC,
261};