Skip to main content

is_simple_chain

Function is_simple_chain 

Source
pub fn is_simple_chain(graph: &NodeGraph, branches: &Branches) -> bool
Expand description

Whether a graph is a strict linear chain — a single strand where node i’s sole input (if any) is FromNode of node i-1, nothing more:

  • branches must be empty (no conditional dispatch to encode).
  • No node declares repeat_until (no loop to encode).
  • No node’s input is Record/List fan-in.
  • Beyond per-node checks: the whole graph must be one strand, not just individually-simple nodes that still fan out or fan in as a group. Concretely: the first declared node has no input; every subsequent declared node’s input must be exactly FromNode of the node declared immediately before it; and no node may be referenced by more than one other node’s FromNode (that would be fan-out — two nodes both reading node k’s output — which individually satisfies every per-node check above while still not being a chain).

cuttlefish build‘s bundle format only knows how to encode this exact shape, walked in spec.nodes’ declaration order.