Spectre.GAM.Consequence.Validator (Spectre v0.4.0)

Copy Markdown View Source

Closed registry of pure, portable consequence validators.

A Spectre.GAM.Surface records one validator identifier for every declared consequence class. The identifier, rather than a module or callback, is durable data: admission and an independent auditor can therefore replay the same rule without executing application code from the ledger.

Ordinary application classes use none/0; their complete material shape is still enforced by Spectre.GAM.Consequence.Contract. Validators in this module exist only for core transitions whose validity depends on the current projection or trusted time. Their immutable class binding comes from Spectre.GAM.GovernedAct.Class, not from a callback named in ledger data.

Summary

Functions

Returns the built-in default recorded for a class by a new Surface.

Identifier for classes whose contract needs no projection-dependent rule.

Applies the validator selected by the active Surface.

Validates the immutable class-to-validator binding recorded by a Surface.

Validates that an identifier names a deterministic built-in rule.

Checks an admitted intrinsic transition against a provisional projection.

Types

id()

@type id() :: String.t()

Functions

default_for_class(class)

@spec default_for_class(String.t()) :: id()

Returns the built-in default recorded for a class by a new Surface.

none()

@spec none() :: id()

Identifier for classes whose contract needs no projection-dependent rule.

validate(id, candidate, projection, time)

@spec validate(id(), Spectre.GAM.Candidate.t(), map(), integer()) ::
  :ok | {:error, term()}

Applies the validator selected by the active Surface.

validate_binding(class, id)

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

Validates the immutable class-to-validator binding recorded by a Surface.

validate_id(id)

@spec validate_id(term()) :: :ok | {:error, term()}

Validates that an identifier names a deterministic built-in rule.

validate_transition(id, candidate, decision, act, projection)

@spec validate_transition(
  id(),
  Spectre.GAM.Candidate.t(),
  Spectre.GAM.Decision.t(),
  Spectre.GAM.Act.t(),
  Spectre.GAM.GovernedAct.State.t()
) :: :ok | {:error, term()}

Checks an admitted intrinsic transition against a provisional projection.