Spectre.GAM.Condition (Spectre v0.4.0)

Copy Markdown View Source

Portable evidence requirement attached to a mandate.

Conditions describe what Recognition must establish. They never select a mandate and never produce authority or a grant. Atom keys in opaque application maps are converted recursively to strings at construction, so attenuation and content identity never depend on which key spelling crossed the boundary; colliding atom/string keys are rejected.

Summary

Functions

Returns whether child is a valid attenuation of parent.

Checks that child is the same requirement as, or a stricter requirement than, parent.

Returns the plain, string-keyed ledger representation.

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

Returns the stable digest of the complete condition.

Restores a condition from its canonical map.

Builds and validates an evidence condition.

Types

t()

@type t() :: %Spectre.GAM.Condition{
  accepted_provenance: [:observed | :derived | :generated],
  allow_provisional: boolean(),
  bindings: map(),
  cardinality: %{required(String.t()) => non_neg_integer() | nil},
  coverage: term(),
  freshness_ms: non_neg_integer() | nil,
  parameters: map(),
  proposition: term(),
  ref: String.t(),
  schema_version: 1
}

Functions

attenuates?(child, parent)

@spec attenuates?(t() | map() | keyword(), t() | map() | keyword()) :: boolean()

Returns whether child is a valid attenuation of parent.

attenuation(parent, child)

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

Checks that child is the same requirement as, or a stricter requirement than, parent.

The comparison is deliberately structural and closed. It permits stronger coverage/bindings, a narrower provenance set, tighter cardinality and freshness, and rejecting provisional Evidence. Proposition and opaque domain-specific parameters must remain byte-for-byte equivalent because the core cannot safely infer a restriction relation for their vocabulary. References are identifiers and are therefore not used as proof of semantic equivalence.

canonical(condition)

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

Returns the plain, string-keyed ledger representation.

content_ref(condition)

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

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

digest(condition)

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

Returns the stable digest of the complete condition.

from_canonical(value)

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

Restores a condition from its canonical map.

new(condition)

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

Builds and validates an evidence condition.