A graph’s logic lives in two places: nodes (what happens at each step) and edges (where it goes next). Cognis lets you mix two styles — declare static edges when the topology is fixed, and let nodes returnDocumentation Index
Fetch the complete documentation index at: https://cognis.vasanth.xyz/llms.txt
Use this file to discover all available pages before exploring further.
Goto when the path depends on state.
Goto
Every node returnsNodeOut { update, goto }. The goto is a Goto enum:
| Constructor / Variant | Effect |
|---|---|
Goto::node("name") | Single successor — go to this named node. |
Goto::end() | Terminate the graph. The current state is the final result. |
Goto::halt() | Pause the graph without ending. Caller gets a halt error and can resume. |
Goto::Multiple(vec!["a", "b"]) | Parallel fan-out. Both targets run in the next superstep. |
Goto::Send(vec![("worker", payload)]) | Cross-graph dispatch with an inline payload (subgraph entry). |
Goto::node(...), Goto::end()); the variants are there for advanced shapes.
Static edges
When two nodes always go in sequence, declare an edge instead of routing in the node body:Goto it wants — the engine prefers the node’s goto when it’s not Goto::end(). Use static edges when the default successor is predictable; let Goto override when the node has a reason to.
Conditional flow inside a node
For state-dependent routing, branch in the node body:Parallel fan-out
Goto::Multiple(vec![...]) runs all named targets in the next superstep. Their updates merge through apply (so reducers matter), and execution flows back into whatever each branch returns.
Loops
Loops are justGoto::node pointing back at the current node:
RunnableConfig::recursion_limit to cap runaway loops — the engine errors with RecursionLimit if exceeded.
Subgraphs
ASubgraph is a graph wrapped to look like a node from the parent’s perspective. Nest them when:
- A team owns a sub-flow and wants to develop / version it independently.
- You want checkpoint isolation — the subgraph has its own state and its own
checkpoint_ns. - You want to reuse the same flow in multiple parents.
How it works
- Each superstep schedules eligible nodes. A node is eligible if some predecessor’s
Gotopoints at it. - All eligible nodes run concurrently. Their updates merge through
applyafter the superstep finishes. Goto::end()from any node terminates the run — even if other nodes also fired in the same step.recursion_limitis the safety net. It bounds total supersteps, not just loops.- Subgraphs are isolated. A subgraph’s checkpoints, observers, and namespace are scoped under the parent’s run.
See also
State and reducers
What
apply does to the merged updates.Streaming
See the supersteps unfold in real time.
Checkpointing
Pause, edit, resume.