agora.fleet.phase_gate

Phase grouping + gate evaluation for the phase-staged runner (integration run 1).

A run-1 flow tags each task with a phase (e.g. "P3"). The runner executes phases in DECLARED order and pauses at each boundary (the staged-pause discipline from scripts/run_sweep_staged.py, applied to phases within one run). A phase’s GATE is green iff every BLOCKING task in the phase had all its postconditions pass; non-blocking tasks (verifiers) are recorded but never gate (the blocking distinction pairs with F5: a verifier is ordered after a blocking task via order_after so it still runs at gate time even when that task failed). A red gate stops the run before the next phase — repair happens against that boundary.

This module is pure: it turns (tasks, per-task postcondition results) into an ordered list of PhaseGateResult. The live runner supplies the results (from postcondition evaluation) and consults first_red_phase() to decide whether to advance. Provenance is emitted via PhaseGateRecord (see agora.observe.jsonl). The MECHANICAL gate re-eval that repair uses (scripts/run_phased.py:reevaluate_phase_gate — F17b persists its captures, F23 makes same-phase repair re-check the whole gate) re-runs these same postconditions over the workspace and feeds the results straight back here.

Functions

evaluate_phase_gate(phase, outcomes)

Compute one phase's gate from its tasks' postcondition outcomes.

first_red_phase(results)

Return the phase name of the first red gate in order, else None.

group_tasks_by_phase(tasks)

Map phase → tasks (declared order preserved within each phase).

ordered_phases(tasks)

Phases in first-seen (declared) order.

phases_runnable_through(results, plan)

Given results so far and the full declared phase plan, return the phases that may run: every phase up to and including the first red one (that red phase is where work/repair sits), and no further.

Classes

PhaseGateResult

The gate outcome for one phase.

TaskGateOutcome

One task's contribution to its phase gate.

class agora.fleet.phase_gate.PhaseGateResult[source]

Bases: object

The gate outcome for one phase.

passed is True iff every BLOCKING task passed. blockers names the blocking tasks that failed (empty when green). Non-blocking task outcomes are retained in tasks for provenance but excluded from the verdict.

phase: str
tasks: tuple[TaskGateOutcome, ...]
passed: bool
blockers: tuple[str, ...]
mechanical: bool = False

True when produced by a mechanical re-evaluation over the workspace (cross-phase repair) rather than a live task run — read as an ARTIFACT-STATE check, its genuine signal being run_check re-execution.

property blocking_tasks: tuple[TaskGateOutcome, ...]
property nonblocking_tasks: tuple[TaskGateOutcome, ...]
__init__(phase, tasks, passed, blockers, mechanical=False)
class agora.fleet.phase_gate.TaskGateOutcome[source]

Bases: object

One task’s contribution to its phase gate.

task_id: str
blocking: bool
postconditions: list[tuple[str, bool]]
property passed: bool

All postconditions green (vacuously True when the task has none).

__init__(task_id, blocking, postconditions=<factory>)
agora.fleet.phase_gate.evaluate_phase_gate(phase, outcomes)[source]

Compute one phase’s gate from its tasks’ postcondition outcomes.

Green iff every BLOCKING task passed. Non-blocking tasks never gate.

agora.fleet.phase_gate.first_red_phase(results)[source]

Return the phase name of the first red gate in order, else None.

The staged runner stops before the phase AFTER this one — a red gate blocks every downstream phase until repair turns it green.

agora.fleet.phase_gate.group_tasks_by_phase(tasks)[source]

Map phase → tasks (declared order preserved within each phase).

agora.fleet.phase_gate.ordered_phases(tasks)[source]

Phases in first-seen (declared) order. Tasks with an empty phase are skipped — a flow that tags no task with a phase has no phase plan.

agora.fleet.phase_gate.phases_runnable_through(results, plan)[source]

Given results so far and the full declared phase plan, return the phases that may run: every phase up to and including the first red one (that red phase is where work/repair sits), and no further.