pub struct Session { /* private fields */ }Expand description
Immutable validation inputs. Every interpretation gets a freshly bound runtime. The caller’s caches, registers, host and atoms are never copied.
use std::sync::Arc;
use dive_trace::{Session, TraceDoc, Validation};
let source = "---- MODULE M ----\nEXTENDS TLC\nVARIABLE x\n\
ASSUME TLCSet(1,42)\nInit == x=0 /\\ TLCGet(1)=42\n\
Next == x'=x\n====\n";
let analysis = dive_sema::analyze_source("M.tla", source, &Default::default());
let ir = Arc::new(dive_ir::lower(&analysis).unwrap());
let config = dive_config::parse("INIT Init\nNEXT Next\n").into_config().unwrap();
let recipe = dive_model::Recipe::new(ir, config, dive_eval::Options::tlc(), false);
let session = Session::new(recipe, None);
let doc = TraceDoc::behavior(vec![serde_json::json!({"x":0})]).unwrap();
assert_eq!(session.read(&doc).0.validation, Validation::Valid);Implementations§
Source§impl Session
impl Session
Sourcepub fn new(recipe: Recipe, config: Option<RunConfig>) -> Self
pub fn new(recipe: Recipe, config: Option<RunConfig>) -> Self
Retains source/config inputs and typed run metadata, with no callbacks.
Sourcepub fn with_inputs(self, inputs: RecordedInputs) -> Self
pub fn with_inputs(self, inputs: RecordedInputs) -> Self
Supplies explicit external assumptions for fresh, ordered source replay. No operating-system input is read. The recipe retains its own category grants; supplied records must match actual binding operations exactly.
Sourcepub fn read(&self, doc: &TraceDoc) -> (Report, Option<TraceDoc>)
pub fn read(&self, doc: &TraceDoc) -> (Report, Option<TraceDoc>)
Reads and validates a document, returning a plain document for transport. Transport uses text/JSON; private interner atoms cannot escape the runtime.
Sourcepub fn read_controlled(
&self,
doc: &TraceDoc,
control: Arc<dyn HostControl>,
) -> Result<(Report, Option<TraceDoc>), ValidationRunError>
pub fn read_controlled( &self, doc: &TraceDoc, control: Arc<dyn HostControl>, ) -> Result<(Report, Option<TraceDoc>), ValidationRunError>
Reads a native trace on a fresh privately bound runtime with typed control. Endpoint descriptors are independently compiled and replayed; no producer validation flag is authority. This new controlled fresh-session path supports native source error endpoints and finite behavior, invariant, action-property and deadlock words. TLC JSON interpretation retains its existing entrypoints.
let (report, _) = session.read_controlled(document, control)?;§Errors
Typed binding or validation interruption with progress, or conflicting evaluator control ownership. Other refusals remain validation reports.
Sourcepub fn read_sampled(
&self,
doc: &TraceDoc,
control: Option<Arc<dyn HostControl>>,
) -> Result<(Report, Option<TraceDoc>), ValidationRunError>
pub fn read_sampled( &self, doc: &TraceDoc, control: Option<Arc<dyn HostControl>>, ) -> Result<(Report, Option<TraceDoc>), ValidationRunError>
Independently checks a native finite sample on a freshly reconstructed
runtime. The document must retain its ordinary behavior ending; this
separate operation also checks every sampled constraint, invariant and
implied finite property. It proves neither exhaustive safety nor liveness.
Fairness-only specifications are allowed; configured temporal properties
remain unsupported. No producer metadata selects this operation.
§Errors
The same typed resource, interruption and control failures as
Self::read_controlled.
Sourcepub fn read_sampled_deadlock(
&self,
doc: &TraceDoc,
control: Option<Arc<dyn HostControl>>,
) -> Result<(Report, Option<TraceDoc>), ValidationRunError>
pub fn read_sampled_deadlock( &self, doc: &TraceDoc, control: Option<Arc<dyn HostControl>>, ) -> Result<(Report, Option<TraceDoc>), ValidationRunError>
Independently checks a native finite deadlock found by simulation on a
freshly reconstructed runtime. Simulation keeps only the successors that
satisfy every CONSTRAINT and ACTION_CONSTRAINT, as TLC’s simulator
does, so its deadlock is a last state none of whose successors is in
the model. This operation regenerates every successor of the last state
and rejects the word if any of them satisfies all the constraints; the
rest of the word is checked as by Self::read_controlled. Exhaustive
checking callers keep Self::read_controlled, whose deadlock has no
successor at all. No producer metadata selects this operation.
let (report, _) = session.read_sampled_deadlock(document, None)?;§Errors
The same typed resource, interruption and control failures as
Self::read_controlled.
Sourcepub fn try_read(
&self,
doc: &TraceDoc,
) -> Result<(Report, Option<TraceDoc>), ValidationRunError>
pub fn try_read( &self, doc: &TraceDoc, ) -> Result<(Report, Option<TraceDoc>), ValidationRunError>
Validates a document with resource exceptions outside the report. No budget or artificial control is installed by this uncontrolled path. Documents without temporal error endpoints use the plain reader; those endpoints use fresh private binding, ordered reconstruction and finite replay.
let (report, _) = session.try_read(doc)?;§Errors
Allocation/resource failure or a typed evaluation-control interruption; neither is a completed validation verdict.
Sourcepub fn initial_error_stage(
&self,
control: Option<Arc<dyn HostControl>>,
) -> Result<(Report, Option<InitialErrorStage>), ValidationRunError>
pub fn initial_error_stage( &self, control: Option<Arc<dyn HostControl>>, ) -> Result<(Report, Option<InitialErrorStage>), ValidationRunError>
Reconstructs the first actual Init operation before selecting an error transport. Reported site/codes cannot disguise an emitted receiver error as a generation error to evade its required diagnostic witness. The no-word stages require matching actual diagnostic receiver catches.
§Errors
Typed interruption, resource/internal failure or control conflict; neither a stage nor an exception certificate exists in these cases.
Sourcepub fn initial_invariant_class(
&self,
doc: &TraceDoc,
control: Option<Arc<dyn HostControl>>,
) -> Result<(Report, Option<InitialInvariantClass>), ValidationRunError>
pub fn initial_invariant_class( &self, doc: &TraceDoc, control: Option<Arc<dyn HostControl>>, ) -> Result<(Report, Option<InitialInvariantClass>), ValidationRunError>
Validates a named invariant-error word, then independently reconstructs its bounded first-Init receiver exception and diagnostic wrapper. Ordinary word validity alone never grants the optional class evidence. The document retains version 2 and names its original underlying cause.
let (report, class) = session.initial_invariant_class(word, None)?;
if let Some(class) = class {
assert!(report.validation.is_valid());
assert_eq!(class.deciding_code(), 2147);
}§Errors
Original typed interruption, resource/internal failure or conflicting control ownership; none can produce a class certificate.
Sourcepub fn invariant_error_class(
&self,
doc: &TraceDoc,
control: Option<Arc<dyn HostControl>>,
) -> Result<(Report, Option<InvariantErrorClass>), ValidationRunError>
pub fn invariant_error_class( &self, doc: &TraceDoc, control: Option<Arc<dyn HostControl>>, ) -> Result<(Report, Option<InvariantErrorClass>), ValidationRunError>
Validates a named successor-invariant word and independently executes one exhausted Init, each earlier admitted source and actual diagnostic replay with bounded private key history. No serialized metadata or ordinary word validity supplies this evidence.
§Errors
Actual interruption, resource/internal failure or control conflict; no completed class certificate is returned for these failures.