Imp.Optimizer.Parameter (Imp v0.5.0)

Copy Markdown View Source

A bounded, data-only optimizer parameter.

Parameters use stable string IDs and one of the supported kinds. Their values are restricted to JSON data with string map keys so optimizer state can be hashed, persisted, and inspected without capturing executable runners, credentials, atoms, or other runtime terms.

Summary

Functions

Returns the deterministic content digest for a kind and JSON value.

Returns a data-only representation suitable for JSON persistence.

Returns every parameter kind supported by the contract.

Loads and verifies a persisted parameter representation.

Builds a parameter after validating its stable ID and data-only value.

Types

json_value()

@type json_value() ::
  nil
  | boolean()
  | number()
  | String.t()
  | [json_value()]
  | %{required(String.t()) => json_value()}

kind()

@type kind() ::
  :instruction
  | :demos
  | :config
  | :playbook
  | :tool_description
  | :tool_schema
  | :artifact

t()

@type t() :: %Imp.Optimizer.Parameter{
  digest: String.t(),
  id: String.t(),
  kind: kind(),
  value: json_value()
}

Functions

content_digest(kind, value)

@spec content_digest(kind() | String.t(), json_value()) :: String.t()

Returns the deterministic content digest for a kind and JSON value.

dump(parameter)

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

Returns a data-only representation suitable for JSON persistence.

kinds()

@spec kinds() :: [kind()]

Returns every parameter kind supported by the contract.

load!(state)

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

Loads and verifies a persisted parameter representation.

new(id, kind, value)

@spec new(String.t(), kind() | String.t(), json_value()) :: t()

Builds a parameter after validating its stable ID and data-only value.