Skip to main content

spacedb_crdt/
lib.rs

1#![forbid(unsafe_code)]
2//! # spacedb-crdt — SpaceDB Layer 1 (convergent collections)
3//!
4//! The default data tier, and the reason SpaceDB survives a partition-prone mesh:
5//! data is modeled as **Y-CRDT** (via `yrs`), so every write is locally available
6//! and merges conflict-free with no coordination. Writing offline on a
7//! Starlink-partitioned home is a non-event, not an error.
8//!
9//! M2-S1 ships [`CrdtDoc`]: a document with a typed field→CRDT-type mapping
10//! (LWW-Register + PN-Counter), local-first mutation, and the sync primitives
11//! (state vector, incremental update, merge). The order-independent convergence
12//! property — *the same updates in any order produce the same state* — is proven
13//! by the fuzzed test in `tests/convergence.rs`.
14//!
15//! Open-core (MIT): this depends on `yrs` directly, never on a MATA crate.
16//! Persistence into the encrypted `spacedb-store` is M2-S2.
17
18mod error;
19pub use error::{CrdtError, CrdtResult};
20
21mod doc;
22pub use doc::CrdtDoc;
23
24mod reactive;
25pub use reactive::{ReactiveQuery, Watcher};
26
27mod persist;
28pub use persist::{CrdtStore, CRDT_DOCS_COLLECTION};
29
30mod compact;
31pub use compact::compact_updates;
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;