Spectre.Instance.Activation (Spectre v0.3.0)

Copy Markdown View Source

Canonical snapshot binding one Instance to an active Definition.

Activation is mutable only through generation-fenced compare-and-swap. The snapshot records the Candidate and publication that were re-read from a trusted Definition Store, the observed authority epoch, execution closure, state bindings, owner fencing token, timestamp, and provenance.

Summary

Functions

Returns 0 when no Activation exists.

Builds and validates an Activation from normalized attributes.

Applies an activation generation compare-and-swap.

Decodes and verifies portable Activation bytes.

Encodes the Activation into portable canonical bytes.

Restores and verifies an Activation from decoded canonical data.

Returns 0 when no Activation exists.

Builds a prospective Activation from a Candidate and verified resolution.

Returns the Activation snapshot schema version.

Returns portable canonical data.

Types

t()

@type t() :: %Spectre.Instance.Activation{
  activated_at: non_neg_integer(),
  activation_receipt: String.t(),
  authority_epoch: non_neg_integer(),
  candidate_ref: Spectre.Definition.Candidate.Ref.t(),
  closure_digest: String.t(),
  definition_ref: Spectre.Definition.Ref.t(),
  generation: pos_integer(),
  manifest_digest: String.t(),
  owner_fencing_token: pos_integer(),
  provenance: map(),
  publication_id: String.t(),
  schema_version: pos_integer(),
  state_bindings: map()
}

Functions

authority_epoch(arg1)

@spec authority_epoch(t() | nil) :: non_neg_integer()

Returns 0 when no Activation exists.

build(attrs)

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

Builds and validates an Activation from normalized attributes.

compare_and_swap(current, expected_generation, next)

@spec compare_and_swap(t() | nil, non_neg_integer(), t()) ::
  {:ok, t()} | {:error, term()}

Applies an activation generation compare-and-swap.

expected_generation is 0 before the first activation. Authority epochs may stay equal or increase; they can never move backwards.

decode(encoded)

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

Decodes and verifies portable Activation bytes.

encode(activation)

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

Encodes the Activation into portable canonical bytes.

from_data(value)

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

Restores and verifies an Activation from decoded canonical data.

generation(arg1)

@spec generation(t() | nil) :: non_neg_integer()

Returns 0 when no Activation exists.

new(candidate, resolution, opts)

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

Builds a prospective Activation from a Candidate and verified resolution.

This function does not commit the snapshot. Callers must pass it through compare_and_swap/3 on the Instance sequencer.

schema_version()

@spec schema_version() :: pos_integer()

Returns the Activation snapshot schema version.

to_data(activation)

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

Returns portable canonical data.