# `Spectre.Authority.Envelope`
[🔗](https://github.com/elchemista/spectre/blob/0.4.0/lib/spectre/authority/envelope.ex#L1)

Effective, portable authority granted to one canonical Definition.

Requests and grants are deliberately separate. `compose/2` intersects every
requested capability with a host-owned ceiling; a request can therefore
never create authority by itself. The resulting envelope contains grants
only and is safe to seal into a `Spectre.Definition.Manifest`.

# `t`

```elixir
@type t() :: %Spectre.Authority.Envelope{
  actions: [term()],
  consents: [term()],
  effects: [term()],
  event_classes: [term()],
  external_data_refs: [term()],
  limits: %{optional(atom()) =&gt; term()},
  model_profiles: [term()],
  model_purposes: [term()],
  open_capabilities: [term()],
  operations: [term()],
  prompt_budget_classes: [term()],
  prompt_phases: [term()],
  schema_version: pos_integer(),
  secret_refs: [term()],
  state_reads: [term()],
  state_writes: [term()]
}
```

# `allows?`

```elixir
@spec allows?(t(), atom(), term()) :: boolean()
```

Returns whether `value` is effectively granted in `field`.

# `compose`

```elixir
@spec compose(t() | map() | keyword(), t() | map() | keyword()) ::
  {:ok, t()} | {:error, term()}
```

Intersects requested authority with the host-owned authority ceiling.

Capability lists use canonical value identity. Numeric limits are reduced to
the stricter value; non-numeric limits, such as risk classes, are taken from
the ceiling and only appear when both sides declared the limit.

# `compose!`

```elixir
@spec compose!(t() | map() | keyword(), t() | map() | keyword()) :: t()
```

Intersects authority or raises with its stable validation reason.

# `digest`

```elixir
@spec digest(t()) :: String.t()
```

Returns the canonical SHA-256 digest of the effective grants.

# `empty`

```elixir
@spec empty() :: t()
```

Returns an envelope with no grants and no limits.

# `from_data`

```elixir
@spec from_data(map()) :: {:ok, t()} | {:error, term()}
```

Restores an envelope from decoded canonical data.

# `new`

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

Builds and validates an effective authority envelope.

# `new!`

```elixir
@spec new!(t() | map() | keyword()) :: t()
```

Builds an envelope or raises with its stable validation reason.

# `schema_version`

```elixir
@spec schema_version() :: pos_integer()
```

Returns the Authority Envelope schema version.

# `to_data`

```elixir
@spec to_data(t()) :: map()
```

Returns the portable data sealed into a Definition Manifest.

---

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