{"record":{"id":"4700b865221f1353","repo":"ruvnet/ruflo","slug":"hierarchy-contains-cycles","errorCode":null,"errorMessage":"Hierarchy contains cycles","messagePattern":"Hierarchy contains cycles","errorType":"validation","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"v3/plugins/hyperbolic-reasoning/src/bridges/hyperbolic-bridge.ts","lineNumber":432,"sourceCode":"    const hasCycle = (nodeId: string): boolean => {\n      if (inStack.has(nodeId)) return true;\n      if (visited.has(nodeId)) return false;\n\n      visited.add(nodeId);\n      inStack.add(nodeId);\n\n      const node = hierarchy.nodes.find(n => n.id === nodeId);\n      if (node?.parent) {\n        if (hasCycle(node.parent)) return true;\n      }\n\n      inStack.delete(nodeId);\n      return false;\n    };\n\n    for (const node of hierarchy.nodes) {\n      if (hasCycle(node.id)) {\n        throw new Error('Hierarchy contains cycles');\n      }\n    }\n\n    // Check max depth\n    const depths = new Map<string, number>();\n    const computeDepth = (node: HierarchyNode): number => {\n      if (depths.has(node.id)) return depths.get(node.id)!;\n\n      if (node.parent === null) {\n        depths.set(node.id, 0);\n        return 0;\n      }\n\n      const parent = hierarchy.nodes.find(n => n.id === node.parent);\n      if (!parent) {\n        depths.set(node.id, 0);\n        return 0;\n      }","sourceCodeStart":414,"sourceCodeEnd":450,"githubUrl":"https://github.com/ruvnet/ruflo/blob/fa13ee4ad60ac2090b1480656eb233521790d640/v3/plugins/hyperbolic-reasoning/src/bridges/hyperbolic-bridge.ts#L414-L450","documentation":"Thrown by validateHierarchy (called from embedHierarchy) when a DFS over the node parent links detects a node that is its own ancestor — i.e. the parent chain forms a cycle — which would make hierarchical embedding depths undefined.","triggerScenarios":"Thrown at v3/plugins/hyperbolic-reasoning/src/bridges/hyperbolic-bridge.ts:432 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"}