Compile-time macro for declarative workflow agent definitions.
use Jido.Composer.Workflow generates a Jido.Agent module wired
to the Jido.Composer.Workflow.Strategy with validated configuration.
Terminal and Success States
By default, workflows use :done and :failed as terminal states, with
:done as the sole success state. Any terminal state not in success_states
is treated as a failure.
To customize, provide both terminal_states and success_states:
terminal_states: [:completed, :errored, :cancelled, :timed_out],
success_states: [:completed]Providing only one without the other raises a compile error — this ensures the success/failure classification is always explicit.
On failure, the error_reason is the original error from the failing node.
When no node error was captured (e.g., a direct transition to :cancelled),
the terminal state atom itself becomes the error reason.
Examples
# Using convention defaults (:done/:failed)
defmodule MyETLPipeline do
use Jido.Composer.Workflow,
name: "etl_pipeline",
nodes: %{
extract: ExtractAction,
transform: TransformAction,
load: LoadAction
},
transitions: %{
{:extract, :ok} => :transform,
{:transform, :ok} => :load,
{:load, :ok} => :done,
{:_, :error} => :failed
},
initial: :extract
end
# Custom terminal states with explicit success classification
defmodule ApprovalPipeline do
use Jido.Composer.Workflow,
name: "approval_pipeline",
nodes: %{process: ProcessAction, review: ReviewAction},
transitions: %{
{:process, :ok} => :review,
{:review, :approved} => :completed,
{:review, :rejected} => :rejected,
{:_, :error} => :errored
},
initial: :process,
terminal_states: [:completed, :rejected, :errored],
success_states: [:completed]
end