Skip to main content

LeanRunner

Struct LeanRunner 

Source
pub struct LeanRunner { /* private fields */ }
Expand description

Runner for invoking the Lean verification binary.

The runner manages invocation of the telltale_validator Lean executable, handling temporary file creation for JSON exchange and parsing results.

Implementations§

Source§

impl LeanRunner

Source

pub const PROTOCOL_MACHINE_RUNNER_BINARY_PATH: &'static str = "lean/.lake/build/bin/protocol_machine_runner"

Default path to the protocol-machine runner binary (relative to workspace root).

Source

pub const PROTOCOL_MACHINE_RUNNER_FALLBACK_PATH: &'static str = "scripts/lean/protocol-machine-runner.sh"

Fallback source-backed launcher for the protocol-machine runner.

Source

pub fn is_projection_available() -> bool

Check if the validator binary is available for projection export.

Source

pub fn project( &self, global_json: &Value, roles: &[String], ) -> Result<HashMap<String, Value>, LeanRunnerError>

Project a GlobalType for a list of roles using the Lean validator export mode.

Writes the GlobalType JSON to a temp file, runs telltale_validator --export-all-projections, and parses the projections.

§Output format (parsed from output file)
{
  "success": true,
  "projections": { "A": { "kind": "send", ... }, "B": { "kind": "recv", ... } }
}
Source

pub fn check_async_subtype( &self, subtype_json: &Value, supertype_json: &Value, ) -> Result<bool, LeanRunnerError>

Check conservative async-subtyping in Lean.

Invokes the Lean validator with --check-async-subtype mode and returns whether the subtype relation holds.

Source

pub fn check_orphan_free( &self, local_json: &Value, ) -> Result<bool, LeanRunnerError>

Check conservative orphan-freedom in Lean.

Invokes the Lean validator with --check-orphan-free mode and returns whether the orphan-freedom predicate holds.

Source

pub fn check_regular_practical_fragment( &self, local_json: &Value, ) -> Result<RegularPracticalFragmentCheckResult, LeanRunnerError>

Check whether a local type is in the regular practical fragment for automatic deadlock-freedom obligations.

Source

pub fn run_protocol_machine( &self, choreographies: &[ChoreographyJson], concurrency: usize, max_steps: usize, ) -> Result<Value, LeanRunnerError>

Run one or more choreographies on the Lean ProtocolMachine at a given concurrency level.

§Errors

Returns an error if the ProtocolMachine runner binary is missing, the process fails, or the output is not valid JSON.

Source

pub fn export_projection( &self, global_json: &Value, role: &str, ) -> Result<Value, LeanRunnerError>

Export Lean’s projection for a single role.

Invokes the Lean runner with --export-projection mode and returns the JSON result containing either the computed LocalTypeR or an error.

Source

pub fn export_all_projections( &self, global_json: &Value, ) -> Result<Value, LeanRunnerError>

Export Lean’s projection for all roles in a GlobalType.

Invokes the Lean runner with --export-all-projections mode and returns the JSON result containing projections for all roles.

Source§

impl LeanRunner

Source

pub const DEFAULT_BINARY_PATH: &'static str = "lean/.lake/build/bin/telltale_validator"

Default path to the Lean binary (relative to workspace root).

Source

pub const DEFAULT_TIMEOUT_MS: u64 = 120_000

Default timeout for Lean process invocations.

Source

pub fn new() -> Result<Self, LeanRunnerError>

Create a new LeanRunner with the default binary path.

§Errors

Returns LeanRunnerError::BinaryNotFound if the binary doesn’t exist.

Source

pub fn with_binary_path(path: impl AsRef<Path>) -> Result<Self, LeanRunnerError>

Create a LeanRunner with a custom binary path.

§Errors

Returns LeanRunnerError::BinaryNotFound if the binary doesn’t exist.

Source

pub fn try_new() -> Option<Self>

Try to create a runner, returning None if the binary is unavailable.

This is useful for tests that should skip gracefully when Lean isn’t built.

Source

pub fn for_projection() -> Result<Self, LeanRunnerError>

Create a LeanRunner for projection export (uses the validator binary).

§Errors

Returns LeanRunnerError::BinaryNotFound if the validator binary doesn’t exist.

Source

pub fn is_available() -> bool

Check if the Lean binary is available at the default path.

Source

pub fn require_available()

Require that the Lean binary is available.

This function is intended for CI environments where Lean tests should not be silently skipped. It panics with instructions if the binary is missing.

§Panics

Panics if the Lean binary is not available.

Source

pub fn validate( &self, choreography_json: &Value, program_json: &Value, ) -> Result<LeanValidationResult, LeanRunnerError>

Run validation with choreography and program JSON.

The choreography JSON should be a GlobalType JSON object.

The program JSON should have the format:

{
  "role": "A",
  "local_type": { "kind": "send", ... }
}
§Errors

Returns an error if:

  • Temporary files cannot be created
  • JSON serialization fails
  • The Lean process fails to execute
  • Output parsing fails

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

Source§

fn az<Dst>(self) -> Dst
where T: Cast<Dst>,

Casts the value.
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<Src, Dst> CastFrom<Src> for Dst
where Src: Cast<Dst>,

Source§

fn cast_from(src: Src) -> Dst

Casts the value.
Source§

impl<T> CheckedAs for T

Source§

fn checked_as<Dst>(self) -> Option<Dst>
where T: CheckedCast<Dst>,

Casts the value.
Source§

impl<Src, Dst> CheckedCastFrom<Src> for Dst
where Src: CheckedCast<Dst>,

Source§

fn checked_cast_from(src: Src) -> Option<Dst>

Casts the value.
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<Src, Dst> LosslessTryInto<Dst> for Src
where Dst: LosslessTryFrom<Src>,

Source§

fn lossless_try_into(self) -> Option<Dst>

Performs the conversion.
Source§

impl<Src, Dst> LossyInto<Dst> for Src
where Dst: LossyFrom<Src>,

Source§

fn lossy_into(self) -> Dst

Performs the conversion.
Source§

impl<T> OverflowingAs for T

Source§

fn overflowing_as<Dst>(self) -> (Dst, bool)
where T: OverflowingCast<Dst>,

Casts the value.
Source§

impl<Src, Dst> OverflowingCastFrom<Src> for Dst
where Src: OverflowingCast<Dst>,

Source§

fn overflowing_cast_from(src: Src) -> (Dst, bool)

Casts the value.
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> SaturatingAs for T

Source§

fn saturating_as<Dst>(self) -> Dst
where T: SaturatingCast<Dst>,

Casts the value.
Source§

impl<Src, Dst> SaturatingCastFrom<Src> for Dst
where Src: SaturatingCast<Dst>,

Source§

fn saturating_cast_from(src: Src) -> Dst

Casts the value.
Source§

impl<T> StrictAs for T

Source§

fn strict_as<Dst>(self) -> Dst
where T: StrictCast<Dst>,

Casts the value.
Source§

impl<Src, Dst> StrictCastFrom<Src> for Dst
where Src: StrictCast<Dst>,

Source§

fn strict_cast_from(src: Src) -> Dst

Casts the value.
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<T> UnwrappedAs for T

Source§

fn unwrapped_as<Dst>(self) -> Dst
where T: UnwrappedCast<Dst>,

Casts the value.
Source§

impl<Src, Dst> UnwrappedCastFrom<Src> for Dst
where Src: UnwrappedCast<Dst>,

Source§

fn unwrapped_cast_from(src: Src) -> Dst

Casts the value.
Source§

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

Source§

fn vzip(self) -> V

Source§

impl<T> WrappingAs for T

Source§

fn wrapping_as<Dst>(self) -> Dst
where T: WrappingCast<Dst>,

Casts the value.
Source§

impl<Src, Dst> WrappingCastFrom<Src> for Dst
where Src: WrappingCast<Dst>,

Source§

fn wrapping_cast_from(src: Src) -> Dst

Casts the value.