Skip to main content

Lab

Struct Lab 

Source
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

Source

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.

Source

pub fn assert_deterministic_with<M, MF, SF>( config: LabConfig, model_factory: MF, scenario_fn: SF, ) -> LabOutput
where M: Model, MF: Fn() -> M, SF: Fn(&mut LabSession<M>),

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

Source

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.

Source

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.

Source

pub fn assert_replay_deterministic<M, MF, SF>( config: LabConfig, model_factory: MF, scenario_fn: SF, ) -> Recording
where M: Model, MF: Fn() -> M, SF: Fn(&mut LabSession<M>),

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.

Auto Trait Implementations§

§

impl Freeze for Lab

§

impl RefUnwindSafe for Lab

§

impl Send for Lab

§

impl Sync for Lab

§

impl Unpin for Lab

§

impl UnsafeUnpin for Lab

§

impl UnwindSafe for Lab

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more