Expand description
§entelix-graph
Control-flow contract for entelix (invariant 8). Houses
StateGraph<S> with typed state, the Reducer<T> trait,
conditional / fan-out edges, subgraphs, the Checkpointer
trait plus InMemoryCheckpointer, and the Command<S>
HITL resume API. recursion_limit (F6 mitigation) is enforced
here. The HITL pause primitive
(entelix_core::interrupt / entelix_core::interrupt_with)
lives in entelix-core so tools, nodes, and middleware layers
all raise the same Error::Interrupted shape.
Surface: StateGraph<S> builder with static and conditional
edges + CompiledGraph<S> executor with recursion_limit
enforcement and the END sentinel target. Checkpointer +
InMemoryCheckpointer for write-after-each-node persistence;
CompiledGraph::resume / CompiledGraph::resume_with crash
recovery. Command<S> for typed resume payloads.
Structs§
- Annotated
- Newtype that bundles a value
Twith the reducerRthat should merge it. The wrapper is a standalone helper users compose into their state types; it does not hook intoStateGraph::add_nodedirectly. - Append
- Append:
currentfollowed byupdate. Specialised forVec<U>whereU: Clone + Send + Sync + 'static. - Checkpoint
- One snapshot of graph progress for a particular
(tenant_id, thread_id).next_node = Noneindicates the graph terminated cleanly (a finish point ran or a conditional edge routed toEND). - Checkpoint
Id - Stable identifier for a checkpoint. Backed by UUID v7 — time-ordered and globally unique across processes.
- Compiled
Graph - Frozen graph ready to execute.
- Conditional
Edge - One conditional-edge dispatch.
- Contributing
Node Adapter Runnable<S, S>adapter that snapshots the inbound state, runs an innerRunnable<S, S::Contribution>to produce only the slots the node touched, and folds that contribution into the snapshot viaS::merge_contribution.- Dispatch
- One unit of fan-out work — semantically equivalent to LangGraph’s
Send(node, payload). Carries the payload that a fanned-out runnable will receive whenscatterruns. - Finalizing
Stream - Stream that fires
finalizeexactly once when dropped before the inner stream returnedNone. Normal completion (the inner stream yieldedNonefrompoll_next) is not an early-cancel — the finalizer is silently skipped. - InMemory
Checkpointer - In-process checkpointer backed by a
HashMap<(tenant_id, thread_id), Vec<Checkpoint>>. The composite key encodes Invariant 11 (multi-tenant isolation): the samethread_idunder two tenants resolves to two distinct histories. - Max
- Keep the larger of
current/updateperT: Ord. Useful for “highest score wins” reducers andusizestep counters merged across parallel branches. - Merge
Map - Merge two
HashMap<K, V>s, right-biased — entries fromupdateoverwrite collisions incurrent. (Right-bias matches typical LangGraph / dict-update semantics.) - Merge
Node Adapter Runnable<S, S>that runs an innerRunnable<S, U>and merges the resultingUback into a fresh copy of the inboundSvia the supplied closure.- Replace
- Last-write-wins. Matches the current
StateGraphdefault — included so users who explicitly opt into reducer machinery have a no-op option. - Send
Edge - Parallel fan-out edge.
- State
Graph - Builder for a state-machine graph parameterised over its state type
S.
Enums§
- Checkpoint
Granularity - How often the compiled graph writes a checkpoint when a
Checkpointeris attached. - Command
- Resume directive supplied to
CompiledGraph::resume_with.
Constants§
- DEFAULT_
RECURSION_ LIMIT - Default cap on node executions per
invoke(F6 mitigation — guards against infinite cycles). - END
- Sentinel target meaning “terminate without running another node”. Use
in
add_conditional_edgesmapping when a branch should end the graph.
Traits§
- Checkpointer
- Persistent (or in-memory) store of
Checkpoint<S>s addressed byThreadKey. - Reducer
- Combines a current value and an incoming update into the next value.
- State
Merge - State-level merge: how an incoming update folds into the current
state. The dispatch-loop counterpart to
Reducer<T>, one level up — implemented on the wholeSshape rather than a single slot.
Functions§
- scatter
- Fan a
Vec<Dispatch<I>>through aRunnable<I, O>in parallel and collect the outputs in submission order.
Type Aliases§
- Edge
Selector - Closure that picks a conditional-edge target by inspecting state.
- Send
Merger - Two-state merger applied per branch result during a send-edge
fold — the dispatch loop calls it once per branch with
(folded_so_far, branch_state) -> next_folded. - Send
Selector - Closure returning the parallel branches a send edge dispatches.
Each pair is
(target_node_name, branch_state); target nodes run concurrently with their respective branch states.
Derive Macros§
- State
Merge - Derive
entelix_graph::StateMergeand generate the<Name>Contributioncompanion struct.