Skip to main content

validate_supernode

Function validate_supernode 

Source
pub fn validate_supernode(sn: &SupernodeConfig) -> Result<(), Vec<String>>
Expand description

Validates a supernode definition’s structure, collecting all violations.

Enforced rules (spec §3):

  • exactly one boundary node of type input, id input; one or more output boundaries (id = port name, output = the success port); one or more error boundaries (id = error-kind port name, error = the default the black-box rule targets);
  • output/error ids must not be in RESERVED_OUTPUT_IDS/RESERVED_ERROR_IDS (collide with fixed instance port names like success, input, etc.);
  • no two nodes share an id (duplicate ids would create ambiguous output ports);
  • inner nodes must not be listener/client/supernode, must not use reserved ids, and must not contain /;
  • exactly one edge leaves input; no edges into input or out of output/error boundaries;
  • every edge endpoint references an existing node;
  • no orphan inner nodes (unconnected output/error boundaries are fine — not every subgraph uses both exits);
  • every inner edge leaves a port its source node’s type actually declares (out normalizes to success; boundary pseudo-nodes are exempt — they have no plugin type and therefore no PortSpec);
  • every success/outcome port of every inner node is wired inside the definition, to another inner node or to a boundary. Definitions are compiled as part of each policy that instantiates them, so an unwired outcome port would otherwise surface as a confusing compile error on an unrelated policy rather than at save time on the definition itself. error ports stay exempt: the black-box rule in expand_policy wires every unhandled inner error port to the instance’s error exit.