minerva 0.2.0

Causal ordering for distributed systems
//! Causal decisions over [`Kairos`](crate::kairos::Kairos) stamps.
//!
//! A total order respects causality but cannot detect concurrency. This module
//! adds the missing partial-order state and the machines that consume it.
//!
//! # Core primitives
//!
//! - [`VersionVector`] detects causal order and concurrency.
//! - [`Ideal`] buffers disordered [`Event`] values behind a caller-chosen
//!   [`Gate`]. [`Causal`], [`Fifo`], and [`And`] provide standard gates.
//! - [`Producer`] mints the send half of causal broadcast. Receipt and delivery
//!   remain separate operations.
//! - [`Stability`] computes the roster-wide safe-to-forget cut.
//! - [`DotSet`] records exactly which dots arrived, in any order. Its
//!   [`floor`][DotSet::floor] is a genuine cut. Its
//!   [`high_water`][DotSet::high_water] can run past holes, so it is an
//!   upper bound of a cut, never a stability report.
//! - [`Dotted`] combines a [`DotStore`] with its causal context. Its merge
//!   supports replicated removal without resurrection.
//! - [`Composer`] mints dots and absorbs deltas for one causal pair.
//!   [`Purview`] tracks, per peer, the context this replica can vouch that
//!   peer has seen.
//!
//! # Stores and reads
//!
//! [`DotFun`] stores values by dot. [`DotMap`] composes stores by caller key.
//! [`Rhapsody`] stores an ordered sequence. [`Node`] combines register, map,
//! and sequence shapes under one identity.
//!
//! Restriction scopes prevent a verdict for one station family from use in
//! another family. Difference reads report the state that one replica owes
//! another. Wire decoders validate canonical form and bound allocation before
//! they allocate.
//!
//! # Epochs and membership
//!
//! [`Epochs`] runs the sealed-epoch lifecycle: declaration, confirmation,
//! adoption, seal. [`EpochLedgerSnapshot`] is its canonical checkpoint.
//! [`EpochGate`] holds native epoch traffic until the adoption witness fixes
//! its address; [`EpochIdeal`] is the buffered form. Recorded membership
//! rides the same rounds: [`ArrivalRound`] collects [`Endorsement`] values
//! for an [`Admission`], and the [`Stability`] departure door narrows the
//! roster with typed refusals.
//!
//! # Witnesses
//!
//! [`Cut`], [`Received`], and [`Retired`] make proven state a type. A
//! consuming seam accepts a witness, never a bare set, so an over-claim does
//! not compile. Each `trust` constructor is the audited escape for external
//! evidence.
//!
//! Minerva does not choose trust, conflict-resolution, retry, reclamation, or
//! membership policy. Callers make those decisions from typed results and
//! witness values.
//!
//! [`VersionVector`]: crate::metis::VersionVector
//! [`Ideal`]: crate::metis::Ideal
//! [`Event`]: crate::metis::Event
//! [`Gate`]: crate::metis::Gate
//! [`Causal`]: crate::metis::Causal
//! [`Fifo`]: crate::metis::Fifo
//! [`And`]: crate::metis::And
//! [`Producer`]: crate::metis::Producer
//! [`Stability`]: crate::metis::Stability
//! [`DotSet`]: crate::metis::DotSet
//! [DotSet::floor]: crate::metis::DotSet::floor
//! [DotSet::high_water]: crate::metis::DotSet::high_water
//! [`Dotted`]: crate::metis::Dotted
//! [`DotStore`]: crate::metis::DotStore
//! [`DotFun`]: crate::metis::DotFun
//! [`DotMap`]: crate::metis::DotMap
//! [`Rhapsody`]: crate::metis::Rhapsody
//! [`Node`]: crate::metis::Node
//! [`Epochs`]: crate::metis::Epochs
//! [`EpochLedgerSnapshot`]: crate::metis::EpochLedgerSnapshot
//! [`EpochGate`]: crate::metis::EpochGate
//! [`EpochIdeal`]: crate::metis::EpochIdeal
//! [`ArrivalRound`]: crate::metis::ArrivalRound
//! [`Endorsement`]: crate::metis::Endorsement
//! [`Admission`]: crate::metis::Admission
//! [`Cut`]: crate::metis::Cut
//! [`Received`]: crate::metis::Received
//! [`Retired`]: crate::metis::Retired
//! [`Composer`]: crate::metis::Composer
//! [`Purview`]: crate::metis::Purview

mod attest;
mod causal_store;
mod composer;
mod dot;
mod dot_fun;
mod dot_set;
mod epoch;
mod event;
mod gate;
mod ideal;
mod metathesis;
mod node;
mod producer;
mod purview;
mod retirement;
mod rhapsody;
mod scholia;
mod scope;
mod span;
mod stability;
// The harness tree is a test module in every ordinary build. Under
// `--cfg fuzzing` its fleet slice compiles too, so the coverage-guided
// leg drives the shipped recipe instead of a copy of it (ruling R-71's
// named path; `fuzz_harness` below is the whole exposure).
//
// Two mutually exclusive declarations rather than one `any(test, fuzzing)`
// gate, deliberately: clippy recognizes harness code by the *literal*
// `#[cfg(test)]` attribute on an ancestor module and suppresses the lints
// that only make sense for shipped surface (const-ness, clone-assignment)
// there. A combined gate silently un-suppresses them across the whole
// harness tree, which would put pre-existing test code under the shipped
// crate's lint contract.
#[cfg(fuzzing)]
pub mod fuzz_harness;
#[cfg(test)]
mod tests;
#[cfg(all(fuzzing, not(test)))]
mod tests;
mod version_vector;

pub use attest::Cut;
pub use causal_store::{DotCollision, DotMap, DotMapIter, DotStore, Dotted, UncoveredDot};
pub use composer::Composer;
pub use dot::{Dot, InvalidDot, RawDot};
pub use dot_fun::{DotFun, DotFunIter};
pub use dot_set::{DotSet, DotSetStation, HaveSetDecodeBudget, HaveSetDecodeError};
#[cfg(feature = "instrumentation")]
pub use epoch::EpochShadowProfile;
pub use epoch::{
    Admission, Adopted, AdoptionReportDecodeError, AdoptionReportRecord, ArrivalRefusal,
    ArrivalRound, ConfirmationDecodeError, ConfirmationRecord, Consigned, Declaration,
    DeclarationDecodeError, Endorsement, EndorsementDecodeBudget, EndorsementDecodeError,
    EpochAddress, EpochAdoptionMismatch, EpochBootstrapError, EpochConsignment,
    EpochConsignmentError, EpochGate, EpochLedgerDecodeBudget, EpochLedgerDecodeError,
    EpochLedgerRehydrateError, EpochLedgerSnapshot, EpochPreparation, EpochPreparationFold,
    EpochPreparationMiss, EpochProjection, EpochRefusal, EpochShadow, EpochStratum,
    EpochStratumError, EpochTransition, Epochs, InvalidEpochAddress, LineageProofDecodeBudget,
    LineageProofDecodeError, LineageProofEntry, LineageProofRecord, SealDecodeBudget,
    SealDecodeError, SealRecord, SealedEpoch, SweptIdentity, Vouched, WireCutError,
};
pub use event::Event;
pub use gate::{
    And, AndProgress, Causal, Fifo, Gate, GateLawCheckError, GateLawPoint, ReleaseDrivenGate,
    check_gate_laws,
};
pub use ideal::{AtCapacity, BoundedInsert, CausalIdeal, FifoIdeal, Ideal, Released};
/// Native epoch traffic held until the adoption witness fixes its address.
pub type EpochIdeal<T> = Ideal<T, EpochGate>;
pub use metathesis::{Metatheses, MetathesesDecodeBudget, MetathesesDecodeError, Metathesis};
pub use node::{Kind, KindPlurality, Kinds, Node, NodeContent};
pub use producer::{ClockCarrier, Producer};
pub use purview::{Purview, Received};
pub use retirement::{Retired, Retirement};
pub use rhapsody::{
    AncestryAdmissionError, AncestryCoordinateError, AncestryQueryError, AncestryRelation, Anchor,
    ExactAncestry, Extent, Locus, MovementBatch, MovementBatchError, OrderWalk, OrderWalkRev,
    Recension, RefoundMap, RefoundMapDecodeBudget, RefoundMapDecodeError, Refounded, Rhapsody,
    RhapsodyDecodeError, SnapshotDecodeError, UnsealedStratum, Verge,
};
#[cfg(feature = "instrumentation")]
pub use rhapsody::{AncestryProfile, RecensionProfile, RhapsodyProfile};
#[cfg(feature = "timing")]
pub use rhapsody::{
    MovementBatchMoveProfile, MovementCycleValidationProfile, MovementCycleValidationWork,
    MovementTopologyPhases, MovementTopologyProfile, MovementTopologyWork, ProfiledMovement,
};

/// The snapshot chain law's successor half, surfaced crate-internally for
/// the clock-fold agreement harness and its sampled twin (never public: the
/// codec is the consumer, the harness the auditor).
#[cfg(any(test, kani))]
pub(crate) use rhapsody::rank_successor;
pub use scholia::{Scholia, Scholion};
pub use scope::{Scope, Scoped, ScopedPeek, with_scope};
pub use stability::{
    AbandonRefusal, Abandoned, Departed, Departure, DepartureRefusal, Fenced, Stability,
    UnknownStation,
};
pub use version_vector::{DecodeError, Disagreement, Iter, VersionVector};