Spectre.Definition.Resolver (Spectre v0.3.0)

Copy Markdown View Source

Verified resolution of published canonical Definitions.

Resolution always re-reads Definition, Manifest, and publication receipt from the configured Store. Code drift is never hidden: without trusted observations the result is marked :unobserved; matching builds are marked :matched; changed or missing builds fail by default and can be returned as evidence only with the explicit on_drift: :report host policy.

Summary

Functions

Creates and publishes a minimal bootstrap Candidate from a verified Definition resolution.

Fetches and verifies a Definition plus its current build observations.

Resolves a Definition or raises when it is missing or invalid.

Re-reads a Candidate by Ref and re-resolves its published Definition.

Enforces the Definition-before-activation publication protocol.

Types

drift_status()

@type drift_status() ::
  %{status: :unobserved, drifts: [], observed_builds: %{}}
  | %{status: :matched, drifts: [], observed_builds: map()}
  | %{
      status: :drifted,
      drifts: [Spectre.Execution.Closure.drift()],
      observed_builds: map()
    }

resolution()

@type resolution() :: %{
  definition_ref: Spectre.Definition.Ref.t(),
  definition: Spectre.Definition.Canonical.t(),
  manifest: Spectre.Definition.Manifest.t(),
  publication_receipt: Spectre.Definition.Store.receipt(),
  drift: drift_status()
}

Functions

bootstrap_candidate(store, definition_ref, opts \\ [])

@spec bootstrap_candidate(
  Spectre.Definition.Store.config(),
  Spectre.Definition.Ref.t() | String.t(),
  keyword()
) :: {:ok, Spectre.Definition.Candidate.Ref.t()} | {:error, term()} | :not_found

Creates and publishes a minimal bootstrap Candidate from a verified Definition resolution.

This boundary is for trusted host code and compiled Definition lowering; runtime-authored ChangeSets and promotion gates are intentionally outside the 0.2.3 scope.

resolve(store, ref, opts \\ [])

@spec resolve(
  Spectre.Definition.Store.config(),
  Spectre.Definition.Ref.t() | String.t(),
  keyword()
) ::
  :not_found | {:ok, resolution()} | {:error, term()}

Fetches and verifies a Definition plus its current build observations.

resolve!(store, ref, opts \\ [])

Resolves a Definition or raises when it is missing or invalid.

resolve_candidate_for_activation(store, candidate_ref, opts \\ [])

@spec resolve_candidate_for_activation(
  Spectre.Definition.Store.config(),
  Spectre.Definition.Candidate.Ref.t() | String.t(),
  keyword()
) ::
  {:ok,
   %{candidate: Spectre.Definition.Candidate.t(), resolution: resolution()}}
  | {:error, term()}
  | :not_found

Re-reads a Candidate by Ref and re-resolves its published Definition.

The returned pair is the only accepted input to the activation snapshot constructor; a caller-supplied Candidate struct is never trusted.

resolve_for_activation(store, ref, opts \\ [])

@spec resolve_for_activation(
  Spectre.Definition.Store.config(),
  Spectre.Definition.Ref.t() | String.t(),
  keyword()
) :: :not_found | {:ok, resolution()} | {:error, term()}

Enforces the Definition-before-activation publication protocol.

This does not perform activation or CAS. It verifies the durability pairing, then re-reads the published artifact through resolve/3; the returned resolution is the only acceptable input to a later activation CAS.