{"record":{"id":"b9e95d5f6fb38143","repo":"ruvnet/ruflo","slug":"circular-dependency-detected-in-tasks","errorCode":null,"errorMessage":"Circular dependency detected in tasks","messagePattern":"Circular dependency detected in tasks","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"v3/src/task-execution/domain/Task.ts","lineNumber":183,"sourceCode":"    return [...tasks].sort((a, b) => b.getPriorityValue() - a.getPriorityValue());\n  }\n\n  /**\n   * Resolve task execution order based on dependencies\n   */\n  static resolveExecutionOrder(tasks: Task[]): Task[] {\n    const resolved: Task[] = [];\n    const resolvedIds = new Set<string>();\n    const remaining = [...tasks];\n\n    // Topological sort\n    while (remaining.length > 0) {\n      const ready = remaining.filter(task =>\n        task.areDependenciesResolved(resolvedIds)\n      );\n\n      if (ready.length === 0 && remaining.length > 0) {\n        throw new Error('Circular dependency detected in tasks');\n      }\n\n      // Sort ready tasks by priority\n      const sorted = Task.sortByPriority(ready);\n\n      for (const task of sorted) {\n        resolved.push(task);\n        resolvedIds.add(task.id);\n        const index = remaining.indexOf(task);\n        if (index > -1) {\n          remaining.splice(index, 1);\n        }\n      }\n    }\n\n    return resolved;\n  }\n}","sourceCodeStart":165,"sourceCodeEnd":201,"githubUrl":"https://github.com/ruvnet/ruflo/blob/fa13ee4ad60ac2090b1480656eb233521790d640/v3/src/task-execution/domain/Task.ts#L165-L201","documentation":"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.","triggerScenarios":"Thrown at v3/src/task-execution/domain/Task.ts:183 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","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."],"exampleFix":null,"handlingStrategy":"validation","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"fa13ee4ad60ac2090b1480656eb233521790d640","analyzedAt":"2026-08-18T21:34:22.708Z","contentChangedAt":"2026-08-18T21:34:22.708Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}