Spectre.Experience.Evidence (Spectre v0.3.0)

Copy Markdown View Source

Immutable, redacted and non-canonical operational evidence.

Evidence is tied to an exact Definition and activation generation. It may inform reflection and future proposals, but it never authorizes execution, replaces Instance state, or becomes a Journal record.

Summary

Functions

Decodes and revalidates canonical evidence bytes.

Returns the stable full-content evidence digest.

Encodes evidence with the production canonical codec.

Returns whether evidence is expired at the supplied millisecond timestamp.

Restores and verifies evidence from portable data.

Builds and verifies already-redacted Experience evidence.

Builds evidence or raises with the stable validation reason.

Returns the content-addressed evidence Ref.

Returns the Experience evidence schema version.

Returns canonical portable evidence data.

Revalidates evidence and its canonical transport representation.

Types

retention()

@type retention() :: :ephemeral | :bounded | :retained

t()

@type t() :: %Spectre.Experience.Evidence{
  activation_generation: non_neg_integer(),
  definition_ref: Spectre.Definition.Ref.t(),
  expires_at: non_neg_integer() | nil,
  facts: map(),
  kind: String.t(),
  observed_at: non_neg_integer(),
  provenance: map(),
  redactions: [[String.t() | non_neg_integer()]],
  retention: retention(),
  schema_version: pos_integer(),
  source_ref: String.t()
}

Functions

decode(encoded)

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

Decodes and revalidates canonical evidence bytes.

digest(evidence)

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

Returns the stable full-content evidence digest.

encode(evidence)

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

Encodes evidence with the production canonical codec.

expired?(evidence, now)

@spec expired?(t(), non_neg_integer()) :: boolean()

Returns whether evidence is expired at the supplied millisecond timestamp.

from_data(data)

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

Restores and verifies evidence from portable data.

new(evidence)

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

Builds and verifies already-redacted Experience evidence.

new!(attrs)

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

Builds evidence or raises with the stable validation reason.

ref(evidence)

Returns the content-addressed evidence Ref.

schema_version()

@spec schema_version() :: pos_integer()

Returns the Experience evidence schema version.

to_data(evidence)

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

Returns canonical portable evidence data.

verify(evidence)

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

Revalidates evidence and its canonical transport representation.