Skip to main content

run_graph

Function run_graph 

Source
pub async fn run_graph<F, S, O>(
    ctx: &RunContext<'_, F, S, O>,
    created_at_unix: u64,
) -> Result<RunGraphOutcome, RunGraphError>
Expand description

Run every task in the validated graph subject to the workspace’s concurrency caps and the mutex compatibility rules of EXEC-006 condition 3 + EXEC-007.

The loop:

  1. Resolves the workspace’s concurrency.default to a concrete cap and pre-computes the per-task tag set.
  2. On each admission round, walks state.ready in canonical order and admits every task whose caps (EXEC-004, EXEC-005) permit. Admission consults caps ONLY; the mutex check is deferred per EXEC-007 step 1 (“no mutex hold is taken during cache lookup”). Each admitted task fires RunObserver::on_task_started once (tracked via started) and pushes a lookup-step future.
  3. The lookup-step future runs cache_lookup_phase. On hit, it drives restore_from_hit inline (no mutex interaction, per MUTEX-007) and reports the outcome. On miss, it stops short and reports the data the scheduler needs for the post-lookup mutex check.
  4. On a miss completion the scheduler evaluates the live mutex hold set. When compatible, it acquires the mutex per MUTEX-006 and pushes a spawn-step future (run_fresh). When incompatible (per MUTEX-005 / EXEC-007 step 3 incompatible branch), the slot is released, the task returns to ready, and the next admission round re-evaluates.
  5. On a spawn-step completion the scheduler releases the held mutex, releases the slot, fires RunObserver::on_task_finished, records the outcome, and either promotes hard successors to ready (succeeded) or cascade-skips hard descendants (failed, per EXEC-010).
  6. Terminates when no futures are in flight; tasks marked skip never enter ready, so the loop’s emptiness condition is well-defined for any graph including diamonds, fan-ins, and disconnected subgraphs.

§Errors

This revision never returns Err: a single task’s failure does not abort the run (per EXEC-010), and the only paths that could yield a top-level error in the current scope are covered by per-task RunTaskErrors captured in RunGraphOutcome::task_errors. Future revisions will grow RunGraphError with scheduler-level diagnostics (runtime cycle detection, runtime output overlap).

§Panics

Panics if ctx.graph references a task whose project or task name is absent from ctx.workspace. A validated graph is built from the workspace’s effective task set; a node referring to a non-existent task would be a builder bug.