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
impl CausalProtocol
Sourcepub fn check_acyclicity(&self) -> Vec<ProtocolViolation>
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.
Sourcepub fn check_reachability(&self) -> Vec<ProtocolViolation>
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.
Sourcepub fn check_performative_definedness(
&self,
defined_performatives: &[&str],
) -> Vec<ProtocolViolation>
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.
Sourcepub fn expansion_size(&self) -> u32
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.
Sourcepub fn check_step_uniqueness(&self) -> Vec<ProtocolViolation>
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.
Sourcepub fn verify_r5_protocol(
&self,
defined_performatives: &[&str],
) -> Vec<ProtocolViolation>
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).