reddb_server/storage/ml/mod.rs
1//! Machine Learning subsystem — registry, versioning, async job queue.
2//!
3//! This is the shared foundation every ML feature (classifier, symbolic
4//! regression, semantic cache, feature store, etc.) is built on top of.
5//! The module intentionally has zero external ML-crate dependencies in
6//! this sprint — only the registry + job queue + persistence primitives
7//! needed for future algorithms to plug in.
8//!
9//! ## Overview
10//!
11//! * [`ModelRegistry`] catalogues named models and their immutable
12//! versions. Each `CREATE MODEL` / `ALTER MODEL` call creates a new
13//! version; versions are never mutated in place.
14//! * [`MlJobQueue`] accepts training / backfill / inference-audit jobs
15//! and runs them on a worker pool. Jobs persist their state so a
16//! crash can resume from the last checkpoint.
17//! * Metadata lives in `red_config` under the `red.ml.*` namespace so
18//! it survives restarts, backups, and replica sync without adding
19//! new system collections.
20//!
21//! The API surface is deliberately small. Feature-specific logic
22//! (which algorithm, how to serialize weights, how to compute metrics)
23//! lives in the caller — the registry only stores opaque bytes.
24
25pub mod classifier;
26pub mod jobs;
27pub mod persist;
28pub mod queue;
29pub mod registry;
30pub mod runtime;
31pub mod semantic_cache;
32
33pub use classifier::{
34 evaluate as evaluate_classifier, ClassifierMetrics, IncrementalClassifier, LogisticRegression,
35 LogisticRegressionConfig, MultinomialNaiveBayes, NaiveBayesConfig, TrainingExample, Vocabulary,
36};
37pub use jobs::{MlJob, MlJobId, MlJobKind, MlJobStatus};
38pub use persist::{InMemoryMlPersistence, MlPersistence, MlPersistenceError, MlPersistenceResult};
39pub use queue::{MlJobQueue, MlWorkFn};
40pub use registry::{ModelRegistry, ModelRegistryError, ModelSummary, ModelVersion};
41pub use runtime::{MlRuntime, MlRuntimeConfig};
42pub use semantic_cache::{
43 SemanticCache, SemanticCacheConfig, SemanticCacheEntry, SemanticCacheStats,
44};