Skip to content
2 min read · 362 words

@nhtio/adk/batteries/orchestration/plan ​

The IR's runtime helpers: pure, graph-shaped predicates and guards.

Remarks ​

This module is the shared vocabulary that WP 04's freeze validation and WP 07's executor both call. It performs NO validation policy itself and throws nothing — it answers questions about a graph. Every export is a pure function over {nodes, edges} (a RawPlanView or any structural subset carrying those two arrays), so the same code path serves a full folded view and a hand-built slice.

The functions here are deliberately small and single-purpose. Policy — "exactly one entry", "the graph is acyclic", "every join is a diamond" — lives in the freeze validator, which composes these primitives; the executor composes them to decide what fires next. Neither reimplements a graph walk.

Interfaces ​

InterfaceDescription
PlanGraphViewThe minimal structural surface these helpers read. A RawPlanView satisfies it; so does any {nodes, edges} subset. Accepting the subset keeps the helpers usable on slices and test fixtures without forcing a full view.

Functions ​

FunctionDescription
entryNodesEvery node of kind 'entry'.
findCycleFind a cycle in the graph, over EVERY edge handle.
handleAppliesToWhether an edge handle may be used on an edge leaving a node of a given kind.
immediateDominatorThe immediate dominator of a node, relative to an entry.
incomingThe edges entering a node.
isPlanEdgeTrue when v is a well-shaped PlanEdge.
isPlanNodeTrue when v is a well-shaped PlanNode.
isValidEdgeIdWhether a string is a valid edge id.
isValidNodeIdWhether a string is a valid node id.
nodeByIdLook up a node by id.
outgoingThe edges leaving a node.
reachableFromThe forward closure from a start node over ALL edge handles.
readPathRead a dot-path from a value, with a per-segment prototype-pollution guard.
routesBetweenAll distinct simple paths from one node to another.