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

View Source

Tracks and manages concurrent task execution within an objective.

This module is responsible for:

  • Tracking multiple concurrent tasks
  • Recording agent assignments
  • Maintaining task status and progress
  • Logging task lifecycle events

Summary

Functions

Assigns a task to an agent.

Returns a specification to start this module under a supervisor.

Marks a task as completed with a result.

Creates a new task for a specific step.

Marks a task as failed with an error reason.

Gets detailed information about a specific task.

Lists all tasks for an agent.

Lists all tasks with their current status.

Starts a new TaskTracker for an objective.

Marks a task as started by an agent.

Types

agent_id()

@type agent_id() :: String.t()

state()

@type state() :: %{
  objective_id: String.t(),
  tasks: %{required(task_id()) => task()},
  agent_tasks: %{required(agent_id()) => MapSet.t(task_id())},
  company_pid: pid()
}

task()

@type task() :: %{
  id: task_id(),
  step: String.t(),
  assigned_agent: agent_id() | nil,
  status: task_status(),
  started_at: DateTime.t() | nil,
  completed_at: DateTime.t() | nil,
  error: term() | nil,
  result: term() | nil,
  metadata: map()
}

task_id()

@type task_id() :: String.t()

task_status()

@type task_status() :: :pending | :assigned | :in_progress | :completed | :failed

Functions

assign_task(tracker, task_id, agent_id)

Assigns a task to an agent.

child_spec(init_arg)

Returns a specification to start this module under a supervisor.

See Supervisor.

complete_task(tracker, task_id, result)

Marks a task as completed with a result.

create_task(tracker, step)

Creates a new task for a specific step.

fail_task(tracker, task_id, error)

Marks a task as failed with an error reason.

get_task(tracker, task_id)

Gets detailed information about a specific task.

list_agent_tasks(tracker, agent_id)

Lists all tasks for an agent.

list_tasks(tracker)

Lists all tasks with their current status.

start_link(opts)

Starts a new TaskTracker for an objective.

Options

  • :objective_id - The ID of the objective these tasks belong to
  • :company_pid - PID of the company process for notifications

start_task(tracker, task_id, agent_id)

Marks a task as started by an agent.