Cannot assign waves: cycle detected in dependency graph
1 min read
assignWaves builds the graph, runs a topological sort, and throws when the sort
reports the graph is not acyclic. The message names the tasks in the cycle.
What a cycle means
Somewhere your plan says A depends on B, B depends on C, and C depends on A. There is no order in which all three can run, so there is no wave assignment to compute.
In prose this is easy to write and hard to see:
"Task C needs the interface from B. B needs the schema from A. A needs C's migration."
Read as a narrative that sounds like a sequence. Written as edges it is obviously impossible.
Why it fails here rather than later
Wave assignment is the step that turns a dependency graph into batches. Every later stage assumes a valid ordering exists, so a cycle discovered afterwards would surface as something incoherent — a wave that never becomes ready, or a task waiting on work that already completed.
Failing at assignment means nothing has been dispatched and no tokens have been spent. On a single agent working sequentially you would discover the same problem three hours in.
How to fix it
The named tasks are the cycle. Look at each edge between them and ask whether the dependency is real.
Most cycles come from one edge that is coarser than it needs to be. "A needs C's migration" is often really "A needs the table C's migration creates" — which can be split out as its own small task that both A and C depend on, converting a loop into a tree.
Writing dependencies as explicit edges rather than narrative order is what makes them visible before you get here.
