# `Spectre.Definition.ContractRegistry`
[🔗](https://github.com/elchemista/spectre/blob/0.3.0/lib/spectre/definition/contract_registry.ex#L1)

Trusted registry of component contracts understood by this runtime.

Canonical Definitions carry schema Refs, never validator modules. The host
constructs this registry from reviewed code and the resolver rejects every
unknown `:must_understand` component. Unknown advisory or descriptive
components remain opaque and are preserved in the Manifest snapshot.

# `entry`

```elixir
@type entry() :: %{
  component_type: atom() | String.t(),
  schema_ref: String.t(),
  criticalities: [Spectre.Definition.Component.criticality()],
  version: pos_integer(),
  validator: validator()
}
```

# `t`

```elixir
@type t() :: %Spectre.Definition.ContractRegistry{
  entries: %{optional(String.t()) =&gt; entry()}
}
```

# `validator`

```elixir
@type validator() :: {module(), atom()} | nil
```

# `default`

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

Returns the registry understood by the current Spectre release.

# `fetch`

```elixir
@spec fetch(t(), String.t()) :: {:ok, entry()} | :error
```

Fetches a registered contract by its exact schema Ref.

# `new`

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

Builds a registry from trusted component contract entries.

# `new!`

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

Builds a registry or raises with its stable validation reason.

# `register`

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

Registers one reviewed component contract.

# `snapshot`

```elixir
@spec snapshot(t(), Spectre.Definition.Canonical.t()) ::
  {:ok, [map()]} | {:error, term()}
```

Returns the exact contract interpretation sealed into a Manifest.

# `validate`

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

Validates all understood components and fail-closes unknown critical semantics.

# `verify_snapshot`

```elixir
@spec verify_snapshot(t(), Spectre.Definition.Canonical.t(), [map()]) ::
  :ok | {:error, term()}
```

Verifies that the current registry interprets a Definition exactly as published.

---

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