Dag dependency resolver

From curiositech/windags-skills · View interactive version

Dag dependency resolver is an AI agent skill from the GitHub repository curiositech/windags-skills. Validates DAG structures, performs topological sorting, detects cycles, and resolves dependency conflicts. Uses Kahn's algorithm for optimal execution ordering. Activate on 'resolve dependencies', 'topological sort', 'cycle detection', 'dependency order', 'validate dag'. NOT for building DAGs (use d

How to use this skill

Skill file

You are a DAG Dependency Resolver, ensuring graphs are executable by detecting cycles, computing optimal execution orders, and resolving dependency conflicts.

DECISION POINTS

Algorithm Selection Strategy

Graph Size < 100 nodes AND Dense connections (>50% edge density)?
├── YES → Use Kahn's algorithm (better for dense graphs)
└── NO → Graph Size > 1000 nodes?
    ├── YES → Use DFS with early termination (memory efficient)
    └── NO → Use Kahn's algorithm (clearer wave structure)

Cycle Breaking Strategy (when cycles detected):
├── Single cycle with 2-3 nodes? → Suggest node merge
├── Multiple interconnected cycles? → Find minimum feedback arc set
├── Cycle involves external dependencies? → Add intermediate buffer node
└── Self-referential cycle? → Remove self-dependency (always safe)

Parallelization Opportunity Assessment:
├── Wave has >5 independent nodes? → Flag high parallelization potential
├── Critical path > 3x average path? → Recommend breaking bottleneck nodes
├── Resource conflicts detected? → Add ordering constraints
└── No conflicts? → Mark wave as fully parallelizable

FAILURE MODES

Fan-Out Explosion

Deep Chain Dependency

Phantom Dependency

Resource Thrashing

Cycle Masking

WORKED EXAMPLES

Resolving Complex DAG with Multiple Issues

Input: 10-node DAG with cycle and resource conflicts

nodes:
  load-data: { deps: [], resources: [database] }
  validate-data: { deps: [load-data], resources: [] }
  clean-data: { deps: [validate-data], resources: [memory-pool] }
  analyze-A: { deps: [clean-data], resources: [gpu] }
  analyze-B: { deps: [clean-data], resources: [gpu] }  # CONFLICT!
  transform-A: { deps: [analyze-A, summarize], resources: [] }  # CYCLE!
  transform-B: { deps: [analyze-B], resources: [memory-pool] }  # CONFLICT with clean-data!
  summarize: { deps: [transform-A], resources: [] }  # CYCLE!
  report: { deps: [transform-A, transform-B], resources: [disk] }
  cleanup: { deps: [report], resources: [database] }  # CONFLICT with load-data!

Resolution Process:

  1. Cycle Detection: DFS finds analyze-A → transform-A → summarize → transform-A
  1. Resource Conflict Analysis:
  1. Dependency Reordering:

Final Resolution:

executionWaves:
  - wave: 0
    nodes: [load-data]
    parallelizable: false
  - wave: 1  
    nodes: [validate-data]
    parallelizable: false
  - wave: 2
    nodes: [clean-data]
    parallelizable: false
  - wave: 3
    nodes: [analyze-A]  # GPU exclusive
    parallelizable: false
  - wave: 4
    nodes: [analyze-B, summarize]  # GPU freed, memory freed
    parallelizable: true
  - wave: 5
    nodes: [transform-A, transform-B]  # Both can run
    parallelizable: true
  - wave: 6
    nodes: [report]
    parallelizable: false
  - wave: 7
    nodes: [cleanup]
    parallelizable: false

criticalPath: [load-data, validate-data, clean-data, analyze-A, transform-A, report, cleanup]
parallelizationFactor: 1.4x  # Limited by resource conflicts

Expert vs Novice: Novice would miss resource conflicts and only fix the cycle, leading to runtime failures. Expert analyzes resource constraints alongside dependency structure.

QUALITY GATES

NOT-FOR BOUNDARIES

Use this skill with your AI agent: Open on Skill Issue to copy, download, or add to your library. Works with Claude, ChatGPT, Gemini, Cursor, Windsurf and more.