pub struct Lab;Expand description
FrankenLab — deterministic model testing harness.
Combines LabScenario (seed, logging, tracing spans, metrics) with
ProgramSimulator (headless model execution) into a single API.
Implementations§
Source§impl Lab
impl Lab
Sourcepub fn run_scenario<M: Model>(
config: LabConfig,
model: M,
run: impl FnOnce(&mut LabSession<M>),
) -> LabScenarioRun<LabOutput>
pub fn run_scenario<M: Model>( config: LabConfig, model: M, run: impl FnOnce(&mut LabSession<M>), ) -> LabScenarioRun<LabOutput>
Run a deterministic scenario with a model.
Creates a LabScenario for the outer tracing span (including
lab.scenario with scenario_name, seed, event_count,
duration_us fields) and lab_scenarios_run_total metric counter.
The closure receives a LabSession that wraps a ProgramSimulator
with deterministic time injection, JSONL logging, and frame checksums.
Sourcepub fn assert_deterministic_with<M, MF, SF>(
config: LabConfig,
model_factory: MF,
scenario_fn: SF,
) -> LabOutput
pub fn assert_deterministic_with<M, MF, SF>( config: LabConfig, model_factory: MF, scenario_fn: SF, ) -> LabOutput
Verify determinism with a custom scenario closure.
Runs scenario_fn twice with the same seed and model, asserting
frame checksum equality.
§Panics
Panics if frame counts differ or any checksum mismatches.
Source§impl Lab
impl Lab
Sourcepub fn record<M: Model>(
config: LabConfig,
model: M,
run: impl FnOnce(&mut LabSession<M>),
) -> Recording
pub fn record<M: Model>( config: LabConfig, model: M, run: impl FnOnce(&mut LabSession<M>), ) -> Recording
Record a deterministic scenario run.
Executes the scenario closure and captures frame checksums and event
ordering into a Recording that can later be replayed with
Lab::replay.
Emits a lab.record tracing span.
Sourcepub fn replay<M: Model>(
recording: &Recording,
model: M,
run: impl FnOnce(&mut LabSession<M>),
) -> ReplayResult
pub fn replay<M: Model>( recording: &Recording, model: M, run: impl FnOnce(&mut LabSession<M>), ) -> ReplayResult
Replay a recording with a new model instance.
Re-runs the same scenario closure with the same seed/config from the
recording and compares frame checksums. Returns a ReplayResult
indicating whether the replay matched.
Emits a lab.replay tracing span. Logs WARN for any divergence.
Sourcepub fn assert_replay_deterministic<M, MF, SF>(
config: LabConfig,
model_factory: MF,
scenario_fn: SF,
) -> Recording
pub fn assert_replay_deterministic<M, MF, SF>( config: LabConfig, model_factory: MF, scenario_fn: SF, ) -> Recording
Record and immediately replay, asserting determinism.
Convenience method: runs the scenario twice (once to record, once to replay) and panics if any frame checksum diverges.
§Panics
Panics on any divergence between recording and replay.