Skip to main content

Session

Struct Session 

Source
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

Source

pub fn new(recipe: Recipe, config: Option<RunConfig>) -> Self

Retains source/config inputs and typed run metadata, with no callbacks.

Source

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.

Source

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.

Source

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.

Source

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.

Source

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.

Source

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.

Source

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.

Source

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.

Source

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.

Trait Implementations§

Source§

impl Clone for Session

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for Session

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

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> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

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

Source§

type Error = !

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

fn try_from(value: U) -> Result<T, !>

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.