Skip to main content
START and END are reserved graph markers. They do not need node implementations. AddEdge uses the source node’s default port; AddEdgeOnPort selects another output port.

Wire an explicit branch

Given a graph containing prepare, review, and send:
Built-in human nodes expose approved and rejected, not default. If/else nodes expose true and false. Switch nodes expose their configured case ports plus default.

Fan out and merge

Multiple outgoing edges on a selected port schedule multiple nodes. Each node in the wave reads the pre-wave state. Results merge in sorted node-ID order, so avoid using overlapping output keys as an implicit synchronization mechanism. The walker visits each node at most once per invocation. It is not a barrier scheduler for branches of different lengths. A downstream node reached by a short branch can run before a longer branch reaches it. Use graph structure with aligned waves or combine the required work in a node when a strict join is required.

Route with Go logic

AddConditionalEdge evaluates a router after the source’s result is merged:
Conditional and static outgoing edges cannot coexist on the same source. An unmapped router label ends that branch. With Temporal, the router runs in workflow code: it must be deterministic and must not perform I/O or read wall-clock/random state.

Compile-time validation

Compilation checks node validation, duplicate/reserved IDs, edge targets, incompatible outgoing routing, cycles, and built-in output ports. A built-in constructor’s node ID must equal the key passed to AddNode. Explicit START edges choose roots. Without them, nodes with no incoming edges are roots. Check unreachable nodes and unintended early branch termination in application tests; syntactically valid routing is not proof the graph expresses the intended business process.