ruvnet/ruflo · error
Cannot compute critical path for cyclic graph
Error message
Cannot compute critical path for cyclic graph
What it means
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.
Source
Thrown at v3/plugins/quantum-optimizer/src/bridges/dag-bridge.ts:205
hasCycle: true,
cycleNodes,
};
}
return {
order,
hasCycle: false,
};
}
/**
* Find critical path in a DAG with durations
*/
criticalPath(dag: Dag, durations: Map<string, number>): CriticalPathResult {
const sortResult = this.topologicalSort(dag);
if (sortResult.hasCycle) {
throw new Error('Cannot compute critical path for cyclic graph');
}
const nodeIndex = new Map<string, number>();
dag.nodes.forEach((node, idx) => nodeIndex.set(node.id, idx));
// Forward pass: compute earliest start times
const earliest = new Map<string, number>();
for (const nodeId of sortResult.order) {
let maxPredecessor = 0;
for (const edge of dag.edges) {
if (edge.to === nodeId) {
const predEnd = (earliest.get(edge.from) ?? 0) + (durations.get(edge.from) ?? 0);
maxPredecessor = Math.max(maxPredecessor, predEnd);
}
}
earliest.set(nodeId, maxPredecessor);View on GitHub (pinned to fa13ee4ad6)
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.
Defensive patterns
Strategy: validation
When it happens
Trigger: Thrown at v3/plugins/quantum-optimizer/src/bridges/dag-bridge.ts:205 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/0aed6e24e27fca41.
Report an issue: GitHub.