Skip to main content

Module graph

Module graph 

Source
Expand description

Graph definition, plus structural validation when you call GraphBuilder::compile.

The public graph API is deliberately a thin builder (GraphBuilder); compile() freezes the graph into an immutable, cheaply-clonable Graph with Arc-wrapped internals and validates structure before any node (or LLM call) ever runs:

  • an entry point must be set and must reference a known node;
  • every edge endpoint must reference a known node;
  • at least one node must be registered;
  • node names must not collide with the reserved END sentinel;
  • edges must be unambiguous: no duplicate from → to edges, at most one conditional edge per source node, and no source node mixing static and conditional edges.

Edge types:

  • Normal edges (GraphBuilder::add_edge): from → to. Multiple outgoing normal edges from one node activate all destinations in parallel in the next super-step.
  • Conditional edges (GraphBuilder::add_conditional_edges): an async routing function reads the post-barrier state and returns a Route — one node, dynamic fan-out via Send, or the end of the run.

Structs§

Graph
A compiled, immutable, thread-safe graph. Cheap to clone (Arc internals).
GraphBuilder
Builder for a Graph. Register nodes and edges, set the entry point, then GraphBuilder::compile to validate and freeze.
Send
A single dynamic fan-out instruction: run node once with state as its scoped input state.

Enums§

Edge
One edge in the graph.
Route
The routing decision of a conditional edge.

Constants§

END
Reserved node name for the terminal route. Not a real node: routers signal termination with Route::End instead of naming a node. GraphBuilder::compile rejects registering a node under this name (or any __-prefixed name) so the sentinel namespace can never collide with user nodes.

Type Aliases§

ConditionalRouter
Async routing function for a conditional edge: reads the post-barrier state and decides where the run goes next.