# `Spectre.Policy.Resolution`
[🔗](https://github.com/elchemista/spectre/blob/0.4.0/lib/spectre/policy/resolution.ex#L1)

Validated policy matcher decision shared by user text and trusted hosts.

`source` identifies who supplied the evidence; lifecycle semantics depend
only on `kind` and `label`. Calling code remains responsible for
authenticating and authorizing a host actor before constructing a
`source: :host` resolution.

# `kind`

```elixir
@type kind() :: :accept | :reject
```

# `source`

```elixir
@type source() :: :user | :host | atom()
```

# `t`

```elixir
@type t() :: %Spectre.Policy.Resolution{
  kind: kind(),
  label: atom(),
  metadata: map(),
  source: source()
}
```

# `new`

```elixir
@spec new(kind(), atom(), source(), map()) :: {:ok, t()} | {:error, term()}
```

Validates and builds an accept or reject resolution.

`kind` must be `:accept` or `:reject`; `label` and `source` must be atoms;
metadata must be a map. The constructor returns an error tuple instead of
raising so host-supplied policy decisions can be rejected without mutating
state.

    {:ok, resolution} =
      Spectre.Policy.Resolution.new(
        :accept,
        :terms_accepted,
        :host,
        %{actor_id: "admin-1"}
      )

# `to_tuple`

```elixir
@spec to_tuple(t()) :: {kind(), atom()}
```

Returns the compact `{kind, label}` representation accepted by lifecycle
policy commands.

    {:accept, :terms_accepted} =
      Spectre.Policy.Resolution.to_tuple(resolution)

---

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