pub struct LockstepWorld { /* private fields */ }Expand description
Single-threaded simulation world for lockstep (synchronous) execution.
Created from a WorldConfig via new().
Each step_sync() call runs one complete
tick: submit commands → drain ingress → run propagator pipeline →
publish snapshot → return results.
§Example
let world = LockstepWorld::new(config)?;
for _ in 0..1000 {
let result = world.step_sync(commands)?;
let obs = result.snapshot.read(field_id);
}Implementations§
Source§impl LockstepWorld
impl LockstepWorld
Sourcepub fn new(config: WorldConfig) -> Result<Self, ConfigError>
pub fn new(config: WorldConfig) -> Result<Self, ConfigError>
Create a new lockstep world from a WorldConfig.
Validates the configuration, builds the read resolution plan,
constructs the arena, and returns a ready-to-step world.
Consumes the WorldConfig.
Sourcepub fn step_sync(
&mut self,
commands: Vec<Command>,
) -> Result<StepResult<'_>, TickError>
pub fn step_sync( &mut self, commands: Vec<Command>, ) -> Result<StepResult<'_>, TickError>
Execute one tick synchronously.
Submits commands to the ingress queue, runs the full propagator
pipeline, publishes the new snapshot, and returns a StepResult
containing the snapshot reference, receipts, and metrics.
The returned Snapshot borrows from self, preventing the caller
from calling step_sync() again until the snapshot is dropped.
§Errors
Returns TickError if a propagator fails (tick is rolled back
atomically) or if ticking is disabled after consecutive rollbacks.
On rollback, the error’s receipts field contains per-command
rollback receipts plus any submission rejections.
Sourcepub fn reset(&mut self, seed: u64) -> Result<Snapshot<'_>, ConfigError>
pub fn reset(&mut self, seed: u64) -> Result<Snapshot<'_>, ConfigError>
Reset the world to tick 0 with a new seed.
Reclaims all arena memory, clears the ingress queue, and resets all counters. Returns a snapshot of the initial (zeroed) state.
The seed is stored for future use when propagators support
seeded RNG. Currently all runs are fully deterministic regardless
of seed.
Sourcepub fn snapshot(&self) -> Snapshot<'_>
pub fn snapshot(&self) -> Snapshot<'_>
Get a read-only snapshot of the current published generation.
Sourcepub fn current_tick(&self) -> TickId
pub fn current_tick(&self) -> TickId
Current tick ID (0 after construction or reset).
Sourcepub fn is_tick_disabled(&self) -> bool
pub fn is_tick_disabled(&self) -> bool
Whether ticking is disabled due to consecutive rollbacks.
Sourcepub fn last_metrics(&self) -> &StepMetrics
pub fn last_metrics(&self) -> &StepMetrics
Metrics from the most recent successful tick.
Sourcepub fn consecutive_rollback_count(&self) -> u32
pub fn consecutive_rollback_count(&self) -> u32
Number of consecutive rollbacks since the last successful tick.