">
Skip to content

Sequencing Work Items — The DAG Dependency Model ​

🔒
Task #1
🔒
Task #2
Level 0
Independent
🔒
Task #3
🔒
Task #4
Level 1
Deps: 1, 2
🔒
Task #5
🔒
Task #6
Level 2
Deps: 3, 4
🔒
Task #7
Level 3
Deps: 5, 6

This page explains how wb-flow determines the execution order of plan tasks using a Directed Acyclic Graph (DAG) dependency model.


1. The Dep Column ​

Every plan task has a Dep column that specifies which tasks must be completed before it can start:

TaskDepMeaning
Task #1—No dependencies — can start immediately
Task #21Blocked until Task #1 is ✅ Done
Task #31, 2Blocked until BOTH Tasks #1 and #2 are ✅ Done
Task #4—No dependencies — can run in parallel with #1–#3

2. The Dependency Graph ​

Dependencies form a DAG — a graph with no cycles:

Task #1 ──→ Task #2 ──→ Task #3
                    ↗
Task #4 ──────────

Graph Rules ​

RuleDescription
No cyclesA → B → A is invalid. The system detects and rejects cycles.
TransitiveIf A → B → C, then C depends on A (transitively).
Fan-inMultiple tasks can depend on the same predecessor.
Fan-outOne task can have multiple dependents.
IndependentTasks with Dep = — can all run in parallel.

3. Execution Ordering ​

The system determines execution order using topological sort:

Level 0: Tasks with Dep = —           (can start immediately)
Level 1: Tasks whose deps are Level 0  (can start after Level 0 completes)
Level 2: Tasks whose deps are Level 1  (can start after Level 1 completes)

Example: A 7-Task Plan ​

TaskDepLevelCan Start After
#1—0Immediately
#2—0Immediately
#311Task #1
#41, 21Tasks #1 AND #2
#532Task #3
#642Task #4
#75, 63Tasks #5 AND #6

Execution visualization:

Level 0:  #1  #2
Level 1:      #3  #4
Level 2:          #5  #6
Level 3:              #7

4. Parallel vs. Serial Execution ​

Parallel (Independent Tasks) ​

Tasks at the same level with no shared dependencies can be executed in parallel:

bash
# Level 0 — both can run simultaneously
/wbWork plan_*.md --task=1   # parallel
/wbWork plan_*.md --task=2   # parallel

In practice, "parallel" means the user can execute them in any order — wb-flow doesn't actually run commands concurrently.

Serial (Dependent Tasks) ​

Tasks with dependencies must be executed in order:

bash
/wbWork plan_*.md --task=1   # must complete first
/wbWork plan_*.md --task=3   # blocked until #1 is done
/wbWork plan_*.md --task=5   # blocked until #3 is done

If you try to execute a blocked task, /wbWork will report the blocking dependency.


5. Dependency Validation ​

When a plan is created, the system validates the dependency graph:

CheckDetectionAction
Cycle detectedA → B → A❌ Error: Circular dependency
Missing dependencyDep references Task #99 (doesn't exist)⚠️ Warning: Unknown dependency #99
Self-dependencyTask #3 depends on Task #3❌ Error: Self-dependency
Over-constrainedEvery task depends on the previous one⚠️ Warning: Fully serial plan — consider parallelizing

← Concepts Hub · Home

Sequencing Work Items — Real-World Examples ​

backend_plan.md
#1 Database Schema
#2 API Endpoints
frontend_plan.md
#1 API Client (Deps: backend#2)
#2 UI Components
Backend execution starts. Frontend is blocked by cross-scope dep.

Part 2 shows real-world sequencing patterns from multi-package refactors, cross-scope dependencies, and how /wbNext uses the DAG to recommend actions.


6. Example: Documentation Rewrite (This Project) ​

The wb-flow-docs content rewrite demonstrates sequencing in practice:

Parent tasks (independent):
  Task #7 (commands)  — Dep: —
  Task #8 (concepts)  — Dep: —
  Task #9 (start_here) — Dep: —
  Task #10 (misc)      — Dep: —

Sub-tasks of #9 (sequential):
  9.1 (bootstrapping)         — Dep: —
  9.2 (first_run_walkthrough) — Dep: 9.1
  9.3 (tutorial_zero_to_app)  — Dep: 9.2
  9.4 (daily_playbook)        — Dep: —

Key insight: Tasks 7, 8, 9, and 10 are independent — they can be executed in any order. But within Task 9, sub-tasks 9.1 → 9.2 → 9.3 are sequential because each tutorial builds on concepts from the previous one.


7. Example: Multi-Package Refactor ​

When refactoring shared code across packages:

Task #1: Update wb-core API     — Dep: —
Task #2: Update wb-press2       — Dep: 1   (uses wb-core)
Task #3: Update wb-dataviewer   — Dep: 1   (uses wb-core)
Task #4: Update wb-flow         — Dep: 1   (uses wb-core)
Task #5: Integration tests      — Dep: 2, 3, 4  (all consumers updated)
Task #6: Release wb-core        — Dep: 5   (tests pass)

Graph:

        ┌→ #2 ─┐
#1 ─────┤→ #3 ─┤→ #5 → #6
        └→ #4 ─┘

This is a fan-out / fan-in pattern — common in monorepo refactors.


8. How /wbNext Uses the DAG ​

/wbNext reads the plan's dependency graph and current state to recommend the optimal next action:

text
$ /wbNext plan_wb-core_20260511.md

[AI] Analyzing plan state...
[AI]   Task #1: ✅ Done
[AI]   Task #2: ⬜ Open (deps satisfied: #1 ✅)
[AI]   Task #3: ⬜ Open (deps satisfied: #1 ✅)
[AI]   Task #4: ⬜ Open (deps satisfied: #1 ✅)
[AI]   Task #5: ⬜ Open (deps NOT satisfied: #2 ⬜, #3 ⬜, #4 ⬜)
[AI]
[AI] Recommended next action:
[AI]   /wbWork plan_*.md --task=2   (P1, deps satisfied, 20 min est.)
[AI]
[AI] Also available:
[AI]   /wbWork plan_*.md --task=3   (P1, deps satisfied, 15 min est.)
[AI]   /wbWork plan_*.md --task=4   (P2, deps satisfied, 10 min est.)

/wbNext Ranking Algorithm ​

FactorWeightDescription
Dependencies satisfiedRequiredOnly suggest unblocked tasks
Priority40%P1 tasks rank higher than P2
Time estimate30%Shorter tasks rank higher (quick wins)
Dependency count20%Tasks that unblock more downstream tasks rank higher
Recency10%Tasks in the same category as last completed task rank higher

9. Cross-Scope Dependencies ​

wb-flow plans are scoped to a single folder, so cross-scope dependencies must be managed manually:

PatternHow to Handle
Package A depends on Package B changesCreate separate plans. Complete Plan B first.
Shared component updateCreate a plan for the shared component, then plans for consumers.
Documentation references code changesExecute code plan first, then docs plan.

Cross-Scope Annotation ​

You can annotate cross-scope deps in the task description:

markdown
| 2 | 🔨 Worker | ⚠️ External: wb-core #1 | Update imports after wb-core API change | ... |

The ⚠️ External: prefix signals that this dependency is outside the current plan's scope.


10. Sequencing Anti-Patterns ​

Anti-PatternProblemFix
Fully serialEvery task depends on the previous oneIdentify truly independent tasks and remove unnecessary deps
No dependenciesAll tasks have Dep: —Add deps where order matters (e.g., API before consumers)
Hidden dependenciesTask #3 actually needs #2's output but has no depAdd the missing dep to prevent execution failures
Circular depsA → B → C → ARestructure into a linear chain or break the cycle

← Concepts Hub · Home


6. Example: Documentation Rewrite (This Project) ​

The wb-flow-docs content rewrite demonstrates sequencing in practice:

Parent tasks (independent):
  Task #7 (commands)  — Dep: —
  Task #8 (concepts)  — Dep: —
  Task #9 (start_here) — Dep: —
  Task #10 (misc)      — Dep: —

Sub-tasks of #9 (sequential):
  9.1 (bootstrapping)         — Dep: —
  9.2 (first_run_walkthrough) — Dep: 9.1
  9.3 (tutorial_zero_to_app)  — Dep: 9.2
  9.4 (daily_playbook)        — Dep: —

Key insight: Tasks 7, 8, 9, and 10 are independent — they can be executed in any order. But within Task 9, sub-tasks 9.1 → 9.2 → 9.3 are sequential because each tutorial builds on concepts from the previous one.


7. Example: Multi-Package Refactor ​

When refactoring shared code across packages:

Task #1: Update wb-core API     — Dep: —
Task #2: Update wb-press2       — Dep: 1   (uses wb-core)
Task #3: Update wb-dataviewer   — Dep: 1   (uses wb-core)
Task #4: Update wb-flow         — Dep: 1   (uses wb-core)
Task #5: Integration tests      — Dep: 2, 3, 4  (all consumers updated)
Task #6: Release wb-core        — Dep: 5   (tests pass)

Graph:

        ┌→ #2 ─┐
#1 ─────┤→ #3 ─┤→ #5 → #6
        └→ #4 ─┘

This is a fan-out / fan-in pattern — common in monorepo refactors.


8. How /wbNext Uses the DAG ​

/wbNext reads the plan's dependency graph and current state to recommend the optimal next action:

text
$ /wbNext plan_wb-core_20260511.md

[AI] Analyzing plan state...
[AI]   Task #1: ✅ Done
[AI]   Task #2: ⬜ Open (deps satisfied: #1 ✅)
[AI]   Task #3: ⬜ Open (deps satisfied: #1 ✅)
[AI]   Task #4: ⬜ Open (deps satisfied: #1 ✅)
[AI]   Task #5: ⬜ Open (deps NOT satisfied: #2 ⬜, #3 ⬜, #4 ⬜)
[AI]
[AI] Recommended next action:
[AI]   /wbWork plan_*.md --task=2   (P1, deps satisfied, 20 min est.)
[AI]
[AI] Also available:
[AI]   /wbWork plan_*.md --task=3   (P1, deps satisfied, 15 min est.)
[AI]   /wbWork plan_*.md --task=4   (P2, deps satisfied, 10 min est.)

/wbNext Ranking Algorithm ​

FactorWeightDescription
Dependencies satisfiedRequiredOnly suggest unblocked tasks
Priority40%P1 tasks rank higher than P2
Time estimate30%Shorter tasks rank higher (quick wins)
Dependency count20%Tasks that unblock more downstream tasks rank higher
Recency10%Tasks in the same category as last completed task rank higher

9. Cross-Scope Dependencies ​

wb-flow plans are scoped to a single folder, so cross-scope dependencies must be managed manually:

PatternHow to Handle
Package A depends on Package B changesCreate separate plans. Complete Plan B first.
Shared component updateCreate a plan for the shared component, then plans for consumers.
Documentation references code changesExecute code plan first, then docs plan.

Cross-Scope Annotation ​

You can annotate cross-scope deps in the task description:

markdown
| 2 | 🔨 Worker | ⚠️ External: wb-core #1 | Update imports after wb-core API change | ... |

The ⚠️ External: prefix signals that this dependency is outside the current plan's scope.


10. Sequencing Anti-Patterns ​

Anti-PatternProblemFix
Fully serialEvery task depends on the previous oneIdentify truly independent tasks and remove unnecessary deps
No dependenciesAll tasks have Dep: —Add deps where order matters (e.g., API before consumers)
Hidden dependenciesTask #3 actually needs #2's output but has no depAdd the missing dep to prevent execution failures
Circular depsA → B → C → ARestructure into a linear chain or break the cycle

← Concepts Hub · Home