Spectre.GAM.Row (Spectre v0.4.0)

Copy Markdown View Source

Decidable summary of the governed dimensions touched by a consequence.

Rows deliberately remain a small boolean vocabulary. Domain-specific classes, targets and quantitative limits live in Spectre.GAM.Surface and Spectre.GAM.Mandate; a row only states which kinds of power are involved.

Summary

Functions

Returns the plain, string-keyed ledger representation.

Returns the stable digest of a row.

Returns enabled dimensions in stable vocabulary order.

Restores a row from its canonical map.

Returns the fixed governed-dimension vocabulary.

Builds and validates an effect row. Omitted dimensions are false.

Returns true when every enabled dimension in row is enabled by ceiling.

Validates an effect row without changing it.

Types

dimension()

@type dimension() ::
  :attempt
  | :observe
  | :read
  | :write
  | :disclose
  | :spend
  | :delegate
  | :govern
  | :present

t()

@type t() :: %Spectre.GAM.Row{
  attempt: boolean(),
  delegate: boolean(),
  disclose: boolean(),
  govern: boolean(),
  observe: boolean(),
  present: boolean(),
  read: boolean(),
  schema_version: 1,
  spend: boolean(),
  write: boolean()
}

Functions

canonical(row)

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

Returns the plain, string-keyed ledger representation.

digest(row)

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

Returns the stable digest of a row.

dimensions(row)

@spec dimensions(t()) :: [dimension()]

Returns enabled dimensions in stable vocabulary order.

from_canonical(value)

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

Restores a row from its canonical map.

known_dimensions()

@spec known_dimensions() :: [dimension()]

Returns the fixed governed-dimension vocabulary.

new(row)

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

Builds and validates an effect row. Omitted dimensions are false.

subset?(row, ceiling)

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

Returns true when every enabled dimension in row is enabled by ceiling.

Both arguments may be structs, keyword lists or canonical maps. Malformed rows fail closed and return false; unknown keys are never ignored.

validate(row)

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

Validates an effect row without changing it.