Spectre.GAM.Decision (Spectre v0.4.0)

Copy Markdown View Source

Durable result of evaluating a candidate at one authority revision.

The four outcomes are intentionally disjoint. Only :admitted may be paired with an Act; refusal, inability to decide and an unknown surface class must never be collapsed into one generic error. recognition_refs identifies the evaluated Conditions; recognition_evidence_refs separately freezes the Evidence basis that actually reached the Recognition stage.

Summary

Functions

Returns true only for the sole outcome that can produce an Act.

Returns the plain, string-keyed ledger representation.

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

Returns the stable digest of the complete decision.

Restores a decision from its canonical map.

Builds and validates a durable decision.

Returns whether Admission planned any Meter reservation.

Types

outcome()

@type outcome() :: :admitted | :refused | :undecidable | :unknown_class

t()

@type t() :: %Spectre.GAM.Decision{
  accountable_ref: String.t() | nil,
  authenticated_principal_ref: String.t(),
  authentication_ref: String.t(),
  authority_revision: non_neg_integer(),
  authorizer_ref: String.t() | nil,
  candidate_class: String.t(),
  candidate_digest: String.t(),
  candidate_identity_key: String.t(),
  channel_ref: String.t() | nil,
  consent: Spectre.GAM.Consent.t() | nil,
  decided_at: integer(),
  domain_ref: String.t(),
  executor_ref: String.t() | nil,
  host_generation: non_neg_integer(),
  host_profile_ref: String.t(),
  ingress_ref: String.t(),
  mandate_ref: String.t() | nil,
  mandate_revision: pos_integer() | nil,
  outcome: outcome(),
  proposer_ref: String.t(),
  reasons: [term()],
  recognition_evidence_refs: [String.t()],
  recognition_refs: [String.t()],
  ref: String.t(),
  reservations: Spectre.GAM.Kernel.Meter.Amounts.t(),
  schema_version: 1,
  scope_ref: String.t(),
  session_ref: String.t() | nil,
  submission_context_ref: String.t(),
  surface_revision: non_neg_integer()
}

Functions

admitted?(decision)

@spec admitted?(t()) :: boolean()

Returns true only for the sole outcome that can produce an Act.

canonical(decision)

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

Returns the plain, string-keyed ledger representation.

content_ref(decision)

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

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

digest(decision)

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

Returns the stable digest of the complete decision.

from_canonical(value)

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

Restores a decision from its canonical map.

new(decision)

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

Builds and validates a durable decision.

reservations?(decision)

@spec reservations?(t()) :: boolean()

Returns whether Admission planned any Meter reservation.