Spectre.Execution.Program (Spectre v0.3.0)

Copy Markdown View Source

Immutable, data-only program for a precise Work.

A program is a finite graph of registered operation steps, pure decisions, bounded repeats, inference steps and terminal nodes. The graph contains no callback or module selected by authored data. It materializes an ordinary Spectre.Operation.Definition, so execution, fencing, retry, recovery and control-plane semantics remain those of the existing operational runtime.

Summary

Functions

Fetches one exact node by its stable id.

Loads a compiled declarative Work module into the same program IR.

Restores a program from canonical data and verifies its digest.

Builds and fully validates a data-driven Work program.

Builds a program or raises with its stable validation reason.

Builds the code-owned operational contract consumed by the shared runtime.

Returns the registered operation IDs required by the program.

Returns exact model-profile IDs pinned by inference nodes.

Returns prompt fragment IDs required by inference nodes.

Returns the complete portable program representation.

Validates registered operation kinds and purity constraints for one Agent.

Validates a user state value against the program's declared schema.

Types

program_node()

@type program_node() :: map()

t()

@type t() :: %Spectre.Execution.Program{
  budget: map(),
  digest: String.t(),
  entry: String.t(),
  id: String.t(),
  initial: Spectre.Execution.Expression.t(),
  input: atom(),
  metadata: map(),
  migrations: [map()],
  mutable_paths: [[String.t() | non_neg_integer()]],
  nodes: %{required(String.t()) => program_node()},
  operation_refs: [String.t()],
  prompt_refs: [String.t()],
  schema_version: pos_integer(),
  security: map(),
  state: atom(),
  update: atom(),
  version: pos_integer() | String.t()
}

Functions

fetch_node(program, id)

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

Fetches one exact node by its stable id.

from_compiled(module)

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

Loads a compiled declarative Work module into the same program IR.

from_data(data)

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

Restores a program from canonical data and verifies its digest.

new(program)

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

Builds and fully validates a data-driven Work program.

new!(attrs)

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

Builds a program or raises with its stable validation reason.

operation_definition(program)

@spec operation_definition(t()) :: Spectre.Operation.Definition.t()

Builds the code-owned operational contract consumed by the shared runtime.

operation_refs(program)

@spec operation_refs(t()) :: [String.t()]

Returns the registered operation IDs required by the program.

profile_refs(program)

@spec profile_refs(t()) :: [String.t()]

Returns exact model-profile IDs pinned by inference nodes.

prompt_refs(program)

@spec prompt_refs(t()) :: [String.t()]

Returns prompt fragment IDs required by inference nodes.

to_data(program)

@spec to_data(t()) :: map()

Returns the complete portable program representation.

validate_bindings(program, agent)

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

Validates registered operation kinds and purity constraints for one Agent.

validate_state(program, state)

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

Validates a user state value against the program's declared schema.