Jidoka.Agent.Spec.Result (Jidoka v0.9.0)

Copy Markdown View Source

Structured app-facing result contract for an agent.

The result contract is intentionally provider-neutral. It stores a Zoi schema used by the runtime after a model returns a final decision, plus a bounded repair count for deterministic retry behavior.

Summary

Functions

Normalizes a result contract or treats a schema value as the contract schema.

Builds a structured-result contract from keyword or map attributes.

Builds a structured-result contract and raises if the attributes are invalid.

Returns the Zoi schema for a structured-result contract.

Validates and normalizes a value through the result schema.

Types

t()

@type t() :: %Jidoka.Agent.Spec.Result{
  max_repairs: integer(),
  metadata: map(),
  schema: any()
}

Functions

from_input(result)

@spec from_input(t() | keyword() | map() | term()) :: {:ok, t()} | {:error, term()}

Normalizes a result contract or treats a schema value as the contract schema.

new(attrs)

@spec new(keyword() | map()) :: {:ok, t()} | {:error, term()}

Builds a structured-result contract from keyword or map attributes.

new!(attrs)

@spec new!(keyword() | map()) :: t()

Builds a structured-result contract and raises if the attributes are invalid.

schema()

@spec schema() :: Zoi.schema()

Returns the Zoi schema for a structured-result contract.

validate(result, value)

@spec validate(t(), term()) :: {:ok, term()} | {:error, term()}

Validates and normalizes a value through the result schema.