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