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

Immutable Candidate admitted by the activation boundary.

Bootstrap Candidates are authored by trusted host code or compiled Definition
lowering. Governed Candidates additionally bind verified governance state
produced by the host Composer/review pipeline. Both forms point at an
already-published Definition, Manifest, and publication receipt; activation
always re-reads the value from the Store by `Candidate.Ref`.

# `source`

```elixir
@type source() :: :compiled | :trusted_host | :governed_host
```

# `t`

```elixir
@type t() :: %Spectre.Definition.Candidate{
  created_at: non_neg_integer(),
  definition_ref: Spectre.Definition.Ref.t(),
  governance: Spectre.Governance.CandidateState.t() | nil,
  manifest_digest: String.t(),
  parent_ref: Spectre.Definition.Candidate.Ref.t() | nil,
  provenance_refs: [String.t()],
  publication_id: String.t(),
  schema_version: pos_integer(),
  source: source()
}
```

# `decode`

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

Decodes and validates canonical Candidate bytes.

# `digest`

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

Returns the stable Candidate digest.

# `encode`

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

Encodes the Candidate into canonical portable bytes.

# `from_data`

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

Restores a Candidate from decoded canonical data.

# `from_resolution`

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

Builds a Candidate from a verified Definition resolution.

# `new`

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

Builds and validates a Candidate from normalized attributes.

# `new!`

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

Builds a Candidate or raises with the stable validation reason.

# `ref`

```elixir
@spec ref(t()) :: Spectre.Definition.Candidate.Ref.t()
```

Returns the Candidate's content-addressed Ref.

# `schema_version`

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

Returns the Candidate schema version.

# `to_data`

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

Returns portable canonical data.

---

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