# `Spectre.Governance.Composition`
[🔗](https://github.com/elchemista/spectre/blob/0.4.0/lib/spectre/governance/composition.ex#L1)

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.

# `risk`

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

The highest governance risk contributed by applied operations.

# `t`

```elixir
@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()]
}
```

# `mark`

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

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

# `new`

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

Creates an empty composition rooted in the supplied Definition.

# `update`

```elixir
@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.

---

*Consult [api-reference.md](api-reference.md) for complete listing*
