Skip to main content

Edge

Struct Edge 

Source
pub struct Edge {
    pub guard: Option<LeafId>,
    pub label: Transition,
    pub target: ThreadStateId,
}
Expand description

One edge out of a ThreadStateId in a compiled Automaton: the condition/action it carries (Transition) plus the state it leads to.

T9 (docs/superpowers/plans/2026-10-03-sva.md) adds this type (and State/Automaton below) – T4’s own skeleton defined Transition’s five label shapes but, by its own module doc comment (“no lowering yet”), never wired a target state onto any of them, so there was no way yet to connect two states into an actual graph. T9 is the first task that builds a real automaton, so it is the one that completes the IR with the missing graph structure.

guard, a deliberate, documented addition beyond the plan’s literal text. Plan §1.2 says a Boolean leaf (16.6) is evaluated by the engine and “the automaton engine calls these compiled leaves” – but it never says which edge a leaf’s truth value gates, and Transition itself has no LeafId field on its Delay/Epsilon/Match variants (only Abort/LocalVarWrite carry one, and for a different purpose: an abort condition and a match-item’s write value, neither of which is “the per-tick Boolean this edge requires to be taken”). Without a place to put that leaf reference, nothing in the IR could represent even the simplest legal sequence, a (16.9.1: a lone Boolean expression as a sequence matches over exactly one tick, true -> match, false -> no match) – there is no way to say “this edge may be taken on a tick only if a evaluates true” using Transition alone. Edge::guard closes that gap at the EDGE level (not a sixth Transition variant, preserving T4’s own “every LRM operator is built from these five shapes… not a sixth” design intent): guard = Some(leaf) means this edge is eligible only on a tick where leaf evaluates true; guard = None means the edge’s own label is the only eligibility condition (a pure elapsed-tick window for Delay, or unconditional for Epsilon/Match).

Two combinations matter in practice (both built by vj-codegen::sva::build, T9):

  • guard = Some(leaf) + label = Epsilon: 16.9.1’s Boolean-leaf point-sample – “this tick, leaf must evaluate true”, costing zero ADDITIONAL elapsed ticks beyond the one it is sampled on (the thing that advances a sequence’s clock is a ##/repetition operator between samples, never a sample’s own evaluation – confirmed against the well-known identity a[*3] spans exactly 2 ticks, i to i+2, not 3, which only holds if a bare leaf’s own cost is zero).
  • guard = None + label = Delay { min, max }: the elapsed-tick window a ##min:max cycle delay (16.7) or an inter-repetition link (16.9.2’s implicit ##1 between consecutive repeats, or a wider search window for [->]/[=]’s nonconsecutive/goto repeats) imposes between two samples.

A guard has no polarity of its own: the gap of a goto/nonconsecutive repetition (16.9.2, b[->n] == (!b[*0:$] ##1 b)[*n]) is guarded by a SEPARATE leaf standing for the expression !b, which the builder marks negated in its leaf table (LeafTable::is_negated). The negation must live in the leaf, not on the edge, because it is a 4-state operator: !x is x, which a Boolean context collapses to false, so !b holds only where b is KNOWN false – not wherever b fails to hold, which an edge flag over a leaf already collapsed to a bool could not tell apart.

Fields§

§guard: Option<LeafId>§label: Transition§target: ThreadStateId

Trait Implementations§

Source§

impl Clone for Edge

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 Edge

Source§

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

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

impl Eq for Edge

Source§

impl PartialEq for Edge

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 Edge

Auto Trait Implementations§

§

impl Freeze for Edge

§

impl RefUnwindSafe for Edge

§

impl Send for Edge

§

impl Sync for Edge

§

impl Unpin for Edge

§

impl UnsafeUnpin for Edge

§

impl UnwindSafe for Edge

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<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

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

Source§

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

Compare self to key and return true if they are equal.
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> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

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.
Source§

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

Source§

fn vzip(self) -> V