Spectre.Action.Provider behaviour (Spectre v0.3.3)

Copy Markdown View Source

Contract and safe invocation facade for action providers.

Providers own discovery and execution. Spectre owns provider registration, policy, persistence, idempotency, and the effect lifecycle.

Discovery through actions/1 must be side-effect free. Runtime planning and read-only diagnostics may call it without starting provider resources.

Summary

Functions

Returns normalized discovery specs for a mounted provider.

Executes one action through its already-resolved provider mount.

Validates arguments against the exact provider spec selected for an action.

Types

provider_result()

@type provider_result() :: {:ok, term()} | {:error, term()}

Callbacks

actions(keyword)

(optional)
@callback actions(keyword()) ::
  [Spectre.Action.Spec.t() | map()]
  | {:ok, [Spectre.Action.Spec.t() | map()]}
  | {:error, term()}

execute(t, t, keyword)

@callback execute(Spectre.Action.t(), Spectre.Context.t(), keyword()) :: term()

schema_hash(t, keyword)

(optional)
@callback schema_hash(
  Spectre.Action.t(),
  keyword()
) :: String.t() | nil | {:ok, String.t() | nil}

Functions

actions(mount, visibility \\ :planner)

@spec actions(Spectre.Action.Provider.Mount.t(), :planner | :all) ::
  {:ok, [Spectre.Action.Spec.t()]} | {:error, term()}

Returns normalized discovery specs for a mounted provider.

execute(mount, action, ctx)

Executes one action through its already-resolved provider mount.

If a planner attached a schema hash, the provider must support schema verification and report the same hash before execution.

validate_arguments(mount, action)

@spec validate_arguments(Spectre.Action.Provider.Mount.t(), Spectre.Action.t()) ::
  :ok | {:error, term()}

Validates arguments against the exact provider spec selected for an action.