{"record":{"id":"5ea297703e629347","repo":"ruvnet/ruflo","slug":"cycle-detected-in-obligation-dependencies","errorCode":null,"errorMessage":"Cycle detected in obligation dependencies","messagePattern":"Cycle detected in obligation dependencies","errorType":"console","errorClass":null,"httpStatus":null,"severity":"error","filePath":"v3/plugins/legal-contracts/src/bridges/dag-bridge.ts","lineNumber":269,"sourceCode":"    const sorted: Obligation[] = [];\n    while (queue.length > 0) {\n      const current = queue.shift()!;\n      const obligation = indexMap.get(current);\n      if (obligation) {\n        sorted.push(obligation);\n      }\n\n      for (const neighbor of adj[current] ?? []) {\n        inDegree[neighbor] = (inDegree[neighbor] ?? 1) - 1;\n        if (inDegree[neighbor] === 0) {\n          queue.push(neighbor);\n        }\n      }\n    }\n\n    // If not all nodes are in sorted, there's a cycle\n    if (sorted.length !== obligations.length) {\n      console.warn('Cycle detected in obligation dependencies');\n    }\n\n    return sorted;\n  }\n\n  /**\n   * Detect cycles in dependency graph\n   */\n  async detectCycles(\n    graph: ObligationTrackingResult['graph']\n  ): Promise<string[][]> {\n    if (!this.initialized) {\n      await this.initialize();\n    }\n\n    const obligations = graph.nodes.map(n => n.obligation);\n\n    // Create node lookup","sourceCodeStart":251,"sourceCodeEnd":287,"githubUrl":"https://github.com/ruvnet/ruflo/blob/fa13ee4ad60ac2090b1480656eb233521790d640/v3/plugins/legal-contracts/src/bridges/dag-bridge.ts#L251-L287","documentation":"Cycle guard in DAGBridge.topologicalSort(): Kahn's algorithm finished with fewer nodes sorted than exist in the obligation dependency graph, proving a cycle. The remaining nodes cannot be ordered, so the method warns and returns the partial sort; dependency float/critical-path results are unreliable.","triggerScenarios":"Obligation dependency graph contains a cycle (A depends on B which transitively depends on A); topological ordering cannot proceed and the cycle is reported.","commonSituations":"See trigger scenarios.","solutions":["Inspect the reported dependency chain and remove the circular obligation dependency from the contract definition.","If cycles are intentional, switch the traversal to a cycle-tolerant algorithm with explicit handling.","Validate obligation graphs at authoring time to reject cycles before runtime."],"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"}