Skip to main content

cbcl_core/
splice.rs

1//! Splice-coherence: a **de-risking prototype** of a candidate relaxation of
2//! R6(vi) causal locality (NOT a shipped installation check).
3//!
4//! R6(vi) (`r6::r6_violations` / `NotCausallyLocal`) demands that every
5//! endpoint role of a performative `t` is also an endpoint role of every legal
6//! predecessor of `t`: a role must *observe* every message its own messages
7//! causally cite. Splice-coherence is the proposed weaker condition under which
8//! a role `r` may cite a *bystander* predecessor `b` (one `r` is not an endpoint
9//! of) provided the bystander's TYPE is recoverable from the r-relevant messages
10//! that bracket it:
11//!
12//! - (A) INTERVAL TYPE-FORCING — the bystander's performative type is uniquely
13//!   determined by the r-relevant messages that causally bracket it (a `Single`
14//!   or `All` predecessor edge forces the type; an `(any …)` of ≥2 distinct
15//!   bystander types does not);
16//! - (B) CHOICE-RECOVERY — an unobserved `(any …)` chooser among bystanders is
17//!   admissible iff either (a) it is r-invariant (MERGE: every branch reaches the
18//!   same r-relevant continuation) or (b) it is hash-pinned (each branch is the
19//!   unique `Single` predecessor of a distinct r-relevant message, so whichever
20//!   branch is taken, `r` holds an r-relevant message that type-forces it).
21//!
22//! This module is a faithful, static encoding of that *candidate* definition so
23//! the de-risking study can run it over the real corpus. It quantifies over the
24//! dialect's roles and causal protocol only (a pure function of the same data
25//! `r6_violations` reads), and is decidable: a backward DAG walk over finitely
26//! many bystander intervals (see `splice_coherence_violations`' complexity note).
27//!
28//! IMPORTANT (soundness caveat, documented for the de-risking verdict): the
29//! *structural* coherence computed here is NOT the same as local verifiability
30//! in the mechanised semantics. `protocol::predecessor_type` resolves a
31//! `:caused-by` hash only from a held full message or a held (type-tagged)
32//! envelope; a bare content-hash is type-opaque, so
33//! `Projectability.permanently_unknown_of_nonlocal_pred` proves an r-relevant
34//! message with an unheld predecessor is *permanently* `Unknown`. A `Single`
35//! edge marked "type-forced" here does not let `r` itself decide the referent's
36//! type. The tests below exhibit a protocol this structural check ACCEPTS that
37//! has no correct projection — the evidence behind the study's verdict.
38
39#![forbid(unsafe_code)]
40
41use crate::dialect::Dialect;
42use crate::protocol::{repeat_base_name, NodeRef, BEGIN_KEYWORD};
43use crate::role::RoleAnnotation;
44use alloc::collections::{BTreeMap, BTreeSet};
45use alloc::string::String;
46use alloc::vec::Vec;
47
48/// Endpoint roles of an annotated performative: sender ∪ recipients.
49fn endpoints(ann: &RoleAnnotation) -> BTreeSet<&str> {
50    let mut set: BTreeSet<&str> = ann.to.iter().map(String::as_str).collect();
51    set.insert(ann.from.as_str());
52    set
53}
54
55/// Why a spliced citation onto a role is not coherent.
56#[derive(Debug, Clone, PartialEq, Eq)]
57pub enum SpliceReason {
58    /// (A) failed and neither (B)(a) MERGE nor (B)(b) HASH-PIN rescued it: an
59    /// unobserved `(any …)` chooser among ≥2 distinct-typed bystanders whose
60    /// branch `r` cannot recover.
61    UnrecoverableChoice,
62}
63
64/// A failure of splice-coherence onto one role: the r-relevant message `m`
65/// whose `:caused-by` reaches a bystander whose type `r` cannot recover.
66#[derive(Debug, Clone, PartialEq, Eq)]
67pub struct SpliceFailure {
68    pub role: String,
69    /// The r-relevant message whose spliced citation cannot be verified.
70    pub message: String,
71    /// The bystander predecessor (the `(any …)` chooser) that breaks forcing.
72    pub bystander: String,
73    pub reason: SpliceReason,
74}
75
76/// How a spliced-citation edge onto `r` is discharged (for the study table).
77#[derive(Debug, Clone, Copy, PartialEq, Eq)]
78pub enum Discharge {
79    /// (A): a `Single`/`All` edge — the bystander's type is forced.
80    TypeForced,
81    /// (B)(a): an unobserved choice whose branches reach the same r-relevant
82    /// continuation.
83    Merge,
84    /// (B)(b): an unobserved choice each of whose branches is the unique
85    /// `Single` predecessor of a distinct r-relevant message.
86    HashPinned,
87}
88
89/// One discharged spliced-citation edge (for reporting which disjunct fired).
90#[derive(Debug, Clone, PartialEq, Eq)]
91pub struct DischargedEdge {
92    pub role: String,
93    pub message: String,
94    pub bystander: String,
95    pub how: Discharge,
96}
97
98struct Analyzer<'d> {
99    ann: BTreeMap<&'d str, &'d RoleAnnotation>,
100    /// name -> its predecessor node-refs.
101    preds: BTreeMap<&'d str, &'d [NodeRef]>,
102    /// forward edges a -> {b : a is a legal predecessor of b}.
103    forward: BTreeMap<&'d str, BTreeSet<&'d str>>,
104}
105
106impl<'d> Analyzer<'d> {
107    fn new(d: &'d Dialect) -> Option<Self> {
108        let cp = d.causal_protocol.as_ref()?;
109        let ann: BTreeMap<&str, &RoleAnnotation> = d
110            .performatives
111            .iter()
112            .filter_map(|p| p.role.as_ref().map(|a| (p.name.as_str(), a)))
113            .collect();
114        let mut preds: BTreeMap<&str, &[NodeRef]> = BTreeMap::new();
115        let mut forward: BTreeMap<&str, BTreeSet<&str>> = BTreeMap::new();
116        for step in cp.steps.values() {
117            preds.insert(step.performative.as_str(), step.predecessors.as_slice());
118            for nr in &step.predecessors {
119                for p in nr.performatives() {
120                    forward
121                        .entry(p)
122                        .or_default()
123                        .insert(step.performative.as_str());
124                }
125            }
126            for nr in &step.successors {
127                for s in nr.performatives() {
128                    forward
129                        .entry(step.performative.as_str())
130                        .or_default()
131                        .insert(s);
132                }
133            }
134        }
135        Some(Self {
136            ann,
137            preds,
138            forward,
139        })
140    }
141
142    fn endpoints_of(&self, name: &str) -> Option<BTreeSet<&'d str>> {
143        self.ann.get(repeat_base_name(name)).map(|a| endpoints(a))
144    }
145
146    /// r-relevance: `r` is an endpoint of `name` (root convention: `begin`
147    /// counts every role — it is a universal bracket).
148    fn relevant(&self, name: &str, r: &str) -> bool {
149        if name == BEGIN_KEYWORD {
150            return true;
151        }
152        self.endpoints_of(name).is_some_and(|e| e.contains(r))
153    }
154
155    /// r-relevant steps forward-reachable from `from` (its onward closure).
156    fn forward_relevant(&self, from: &str, r: &str) -> BTreeSet<String> {
157        let mut seen: BTreeSet<&str> = BTreeSet::new();
158        let mut stack = alloc::vec![from];
159        let mut out = BTreeSet::new();
160        while let Some(n) = stack.pop() {
161            if !seen.insert(n) {
162                continue;
163            }
164            if n != from && n != BEGIN_KEYWORD && self.relevant(n, r) {
165                out.insert(String::from(n));
166            }
167            if let Some(succs) = self.forward.get(n) {
168                for &s in succs {
169                    stack.push(s);
170                }
171            }
172        }
173        out
174    }
175
176    /// (B)(b): every branch `c` of the choice is the unique `Single`-predecessor
177    /// of some *distinct* r-relevant message.
178    fn hash_pinned(&self, branches: &BTreeSet<String>, r: &str) -> bool {
179        let mut witnesses: BTreeSet<&str> = BTreeSet::new();
180        for c in branches {
181            // find an r-relevant step whose predecessors are exactly Single(c)
182            let mut found = None;
183            for (name, prs) in &self.preds {
184                if !self.relevant(name, r) || *name == BEGIN_KEYWORD {
185                    continue;
186                }
187                let cites_c_single =
188                    prs.len() == 1 && matches!(&prs[0], NodeRef::Single(x) if x == c);
189                if cites_c_single && witnesses.insert(name) {
190                    found = Some(*name);
191                    break;
192                }
193            }
194            if found.is_none() {
195                return false;
196            }
197        }
198        true
199    }
200
201    /// (B)(a): all branches reach the same onward r-relevant continuation.
202    fn mergeable(&self, branches: &BTreeSet<String>, r: &str) -> bool {
203        let mut it = branches.iter();
204        let Some(first) = it.next() else {
205            return true;
206        };
207        let base = self.forward_relevant(first, r);
208        it.all(|c| self.forward_relevant(c, r) == base)
209    }
210
211    /// Walk backward from a bystander `b` cited by an r-relevant message,
212    /// checking every predecessor edge is type-forced (A) or a (B)-recoverable
213    /// choice, until every path reaches an r-relevant / `begin` bracket.
214    /// Records the discharge of the *first* (immediate) edge into `edges`.
215    fn check_bystander(
216        &self,
217        m: &str,
218        b: &'d str,
219        r: &str,
220        immediate: Discharge,
221        edges: &mut Vec<DischargedEdge>,
222        failures: &mut Vec<SpliceFailure>,
223    ) {
224        edges.push(DischargedEdge {
225            role: String::from(r),
226            message: String::from(m),
227            bystander: String::from(b),
228            how: immediate,
229        });
230        let mut visited: BTreeSet<&str> = BTreeSet::new();
231        let mut stack: Vec<&str> = alloc::vec![b];
232        while let Some(node) = stack.pop() {
233            if !visited.insert(node) {
234                continue;
235            }
236            let Some(prs) = self.preds.get(node) else {
237                continue;
238            };
239            for nr in *prs {
240                match nr {
241                    NodeRef::Single(_) | NodeRef::All(_) => {
242                        // type-forced edge: descend into any bystander members
243                        for p in nr.performatives() {
244                            if p != BEGIN_KEYWORD && !self.relevant(p, r) {
245                                stack.push(p);
246                            }
247                        }
248                    }
249                    NodeRef::Any(set) => {
250                        // an (any …) among this node's predecessors
251                        let bystander_branches: BTreeSet<String> = set
252                            .iter()
253                            .filter(|x| x.as_str() != BEGIN_KEYWORD && !self.relevant(x, r))
254                            .cloned()
255                            .collect();
256                        if bystander_branches.len() < 2 {
257                            // ≤1 distinct bystander type: forced. Descend using
258                            // the &'d names from the node-ref itself.
259                            for p in nr.performatives() {
260                                if p != BEGIN_KEYWORD && !self.relevant(p, r) {
261                                    stack.push(p);
262                                }
263                            }
264                            continue;
265                        }
266                        // unobserved choice among ≥2 distinct-typed bystanders
267                        let ok = self.mergeable(&bystander_branches, r)
268                            || self.hash_pinned(&bystander_branches, r);
269                        if !ok {
270                            failures.push(SpliceFailure {
271                                role: String::from(r),
272                                message: String::from(m),
273                                bystander: String::from(node),
274                                reason: SpliceReason::UnrecoverableChoice,
275                            });
276                        }
277                        // do not descend past an (unresolved) choice
278                    }
279                }
280            }
281        }
282    }
283}
284
285/// Compute splice-coherence over a dialect: the failures, and (for the study
286/// table) the discharged edges showing which disjunct carried each splice.
287///
288/// Pure static function over `d.roles` and `d.causal_protocol`. Decidable in
289/// `O(|R| · |P|² )`: for each of `|R|` roles and each r-relevant step, a
290/// backward walk touches each of `|P|` steps once, and each `(any …)` recovery
291/// test scans the `|P|` steps.
292pub fn analyze(d: &Dialect) -> (Vec<SpliceFailure>, Vec<DischargedEdge>) {
293    let mut failures = Vec::new();
294    let mut edges = Vec::new();
295    let Some(a) = Analyzer::new(d) else {
296        return (failures, edges);
297    };
298    if d.roles.is_empty() {
299        return (failures, edges);
300    }
301    for role in &d.roles {
302        let r = role.name.as_str();
303        for (m, prs) in &a.preds {
304            if *m == BEGIN_KEYWORD || !a.relevant(m, r) {
305                continue;
306            }
307            for nr in *prs {
308                let (members, forced): (Vec<&str>, bool) = match nr {
309                    NodeRef::Single(_) | NodeRef::All(_) => (nr.performatives().collect(), true),
310                    NodeRef::Any(set) => {
311                        let bys: Vec<&str> = set
312                            .iter()
313                            .map(String::as_str)
314                            .filter(|x| *x != BEGIN_KEYWORD && !a.relevant(x, r))
315                            .collect();
316                        (nr.performatives().collect(), bys.len() < 2)
317                    }
318                };
319                if forced {
320                    for pred in members {
321                        if pred == BEGIN_KEYWORD || a.relevant(pred, r) {
322                            continue; // observed / root bracket: no splice
323                        }
324                        // bystander cited by an (A) type-forced edge.
325                        a.check_bystander(
326                            m,
327                            pred,
328                            r,
329                            Discharge::TypeForced,
330                            &mut edges,
331                            &mut failures,
332                        );
333                    }
334                } else {
335                    // m's own predecessor is an unobserved choice
336                    let NodeRef::Any(set) = nr else {
337                        unreachable!()
338                    };
339                    let branches: BTreeSet<String> = set
340                        .iter()
341                        .filter(|x| x.as_str() != BEGIN_KEYWORD && !a.relevant(x, r))
342                        .cloned()
343                        .collect();
344                    if a.mergeable(&branches, r) {
345                        record_choice(&a, m, &branches, r, Discharge::Merge, &mut edges);
346                    } else if a.hash_pinned(&branches, r) {
347                        record_choice(&a, m, &branches, r, Discharge::HashPinned, &mut edges);
348                    } else {
349                        for b in &branches {
350                            failures.push(SpliceFailure {
351                                role: String::from(r),
352                                message: String::from(*m),
353                                bystander: b.clone(),
354                                reason: SpliceReason::UnrecoverableChoice,
355                            });
356                        }
357                    }
358                }
359            }
360        }
361    }
362    (failures, edges)
363}
364
365fn record_choice(
366    _a: &Analyzer,
367    m: &str,
368    branches: &BTreeSet<String>,
369    r: &str,
370    how: Discharge,
371    edges: &mut Vec<DischargedEdge>,
372) {
373    for b in branches {
374        edges.push(DischargedEdge {
375            role: String::from(r),
376            message: String::from(m),
377            bystander: b.clone(),
378            how,
379        });
380    }
381}
382
383/// Splice-coherence failures over the whole dialect (empty ⇒ splice-coherent).
384pub fn splice_coherence_violations(d: &Dialect) -> Vec<SpliceFailure> {
385    analyze(d).0
386}
387
388/// Roles onto which the dialect is NOT splice-coherent.
389pub fn non_coherent_roles(d: &Dialect) -> BTreeSet<String> {
390    splice_coherence_violations(d)
391        .into_iter()
392        .map(|f| f.role)
393        .collect()
394}
395
396/// Whether the dialect is splice-coherent onto every declared role.
397pub fn is_splice_coherent(d: &Dialect) -> bool {
398    splice_coherence_violations(d).is_empty()
399}
400
401#[cfg(test)]
402mod tests {
403    use super::*;
404    use crate::dialect::{Dialect, PerformativeDef, ResourceBounds};
405    use crate::protocol::{CausalProtocol, StepDecl};
406    use crate::r6::r6_violations;
407    use crate::role::{RoleCardinality, RoleDecl};
408    use crate::sexpr::{Atom, SExpr};
409    use alloc::string::ToString;
410    use alloc::vec;
411
412    const S: RoleCardinality = RoleCardinality::Singleton;
413
414    fn perf(name: &str, from: &str, to: &[&str]) -> PerformativeDef {
415        PerformativeDef {
416            name: name.to_string(),
417            params: Vec::new(),
418            template: SExpr::Atom(Atom::Symbol("t".to_string())),
419            role: Some(RoleAnnotation {
420                from: from.to_string(),
421                to: to.iter().map(|s| s.to_string()).collect(),
422            }),
423        }
424    }
425    fn single(n: &str) -> NodeRef {
426        NodeRef::Single(n.to_string())
427    }
428    fn any(ns: &[&str]) -> NodeRef {
429        NodeRef::Any(ns.iter().map(|s| s.to_string()).collect())
430    }
431    fn step(name: &str, preds: Vec<NodeRef>, succs: Vec<NodeRef>) -> (String, StepDecl) {
432        (
433            name.to_string(),
434            StepDecl {
435                performative: name.to_string(),
436                predecessors: preds,
437                successors: succs,
438            },
439        )
440    }
441    fn dialect(
442        roles: &[(&str, RoleCardinality)],
443        perfs: Vec<PerformativeDef>,
444        steps: Vec<(String, StepDecl)>,
445    ) -> Dialect {
446        Dialect {
447            types: Default::default(),
448            roles: roles
449                .iter()
450                .map(|(n, c)| RoleDecl {
451                    name: n.to_string(),
452                    cardinality: *c,
453                })
454                .collect(),
455            state: None,
456            state_bounds: None,
457            causal_locality: Default::default(),
458            name: "test".to_string(),
459            extends: Vec::new(),
460            author: None,
461            performatives: perfs,
462            resources: ResourceBounds {
463                max_depth: 8,
464                max_expansion_size: 512,
465            },
466            examples: Vec::new(),
467            signature: None,
468            hash: None,
469            protocol: None,
470            causal_protocol: Some(CausalProtocol {
471                steps: steps.into_iter().collect(),
472            }),
473            shapes: Vec::new(),
474        }
475    }
476
477    /// OAuth as written (fails R6(vi)); §6.1.
478    fn oauth() -> Dialect {
479        dialect(
480            &[("server", S), ("client", S), ("authoriser", S)],
481            vec![
482                perf("login", "server", &["client"]),
483                perf("abort", "server", &["client"]),
484                perf("passwd", "client", &["authoriser"]),
485                perf("auth", "authoriser", &["server"]),
486                perf("quit", "client", &["authoriser"]),
487            ],
488            vec![
489                step("begin", vec![], vec![any(&["login", "abort"])]),
490                step("login", vec![single("begin")], vec![single("passwd")]),
491                step("abort", vec![single("begin")], vec![single("quit")]),
492                step("passwd", vec![single("login")], vec![single("auth")]),
493                step("auth", vec![single("passwd")], vec![]),
494                step("quit", vec![single("abort")], vec![]),
495            ],
496        )
497    }
498
499    #[test]
500    fn oauth_is_splice_coherent_but_not_causally_local() {
501        let d = oauth();
502        // NOT causally local: R6(vi) fires (the paper's three hand-offs).
503        assert!(!r6_violations(&d).is_empty());
504        // Splice-coherent onto every role (via (A) type-forcing).
505        let (failures, edges) = analyze(&d);
506        assert_eq!(failures, Vec::new(), "OAuth must be splice-coherent");
507        // The load-bearing splice is authoriser citing the bystander `login`
508        // through passwd — discharged by TypeForced, NOT the (B)(b) hash-pin
509        // disjunct the informal prediction credited.
510        assert!(edges.iter().any(|e| e.role == "authoriser"
511            && e.message == "passwd"
512            && e.bystander == "login"
513            && e.how == Discharge::TypeForced));
514        // And there is genuinely a bystander citation (beyond R6(vi)).
515        assert!(edges.iter().any(|e| e.role == "authoriser"));
516    }
517
518    /// (B)(b) HASH-PIN exerciser: `report`'s predecessor is an unobserved
519    /// choice `(any hi lo)` of distinct bystander types; each branch is the
520    /// unique Single-predecessor of a distinct w-relevant message
521    /// (`seehi`/`seelo`), so (B)(b) fires and merge does NOT.
522    fn hashpin() -> Dialect {
523        dialect(
524            &[("a", S), ("b", S), ("w", S)],
525            vec![
526                perf("hi", "a", &["b"]),
527                perf("lo", "a", &["b"]),
528                perf("seehi", "b", &["w"]),
529                perf("seelo", "b", &["w"]),
530                perf("report", "b", &["w"]),
531            ],
532            vec![
533                step("begin", vec![], vec![any(&["hi", "lo"])]),
534                step("hi", vec![single("begin")], vec![any(&["seehi", "report"])]),
535                step("lo", vec![single("begin")], vec![any(&["seelo", "report"])]),
536                step("seehi", vec![single("hi")], vec![]),
537                step("seelo", vec![single("lo")], vec![]),
538                step("report", vec![any(&["hi", "lo"])], vec![]),
539            ],
540        )
541    }
542
543    #[test]
544    fn hashpin_choice_is_discharged_by_disjunct_b() {
545        let d = hashpin();
546        let (failures, edges) = analyze(&d);
547        assert_eq!(failures, Vec::new(), "hash-pin dialect must be coherent");
548        // report's (any hi lo) predecessor onto w is discharged by HashPinned,
549        // not Merge (the branches reach distinct r-relevant seehi/seelo).
550        assert!(edges
551            .iter()
552            .any(|e| e.role == "w" && e.message == "report" && e.how == Discharge::HashPinned));
553        assert!(!edges
554            .iter()
555            .any(|e| e.role == "w" && e.message == "report" && e.how == Discharge::Merge));
556    }
557
558    /// (B)(a) MERGE exerciser: the choice's branches reach the SAME r-relevant
559    /// continuation, so `report`'s unobserved choice merges.
560    fn mergecase() -> Dialect {
561        dialect(
562            &[("a", S), ("b", S), ("w", S)],
563            vec![
564                perf("hi", "a", &["b"]),
565                perf("lo", "a", &["b"]),
566                perf("report", "b", &["w"]),
567            ],
568            vec![
569                step("begin", vec![], vec![any(&["hi", "lo"])]),
570                step("hi", vec![single("begin")], vec![single("report")]),
571                step("lo", vec![single("begin")], vec![single("report")]),
572                step("report", vec![any(&["hi", "lo"])], vec![]),
573            ],
574        )
575    }
576
577    #[test]
578    fn merge_choice_is_discharged_by_disjunct_a() {
579        let d = mergecase();
580        let (failures, edges) = analyze(&d);
581        assert_eq!(failures, Vec::new());
582        assert!(edges
583            .iter()
584            .any(|e| e.role == "w" && e.message == "report" && e.how == Discharge::Merge));
585    }
586
587    /// UNRECOVERABLE: `mark`'s predecessor is the unobserved choice `(any hi
588    /// lo)`. The branches are NOT mergeable (only the `hi` branch reaches the
589    /// w-relevant `gh`) and NOT hash-pinned (no branch is the *unique Single*
590    /// predecessor of a distinct w-relevant message — `gh` cites `hi` only
591    /// inside an `(any …)`). So neither (B)(a) nor (B)(b) rescues it: rejected.
592    #[test]
593    fn unmergeable_unpinned_choice_is_rejected() {
594        let d = dialect(
595            &[("a", S), ("b", S), ("w", S)],
596            vec![
597                perf("hi", "a", &["b"]),
598                perf("lo", "a", &["b"]),
599                perf("extra", "a", &["b"]),
600                perf("gh", "b", &["w"]),
601                perf("mark", "b", &["w"]),
602            ],
603            vec![
604                step("begin", vec![], vec![any(&["hi", "lo", "extra"])]),
605                step("hi", vec![single("begin")], vec![]),
606                step("lo", vec![single("begin")], vec![]),
607                step("extra", vec![single("begin")], vec![]),
608                // gh reachable from hi (and extra) via an (any …), never a
609                // Single — so it distinguishes the hi branch without pinning it.
610                step("gh", vec![any(&["hi", "extra"])], vec![]),
611                step("mark", vec![any(&["hi", "lo"])], vec![]),
612            ],
613        );
614        let (failures, _) = analyze(&d);
615        assert!(
616            failures
617                .iter()
618                .any(|f| f.message == "mark" && f.reason == SpliceReason::UnrecoverableChoice),
619            "mark's unmergeable, unpinned choice must fail splice-coherence for w"
620        );
621    }
622
623    /// THE SOUNDNESS WITNESS (de-risking evidence): this protocol is ACCEPTED
624    /// by the structural splice check yet has NO correct projection. Role `w`
625    /// must SEND a branch-dependent performative (`donehi` vs `donelo`) whose
626    /// only causal witness is a bare content-hash inside `ack` — which is
627    /// type-opaque, so `w` cannot decide which to send. R6(vi) correctly
628    /// REJECTS it; structural splice-coherence wrongly ACCEPTS it.
629    #[test]
630    fn structural_coherence_accepts_an_unimplementable_protocol() {
631        // donehi/donelo cite `hi`/`lo` via Single edges — each "type-forced".
632        let d = dialect(
633            &[("a", S), ("b", S), ("w", S), ("z", S)],
634            vec![
635                perf("hi", "a", &["b"]),
636                perf("lo", "a", &["b"]),
637                perf("ack", "b", &["w"]),
638                perf("donehi", "w", &["z"]),
639                perf("donelo", "w", &["z"]),
640            ],
641            vec![
642                step("begin", vec![], vec![any(&["hi", "lo"])]),
643                step("hi", vec![single("begin")], vec![single("ack")]),
644                step("lo", vec![single("begin")], vec![single("ack")]),
645                // ack: same label both branches, predecessor is the merge point.
646                step(
647                    "ack",
648                    vec![any(&["hi", "lo"])],
649                    vec![any(&["donehi", "donelo"])],
650                ),
651                // w's SENDS cite hi/lo by Single edges — structurally forced…
652                step("donehi", vec![single("hi")], vec![]),
653                step("donelo", vec![single("lo")], vec![]),
654            ],
655        );
656        // R6(vi) rejects (w is endpoint of donehi but not of its predecessor hi).
657        assert!(r6_violations(&d).iter().any(|v| matches!(
658            v,
659            crate::role::R6Violation::NotCausallyLocal { performative, role, .. }
660                if performative == "donehi" && role == "w"
661        )));
662        // ack's own predecessor (any hi lo) merges for w (both branches reach
663        // the same onward r-relevant closure {donehi,donelo} from w's view are
664        // distinct — so NOT merge). The donehi/donelo Single citations are
665        // marked TypeForced. Net: the structural check finds w splice-coherent
666        // on the SEND citations, exposing the unsoundness.
667        let (failures, edges) = analyze(&d);
668        let sends_forced = edges
669            .iter()
670            .any(|e| e.role == "w" && e.message == "donehi" && e.how == Discharge::TypeForced);
671        assert!(
672            sends_forced,
673            "structural check marks w's branch-dependent SEND citation type-forced"
674        );
675        // Document (not assert green/red beyond the send edge) that the send
676        // citations themselves raise no failure — the unsoundness.
677        assert!(
678            !failures.iter().any(|f| f.message == "donehi"),
679            "structural splice-coherence raises no failure on w's unimplementable SEND"
680        );
681    }
682}