2026-02-24 09:12:28 +00:00
|
|
|
pub mod runner;
|
2026-02-12 09:13:50 +00:00
|
|
|
pub mod topology;
|
|
|
|
|
pub mod properties;
|
2026-02-24 09:12:28 +00:00
|
|
|
|
|
|
|
|
#[cfg(feature = "distribution")]
|
refactor: remove dead code, consolidate files (#52)
Remove the unused TCP transport and dead CLI/simulation scaffolding and collapse scattered single-purpose modules into consolidated files across the dashboard, process, and simulation crates.
- crates/transport: drop the TCP transport (src/tcp.rs and its tcp feature), leaving only ed25519 identity and encoding utilities behind the iroh transport
- crates/dashboard: collapse actor_detail_html/actors_html/dashboard_html/topology_html into a single html.rs, drop command/parse.rs, and inline the trace types into lib.rs
- crates/process: fold driver, pipeline_types, queue, subscriber, waker, and local pipes/signal/wait into local/mod.rs, pipeline.rs, and a unified types.rs, consolidating the public re-exports
- crates/simulation: remove the ci subdirectory (local_sim, sim) and dead node/config/trace modules, and flatten the distribution subdirectory into top-level files
- crates/datastore: remove the unused store_cli, cli, and in-memory storage, and deduplicate crypto.rs across datastore and distribution (about 190 lines of shared code removed)
- crates/distribution: drop dead codec code and trim the messages module
Signed-off-by: Zachery Aaron Shores-Chmielewski <zacheryasc@gmail.com>
2026-02-25 14:33:04 +00:00
|
|
|
#[path = "distribution_mod.rs"]
|
2026-02-12 09:13:50 +00:00
|
|
|
pub mod distribution;
|
|
|
|
|
|
|
|
|
|
#[cfg(feature = "gossip")]
|
|
|
|
|
pub mod gossip;
|
2026-02-13 17:34:01 +00:00
|
|
|
|
|
|
|
|
#[cfg(feature = "dashboard")]
|
|
|
|
|
pub mod dashboard;
|
refactor: remove dead code, consolidate files (#52)
Remove the unused TCP transport and dead CLI/simulation scaffolding and collapse scattered single-purpose modules into consolidated files across the dashboard, process, and simulation crates.
- crates/transport: drop the TCP transport (src/tcp.rs and its tcp feature), leaving only ed25519 identity and encoding utilities behind the iroh transport
- crates/dashboard: collapse actor_detail_html/actors_html/dashboard_html/topology_html into a single html.rs, drop command/parse.rs, and inline the trace types into lib.rs
- crates/process: fold driver, pipeline_types, queue, subscriber, waker, and local pipes/signal/wait into local/mod.rs, pipeline.rs, and a unified types.rs, consolidating the public re-exports
- crates/simulation: remove the ci subdirectory (local_sim, sim) and dead node/config/trace modules, and flatten the distribution subdirectory into top-level files
- crates/datastore: remove the unused store_cli, cli, and in-memory storage, and deduplicate crypto.rs across datastore and distribution (about 190 lines of shared code removed)
- crates/distribution: drop dead codec code and trim the messages module
Signed-off-by: Zachery Aaron Shores-Chmielewski <zacheryasc@gmail.com>
2026-02-25 14:33:04 +00:00
|
|
|
|
|
|
|
|
// ─── Generic Simulation Node Traits ─────────────────────────────────────────
|
|
|
|
|
|
|
|
|
|
/// A message produced by a simulated node.
|
|
|
|
|
pub trait SimMessage {
|
|
|
|
|
type NodeId;
|
|
|
|
|
/// The target node for this message, if any.
|
|
|
|
|
/// `None` means the message is a local notification (no delivery needed).
|
|
|
|
|
fn target(&self) -> Option<&Self::NodeId>;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// A simulated protocol node.
|
|
|
|
|
pub trait SimNode: Sized {
|
|
|
|
|
type Config: Clone;
|
|
|
|
|
type NodeId: Clone + Eq + std::hash::Hash + std::fmt::Debug;
|
|
|
|
|
type Message: SimMessage<NodeId = Self::NodeId>;
|
|
|
|
|
type Snapshot: serde::Serialize;
|
|
|
|
|
type EventKind: serde::Serialize;
|
|
|
|
|
|
|
|
|
|
fn new(config: Self::Config) -> Self;
|
|
|
|
|
fn node_id(&self) -> Self::NodeId;
|
|
|
|
|
fn tick(&mut self) -> Vec<Self::Message>;
|
|
|
|
|
fn receive(&mut self, from: Self::NodeId, msg: Self::Message) -> Vec<Self::Message>;
|
|
|
|
|
fn snapshot(&self) -> Self::Snapshot;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// ─── Simulation Configuration ───────────────────────────────────────────────
|
|
|
|
|
|
|
|
|
|
use crate::topology::Topology;
|
|
|
|
|
|
|
|
|
|
/// Generic simulation configuration (protocol-agnostic).
|
|
|
|
|
#[derive(Debug, Clone)]
|
|
|
|
|
pub struct SimConfig {
|
|
|
|
|
pub name: String,
|
|
|
|
|
pub topology: Topology,
|
|
|
|
|
pub num_nodes: usize,
|
|
|
|
|
pub num_rounds: usize,
|
|
|
|
|
pub ticks_per_round: usize,
|
|
|
|
|
/// If `Some(r)`, cross-partition links are added after round `r`.
|
|
|
|
|
pub heal_after_round: Option<usize>,
|
|
|
|
|
/// Number of worker threads: 1 = deterministic single-threaded.
|
|
|
|
|
pub num_threads: usize,
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// ─── Trace Types ────────────────────────────────────────────────────────────
|
|
|
|
|
|
|
|
|
|
use std::sync::atomic::AtomicU64;
|
|
|
|
|
use std::sync::Arc;
|
|
|
|
|
|
|
|
|
|
use serde::{Deserialize, Serialize};
|
|
|
|
|
|
|
|
|
|
/// Shared tick counter — the simulation harness increments this.
|
|
|
|
|
pub type TickCounter = Arc<AtomicU64>;
|
|
|
|
|
|
|
|
|
|
/// A single simulation event, generic over the event kind `K`.
|
|
|
|
|
#[derive(Debug, Clone, Serialize, Deserialize)]
|
|
|
|
|
#[serde(bound(
|
|
|
|
|
serialize = "K: Serialize",
|
|
|
|
|
deserialize = "K: serde::de::DeserializeOwned"
|
|
|
|
|
))]
|
|
|
|
|
pub struct Event<K> {
|
|
|
|
|
pub tick: u64,
|
|
|
|
|
pub node_name: String,
|
|
|
|
|
pub kind: K,
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// Complete output of a simulation run, generic over event kind `K` and snapshot type `S`.
|
|
|
|
|
#[derive(Debug, Clone, Serialize, Deserialize)]
|
|
|
|
|
#[serde(bound(
|
|
|
|
|
serialize = "K: Serialize, S: Serialize",
|
|
|
|
|
deserialize = "K: serde::de::DeserializeOwned, S: serde::de::DeserializeOwned"
|
|
|
|
|
))]
|
|
|
|
|
pub struct SimulationTrace<K, S> {
|
|
|
|
|
pub name: String,
|
|
|
|
|
/// Discriminator for dashboard rendering ("gossip" or "distribution").
|
|
|
|
|
#[serde(default)]
|
|
|
|
|
pub trace_type: String,
|
|
|
|
|
pub node_names: Vec<String>,
|
|
|
|
|
pub topology_edges: Vec<(String, String)>,
|
|
|
|
|
pub events: Vec<Event<K>>,
|
|
|
|
|
pub snapshots_per_round: Vec<Vec<(String, S)>>,
|
|
|
|
|
pub num_rounds: usize,
|
|
|
|
|
}
|