Field-level reducer configuration keyed by dot-notation paths
(e.g. 'scratch.messages'). Determines how conflicting values
are merged during updateScratch() and mergeParallelBranches().
Create a clean initial GraphState from the caller-supplied input value.
The input partition is frozen with Object.freeze() so that no node can
accidentally mutate it. All other partitions start empty.
Arbitrary value provided by the graph caller; becomes state.input.
A fully initialised GraphState ready for the first node execution.
Apply a patch to the scratch partition, honoring any registered reducers.
For each key in patch:
scratch.<key> and the key already exists
in the current scratch, the reducer is called to merge the existing and incoming
values.Current graph state (not mutated).
Partial scratch update emitted by a completed node.
New GraphState with the merged scratch partition.
Apply a patch to the artifacts partition using last-write-wins semantics.
Artifact fields are intended for caller-facing outputs and are not subject to
reducer logic in this method. If you need reducer-aware artifact merging, use
mergeParallelBranches() instead.
Current graph state (not mutated).
Partial artifacts update emitted by a completed node.
New GraphState with the updated artifacts partition.
Record that execution has entered nodeId.
Updates currentNodeId, appends to visitedNodes, and increments iteration.
Current graph state (not mutated).
Id of the node that is about to execute.
New GraphState reflecting the visit.
Merge the scratch partitions of one or more parallel branch states back into
a single GraphState.
The algorithm walks every key present in any branch's scratch object and applies the registered reducer for that key (if any) against the accumulator. When no reducer is registered, the last branch's value wins.
The artifacts, memory, diagnostics, visitedNodes, and iteration fields
of baseState are preserved unchanged — the caller is responsible for merging
those separately if needed.
State prior to the parallel fan-out (provides the baseline scratch).
States produced by each parallel branch.
New GraphState with the merged scratch partition.
Manages the GraphState partitions (
input,scratch,artifacts,memory,diagnostics) for a single graph run.All methods return a new
GraphStateobject; the original is never mutated.Example