Class DeadlockDetector

java.lang.Object
com.tnsai.coordination.choreography.DeadlockDetector

public final class DeadlockDetector extends Object
Detects potential deadlocks in choreography specifications by finding cycles in the agent interaction graph using DFS-based cycle detection.

Can analyze both static choreography specs and runtime wait-for graphs.

Example usage:


 DeadlockDetector.DetectionResult result = DeadlockDetector.detect(spec);
 if (result.hasDeadlock()) {
     result.cycles().forEach(c -> log.warn("Cycle: {}", c));
 }
 
  • Method Details

    • detect

      Detects cycles in a choreography specification's interaction graph. Builds a directed graph from source → target agent relationships.
      Parameters:
      spec - the choreography specification to analyze
      Returns:
      detection result with any found cycles
    • detectFromWaitGraph

      public static DeadlockDetector.DetectionResult detectFromWaitGraph(Map<String,Set<String>> waitForGraph)
      Detects cycles from a runtime wait-for graph.
      Parameters:
      waitForGraph - map of agentId → set of agents it's waiting for
      Returns:
      detection result with any found cycles