Crate Map
Moonpool is organized as a workspace of eight crates. The dependency graph is deliberately layered: lower crates know nothing about higher ones, and the leaf crate (moonpool-explorer) has no moonpool dependencies at all.
Dependency Diagram
moonpool
(facade crate)
/ | \
/ | \
moonpool-transport moonpool-sim moonpool-core
(peer, wire, RPC) (simulation) (provider traits)
| \ |
| \ |
| moonpool- |
| transport- |
| derive |
| (proc macros) |
| |
+---> moonpool-core |
+---> moonpool-sim |
| |
v v
moonpool-explorer
(fork-based exploration)
|
v
libc
moonpool-sim-examples (example simulation binaries)
xtask (cargo automation, not a library dependency)
Crate Details
moonpool
Role: Facade crate. Re-exports everything from the lower crates so users only need one dependency.
Dependencies: moonpool-core, moonpool-sim, moonpool-transport
Key types: Re-exports all types from moonpool-core, moonpool-sim, and moonpool-transport.
moonpool-core
Role: Provider traits and core type definitions. Defines the abstraction boundary between real and simulated runtimes.
Dependencies: async-trait, rand, serde, serde_json, thiserror, tokio, tracing
Key traits:
TimeProvider–sleep(),timeout(), clock accessTaskProvider–spawn_task()for local task spawningNetworkProvider– TCP listener and stream creationRandomProvider– deterministic random number generationStorageProvider– file I/O with simulation support
Key types:
Endpoint–(IpAddr, Token)pair identifying a connection endpointUID– unique identifier typeNetworkAddress– parsed network addressWellKnownToken– reserved token namespace for framework servicesProviders– bundle of all provider traitsSimulationError/SimulationResult– error types
moonpool-sim
Role: Simulation runtime, chaos testing, buggify system, and assertion macros. The core simulation engine that drives deterministic testing.
Dependencies: moonpool-core, moonpool-explorer, async-trait, crc32c, futures, rand, rand_chacha, serde, serde_json, thiserror, tokio, tokio-util, tracing
Key types:
SimWorld– the simulated world containing network, time, storage, and event queueSimulationBuilder– builder pattern for configuring experimentsSimContext– per-workload context providing access to providers and topologyNetworkConfiguration/ChaosConfiguration– network chaos parametersProcess– trait for system-under-test server processesWorkload– trait for test driver workloadsAttrition– automatic process reboot configurationFaultInjector/FaultContext– custom fault injection during chaos phaseIterationControl– how many iterations to runSimulationReport– results, metrics, and assertion dataInvariant– trait for cross-system property validation
Assertion macros (15 total): assert_always!, assert_sometimes!, assert_reachable!, assert_unreachable!, assert_always_greater_than!, assert_sometimes_each!, and more. See the Assertion Reference for the complete list.
moonpool-transport
Role: Peer connections, wire format, FlowTransport-style networking, and RPC. Modeled after FoundationDB’s FlowTransport.
Dependencies: moonpool-core, moonpool-sim, moonpool-transport-derive, async-trait, crc32c, futures, serde, serde_json, thiserror, tokio, tokio-util, tracing
Key types:
Peer– manages a connection to a remote endpoint with automatic reconnectionPeerConfig– reconnection delays, queue size, connection timeoutMonitorConfig– ping-based connection health monitoringNetTransport– central coordinator managing peers and packet dispatchEndpointMap– hybrid token routing (O(1) well-known, O(log n) dynamic)FailureMonitor/FailureStatus– reactive address/endpoint failure trackingReplyPromise– server-side response promise (auto-sendsBrokenPromiseon Drop)ReplyFuture– client-side response future (auto-closes queue on Drop)ReplyError– error enum includingMaybeDelivered,Timeout,BrokenPromiseRequestStream– server-side typed request receiver withrecv_with_transport()RequestEnvelope– request + reply_to endpoint for bidirectional RPCMessagingError– transport-level error type- Delivery modes:
send,try_get_reply,get_reply,get_reply_unless_failed_for - Load balancing:
Alternatives,Distance,AtMostOnce,QueueModel,ModelHolder,Smoother,load_balance() - Fan-out:
fan_out_all,fan_out_quorum,fan_out_race,fan_out_all_partial,FanOutError
Proc macros (from moonpool-transport-derive):
#[service]– generates service trait, server, client, and bound client types
moonpool-transport-derive
Role: Procedural macros for RPC service definitions.
Dependencies: proc-macro2, quote, syn (compile-time only, no runtime deps)
Provides:
#[service]– derive macro for RPC service definitions
This is a proc-macro crate and cannot export regular types or functions.
moonpool-explorer
Role: Fork-based multiverse exploration, coverage tracking, and energy budgets. A leaf crate with zero moonpool knowledge – communicates with the simulation only through RNG function pointers.
Dependencies: libc (only dependency)
Key types:
ExplorationConfig– max depth, energy, timelines per split, adaptive configAdaptiveConfig– batch size, min/max timelines, per-mark energyParallelism– multi-core exploration variants (MaxCores, HalfCores, Cores, MaxCoresMinus)AssertionSlot/AssertionSlotSnapshot– shared-memory assertion tracking (128 slots)AssertKind– Always, AlwaysOrUnreachable, Sometimes, Reachable, Unreachable, NumericAlways, NumericSometimes, BooleanSometimesAllAssertCmp– Gt, Ge, Lt, LeEachBucket– per-value bucketed assertion tracking (256 buckets)CoverageBitmap/ExploredMap– 8192-bit coverage bitmapsEnergyBudget– 3-level energy system (global + per-mark + reallocation pool)SharedStats/SharedRecipe– cross-process counters and bug replay dataExplorationStats– snapshot of exploration progress
Key functions:
init()/cleanup()– lifecycle managementinit_assertions()/cleanup_assertions()– assertion-only lifecycleset_rng_hooks()– connect to simulation’s RNGassertion_bool(),assertion_numeric(),assertion_sometimes_all(),assertion_sometimes_each()– assertion recordingsplit_on_discovery()– fork the process at a splitpointexit_child()– terminate a forked child processprepare_next_seed()– selective reset for multi-seed explorationsancov_edges_covered(),sancov_edge_count(),sancov_is_available()– sanitizer coverage integration
moonpool-sim-examples
Role: Example simulation binaries demonstrating exploration features.
Dependencies: moonpool-sim
Binaries:
sim-maze-explore– adaptive exploration on maze workloadsim-dungeon-explore– adaptive exploration on dungeon workload
Not a library dependency – contains only binary targets for demonstration and testing of the exploration subsystem.
xtask
Role: Cargo xtask automation for running simulation binaries.
Not a library dependency – invoked via cargo xtask.
Commands:
cargo xtask sim list– list all simulation binariescargo xtask sim run <filter>– run simulation binaries matching a filtercargo xtask sim run-all– run all simulation binaries