Skip to main content

spacedb_query/
lib.rs

1#![forbid(unsafe_code)]
2//! # spacedb-query — SpaceDB Layer 4 (compute-to-data)
3//!
4//! The environment forbids hauling data to a central brain, so SpaceDB inverts
5//! it: **the query travels to the data; only the answer travels back.** A query
6//! is a deterministic, fuel/memory-bounded WASM function that runs on the node
7//! holding the data — and because the runtime is deterministic, the result is
8//! **corroboratable**: a host that returns a different answer than its peers is
9//! caught.
10//!
11//! M6-S1 ships the verifiable-compute core: [`FunctionRuntime`] (deterministic,
12//! no-WASI WASM execution), the [`FunctionRun`] attestation, and [`corroborate`].
13//! The partition-aware planner + pinned-snapshot reads (S2) and the on-node vector
14//! index (`spacedb-vector`, S3) build on this.
15//!
16//! Open-core (MIT): built on `wasmtime` directly — the engine MATA's
17//! `maestro-fn-runtime` wraps — with no MATA dependency. Fanning corroboration
18//! across independent marketplace hosts is the MATA seam; the runtime, the
19//! attestation, and the comparison are here.
20
21mod error;
22pub use error::{QueryError, QueryResult};
23
24mod corroborate;
25pub use corroborate::{corroborate, Corroboration, FunctionRun};
26
27mod runtime;
28pub use runtime::{Execution, FunctionRuntime, RunLimits};
29
30mod functions;
31pub use functions::{CtxRights, FunctionCtx, FunctionOutcome, PinnedRecords, RecordSnapshot};
32
33mod snapshot;
34pub use snapshot::Snapshot;
35
36mod planner;
37pub use planner::{run_query, Coverage, QueryOutcome, QueryPlan, Shard};
38
39/// Compiles the README's examples as doctests, so the documented API can never
40/// drift from the real one. Not part of the public API, and not rendered into
41/// the crate docs — it exists only under `cargo test --doc`.
42#[cfg(doctest)]
43#[doc = include_str!("../README.md")]
44pub struct ReadmeDoctests;