Declarative workflow contract for Squidie workflow modules.
Example
defmodule Billing.InvoiceReminder do
use Squidie.Workflow
workflow do
trigger :invoice_delivery do
manual()
payload do
field :account_id, :string
field :invoice_id, :string
end
end
step :load_invoice, Billing.Steps.LoadInvoice
step :send_email, Billing.Steps.SendReminderEmail, retry: [max_attempts: 3]
transition :load_invoice, on: :ok, to: :send_email
end
endThe contract defined here captures workflow structure. Validation and runtime execution behavior are added in subsequent slices.
Summary
Functions
Validates the collected workflow declarations and emits runtime accessors.
Resolves late-bound runtime metadata for generated workflow definitions.
Injects the workflow DSL into a workflow module.
Resolves runtime-authored :action step keys to host-approved modules.
Converts a compiled workflow module into Squidie's normalized workflow spec.
Validates a normalized workflow spec without resolving workflow or step modules.
Validates a normalized workflow spec after resolving host-approved action keys.
Functions
@spec __before_compile__(Macro.Env.t()) :: Macro.t()
Validates the collected workflow declarations and emits runtime accessors.
Resolves late-bound runtime metadata for generated workflow definitions.
Workflow modules store a compile-time definition, but step modules may expose Squidie step metadata that should be read when the workflow definition is consumed. This keeps generated workflow modules small while preserving the runtime contract used by dispatch and inspection.
Injects the workflow DSL into a workflow module.
@spec resolve_spec_actions( Squidie.Workflow.Spec.t() | map() | term(), keyword() ) :: {:ok, Squidie.Workflow.Spec.t() | map()} | {:error, {:invalid_workflow_spec, [map()]}}
Resolves runtime-authored :action step keys to host-approved modules.
@spec to_spec(module()) :: {:ok, Squidie.Workflow.Spec.t()} | {:error, Squidie.Workflow.Definition.load_error()}
Converts a compiled workflow module into Squidie's normalized workflow spec.
@spec validate_spec(Squidie.Workflow.Spec.t() | map() | term()) :: :ok | {:error, {:invalid_workflow_spec, [map()]}}
Validates a normalized workflow spec without resolving workflow or step modules.
This validates the structural contract used by Squidie planner state. It does not prove that arbitrary module atoms are owned by the host application or executable as runtime-authored workflow code.
@spec validate_spec( Squidie.Workflow.Spec.t() | map() | term(), keyword() ) :: :ok | {:error, {:invalid_workflow_spec, [map()]}}
Validates a normalized workflow spec after resolving host-approved action keys.
Runtime-authored specs can use stable :action keys instead of raw module
atoms when the host provides an :action_registry. Module-authored workflow
specs without action keys keep using the normal validation path.