Spectre.GAM.SubmissionContext (Spectre v0.4.0)

Copy Markdown View Source

Authenticated ingress context supplied separately from a candidate.

Only the ingress adapter declared by the running Domain may produce a trusted context. The Sequencer authenticates through that adapter and adds a generation-bound, process-local seal. Scope opening, resumption and Candidate submission verify the seal as well as the fixed ingress_ref; merely building this public data structure does not cross the ingress boundary.

The seal is deliberately excluded from the canonical representation. It is a live fencing mechanism, not durable Evidence or part of the Domain history. The context identifies the authenticated principal and host generation without carrying reusable source credentials. Authentication narrows mandate eligibility; it never creates authority.

Summary

Functions

Returns the plain, string-keyed representation suitable for a decision record.

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

Returns the trusted ingress fields frozen into a durable Decision.

Returns the stable digest of the complete context.

Returns the exact trusted context fields embedded in scoped Evidence.

Returns the complete scoped context in Evidence bindings, or nil when unscoped.

Restores a context from its canonical map.

Restores the trusted ingress context frozen in a durable Decision.

Restores and verifies a context from the trusted portion of Evidence bindings.

Adds application bindings without permitting trusted context fields to be supplied.

Builds and validates an authenticated submission context.

Checks that scoped Evidence carries exactly this trusted context.

Types

t()

@type t() :: %Spectre.GAM.SubmissionContext{
  authenticated_principal_ref: String.t(),
  authentication_ref: String.t(),
  channel_ref: String.t() | nil,
  domain_ref: String.t(),
  host_generation: non_neg_integer(),
  ingress_ref: String.t(),
  ref: String.t(),
  schema_version: 1,
  scope_ref: String.t(),
  seal: String.t() | nil,
  session_ref: String.t() | nil
}

Functions

canonical(context)

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

Returns the plain, string-keyed representation suitable for a decision record.

content_ref(context)

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

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

decision_bindings(context)

@spec decision_bindings(t()) :: map()

Returns the trusted ingress fields frozen into a durable Decision.

digest(context)

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

Returns the stable digest of the complete context.

evidence_bindings(context)

@spec evidence_bindings(t()) :: map()

Returns the exact trusted context fields embedded in scoped Evidence.

extract_evidence_context(bindings)

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

Returns the complete scoped context in Evidence bindings, or nil when unscoped.

from_canonical(value)

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

Restores a context from its canonical map.

from_decision(decision)

@spec from_decision(Spectre.GAM.Decision.t()) :: {:ok, t()} | {:error, term()}

Restores the trusted ingress context frozen in a durable Decision.

from_evidence_bindings(bindings)

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

Restores and verifies a context from the trusted portion of Evidence bindings.

merge_evidence_bindings(context, additional \\ %{})

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

Adds application bindings without permitting trusted context fields to be supplied.

new(context)

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

Builds and validates an authenticated submission context.

validate_evidence_bindings(expected, bindings)

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

Checks that scoped Evidence carries exactly this trusted context.