Aludel.Executor behaviour (aludel v0.7.0)

Copy Markdown View Source

Behaviour and configuration helpers for execution mode dispatch.

Summary

Functions

Validates and normalizes the configured execution mode.

Resolves the configured callback executor module.

Returns the raw configured execution mode, defaulting to :native.

Returns the execution mode label used by the web interface.

Types

document_input()

@type document_input() :: %{
  name: String.t(),
  content_type: String.t(),
  data: binary()
}

input()

@type input() :: %{
  kind: :run | :suite,
  prompt_version: prompt_version_input(),
  variables: map(),
  messages: [map()],
  documents: [document_input()],
  provider: provider_input() | nil,
  metadata: map() | nil
}

prompt_version_input()

@type prompt_version_input() :: %{
  id: binary(),
  template: String.t(),
  version: integer()
}

provider_input()

@type provider_input() :: %{
  id: binary(),
  provider: atom(),
  model: String.t(),
  config: map() | nil
}

result()

@type result() :: %{
  output: String.t(),
  input_tokens: non_neg_integer() | nil,
  output_tokens: non_neg_integer() | nil,
  latency_ms: non_neg_integer() | nil,
  cost_usd: float() | nil,
  metadata: map() | nil
}

Callbacks

run(input)

@callback run(input()) :: {:ok, result()} | {:error, term()}

Functions

configured_execution_mode()

@spec configured_execution_mode() ::
  {:ok, :native | :callback} | {:error, {:invalid_execution_mode, term()}}

Validates and normalizes the configured execution mode.

An unset value selects native execution. Any value other than :native or :callback returns an :invalid_execution_mode error.

configured_executor()

@spec configured_executor() ::
  {:ok, module()} | {:error, :executor_not_configured | term()}

Resolves the configured callback executor module.

The module must be loaded and export run/1. Missing and invalid configuration return tagged errors instead of raising.

execution_mode()

@spec execution_mode() :: term()

Returns the raw configured execution mode, defaulting to :native.

Use configured_execution_mode/0 when validating configuration at a runtime boundary.

execution_mode_label()

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

Returns the execution mode label used by the web interface.