Jidoka.Agent.Spec (Jidoka v0.9.0)

Copy Markdown View Source

Canonical immutable definition of a Jidoka agent.

Summary

Functions

Normalizes a specification, DSL agent module, keyword list, or map.

Builds an agent specification from keyword or map attributes.

Builds an agent specification and raises if the attributes are invalid.

Returns the Zoi schema for an agent specification.

Validates public context data against the agent context schema.

Validates the control policy for every operation in the specification.

Validates that one operation has the controls that its idempotency policy requires.

Validates a result value against the optional structured-result contract.

Types

t()

@type t() :: %Jidoka.Agent.Spec{
  context_schema: nil | nil | any(),
  controls: term(),
  generation: term(),
  id: binary(),
  instructions: binary(),
  memory: nil | nil | term(),
  metadata: map(),
  model: term(),
  operations: [term()],
  result: nil | nil | term(),
  runtime_defaults: map()
}

Functions

from_input(spec)

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

Normalizes a specification, DSL agent module, keyword list, or map.

new(attrs)

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

Builds an agent specification from keyword or map attributes.

new!(attrs)

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

Builds an agent specification and raises if the attributes are invalid.

schema()

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

Returns the Zoi schema for an agent specification.

validate_context(spec, context)

@spec validate_context(t(), Jidoka.Context.t()) :: :ok | {:error, term()}

Validates public context data against the agent context schema.

validate_operation_policies(spec)

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

Validates the control policy for every operation in the specification.

validate_operation_policy(spec, operation)

@spec validate_operation_policy(t(), Jidoka.Agent.Spec.Operation.t()) ::
  :ok | {:error, term()}

Validates that one operation has the controls that its idempotency policy requires.

validate_result(spec, value)

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

Validates a result value against the optional structured-result contract.