ruvnet/ruflo · error · Error

Circular dependency detected in tasks

Error message

Circular dependency detected in tasks

What it means

Task.resolveExecutionOrder() topological sort stalled: no remaining task has all dependencies resolved, yet tasks remain unplaced. The task set contains a dependency cycle (direct or transitive), so no valid execution order exists.

Source

Thrown at v3/src/task-execution/domain/Task.ts:183

    return [...tasks].sort((a, b) => b.getPriorityValue() - a.getPriorityValue());
  }

  /**
   * Resolve task execution order based on dependencies
   */
  static resolveExecutionOrder(tasks: Task[]): Task[] {
    const resolved: Task[] = [];
    const resolvedIds = new Set<string>();
    const remaining = [...tasks];

    // Topological sort
    while (remaining.length > 0) {
      const ready = remaining.filter(task =>
        task.areDependenciesResolved(resolvedIds)
      );

      if (ready.length === 0 && remaining.length > 0) {
        throw new Error('Circular dependency detected in tasks');
      }

      // Sort ready tasks by priority
      const sorted = Task.sortByPriority(ready);

      for (const task of sorted) {
        resolved.push(task);
        resolvedIds.add(task.id);
        const index = remaining.indexOf(task);
        if (index > -1) {
          remaining.splice(index, 1);
        }
      }
    }

    return resolved;
  }
}

View on GitHub (pinned to fa13ee4ad6)

Solutions

  1. Remove the circular dependency: inspect the reported nodes and break the cycle by reordering or dropping an edge.
  2. 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/src/task-execution/domain/Task.ts:183 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/b9e95d5f6fb38143. Report an issue: GitHub.