Skip to main content

krabka_kraft_core/
lib.rs

1//! Deterministic, sans-IO `KRaft` consensus core (KIP-595 + KIP-996).
2//!
3//! This crate is Krabka's metadata-quorum engine: a synchronous
4//! `on_event(event, log, now) -> Vec<Action>` state machine
5//! ([`core::QuorumStateMachine`]) over the `QuorumState`/[`Role`] model. It
6//! never reads the clock, touches a socket, or writes a byte to disk. The
7//! caller injects the time as a [`SimInstant`], the state machine reads the log
8//! through the [`LogView`] seam, and it returns every effect as an [`Action`]
9//! for the caller to execute.
10//!
11//! `krabka-raft` wraps this core with the async engine, the real KIP-595 wire,
12//! and the on-disk `krabka-log`. It re-exports these modules under
13//! `krabka_raft::kraft`. The core is a leaf crate with no tokio, no filesystem,
14//! and no crypto, so it compiles for `wasm32-unknown-unknown`. The `sim`
15//! module, behind the `sim` feature, uses this to drive an interactive
16//! consensus simulation in the browser playground.
17
18#![doc(html_root_url = "https://docs.rs/krabka-kraft-core/1.1.0")]
19#![allow(dead_code, unused_imports)]
20
21pub mod action;
22pub mod core;
23pub mod event;
24pub mod role;
25pub mod simulation_support;
26pub mod snapshot_fetch;
27pub mod types;
28
29#[cfg(feature = "sim")]
30pub mod sim;
31
32pub use {
33    action::{Action, TimerKind},
34    core::{QuorumStateMachine, QuorumTimeouts, election_jitter_ms},
35    event::{Event, LogEnd, SuccessorRank},
36    role::{ReplicaProgress, Role},
37    types::{Epoch, LogOffsetMetadata, LogView, NodeId, QuorumState, ReplicaKey, SimInstant},
38};