Imp.Optimizer.Parameter.Set (Imp v0.5.0)

Copy Markdown View Source

Immutable parameter state with playbook-style revision lineage.

A committed set increments revision, records the prior hash as parent_hash, and rehashes the complete canonical data representation. This gives a compact persistence boundary while each individual change retains its own base_digest optimistic guard.

Summary

Functions

Applies all changes or returns an error without yielding a partial set.

Returns the minimal ordered replacement changes from source to target.

Returns a deterministic data-only representation.

Returns a parameter by stable string ID.

Loads and verifies a persisted parameter set.

Builds a root parameter set from unique typed parameters.

Types

t()

@type t() :: %Imp.Optimizer.Parameter.Set{
  hash: String.t(),
  id: String.t(),
  parameters: [Imp.Optimizer.Parameter.t()],
  parent_hash: String.t() | nil,
  revision: non_neg_integer()
}

Functions

apply_changes(set, changes)

@spec apply_changes(t(), [Imp.Optimizer.Parameter.Change.t() | map()]) ::
  {:ok, t()} | {:error, term()}

Applies all changes or returns an error without yielding a partial set.

diff(source, target)

@spec diff(t(), t()) :: [Imp.Optimizer.Parameter.Change.t()]

Returns the minimal ordered replacement changes from source to target.

dump(set)

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

Returns a deterministic data-only representation.

fetch(set, id)

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

Returns a parameter by stable string ID.

load!(state)

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

Loads and verifies a persisted parameter set.

new(id, parameters)

@spec new(String.t(), [Imp.Optimizer.Parameter.t()]) :: t()

Builds a root parameter set from unique typed parameters.