Oi. Compile. Planning
(oi v0.6.1)
Copy Markdown
Execution plan built from compiled Bundles.
Bundles sharing the same topological depth are grouped into stages. Tasks within a stage run in parallel; stages execute sequentially (barrier synchronization).
Relationship to Bundle.compile_graph/2
Bundle.compile_graph/2 already guarantees the graph is a DAG via
topological sort. Planning.build/1 does NOT re-detect cycles — its
job is to determine which bundles can run in parallel by assigning
levels based on requires / exports cross-references.
The fuel parameter in do_assign/4 is a defensive guard: the
iteration count is bounded by length(bundles), which is always
sufficient for any DAG (longest path ≤ node count). If the graph
somehow contained a cycle despite the earlier topo sort, the fuel
guard prevents infinite recursion.
Summary
Functions
Build a Plan from a flat list of Bundles.
Functions
@spec build([Oi.Compile.Bundle.t()]) :: {:ok, Oi.Compile.Planning.Plan.t()} | {:error, :cycle_detected}
Build a Plan from a flat list of Bundles.
Assigns each bundle a level based on its upstream dependencies
(via requires / exports). Bundles at the same level have no
cross-dependencies and can execute in parallel within a stage.
The graph must already be a DAG — cycle detection here is defensive
(see moduledoc). Callers should ensure Bundle.compile_graph/2 ran
first to verify acyclicity.