Skip to main content

spectroscope/
lib.rs

1//! Consistency checkers for distributed systems testing.
2//!
3//! Spectroscope verifies that operation histories from distributed systems conform to
4//! expected consistency models. Currently implements a set linearizability checker
5//! derived from [Jepsen](https://github.com/jepsen-io/jepsen).
6//!
7//! # Quick Start
8//!
9//! ```
10//! use spectroscope::{History, Op, Pid, SetFullChecker, Validity};
11//!
12//! let mut history = History::new();
13//!
14//! // Process 0 adds element 1
15//! history.push(Op::add_invoke(0, Pid(0), 1).at_millis(0));
16//! history.push(Op::add_ok(1, Pid(0), 1).at_millis(5));
17//!
18//! // Process 1 reads and sees it
19//! history.push(Op::read_invoke(2, Pid(1)).at_millis(10));
20//! history.push(Op::read_ok(3, Pid(1), [1]).at_millis(12));
21//!
22//! let result = SetFullChecker::default().check(&history);
23//! assert_eq!(result.valid, Validity::Valid);
24//! ```
25//!
26//! # Set-Full Checker
27//!
28//! The [`SetFullChecker`] analyzes histories of set operations (add elements, read the set)
29//! and determines whether elements were properly persisted:
30//!
31//! - **Stable**: Element visible in all reads after being added
32//! - **Lost**: Element confirmed added but later disappeared
33//! - **Stale**: Element took multiple reads to become visible
34//! - **Never-read**: Element added but no subsequent reads occurred
35//!
36//! Use [`SetFullChecker::linearizable()`] for strict linearizability checking where
37//! elements must appear immediately after being added.
38
39pub mod history;
40pub mod set_full;
41
42pub use history::{History, Op, OpFn, OpType, OpValue, Pid, Timestamp};
43pub use set_full::{
44    ElementOutcome, SetFullChecker, SetFullOptions, SetFullResult, Validity, WorstStaleEntry,
45};