Skip to content

Add cycle/loop detection in message flow #32

@lowhung

Description

@lowhung

Summary

Detect and highlight cycles in the message flow graph. Cycles can indicate feedback loops, potential deadlocks, or architectural issues.

Why Detect Cycles?

  • Feedback loops: Module A → B → C → A can cause cascading updates
  • Deadlock risk: Circular dependencies in request/response patterns
  • Design review: Sometimes cycles are intentional, sometimes bugs
  • Debugging: Helps understand why messages are multiplying

Proposed Features

Cycle Detection

  • Find all strongly connected components (SCCs) with >1 node
  • Identify specific edges that form cycles
  • Distinguish between:
    • Simple cycles (A → B → A)
    • Complex cycles (A → B → C → A)
    • Nested cycles

Visualization

  • Highlight cycle edges with distinct color (e.g., orange)
  • Add cycle indicator icon on participating nodes
  • Optional: animate flow direction in cycle
  • "Cycle view" mode that dims non-cycle elements

Cycle Panel

  • List detected cycles
  • Show nodes involved in each cycle
  • Cycle length and involved topics
  • Click to focus on cycle

Acceptance Criteria

  • Detect all cycles in graph
  • Visual highlighting of cycle edges
  • Cycle list in side panel
  • Click-to-focus on cycles
  • Handle overlapping cycles

Technical Notes

  • Use Tarjan's or Kosaraju's algorithm for SCC detection
  • petgraph has tarjan_scc() built-in
  • Consider performance for large graphs

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions