Declarative workflow contract for Squid Mesh workflow modules.
Example
defmodule Billing.InvoiceReminder do
use SquidMesh.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.
Adds one trigger definition to the workflow module currently being compiled.
Adds one payload field to the trigger currently being compiled.
Resolves late-bound runtime metadata for generated workflow definitions.
Injects the workflow DSL and compile-time collectors into a workflow module.
Declares a cron-based trigger.
Declares one payload field inside a trigger payload block.
Declares a manual trigger.
Declares the payload contract for the current trigger.
Converts a compiled workflow module into Squid Mesh's normalized workflow spec.
Declares a transition from one step outcome to the next step.
Declares a named workflow trigger.
Validates a normalized workflow spec without resolving workflow or step modules.
Functions
@spec __before_compile__(Macro.Env.t()) :: Macro.t()
Validates the collected workflow declarations and emits runtime accessors.
Adds one trigger definition to the workflow module currently being compiled.
Adds one payload field to the trigger currently being compiled.
Resolves late-bound runtime metadata for generated workflow definitions.
Workflow modules store a compile-time definition, but step modules may expose Squid Mesh 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 and compile-time collectors into a workflow module.
Declares a cron-based trigger.
Pass idempotency: :return_existing_run when duplicate deliveries should
return the first run, or idempotency: :skip_duplicate when duplicates should
be reported as skipped. Idempotent cron triggers require either a
scheduler-provided :signal_id or an :intended_window with both bounds so
the runtime can derive a stable idempotency key.
Declares one payload field inside a trigger payload block.
Declares a manual trigger.
Declares the payload contract for the current trigger.
@spec to_spec(module()) :: {:ok, SquidMesh.Workflow.Spec.t()} | {:error, SquidMesh.Workflow.Definition.load_error()}
Converts a compiled workflow module into Squid Mesh's normalized workflow spec.
Declares a transition from one step outcome to the next step.
Declares a named workflow trigger.
@spec validate_spec(SquidMesh.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 Squid Mesh planner state. It does not prove that arbitrary module atoms are owned by the host application or executable as runtime-authored workflow code.