Spectre.Governance.Composition (Spectre v0.3.0)

Copy Markdown View Source

Accumulates the typed result of applying governed ChangeSet operations.

Registered Spectre.Governance.ChangeSet.Handler implementations receive a Composition and return its next immutable value. The struct records the candidate Definition, evaluation obligations, state migrations, affected component classes, operation vocabulary, and maximum risk observed so far.

A Composition is transient governance state. It is never an activation, authority grant, or durable Candidate by itself.

Summary

Types

The highest governance risk contributed by applied operations.

t()

Functions

Records an operation type, affected component classes, and risk.

Creates an empty composition rooted in the supplied Definition.

Applies one validated handler result to the composition.

Types

risk()

@type risk() :: :low | :medium | :high | :critical

The highest governance risk contributed by applied operations.

t()

@type t() :: %Spectre.Governance.Composition{
  changed_components: [atom()],
  definition: Spectre.Definition.Canonical.t(),
  eval_cases: [map()],
  operation_types: [String.t()],
  risk: risk(),
  state_migrations: [map()]
}

Functions

mark(composition, operation_type, components, risk)

@spec mark(t(), String.t(), [atom()], risk()) :: t()

Records an operation type, affected component classes, and risk.

new(definition)

@spec new(Spectre.Definition.Canonical.t()) :: t()

Creates an empty composition rooted in the supplied Definition.

update(composition, opts)

@spec update(
  t(),
  keyword()
) :: t()

Applies one validated handler result to the composition.

:operation_type is required. A handler may also provide a replacement Definition, one evaluation case, one state migration, component classes, and its risk contribution.