Imp.Playbook (Imp v0.5.0)

Copy Markdown View Source

Provider-independent, immutable instructions with transactional evolution.

A delta is evaluated against a private candidate and committed only if every operation and final policy bound succeeds. Content equality is exact after Imp.Playbook.Entry.normalize/1; no semantic or fuzzy deduplication occurs.

Summary

Functions

Applies all operations or returns an error without a partially updated playbook.

Returns a deterministic data-only representation.

Returns an entry by ID, regardless of its active status.

Loads and validates a data-only playbook representation.

Creates an empty playbook with a stable ID and canonical root hash.

Renders active entries in stable playbook order.

Serializes a playbook as canonical JSON with lexicographically sorted keys.

Types

error()

@type error() :: {:error, term()}

t()

@type t() :: %Imp.Playbook{
  entries: [Imp.Playbook.Entry.t()],
  hash: String.t(),
  id: String.t(),
  parent_hash: String.t() | nil,
  policy: Imp.Playbook.Policy.t(),
  revision: non_neg_integer(),
  tombstones: [Imp.Playbook.Tombstone.t()]
}

Functions

apply_delta(playbook, operations)

@spec apply_delta(t(), Imp.Playbook.Delta.t() | [Imp.Playbook.Delta.operation()]) ::
  {:ok, t()} | error()

Applies all operations or returns an error without a partially updated playbook.

dump(playbook)

@spec dump(t()) :: map()

Returns a deterministic data-only representation.

fetch(playbook, id)

@spec fetch(t(), String.t()) :: {:ok, Imp.Playbook.Entry.t()} | :error

Returns an entry by ID, regardless of its active status.

load!(state)

@spec load!(map()) :: t()

Loads and validates a data-only playbook representation.

new(opts \\ [])

@spec new(keyword()) :: t()

Creates an empty playbook with a stable ID and canonical root hash.

render(playbook)

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

Renders active entries in stable playbook order.

serialize(playbook)

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

Serializes a playbook as canonical JSON with lexicographically sorted keys.