ruvnet/ruflo · error

Cycle detected in obligation dependencies

Error message

Cycle detected in obligation dependencies

What it means

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.

Solutions

  1. Inspect the reported dependency chain and remove the circular obligation dependency from the contract definition.
  2. If cycles are intentional, switch the traversal to a cycle-tolerant algorithm with explicit handling.
  3. Validate obligation graphs at authoring time to reject cycles before runtime.
Defensive patterns

Strategy: validation

When it happens

Trigger: Obligation dependency graph contains a cycle (A depends on B which transitively depends on A); topological ordering cannot proceed and the cycle is reported.

Common situations: See trigger scenarios.


AI-assisted analysis of ruvnet/ruflo@fa13ee4ad6 (2026-08-18). Data as JSON: /api/errors/5ea297703e629347. Report an issue: GitHub.

Appendix: source

Thrown at v3/plugins/legal-contracts/src/bridges/dag-bridge.ts:269

    const sorted: Obligation[] = [];
    while (queue.length > 0) {
      const current = queue.shift()!;
      const obligation = indexMap.get(current);
      if (obligation) {
        sorted.push(obligation);
      }

      for (const neighbor of adj[current] ?? []) {
        inDegree[neighbor] = (inDegree[neighbor] ?? 1) - 1;
        if (inDegree[neighbor] === 0) {
          queue.push(neighbor);
        }
      }
    }

    // If not all nodes are in sorted, there's a cycle
    if (sorted.length !== obligations.length) {
      console.warn('Cycle detected in obligation dependencies');
    }

    return sorted;
  }

  /**
   * Detect cycles in dependency graph
   */
  async detectCycles(
    graph: ObligationTrackingResult['graph']
  ): Promise<string[][]> {
    if (!this.initialized) {
      await this.initialize();
    }

    const obligations = graph.nodes.map(n => n.obligation);

    // Create node lookup

View on GitHub (pinned to fa13ee4ad6)