reifydb_core/lib.rs
1// SPDX-License-Identifier: Apache-2.0
2// Copyright (c) 2026 ReifyDB
3
4//! Foundational types, traits, on-disk encodings, and runtime primitives shared across the entire ReifyDB workspace.
5//!
6//! Every other crate in the workspace depends on `core`, and `core` depends only on the foundational crates
7//! (`reifydb-codec`, `reifydb-macro`, `reifydb-runtime`, `reifydb-value`). Its purpose is to break what
8//! would otherwise be a forest of circular
9//! dependencies between the storage tier, query engine, catalog, transaction manager, policy enforcer, and
10//! subscription/flow runtime: each of those crates implements traits defined here and consumes data shapes defined
11//! here. Nothing in this crate knows about a specific storage backend, query engine, or catalog implementation - it is
12//! the shared vocabulary that lets the rest of the system talk to itself.
13//!
14//! The cross-crate contract surface defines the catalog object hierarchy, the storage backend trait, the
15//! change-data-capture contract, the expression-evaluation contract, the dataflow-graph contract, the authentication
16//! contract, and component version reporting. When a crate downstream of `core` needs to expose itself to another
17//! crate, it does so by implementing one of these traits.
18//!
19//! The on-disk format lives here. Every key kind is enumerated in `KeyKind` (a `repr(u8)` with one byte per catalog
20//! object kind and per system structure) with a typed key per kind that encodes and decodes itself to the canonical
21//! byte layout. The binary representation of every primitive type - integers, floats, booleans, blobs, temporals,
22//! decimals, plus identity and dictionary references - lives alongside it. Storage backends, replication, and the wire
23//! protocol all serialise through these encodings.
24//!
25//! The runtime data model lives here. The in-memory representation of query results - columns, frames, batches, and
26//! the row-oriented views over them - is what the engine produces and consumers (subscriptions, the wire layer, the
27//! SDK) read. Change records emitted by writes, row-shape primitives, the typed event bus that crates use to publish
28//! and subscribe across actor boundaries, and the canonical catalogue of long-lived background actors all live in this
29//! tier; declaring an actor here is what makes it discoverable to the runtime supervisor.
30//!
31//! The remaining modules are infrastructural. `CoreError` and the diagnostic machinery render user-visible failures
32//! with source-fragment context. Stable content hashes support plan caching and change detection. Shared primitives -
33//! execution, retention, sort, metric - are consumed by the engine and the actor system. A grab-bag of dependency-free
34//! helpers (bloom filters, LRU caches, an inversion-of-control container, retry policies, slab allocators) is
35//! intentionally kept independent so it can be used anywhere. Capture types for the test harness are exposed
36//! separately.
37//!
38//! Invariant: `core` does not depend on any ReifyDB crate outside the foundational set listed above. Adding such a
39//! dependency would re-introduce the cycles this crate exists to break; new shared functionality belongs here, not in
40//! a downstream crate that `core` would then have to import back.
41
42#![cfg_attr(not(debug_assertions), deny(clippy::disallowed_methods))]
43#![cfg_attr(debug_assertions, warn(clippy::disallowed_methods))]
44#![cfg_attr(not(debug_assertions), deny(warnings))]
45#![allow(clippy::tabs_in_doc_comments)]
46
47use crate::interface::version::{ComponentType, HasVersion, SystemVersion};
48
49pub mod actors;
50pub mod common;
51pub mod delta;
52pub mod error;
53pub mod event;
54pub mod execution;
55pub mod fingerprint;
56pub mod interface;
57pub mod key;
58pub mod lifecycle;
59pub mod metrics;
60pub mod partition;
61pub mod profiler;
62pub mod row;
63pub mod sort;
64pub mod state;
65pub mod testing;
66pub mod util;
67pub mod value;
68
69pub struct CoreVersion;
70
71impl HasVersion for CoreVersion {
72 fn version(&self) -> SystemVersion {
73 SystemVersion {
74 name: env!("CARGO_PKG_NAME")
75 .strip_prefix("reifydb-")
76 .unwrap_or(env!("CARGO_PKG_NAME"))
77 .to_string(),
78 version: env!("CARGO_PKG_VERSION").to_string(),
79 description: "Core database interfaces and data structures".to_string(),
80 r#type: ComponentType::Module,
81 }
82 }
83}