ruvnet/ruflo · error · Error
Hierarchy contains cycles
Error message
Hierarchy contains cycles
What it means
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.
Source
Thrown at v3/plugins/hyperbolic-reasoning/src/bridges/hyperbolic-bridge.ts:432
const hasCycle = (nodeId: string): boolean => {
if (inStack.has(nodeId)) return true;
if (visited.has(nodeId)) return false;
visited.add(nodeId);
inStack.add(nodeId);
const node = hierarchy.nodes.find(n => n.id === nodeId);
if (node?.parent) {
if (hasCycle(node.parent)) return true;
}
inStack.delete(nodeId);
return false;
};
for (const node of hierarchy.nodes) {
if (hasCycle(node.id)) {
throw new Error('Hierarchy contains cycles');
}
}
// Check max depth
const depths = new Map<string, number>();
const computeDepth = (node: HierarchyNode): number => {
if (depths.has(node.id)) return depths.get(node.id)!;
if (node.parent === null) {
depths.set(node.id, 0);
return 0;
}
const parent = hierarchy.nodes.find(n => n.id === node.parent);
if (!parent) {
depths.set(node.id, 0);
return 0;
}View on GitHub (pinned to fa13ee4ad6)
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.
Defensive patterns
Strategy: validation
When it happens
Trigger: Thrown at v3/plugins/hyperbolic-reasoning/src/bridges/hyperbolic-bridge.ts:432 when the library encounters an invalid state.
Common situations: See trigger scenarios.
AI-assisted analysis of ruvnet/ruflo@fa13ee4ad6 (2026-08-18).
Data as JSON: /api/errors/4700b865221f1353.
Report an issue: GitHub.