Skip to main content

Crate navian_dst

Crate navian_dst 

Source
Expand description

A domain-agnostic deterministic-simulation-testing (DST) substrate.

DST replays a system under a harness-controlled clock, RNG, network, and executor so that a failing run can be reproduced bit-for-bit and shrunk to its minimal trigger. This crate provides the reusable building blocks — nothing here knows anything about a particular application domain.

§Non-determinism traits

Four traits abstract the sources of non-determinism that would otherwise prevent replay-based testing. Each has a zero-overhead production impl (direct calls to std/tokio/rand) and a deterministic simulation impl:

  • Time — wall-clock and monotonic time, plus async sleep
  • Random — RNG and UUID generation
  • Network — cluster-internal node-to-node communication (marker)
  • Executor — task spawning and block_on

The simulation impls are reproducible only under single-threaded drive. SimulatedTime and SimulatedRandom fix the content of the clock and byte stream, but not the order in which concurrent OS threads consume them. Bit-for-bit replay therefore requires running the workload on the deterministic SimScheduler (one task at a time), not on the multi-threaded tokio runtime. SimulatedExecutor only counts spawns; it does not by itself confer determinism.

§Harness building blocks

Re-exports§

pub use executor::timeout;
pub use executor::Executor;
pub use executor::ProductionExecutor;
pub use executor::SimulatedExecutor;
pub use executor::TimedOut;
pub use network::Delivery;
pub use network::Network;
pub use network::ProductionNetwork;
pub use network::SimulatedNetwork;
pub use random::ProductionRandom;
pub use random::Random;
pub use random::SimulatedRandom;
pub use time::ProductionTime;
pub use time::SimulatedTime;
pub use time::Time;
pub use invariant::Invariant;
pub use invariant::InvariantEngine;
pub use invariant::Violation;
pub use schedule::Fault;
pub use schedule::FaultSchedule;
pub use shrink::ddmin;
pub use sim_scheduler::sleep as sim_sleep;
pub use sim_scheduler::yield_now as sim_yield_now;
pub use sim_scheduler::SimScheduler;

Modules§

executor
Executor trait — task spawning.
invariant
A generic, step-aware invariant engine for DST runs.
network
Network trait — cluster-internal node-to-node communication.
random
Random trait — RNG and UUID generation.
schedule
Seeded fault-injection schedules for DST runs.
shrink
Delta-debug shrinking for DST failure traces.
sim_scheduler
Deterministic single-thread scheduler — Phase B #1 keystone.
time
Time trait — wall-clock, monotonic time, and async sleep.