Lux.Company.ExecutionEngine.ObjectiveProcess (Lux v0.5.0)

View Source

A GenServer process that manages the execution of a single objective.

This module is responsible for:

  • Managing the state machine of an objective's execution
  • Tracking progress and current step
  • Handling state transitions
  • Managing errors and failures
  • Coordinating with the company process
  • Integrating with TaskTracker and ArtifactStore

Summary

Functions

Add an error message to the objective's error list

Cancel the objective execution

Returns a specification to start this module under a supervisor.

Mark the objective as completed

Mark the objective as failed with the given reason

Get the artifact store for this objective

Get the task tracker for this objective

Initialize the objective process

Set the current step being executed

Start executing the objective

Starts a new ObjectiveProcess with the given options.

Update the progress percentage (0-100)

Types

state()

@type state() :: %{
  id: String.t(),
  objective: Lux.Company.Objective.t(),
  company_pid: pid(),
  input: map(),
  status:
    :pending | :initializing | :in_progress | :completed | :failed | :cancelled,
  current_step: integer(),
  progress: integer(),
  error: term() | nil,
  started_at: DateTime.t() | nil,
  completed_at: DateTime.t() | nil,
  task_tracker: pid() | nil,
  artifact_store: pid() | nil
}

Functions

add_error(pid, error)

Add an error message to the objective's error list

cancel(pid)

Cancel the objective execution

child_spec(init_arg)

Returns a specification to start this module under a supervisor.

See Supervisor.

complete(pid)

Mark the objective as completed

fail(pid, reason)

Mark the objective as failed with the given reason

get_artifact_store(pid)

Get the artifact store for this objective

get_task_tracker(pid)

Get the task tracker for this objective

initialize(pid)

Initialize the objective process

set_current_step(pid, step)

Set the current step being executed

start(pid)

Start executing the objective

start_link(opts)

Starts a new ObjectiveProcess with the given options.

Required options:

  • :objective_id - Unique identifier for this objective process
  • :objective - The Objective struct to execute
  • :company_pid - PID of the company process
  • :input - Map of input values for the objective
  • :registry - The registry to register this process with

update_progress(pid, progress)

Update the progress percentage (0-100)