# `Spectre.Action.Provider`
[🔗](https://github.com/elchemista/spectre/blob/0.4.0/lib/spectre/action/provider.ex#L1)

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.

# `provider_result`

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

# `actions`
*optional* 

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

# `execute`

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

# `schema_hash`
*optional* 

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

# `actions`

```elixir
@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`

```elixir
@spec execute(
  Spectre.Action.Provider.Mount.t(),
  Spectre.Action.t(),
  Spectre.Context.t()
) ::
  provider_result()
```

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`

```elixir
@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.

---

*Consult [api-reference.md](api-reference.md) for complete listing*
