# `Spectre.Stack.Definition`
[🔗](https://github.com/elchemista/spectre/blob/0.4.0/lib/spectre/stack/definition.ex#L1)

Compiled, immutable environment installed for an Agent.

Definitions validate package compatibility, dependency ordering, ownership,
and capability collisions. They contain logical configuration only.

# `capability_kind`

```elixir
@type capability_kind() ::
  :package | :contract | :service | :operation | :action | :resource
```

# `t`

```elixir
@type t() :: %Spectre.Stack.Definition{
  contract: pos_integer(),
  digest: String.t() | nil,
  id: term(),
  index: %{
    optional({capability_kind(), term()}) =&gt; Spectre.Stack.Installation.t()
  },
  installations: [Spectre.Stack.Installation.t()],
  owner: module(),
  packages: %{optional(term()) =&gt; Spectre.Stack.Package.t()},
  version: pos_integer()
}
```

# `fetch`

```elixir
@spec fetch(module()) :: {:ok, t()} | {:error, term()}
```

Fetches the compiled definition exposed by a Stack module.

# `fetch!`

```elixir
@spec fetch!(module()) :: t()
```

Fetches a Stack definition or raises.

# `installation`

```elixir
@spec installation(t() | module(), term()) ::
  {:ok, Spectre.Stack.Installation.t()} | {:error, term()}
```

Returns a package installation by its local installation identifier.

# `manifest`

```elixir
@spec manifest(t() | module()) :: map()
```

Returns the portable manifest for inspection, contract tests, and tooling.

# `resolve`

```elixir
@spec resolve(t() | module(), capability_kind(), term()) ::
  {:ok, Spectre.Stack.Ref.t()} | {:error, term()}
```

Resolves a closed logical capability to a fenced `Spectre.Stack.Ref`.

# `validate`

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

Revalidates every invariant and digest in a compiled definition.

# `validate!`

```elixir
@spec validate!(t()) :: t()
```

Revalidates a compiled definition or raises.

---

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