Spectre.GAM.Evidence (Spectre v0.4.0)

Copy Markdown View Source

Portable Evidence about a proposition, kept separate from authority.

Its explicit stance distinguishes support from contradiction. Evidence is also scoped by source, provenance, time, bindings and assumptions. :generated and provisional evidence remain visibly so; this record never promotes them to observed facts.

Summary

Functions

Returns the plain, string-keyed ledger representation.

Returns the content-derived reference, independent of an assigned ref.

Returns whether Evidence is current and fresh enough at one trusted instant.

Returns the stable digest of the complete evidence record.

Restores evidence from its canonical map.

Builds and validates evidence.

Returns canonical labels de-duplicated and ordered by stable reference.

Returns whether two records assert opposite stances for the same proposition.

Returns the Evidence time-window status at one trusted instant.

Types

stance()

@type stance() :: :supports | :contradicts

t()

@type t() :: %Spectre.GAM.Evidence{
  assumptions: [term()],
  bindings: map(),
  freshness_ms: non_neg_integer() | nil,
  issuer_ref: String.t(),
  labels: [Spectre.GAM.Label.t()],
  observed_at: integer(),
  parent_refs: [String.t()],
  payload: term(),
  payload_ref: String.t() | nil,
  proposition: term(),
  provenance: :observed | :derived | :generated,
  provisional: boolean(),
  ref: String.t(),
  schema_version: 1,
  source_ref: String.t(),
  stance: stance(),
  valid_from: integer() | nil,
  valid_until: integer() | nil
}

temporal_status()

@type temporal_status() :: :current | :from_future | :not_yet_valid | :expired

Functions

canonical(evidence)

@spec canonical(t()) :: map()

Returns the plain, string-keyed ledger representation.

content_ref(evidence)

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

Returns the content-derived reference, independent of an assigned ref.

current_at?(evidence, time, maximum_age_ms \\ nil)

@spec current_at?(t(), integer(), non_neg_integer() | nil) :: boolean()

Returns whether Evidence is current and fresh enough at one trusted instant.

digest(evidence)

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

Returns the stable digest of the complete evidence record.

from_canonical(value)

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

Restores evidence from its canonical map.

new(evidence)

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

Builds and validates evidence.

normalize_labels(labels)

@spec normalize_labels(term()) :: {:ok, [Spectre.GAM.Label.t()]} | {:error, term()}

Returns canonical labels de-duplicated and ordered by stable reference.

opposes?(left, right)

@spec opposes?(t(), t()) :: boolean()

Returns whether two records assert opposite stances for the same proposition.

temporal_status(evidence, time)

@spec temporal_status(t(), integer()) :: temporal_status()

Returns the Evidence time-window status at one trusted instant.