Squidie.Workflow.ActionRegistry (squidie v0.3.1)

Copy Markdown View Source

Host-owned trust boundary for runtime-authored workflow actions.

Runtime-authored specs should reference stable action keys rather than raw module atoms. The host application owns the registry and maps those keys to approved Squidie.Step or explicit Jido.Action modules before a spec can be activated.

Summary

Functions

Projects a host-owned action registry into editor-safe catalog metadata.

Resolves :action step keys in a workflow spec to approved executable modules.

Resolves action keys and validates the resulting executable spec shape.

Types

action_key()

@type action_key() :: atom() | String.t()

action_validation_error()

@type action_validation_error() ::
  :missing_action_key
  | :invalid_action_key
  | :unknown_action_key
  | :disabled_action_key
  | :incompatible_action_module

catalog_entry()

@type catalog_entry() :: %{
  key: action_key(),
  display_name: String.t(),
  category: String.t() | nil,
  description: String.t(),
  enabled?: boolean(),
  input_contract: term(),
  output_contract: term(),
  credential_requirements: term()
}

catalog_error()

@type catalog_error() :: %{
  path: [atom() | action_key()],
  code: atom(),
  message: String.t(),
  details: map()
}

registry()

@type registry() ::
  %{optional(action_key()) => registry_entry()} | keyword(registry_entry())

registry_entry()

@type registry_entry() ::
  module()
  | keyword()
  | %{optional(:module) => module(), optional(:enabled?) => boolean()}
  | %{optional(String.t()) => term()}

validation_error()

@type validation_error() :: Squidie.Workflow.Spec.validation_error()

Functions

catalog(registry)

@spec catalog(term()) ::
  {:ok, [catalog_entry()]}
  | {:error, {:invalid_action_catalog, [catalog_error()]}}

Projects a host-owned action registry into editor-safe catalog metadata.

The catalog intentionally omits executable modules and credential values. It exposes stable action keys, display metadata, contracts, and credential requirements so editor clients can build palettes while validate_action/2 and resolve_action/2 remain the execution trust boundary.

resolve_spec(spec, registry)

@spec resolve_spec(Squidie.Workflow.Spec.t() | map() | term(), registry()) ::
  {:ok, Squidie.Workflow.Spec.t() | map()}
  | {:error, {:invalid_workflow_spec, [validation_error()]}}

Resolves :action step keys in a workflow spec to approved executable modules.

The resolved spec preserves the stable action key in both :action and step :metadata so later planner and inspection surfaces can expose identity without trusting user-provided module values.

validate_spec(spec, registry)

@spec validate_spec(Squidie.Workflow.Spec.t() | map() | term(), registry()) ::
  :ok | {:error, {:invalid_workflow_spec, [validation_error()]}}

Resolves action keys and validates the resulting executable spec shape.