Graph
Graph:
object
Defined in: Core/Graph.ts:26
Directed Acyclic Graph (DAG) task orchestration module.
Provides declarative step definition with dependency tracking, compile-time acyclicity verification, automatic diamond-dependency deduplication, bounded concurrency, and immediate sibling cancellation.
Type Declaration
Section titled “Type Declaration”make: <
Id,E,Out>(target) =>Graph<E,Out> =makeGraph
Compiles a target sink node into an immutable, validated Graph plan.
Validates acyclicity using Kahn’s algorithm at compilation time and pre-computes reverse-dependency adjacency lists for optimal runtime scheduling throughput.
Type Parameters
Section titled “Type Parameters”Id extends string
E
Out
Parameters
Section titled “Parameters”target
Section titled “target”Node<Id, E, Out>
Returns
Section titled “Returns”Graph<E, Out>
- Graph.node for defining upstream DAG nodes.
- Graph.run for executing compiled graphs.
Example
Section titled “Example”node: <
Id,Deps,E,Out,ETimeout>(config) =>Node<Id,E|ETimeout| [Deps] extends [Record<string,AnyNode>] ?DepsErrors<Deps> :never,Out> =makeNode
Creates an individual node descriptor for inclusion in a DAG.
Dependencies are declared as an object dictionary of upstream nodes.
The run callback contextually receives the strongly typed outputs of those dependencies.
Type Parameters
Section titled “Type Parameters”Id extends string
Deps extends Record<string, AnyNode> | undefined
E
Out
ETimeout
Section titled “ETimeout”ETimeout = never
Parameters
Section titled “Parameters”config
Section titled “config”NodeConfig<Id, Deps, E, Out, ETimeout>
Returns
Section titled “Returns”Node<Id, E | ETimeout | [Deps] extends [Record<string, AnyNode>] ? DepsErrors<Deps> : never, Out>
- Graph.make to compile declared nodes into a validated execution graph.
- Graph.run for executing compiled graphs.
Example
Section titled “Example”run: <
E,Out>(graph,options?) =>Result<E,Out> =runGraph
Executes a compiled Graph within a managed execution context, returning an infallible lazy Task.Result.
Maximizes concurrency across independent branches while guaranteeing that diamond dependencies
execute exactly once. If any node fails or throws, all remaining in-flight sibling tasks are
immediately aborted via an internal AbortController.
Type Parameters
Section titled “Type Parameters”E
Out
Parameters
Section titled “Parameters”Graph<E, Out>
options?
Section titled “options?”Returns
Section titled “Returns”Result<E, Out>
- Graph.make to compile a target node into a validated graph.
- Graph.node for defining upstream DAG nodes.