When a user asks you to "execute a task using DAG" or similar:
1. Task Decomposition
```bash
cd website/
npx tsx src/dag/demos/decompose-and-execute.ts simple
```
This will:
- Call Claude API to decompose the task
- Match subtasks to available skills (128 total)
- Build a DAG with dependencies
- Generate wave-based execution plan
2. Execution Plan Analysis
The demo outputs:
- Waves: Groups of independent tasks
- Parallelizable: Whether tasks in a wave can run concurrently
- Task Calls: Ready-to-use Task tool specifications
Example output:
```
Wave 1: [research-analysis]
Parallelizable: No
Wave 2: [brand-identity, wireframe-structure]
Parallelizable: Yes
Wave 3: [copywriting, design-system]
Parallelizable: Yes
```
3. File Lock Coordination (NEW - CRITICAL!)
BEFORE executing each wave, check for conflicts and acquire locks:
```typescript
// Wave analysis includes conflict detection
Wave 2: [brand-identity, wireframe-structure]
Parallelizable: Yes
Conflicts: None
Predicted Files:
brand-identity β ["src/styles/colors.css", "src/styles/typography.css"]
wireframe-structure β ["src/components/Layout.tsx", "src/pages/Home.tsx"]
```
Conflict Detection:
- β
No file overlap β Safe to parallelize
- β File overlap β Must be sequential (wave will be marked non-parallelizable)
- β Singleton task (build/lint/test) β Must run alone
Lock Acquisition (if wave is parallelizable):
The execution plan ALREADY accounts for conflicts. If parallelizable: true, it means:
- No file conflicts detected
- No singleton tasks in this wave
- Safe to execute in parallel
If parallelizable: false:
- Execute tasks sequentially
- Each task automatically acquires locks via the DAG framework
- Locks released after completion
4. Real Task Execution
For each wave:
If parallelizable (multiple tasks can run simultaneously):
- Make ALL Task calls in a SINGLE message
- This enables true parallel execution
- Conflicts already resolved during planning
Example:
```typescript
// Execute Wave 2 in parallel - make BOTH calls in one message
// (Conflict detection confirmed no file overlap)
Task({
description: "Execute design-system-creator: brand-identity",
subagent_type: "design-system-creator",
model: "sonnet",
prompt: "Create a comprehensive brand identity system for a modern SaaS product..."
});
Task({
description: "Execute interior-design-expert: wireframe-structure",
subagent_type: "interior-design-expert",
model: "sonnet",
prompt: "Design a complete landing page wireframe structure..."
});
```
If sequential (single task or conflicts detected):
- Make Task call, wait for completion
- Use result as input for next wave
- Locks automatically managed
5. Result Aggregation
After each wave:
- Collect results from Task outputs
- Pass relevant data to dependent tasks
- Update execution context
- Release any locks (automatic)