Spectre.GAM.Mandate (Spectre v0.4.0)

Copy Markdown View Source

Portable, decidable boundary of delegated authority.

A mandate states who may propose, which executors and executor contracts may carry an admitted Act, what may be touched, and for which closed purpose, Evidence, time, resource, delegation and revocation constraints. Possessing a mandate reference is not an execution capability.

Summary

Functions

Returns the plain, string-keyed ledger representation.

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

Returns the stable digest of the complete mandate.

Restores a mandate from its canonical map.

Materializes an exact canonical issue draft under the Act that authorized it.

Builds the canonical, validated body frozen by a mandate-issuance Candidate.

Builds and validates a mandate.

Returns whether the mandate has no parent mandate.

Types

delegation_policy()

@type delegation_policy() :: %{required(String.t()) => boolean() | non_neg_integer()}

revocation_mode()

@type revocation_mode() :: :cascade | :retained_controller

revocation_policy()

@type revocation_policy() :: %{
  required(String.t()) => revocation_mode() | [String.t()]
}

t()

@type t() :: %Spectre.GAM.Mandate{
  accountable_ref: String.t(),
  ceiling: Spectre.GAM.Row.t(),
  classes: [String.t()],
  conditions: [Spectre.GAM.Condition.t()],
  delegation: delegation_policy(),
  disclosable_labels: [Spectre.GAM.Label.t()],
  executor_contract_refs: [String.t()],
  executor_refs: [String.t()],
  expires_at: integer(),
  grantor_ref: String.t(),
  holder_ref: String.t(),
  meters: %{optional(String.t()) => non_neg_integer()},
  not_before: integer(),
  parent_ref: String.t() | nil,
  purpose_params: map(),
  purpose_ref: String.t(),
  ref: String.t(),
  revision: pos_integer(),
  revocation: revocation_policy(),
  schema_version: 1,
  scope_refs: [String.t()],
  source_ref: String.t(),
  subject_refs: [String.t()],
  target_refs: [String.t()]
}

Functions

canonical(mandate)

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

Returns the plain, string-keyed ledger representation.

content_ref(mandate)

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

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

digest(mandate)

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

Returns the stable digest of the complete mandate.

from_canonical(value)

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

Restores a mandate from its canonical map.

from_issue_draft(draft, source_ref)

@spec from_issue_draft(map(), String.t()) :: {:ok, t()} | {:error, term()}

Materializes an exact canonical issue draft under the Act that authorized it.

issue_draft(mandate)

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

Builds the canonical, validated body frozen by a mandate-issuance Candidate.

new(mandate)

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

Builds and validates a mandate.

root?(mandate)

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

Returns whether the mandate has no parent mandate.