Durable run persistence and lifecycle operations.
This module translates between the public SquidMesh.Run struct and the
underlying persistence schema while applying workflow-level rules such as
payload validation, trigger resolution, replay lineage, and legal run-state
transitions.
Summary
Functions
Requests cancellation for a run if its current status allows it.
Creates a new run for a workflow using the workflow's default trigger.
Creates a new run for a workflow through an explicit trigger.
Fetches one persisted run and returns the public run representation.
Lists runs using the supported filter set.
Creates a new pending run from a prior run while preserving replay lineage.
Returns whether a run in the given state should schedule additional step work.
Applies a validated run-state transition and persists the updated run.
Updates durable run fields without changing the run state machine directly.
Types
@type attrs_fun() :: (SquidMesh.Run.t() -> transition_attrs())
@type create_error() :: {:invalid_payload, :expected_map} | {:invalid_payload, SquidMesh.Workflow.Definition.payload_error_details()} | {:invalid_trigger, atom() | String.t()} | {:invalid_workflow, module() | String.t()} | {:invalid_run, Ecto.Changeset.t()}
@type dispatch_fun() :: (SquidMesh.Run.t() -> {:ok, term()} | {:error, term()})
@type failure_attrs_fun() :: (SquidMesh.Run.t(), term() -> transition_attrs())
@type get_error() :: :not_found
@type get_option() :: {:include_history, boolean()}
@type list_filter() :: {:workflow, module()} | {:status, SquidMesh.Run.status()} | {:limit, pos_integer()}
@type list_filters() :: [list_filter()]
@type pause_result() :: %{ run: SquidMesh.Run.t(), from_status: SquidMesh.Run.status(), to_status: SquidMesh.Run.status(), terminal_noop?: true, finalized_step?: boolean(), error: map() } | %{ run: SquidMesh.Run.t(), from_status: SquidMesh.Run.status(), to_status: SquidMesh.Run.status() }
@type progress_event() :: run_transition_event() | term()
@type progress_operation() :: :update | {:transition, SquidMesh.Run.status()} | {:dispatch, dispatch_fun()} | {:dispatch_or_fail, dispatch_fun(), failure_attrs_fun()} | {:transition_or_dispatch, SquidMesh.Run.status(), dispatch_fun()} | {:transition_or_dispatch_or_fail, SquidMesh.Run.status(), dispatch_fun(), failure_attrs_fun()}
@type progress_result() :: SquidMesh.Run.t() | :noop
@type replay_error() :: get_error() | create_error()
@type run_transition_event() :: {:run_transition, SquidMesh.Run.t(), SquidMesh.Run.status(), SquidMesh.Run.status()}
@type transition_error() :: get_error() | SquidMesh.Runtime.StateMachine.transition_error() | {:invalid_run, Ecto.Changeset.t()}
@type update_error() :: get_error() | {:invalid_run, Ecto.Changeset.t()}
Functions
@spec cancel_run(module(), Ecto.UUID.t()) :: {:ok, SquidMesh.Run.t()} | {:error, transition_error()}
Requests cancellation for a run if its current status allows it.
@spec create_run(module(), module(), map()) :: {:ok, SquidMesh.Run.t()} | {:error, create_error()}
Creates a new run for a workflow using the workflow's default trigger.
@spec create_run(module(), module(), atom(), map()) :: {:ok, SquidMesh.Run.t()} | {:error, create_error()}
Creates a new run for a workflow through an explicit trigger.
@spec get_run(module(), Ecto.UUID.t(), [get_option()]) :: {:ok, SquidMesh.Run.t()} | {:error, get_error()}
Fetches one persisted run and returns the public run representation.
@spec list_runs(module(), list_filters()) :: {:ok, [SquidMesh.Run.t()]}
Lists runs using the supported filter set.
@spec replay_run(module(), Ecto.UUID.t()) :: {:ok, SquidMesh.Run.t()} | {:error, replay_error()}
Creates a new pending run from a prior run while preserving replay lineage.
@spec schedule_next_step?(SquidMesh.Run.t() | SquidMesh.Run.status()) :: boolean()
Returns whether a run in the given state should schedule additional step work.
@spec transition_run( module(), Ecto.UUID.t(), SquidMesh.Run.status(), transition_attrs() ) :: {:ok, SquidMesh.Run.t()} | {:error, transition_error()}
Applies a validated run-state transition and persists the updated run.
@spec update_run(module(), Ecto.UUID.t(), transition_attrs()) :: {:ok, SquidMesh.Run.t()} | {:error, update_error()}
Updates durable run fields without changing the run state machine directly.