Skip to main content

spacedb_consistency/
lib.rs

1#![forbid(unsafe_code)]
2//! # spacedb-consistency — SpaceDB Layer 3 (consistency tiers)
3//!
4//! Consistency is a **per-field choice**, declared in the schema, because in a
5//! partition-prone world one global setting is always wrong. Three tiers:
6//!
7//! - [`Tier::Convergent`] — CRDT, the default: always available, auto-merging.
8//! - [`Tier::Causal`] — session read-your-writes / monotonic reads via a
9//!   [`CausalSession`], cheap and partition-tolerant, no consensus.
10//! - [`Tier::Strong`] — linearizable, a quorum that **fails safe** under partition
11//!   (M7-S2).
12//!
13//! And the honesty contract: every op returns the [`Outcome`] it actually achieved
14//! — `Committed{tier}` / `Local` / `Stale{lag}` / `Unavailable{reason}` — so an app
15//! can never mistake a local-only write for a durable one or a lagging read for a
16//! current one.
17//!
18//! M7-S1 ships the tier annotations, the honesty contract, and the Causal+ tier;
19//! the Strong quorum tier is S2. Open-core (MIT).
20
21mod tier;
22pub use tier::{ConsistencySchema, Tier};
23
24mod outcome;
25pub use outcome::{Outcome, UnavailableReason};
26
27mod causal;
28pub use causal::CausalSession;
29
30mod strong;
31pub use strong::{QuorumGroup, RejectReason, StrongResult};
32
33/// Compiles the README's examples as doctests, so the documented API can never
34/// drift from the real one. Not part of the public API, and not rendered into
35/// the crate docs — it exists only under `cargo test --doc`.
36#[cfg(doctest)]
37#[doc = include_str!("../README.md")]
38pub struct ReadmeDoctests;