Interface: PlanInput
Defined in: packages/core/src/graph/plan.ts:34
Topological planner for the graph composition primitive.
Task A2 — pure string-level DAG math. No Processables, no Streams,
no runtime hooks. The graph runner (A4) calls plan(...) once at
construction to produce the execution order + predecessor / successor
maps, then drives the DAG at runtime using the returned shape.
The planner is deliberately split from the runtime so it can also
serve the web app's config-form compiler (apps/edge/src/lib/ pipeline-compile.ts in Phase C). Same algorithm, two entry points.
Algorithm:
- Validate — unknown nodes, duplicate edges, source with incoming
- Compute reachability from source (BFS). Unreachable nodes are silently pruned — matches the DIY runner's current behavior and the fluent API's "you can only build connected graphs" guarantee
- Detect cycles in the reachable subgraph via colored DFS; report the cycle path so errors are debuggable
- Topologically sort via Kahn's algorithm over the reachable subgraph
- Resolve the output node: explicit > unique sink > ambiguous (error)
Determinism: the planner preserves edge declaration order in
predecessors and successors. That's load-bearing — in A4, multi-
predecessor bots learn their input field names from the order edges
were added (config form) or from merge() key order (fluent form).
Shuffling would silently rename fields.
Properties
edges
edges: readonly
object[]
Defined in: packages/core/src/graph/plan.ts:44
Directed edges. Order matters for multi-predecessor nodes — see the class comment on determinism.
nodes
nodes:
Iterable<string>
Defined in: packages/core/src/graph/plan.ts:40
All node ids in the graph. Iterable so the fluent API can hand in a
Set and the config form can hand in Object.keys(nodes).
output?
optionaloutput?:string
Defined in: packages/core/src/graph/plan.ts:48
Explicit sink. Required when the reachable graph has multiple sinks; forbidden to be unreachable from source.
source
source:
string
Defined in: packages/core/src/graph/plan.ts:36
Root node that receives the graph's outer input.