Skip to main content

Module executor

Module executor 

Source
Expand description

Durable graph executor — the node-visiting drive loop.

Ports the semantics of the greentic-designer spike (src/orchestrate/agent_graph/executor.rs, origin/spike/agent-graph-engine-slice) with the following adaptations:

  • Uses GraphConfig / GraphRunState / CheckpointStore from this crate rather than the designer’s SQLite-backed checkpoint module.
  • Effect closures are Arc<dyn Fn(…) -> BoxFut<…>> (shared, cloneable) instead of owned Box<dyn Fn…>.
  • start/resume return Result<GraphRunOutcome, GraphExecError> (not Result<()>), carrying the final reply and visit trail.

§Record-then-checkpoint ordering (replayable resume)

Each side-effect node (Agent, Tool) follows a strict two-write ordering: the effect’s result is recorded into the node-visit store (CheckpointStore::record_node_visit) immediately after the effect returns and before the checkpoint update. The checkpoint update then commits the new cursor, state, and per-node visits counts atomically.

On resume at cursor node N, the next attempt is visits[N] + 1. If a (run, N, attempt) visit row already exists, the effect ran but the process crashed before the checkpoint committed — so the recorded result is replayed instead of re-invoking the effect.

Structs§

AgentTurnRequest
Request payload delivered to an injected agent-turn closure.
AgentTurnResult
Result returned by an injected agent-turn closure.
ApprovalRequest
Request payload delivered to an injected approval closure.
GraphExecutor
Drives agent-graph runs to completion, persisting checkpoints after every node so that a killed process can resume mid-loop.
GraphRunOutcome
The final result of a drive-loop execution.
SupervisorRequest
Request payload delivered to an injected supervisor closure.
SupervisorResult
Result returned by an injected supervisor closure.
ToolCallRequest
Request payload delivered to an injected tool closure.

Enums§

ApprovalOutcome
Result returned by an injected approval closure.
GraphExecError
Errors that may surface from GraphExecutor::start or GraphExecutor::resume.

Constants§

MAX_NODE_VISITS
Hard upper bound on node visits per drive call, independent of the per-router maxIterations cap. Prevents infinite loops on malformed graphs.

Type Aliases§

AgentTurnFn
One agent turn: the host wires this to AgentRuntime::step.
ApprovalFn
One approval-gate check: the host wires this to its approval-request transport (e.g. the greentic.approval.request.v1 / .response.v1 NATS subjects) and reports whether a decision has arrived yet.
BoxFut
Owned heap-allocated future, Send + 'static.
SupervisorFn
One supervisor routing decision: the host wires this to AgentRuntime::step with a generated routing prompt containing the route menu.
ToolFn
One deterministic tool call.