{"record":{"id":"abc2b3c094c55af7","repo":"ruvnet/ruflo","slug":"cycle-detected-in-task-dependencies-sortresult","errorCode":null,"errorMessage":"Cycle detected in task dependencies: ${sortResult.cycleNodes?.join(', ')}","messagePattern":"Cycle detected in task dependencies: (.+?)","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"v3/plugins/quantum-optimizer/src/bridges/dag-bridge.ts","lineNumber":453,"sourceCode":"   * Optimize task schedule using DAG analysis\n   */\n  async optimizeSchedule(\n    tasks: ReadonlyArray<ScheduleTask>,\n    resources: ReadonlyArray<ScheduleResource>,\n    objective: ScheduleObjective\n  ): Promise<ScheduleResult> {\n    // Build task DAG\n    const dag: Dag = {\n      nodes: tasks.map(t => ({ id: t.id })),\n      edges: tasks.flatMap(t =>\n        t.dependencies.map(dep => ({ from: dep, to: t.id }))\n      ),\n    };\n\n    // Check for cycles\n    const sortResult = this.topologicalSort(dag);\n    if (sortResult.hasCycle) {\n      throw new Error(`Cycle detected in task dependencies: ${sortResult.cycleNodes?.join(', ')}`);\n    }\n\n    // Build duration map\n    const durations = new Map<string, number>();\n    tasks.forEach(t => durations.set(t.id, t.duration));\n\n    // Find critical path\n    const critPath = this.criticalPath(dag, durations);\n\n    // Schedule tasks\n    const schedule: ScheduledTask[] = [];\n    const resourceUsage = new Map<string, Array<{ start: number; end: number }>>();\n\n    resources.forEach(r => resourceUsage.set(r.id, []));\n\n    const taskEndTimes = new Map<string, number>();\n\n    for (const taskId of sortResult.order) {","sourceCodeStart":435,"sourceCodeEnd":471,"githubUrl":"https://github.com/ruvnet/ruflo/blob/fa13ee4ad60ac2090b1480656eb233521790d640/v3/plugins/quantum-optimizer/src/bridges/dag-bridge.ts#L435-L471","documentation":"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.","triggerScenarios":"Thrown at v3/plugins/quantum-optimizer/src/bridges/dag-bridge.ts:453 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"}