ruvnet/ruflo · error
Cycle detected in task dependencies: ${sortResult.cycleNodes
Error message
Cycle detected in task dependencies: ${sortResult.cycleNodes?.join(', ')} What it means
optimizeSchedule() built a DAG from task dependencies and topologicalSort() detected a cycle (the offending task ids are listed). Tasks mutually depend on each other, so no valid schedule ordering exists and the optimization aborts before allocating resources.
Source
Thrown at v3/plugins/quantum-optimizer/src/bridges/dag-bridge.ts:453
* Optimize task schedule using DAG analysis
*/
async optimizeSchedule(
tasks: ReadonlyArray<ScheduleTask>,
resources: ReadonlyArray<ScheduleResource>,
objective: ScheduleObjective
): Promise<ScheduleResult> {
// Build task DAG
const dag: Dag = {
nodes: tasks.map(t => ({ id: t.id })),
edges: tasks.flatMap(t =>
t.dependencies.map(dep => ({ from: dep, to: t.id }))
),
};
// Check for cycles
const sortResult = this.topologicalSort(dag);
if (sortResult.hasCycle) {
throw new Error(`Cycle detected in task dependencies: ${sortResult.cycleNodes?.join(', ')}`);
}
// Build duration map
const durations = new Map<string, number>();
tasks.forEach(t => durations.set(t.id, t.duration));
// Find critical path
const critPath = this.criticalPath(dag, durations);
// Schedule tasks
const schedule: ScheduledTask[] = [];
const resourceUsage = new Map<string, Array<{ start: number; end: number }>>();
resources.forEach(r => resourceUsage.set(r.id, []));
const taskEndTimes = new Map<string, number>();
for (const taskId of sortResult.order) {View on GitHub (pinned to fa13ee4ad6)
Solutions
- Remove the circular dependency: inspect the reported nodes and break the cycle by reordering or dropping an edge.
- Validate the dependency graph with a topological sort before execution and reject cyclic definitions early.
Defensive patterns
Strategy: validation
When it happens
Trigger: Thrown at v3/plugins/quantum-optimizer/src/bridges/dag-bridge.ts:453 when the library encounters an invalid state.
Common situations: See trigger scenarios.
AI-assisted analysis of ruvnet/ruflo@fa13ee4ad6 (2026-08-18).
Data as JSON: /api/errors/abc2b3c094c55af7.
Report an issue: GitHub.