Skip to main content

CausalProtocol

Struct CausalProtocol 

Source
pub struct CausalProtocol {
    pub steps: BTreeMap<String, StepDecl>,
}
Expand description

Parsed causal protocol declaration (REQ-200, REQ-201).

Built from (protocol (then ...)+) S-expression syntax. Stores the dependency graph as a map from performative name to step declaration.

Fields§

§steps: BTreeMap<String, StepDecl>

Implementations§

Source§

impl CausalProtocol

Source

pub fn check_acyclicity(&self) -> Vec<ProtocolViolation>

Check acyclicity of the protocol dependency graph (REQ-204).

Uses DFS with white/gray/black colouring to detect back edges. Returns violations for each cycle found.

Source

pub fn check_reachability(&self) -> Vec<ProtocolViolation>

Check that all steps are reachable from begin (REQ-205).

Uses BFS from begin over the successor graph.

Source

pub fn check_performative_definedness( &self, defined_performatives: &[&str], ) -> Vec<ProtocolViolation>

Check that all referenced performatives are defined (REQ-206).

defined_performatives should include all performatives from the dialect’s extend clauses and installed ancestors. begin is always valid.

Source

pub fn expansion_size(&self) -> u32

Number of protocol steps that count against R2’s declared expansion budget at install (SPEC-015 REQ-704): every named step — including (repeat k …) copies, which are already materialised in steps by the time a CausalProtocol exists — except the begin root, which is a keyword, not an expansion product. A hand-unrolled equivalent protocol counts identically, which is what keeps k honest.

Source

pub fn check_step_uniqueness(&self) -> Vec<ProtocolViolation>

Check that no performative has duplicate step declarations (REQ-207).

CausalProtocol::steps is keyed by performative name, so step names cannot collide structurally. The remaining hazard is the (then …) parser, which accumulates predecessor NodeRef entries across clauses by push: every clause that targets the same performative pushes another entry. Distinct-alternative declarations like (then begin a) (then b a) are intentional — verify_causal reads the resulting [Single("begin"), Single("b")] as begin ∨ b for the predecessor of a (see allowed_single_predecessors), so this shape must pass R5. What R5 does forbid is literal duplication, e.g. the same (then begin a) clause written twice, which collapses to [Single("begin"), Single("begin")] and signals an authoring error rather than an alternative. Use has_duplicate so only equal NodeRef entries are rejected. Successor duplicates are still flagged as a defence-in-depth check against programmatically-constructed protocols whose two sides have drifted out of sync.

Source

pub fn verify_r5_protocol( &self, defined_performatives: &[&str], ) -> Vec<ProtocolViolation>

Run all R5 protocol checks (REQ-208).

Checks: step uniqueness (REQ-207), acyclicity (REQ-204), reachability (REQ-205), and performative definedness (REQ-206).

Trait Implementations§

Source§

impl Clone for CausalProtocol

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 CausalProtocol

Source§

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

Formats the value using the given formatter. Read more
Source§

impl Eq for CausalProtocol

Source§

impl PartialEq for CausalProtocol

Source§

fn eq(&self, other: &Self) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

impl StructuralPartialEq for CausalProtocol

Auto Trait Implementations§

§

impl Forget for CausalProtocol

§

impl Freeze for CausalProtocol
where *const LeafNode<String, StepDecl> is !null: Freeze, PhantomData<(Owned, LeafOrInternal)>: Freeze, PhantomData<Box<(String, StepDecl)>>: Freeze,

§

impl Move for CausalProtocol

§

impl RefUnwindSafe for CausalProtocol

§

impl Send for CausalProtocol
where NodeRef<Owned, String, StepDecl, LeafOrInternal>: Send, BoxRaw<(String, StepDecl)>: Send,

§

impl Sync for CausalProtocol
where NodeRef<Owned, String, StepDecl, LeafOrInternal>: Sync, BoxRaw<(String, StepDecl)>: Sync,

§

impl Unpin for CausalProtocol
where *const LeafNode<String, StepDecl> is !null: Unpin, Box<(String, StepDecl)>: Unpin,

§

impl UnsafeUnpin for CausalProtocol
where *const LeafNode<String, StepDecl> is !null: UnsafeUnpin, PhantomData<(Owned, LeafOrInternal)>: UnsafeUnpin, PhantomData<Box<(String, StepDecl)>>: UnsafeUnpin,

§

impl UnwindSafe for CausalProtocol

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<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

Source§

fn equivalent(&self, key: &K) -> bool

Checks if this value is equivalent to the given key. 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.