pub struct LabRuntime {
pub state: RuntimeState,
pub scheduler: Arc<Mutex<LabScheduler>>,
pub oracles: OracleSuite,
/* private fields */
}Expand description
The deterministic lab runtime.
This runtime is designed for testing and provides:
- Virtual time instead of wall-clock time
- Deterministic scheduling based on a seed
- Trace capture for debugging and replay
- Chaos injection for stress testing
Fields§
§state: RuntimeStateRuntime state (public for tests and oracle access).
scheduler: Arc<Mutex<LabScheduler>>Scheduler.
oracles: OracleSuiteOracle suite for invariant verification.
Implementations§
Source§impl LabRuntime
impl LabRuntime
Sourcepub fn new(config: LabConfig) -> LabRuntime
pub fn new(config: LabConfig) -> LabRuntime
Creates a new lab runtime with the given configuration.
Sourcepub fn with_seed(seed: u64) -> LabRuntime
pub fn with_seed(seed: u64) -> LabRuntime
Creates a lab runtime with the default configuration.
Sourcepub fn lab_reactor(&self) -> &Arc<LabReactor>
pub fn lab_reactor(&self) -> &Arc<LabReactor>
Returns a handle to the lab reactor for deterministic I/O injection.
Sourcepub fn trace(&self) -> &TraceBufferHandle
pub fn trace(&self) -> &TraceBufferHandle
Returns a reference to the trace buffer handle.
Sourcepub fn detected_races(&self) -> RaceReport
pub fn detected_races(&self) -> RaceReport
Returns a race report derived from the current trace buffer.
Sourcepub fn chaos_stats(&self) -> &ChaosStats
pub fn chaos_stats(&self) -> &ChaosStats
Returns a reference to the chaos statistics.
Sourcepub fn certificate(&self) -> &ScheduleCertificate
pub fn certificate(&self) -> &ScheduleCertificate
Returns the schedule certificate for determinism verification.
Sourcepub fn has_replay_recording(&self) -> bool
pub fn has_replay_recording(&self) -> bool
Returns true if replay recording is enabled.
Sourcepub fn replay_recorder(&self) -> &TraceRecorder
pub fn replay_recorder(&self) -> &TraceRecorder
Returns a reference to the replay recorder.
Sourcepub fn take_replay_trace(&mut self) -> Option<ReplayTrace>
pub fn take_replay_trace(&mut self) -> Option<ReplayTrace>
Takes the replay trace, leaving an empty trace in place.
Returns None if recording is disabled.
Sourcepub fn finish_replay_trace(&mut self) -> Option<ReplayTrace>
pub fn finish_replay_trace(&mut self) -> Option<ReplayTrace>
Finishes recording and returns the replay trace.
This consumes the replay recorder. Returns None if recording is disabled.
Sourcepub fn is_quiescent(&self) -> bool
pub fn is_quiescent(&self) -> bool
Returns true if the runtime is quiescent.
Sourcepub fn advance_time(&mut self, nanos: u64)
pub fn advance_time(&mut self, nanos: u64)
Advances virtual time by the given number of nanoseconds.
Sourcepub fn advance_time_to(&mut self, time: Time)
pub fn advance_time_to(&mut self, time: Time)
Advances time to the given absolute time.
Sourcepub fn run_until_quiescent(&mut self) -> u64
pub fn run_until_quiescent(&mut self) -> u64
Runs until quiescent or max steps reached.
Returns the number of steps executed.
Sourcepub fn enable_deadline_monitoring(&mut self, config: MonitorConfig)
pub fn enable_deadline_monitoring(&mut self, config: MonitorConfig)
Enable deadline monitoring with the default warning handler.
Sourcepub fn enable_deadline_monitoring_with_handler<F>(
&mut self,
config: MonitorConfig,
f: F,
)
pub fn enable_deadline_monitoring_with_handler<F>( &mut self, config: MonitorConfig, f: F, )
Enable deadline monitoring with a custom warning handler.
Sourcepub fn deadline_monitor_mut(&mut self) -> Option<&mut DeadlineMonitor>
pub fn deadline_monitor_mut(&mut self) -> Option<&mut DeadlineMonitor>
Returns a mutable reference to the deadline monitor, if enabled.
Sourcepub fn step_for_test(&mut self)
pub fn step_for_test(&mut self)
Public wrapper for step() for use in tests.
This is useful for testing determinism across multiple step executions.
Sourcepub fn check_invariants(&mut self) -> Vec<InvariantViolation>
pub fn check_invariants(&mut self) -> Vec<InvariantViolation>
Checks invariants and returns any violations.