Spectre.Definition.Candidate (Spectre v0.3.0)

Copy Markdown View Source

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.

Summary

Functions

Decodes and validates canonical Candidate bytes.

Returns the stable Candidate digest.

Encodes the Candidate into canonical portable bytes.

Restores a Candidate from decoded canonical data.

Builds a Candidate from a verified Definition resolution.

Builds and validates a Candidate from normalized attributes.

Builds a Candidate or raises with the stable validation reason.

Returns the Candidate's content-addressed Ref.

Returns the Candidate schema version.

Returns portable canonical data.

Types

source()

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

t()

@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()
}

Functions

decode(encoded)

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

Decodes and validates canonical Candidate bytes.

digest(candidate)

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

Returns the stable Candidate digest.

encode(candidate)

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

Encodes the Candidate into canonical portable bytes.

from_data(data)

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

Restores a Candidate from decoded canonical data.

from_resolution(resolution, opts \\ [])

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

Builds a Candidate from a verified Definition resolution.

new(candidate)

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

Builds and validates a Candidate from normalized attributes.

new!(attrs)

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

Builds a Candidate or raises with the stable validation reason.

ref(candidate)

Returns the Candidate's content-addressed Ref.

schema_version()

@spec schema_version() :: pos_integer()

Returns the Candidate schema version.

to_data(candidate)

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

Returns portable canonical data.