Spectre.Gate.Receipt (Spectre v0.3.0)

Copy Markdown View Source

Content-addressed evidence emitted by one trusted governance checker.

Receipts bind the immutable proposal, both Definition identities, execution closure, evaluation corpus, checker version, profile, result, provenance, and validity window. Passing a struct does not grant trust: activation reads the receipt back from the configured Definition Store by Receipt.Ref.

Summary

Functions

Decodes and revalidates a receipt.

Returns the canonical receipt digest.

Encodes a receipt with the production canonical codec.

Builds and validates one gate receipt.

Builds a receipt or raises with the stable validation reason.

Returns the receipt's content Ref.

Returns canonical portable receipt data.

Verifies receipt binding, freshness, status, and optional checker policy.

Verifies immutable proposal binding without interpreting gate outcome.

Types

gate_class()

@type gate_class() :: Spectre.Governance.CandidateState.gate_class() | :approval

t()

@type t() :: %Spectre.Gate.Receipt{
  candidate_definition_ref: String.t(),
  candidate_digest: String.t(),
  checker_id: String.t(),
  checker_version: pos_integer(),
  closure_digest: String.t(),
  evaluation_cases_digest: String.t(),
  expires_at: non_neg_integer() | nil,
  gate_class: gate_class(),
  issued_at: non_neg_integer(),
  parent_definition_ref: String.t(),
  profile_ref: String.t() | nil,
  provenance: map(),
  result_digest: String.t(),
  schema_version: pos_integer(),
  status: :passed | :failed
}

Functions

decode(encoded)

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

Decodes and revalidates a receipt.

digest(receipt)

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

Returns the canonical receipt digest.

encode(receipt)

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

Encodes a receipt with the production canonical codec.

new(receipt)

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

Builds and validates one gate receipt.

new!(attrs)

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

Builds a receipt or raises with the stable validation reason.

ref(receipt)

@spec ref(t()) :: Spectre.Gate.Receipt.Ref.t()

Returns the receipt's content Ref.

to_data(receipt)

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

Returns canonical portable receipt data.

verify(receipt, candidate, opts \\ [])

@spec verify(t(), Spectre.Governance.CandidateState.t(), keyword()) ::
  :ok | {:error, term()}

Verifies receipt binding, freshness, status, and optional checker policy.

verify_binding(receipt, candidate)

@spec verify_binding(t(), Spectre.Governance.CandidateState.t()) ::
  :ok | {:error, term()}

Verifies immutable proposal binding without interpreting gate outcome.