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_TRANSITIONSedges (enforced bytransition_task(), which raises rather than silently allow a jump).Two distinct edge kinds (F5):
depends_ongates readiness on the predecessor reaching DONE;order_aftergates 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 adjacency list (task_id -> dependency ids). |
|
Return PENDING tasks whose |
|
Return tasks in dependency-respecting order (Kahn's algorithm). |
|
Validate and apply a status change. |
Classes
One unit of work in a project DAG. |
- class agora.core.task.Task[source]
Bases:
objectOne unit of work in a project DAG.
Each task carries its own
Specification(preconditions + postconditions evaluated by the orchestrator) and adepends_ontuple that defines the DAG edges. Status transitions go throughtransition_task()to enforce the state machine inVALID_TASK_TRANSITIONS.Tasks are immutable; mutations return a new instance via
dataclasses.replace().artifactsandresult_summaryare populated when the runtime evaluates the postconditions and the agent completes its turn.- spec: Specification
- status: TaskStatus = 'pending'
- 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_filelogs 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), anorder_aftertask 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_onare all DONE and whoseorder_afterpredecessors have all reached a terminal state.depends_ongates on success (predecessor DONE);order_aftergates only on completion (DONE or FAILED) — so a verifier ordered after a blocking task runs even when that task failed (F5 fix).