Class DeadlockDetector
java.lang.Object
com.tnsai.coordination.choreography.DeadlockDetector
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));
}
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic final recordA detected cycle in the interaction graph.static final recordResult of deadlock detection. -
Method Summary
Modifier and TypeMethodDescriptiondetect(ChoreographySpec spec) Detects cycles in a choreography specification's interaction graph.detectFromWaitGraph(Map<String, Set<String>> waitForGraph) Detects cycles from a runtime wait-for graph.
-
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
-