{"record":{"id":"0aed6e24e27fca41","repo":"ruvnet/ruflo","slug":"cannot-compute-critical-path-for-cyclic-graph","errorCode":null,"errorMessage":"Cannot compute critical path for cyclic graph","messagePattern":"Cannot compute critical path for cyclic graph","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"v3/plugins/quantum-optimizer/src/bridges/dag-bridge.ts","lineNumber":205,"sourceCode":"        hasCycle: true,\n        cycleNodes,\n      };\n    }\n\n    return {\n      order,\n      hasCycle: false,\n    };\n  }\n\n  /**\n   * Find critical path in a DAG with durations\n   */\n  criticalPath(dag: Dag, durations: Map<string, number>): CriticalPathResult {\n    const sortResult = this.topologicalSort(dag);\n\n    if (sortResult.hasCycle) {\n      throw new Error('Cannot compute critical path for cyclic graph');\n    }\n\n    const nodeIndex = new Map<string, number>();\n    dag.nodes.forEach((node, idx) => nodeIndex.set(node.id, idx));\n\n    // Forward pass: compute earliest start times\n    const earliest = new Map<string, number>();\n    for (const nodeId of sortResult.order) {\n      let maxPredecessor = 0;\n\n      for (const edge of dag.edges) {\n        if (edge.to === nodeId) {\n          const predEnd = (earliest.get(edge.from) ?? 0) + (durations.get(edge.from) ?? 0);\n          maxPredecessor = Math.max(maxPredecessor, predEnd);\n        }\n      }\n\n      earliest.set(nodeId, maxPredecessor);","sourceCodeStart":187,"sourceCodeEnd":223,"githubUrl":"https://github.com/ruvnet/ruflo/blob/fa13ee4ad60ac2090b1480656eb233521790d640/v3/plugins/quantum-optimizer/src/bridges/dag-bridge.ts#L187-L223","documentation":"criticalPath() ran topologicalSort() on the supplied DAG and the sort reported hasCycle=true (cycleNodes populated). Earliest/latest-start computation requires an acyclic graph, so execution is refused before the forward pass; the input DAG's edge set contains a dependency cycle.","triggerScenarios":"Thrown at v3/plugins/quantum-optimizer/src/bridges/dag-bridge.ts:205 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Inspect the underlying cause in logs, fix the root issue, and retry the operation.","Validate inputs and preconditions before invoking this code path so the error is avoided."],"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-14T00:17:10.932Z"}