agora.core.task

Task model plus DAG construction, topological sort, and status transitions.

Position: the unit the orchestrator schedules. A flow instantiates Task nodes; build_task_graph() / topological_sort() order them by their depends_on edges; the runtime walks that order, evaluates each task’s Specification, and drives status through the machine in VALID_TASK_TRANSITIONS.

Invariants:
  • Tasks are FROZEN — every mutation returns a fresh instance via dataclasses.replace(); nothing edits a task in place.

  • Status only moves along VALID_TASK_TRANSITIONS edges (enforced by transition_task(), which raises rather than silently allow a jump).

  • Two distinct edge kinds (F5): depends_on gates readiness on the predecessor reaching DONE; order_after gates only on a TERMINAL state (DONE or FAILED), so a verifier ordered after a blocking task still runs at gate time when that task FAILED — the fix for verifiers being skipped behind a red task.

Functions

build_dag(tasks)

Build adjacency list (task_id -> dependency ids).

ready_tasks(tasks)

Return PENDING tasks whose depends_on are all DONE and whose order_after predecessors have all reached a terminal state.

topological_sort(tasks)

Return tasks in dependency-respecting order (Kahn's algorithm).

transition_task(task, new_status)

Validate and apply a status change.

Classes

Task

One unit of work in a project DAG.

class agora.core.task.Task[source]

Bases: object

One unit of work in a project DAG.

Each task carries its own Specification (preconditions + postconditions evaluated by the orchestrator) and a depends_on tuple that defines the DAG edges. Status transitions go through transition_task() to enforce the state machine in VALID_TASK_TRANSITIONS.

Tasks are immutable; mutations return a new instance via dataclasses.replace(). artifacts and result_summary are populated when the runtime evaluates the postconditions and the agent completes its turn.

id: str
spec: Specification
description: str = ''
agent_id: str | None = None
depends_on: tuple[str, ...] = ()
status: TaskStatus = 'pending'
artifacts: tuple[str, ...] = ()
result_summary: str = ''
created_at: str = ''
updated_at: str = ''
output_path: str = ''

Required relative path of the task’s primary output file. When set, agent prompts display it as a structured constant and write_file logs a warning if called with a different path. Empty string means “no single canonical output”.

phase: str = ''

the phase this task belongs to (e.g. "P3"). The phase-staged runner groups tasks by this and gates at each boundary. Empty string means “no phase” (pre-run-1 flows).

Type:

Integration run 1

blocking: bool = True

whether this task’s postconditions gate its phase. Verifier tasks are blocking=False — their verdict is recorded but never blocks the next phase.

Type:

Integration run 1

order_after: tuple[str, ...] = ()

ORDERING-only predecessors. Unlike depends_on (which gates readiness on the predecessor reaching DONE), an order_after task runs once its predecessors reach a TERMINAL state (DONE or FAILED) — so a verifier ordered after a blocking task runs unconditionally at gate time, even when that task failed.

Type:

Integration run 1.2 (F5 fix)

__init__(id, spec, description='', agent_id=None, depends_on=(), status=TaskStatus.PENDING, artifacts=(), result_summary='', created_at='', updated_at='', output_path='', phase='', blocking=True, order_after=())
agora.core.task.transition_task(task, new_status)[source]

Validate and apply a status change. Returns a new Task.

agora.core.task.build_dag(tasks)[source]

Build adjacency list (task_id -> dependency ids). Raises on cycles or missing deps.

agora.core.task.topological_sort(tasks)[source]

Return tasks in dependency-respecting order (Kahn’s algorithm).

agora.core.task.ready_tasks(tasks)[source]

Return PENDING tasks whose depends_on are all DONE and whose order_after predecessors have all reached a terminal state.

depends_on gates on success (predecessor DONE); order_after gates only on completion (DONE or FAILED) — so a verifier ordered after a blocking task runs even when that task failed (F5 fix).