@brunosps00/dev-workflow 0.8.0 → 0.9.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (73) hide show
  1. package/README.md +18 -14
  2. package/bin/dev-workflow.js +1 -1
  3. package/lib/constants.js +8 -2
  4. package/lib/init.js +6 -0
  5. package/lib/install-deps.js +0 -5
  6. package/lib/migrate-gsd.js +164 -0
  7. package/lib/uninstall.js +2 -2
  8. package/package.json +1 -1
  9. package/scaffold/en/commands/dw-analyze-project.md +6 -11
  10. package/scaffold/en/commands/dw-autopilot.md +6 -13
  11. package/scaffold/en/commands/dw-brainstorm.md +1 -1
  12. package/scaffold/en/commands/dw-code-review.md +6 -5
  13. package/scaffold/en/commands/dw-create-prd.md +5 -4
  14. package/scaffold/en/commands/dw-create-techspec.md +5 -4
  15. package/scaffold/en/commands/dw-execute-phase.md +149 -0
  16. package/scaffold/en/commands/dw-fix-qa.md +34 -13
  17. package/scaffold/en/commands/dw-help.md +5 -2
  18. package/scaffold/en/commands/dw-intel.md +98 -29
  19. package/scaffold/en/commands/dw-map-codebase.md +125 -0
  20. package/scaffold/en/commands/dw-new-project.md +1 -1
  21. package/scaffold/en/commands/dw-plan-checker.md +144 -0
  22. package/scaffold/en/commands/dw-quick.md +30 -12
  23. package/scaffold/en/commands/dw-redesign-ui.md +5 -9
  24. package/scaffold/en/commands/dw-refactoring-analysis.md +6 -5
  25. package/scaffold/en/commands/dw-resume.md +10 -8
  26. package/scaffold/en/commands/dw-run-plan.md +14 -20
  27. package/scaffold/en/commands/dw-run-qa.md +124 -23
  28. package/scaffold/en/commands/dw-run-task.md +5 -4
  29. package/scaffold/en/commands/dw-update.md +3 -1
  30. package/scaffold/en/templates/idea-onepager.md +1 -1
  31. package/scaffold/pt-br/commands/dw-analyze-project.md +6 -11
  32. package/scaffold/pt-br/commands/dw-autopilot.md +6 -13
  33. package/scaffold/pt-br/commands/dw-brainstorm.md +1 -1
  34. package/scaffold/pt-br/commands/dw-code-review.md +6 -5
  35. package/scaffold/pt-br/commands/dw-create-prd.md +5 -4
  36. package/scaffold/pt-br/commands/dw-create-techspec.md +5 -4
  37. package/scaffold/pt-br/commands/dw-execute-phase.md +149 -0
  38. package/scaffold/pt-br/commands/dw-fix-qa.md +34 -13
  39. package/scaffold/pt-br/commands/dw-help.md +5 -2
  40. package/scaffold/pt-br/commands/dw-intel.md +98 -29
  41. package/scaffold/pt-br/commands/dw-map-codebase.md +125 -0
  42. package/scaffold/pt-br/commands/dw-new-project.md +1 -1
  43. package/scaffold/pt-br/commands/dw-plan-checker.md +144 -0
  44. package/scaffold/pt-br/commands/dw-quick.md +30 -12
  45. package/scaffold/pt-br/commands/dw-redesign-ui.md +5 -9
  46. package/scaffold/pt-br/commands/dw-refactoring-analysis.md +6 -5
  47. package/scaffold/pt-br/commands/dw-resume.md +10 -8
  48. package/scaffold/pt-br/commands/dw-run-plan.md +16 -22
  49. package/scaffold/pt-br/commands/dw-run-qa.md +124 -23
  50. package/scaffold/pt-br/commands/dw-run-task.md +5 -4
  51. package/scaffold/pt-br/commands/dw-update.md +3 -1
  52. package/scaffold/pt-br/templates/idea-onepager.md +1 -1
  53. package/scaffold/skills/api-testing-recipes/SKILL.md +104 -0
  54. package/scaffold/skills/api-testing-recipes/recipes/dotnet-webapp-factory.md +168 -0
  55. package/scaffold/skills/api-testing-recipes/recipes/http-rest-client.md +130 -0
  56. package/scaffold/skills/api-testing-recipes/recipes/pytest-httpx.md +157 -0
  57. package/scaffold/skills/api-testing-recipes/recipes/rust-reqwest.md +173 -0
  58. package/scaffold/skills/api-testing-recipes/recipes/supertest-node.md +153 -0
  59. package/scaffold/skills/api-testing-recipes/references/auth-patterns.md +138 -0
  60. package/scaffold/skills/api-testing-recipes/references/log-conventions.md +117 -0
  61. package/scaffold/skills/api-testing-recipes/references/matrix-conventions.md +68 -0
  62. package/scaffold/skills/api-testing-recipes/references/openapi-driven.md +97 -0
  63. package/scaffold/skills/dw-codebase-intel/SKILL.md +101 -0
  64. package/scaffold/skills/dw-codebase-intel/agents/intel-updater.md +318 -0
  65. package/scaffold/skills/dw-codebase-intel/references/incremental-update.md +79 -0
  66. package/scaffold/skills/dw-codebase-intel/references/intel-format.md +208 -0
  67. package/scaffold/skills/dw-codebase-intel/references/query-patterns.md +148 -0
  68. package/scaffold/skills/dw-execute-phase/SKILL.md +133 -0
  69. package/scaffold/skills/dw-execute-phase/agents/executor.md +264 -0
  70. package/scaffold/skills/dw-execute-phase/agents/plan-checker.md +215 -0
  71. package/scaffold/skills/dw-execute-phase/references/atomic-commits.md +143 -0
  72. package/scaffold/skills/dw-execute-phase/references/plan-verification.md +156 -0
  73. package/scaffold/skills/dw-execute-phase/references/wave-coordination.md +102 -0
@@ -0,0 +1,215 @@
1
+ ---
2
+ name: dw-plan-checker
3
+ description: Goal-backward verification of tasks.md before /dw-execute-phase runs. Returns PASS, REVISE, or BLOCK based on 6 dimensions of plan quality.
4
+ tools: Read, Bash, Glob, Grep
5
+ color: green
6
+ ---
7
+
8
+ <required_reading>
9
+ CRITICAL: If your spawn prompt contains a required_reading block, you MUST Read every listed file BEFORE any other action.
10
+ </required_reading>
11
+
12
+ # dw-plan-checker
13
+
14
+ <role>
15
+ You are **dw-plan-checker**, the plan verification agent for dev-workflow. You verify that `.dw/spec/prd-<slug>/tasks.md` WILL achieve the PRD goal — not just that it looks complete.
16
+
17
+ Spawned by `/dw-plan-checker` (manual gate) or `/dw-create-tasks` (auto-gate before declaring tasks ready) or `/dw-autopilot` (gate before execution).
18
+
19
+ Goal-backward verification of plans BEFORE execution. Start from what the PRD SHOULD deliver, verify the tasks address it.
20
+
21
+ **Critical mindset:** Plans describe intent. You verify they deliver. A plan can have all tasks filled in and still miss the goal if:
22
+ - Key requirements have no tasks
23
+ - Tasks exist but don't actually achieve the requirement
24
+ - Dependencies are broken or circular
25
+ - Artifacts are planned but wiring between them isn't
26
+ - Scope exceeds context budget (quality will degrade mid-execution)
27
+ - Plans contradict locked decisions in `.dw/rules/` or CONTEXT.md
28
+
29
+ You are NOT the executor or QA — you verify plans WILL work BEFORE execution burns context.
30
+ </role>
31
+
32
+ <core_principle>
33
+ **Plan completeness ≠ Goal achievement**
34
+
35
+ A task "create auth endpoint" can be in the plan while password hashing is missing. The task exists but the goal "secure authentication" won't be achieved.
36
+
37
+ Goal-backward verification works backwards from outcome:
38
+
39
+ 1. What must be TRUE for the PRD goal to be achieved?
40
+ 2. Which tasks address each truth?
41
+ 3. Are those tasks complete (files, action, verify, done)?
42
+ 4. Are artifacts wired together, not just created in isolation?
43
+ 5. Will execution complete within context budget?
44
+ 6. Do tasks honor locked decisions and project conventions?
45
+
46
+ Then verify each level against the actual plan files.
47
+ </core_principle>
48
+
49
+ ## Inputs
50
+
51
+ - `prd_path` (from spawn prompt): `.dw/spec/prd-<slug>/`
52
+ - Reads:
53
+ - `<prd_path>/prd.md` — the goal, requirements (RF-XX), acceptance criteria
54
+ - `<prd_path>/techspec.md` — architecture decisions
55
+ - `<prd_path>/tasks.md` — the plan to verify
56
+ - `<prd_path>/<NN>_task.md` — per-task detail
57
+ - `.dw/rules/index.md` and `.dw/rules/<module>.md` — project conventions
58
+ - `.dw/intel/files.json`, `arch.md` (if present) — codebase facts
59
+ - `./CLAUDE.md` — project hard constraints
60
+
61
+ ## Verification Dimensions (apply ALL six)
62
+
63
+ ### Dimension 1: Requirement Coverage
64
+
65
+ **Question:** Does every PRD requirement (RF-XX) have at least one task addressing it?
66
+
67
+ **Process:**
68
+ 1. Extract every numbered requirement from `prd.md`
69
+ 2. For each RF-XX, search `tasks.md` for tasks tagged with that RF
70
+ 3. List uncovered requirements
71
+
72
+ **Pass:** every RF has at least one task.
73
+ **Revise:** ≥1 RF has no task; the planner missed it.
74
+ **Block:** the PRD has no requirements at all (plan can't verify).
75
+
76
+ ### Dimension 2: Task Completeness
77
+
78
+ **Question:** Does each task have files / action / verification / done criteria?
79
+
80
+ **Process:**
81
+ For each task in `tasks.md`, check that the corresponding `<NN>_task.md` (or inline section) has:
82
+ - Files to create/modify (specific paths, not "the auth files")
83
+ - Action (what to implement; concrete code or behavior)
84
+ - Verification (linter, tests, build, manual smoke)
85
+ - Done criteria (what must be true to mark `[x]`)
86
+
87
+ **Pass:** all tasks have all four.
88
+ **Revise:** ≥1 task missing one of the four — fixable.
89
+
90
+ ### Dimension 3: Dependency Soundness
91
+
92
+ **Question:** Are `Depends on:` fields correct (no cycles, no broken refs)?
93
+
94
+ **Process:**
95
+ 1. Parse `Depends on:` for every task
96
+ 2. Build a dependency graph
97
+ 3. Topological sort:
98
+ - If cycle detected → BLOCK with cycle path
99
+ - If a `Depends on` references a task number that doesn't exist → REVISE with the dangling ref
100
+ 4. Compute waves and check max wave width: if any wave has more tasks than the project's parallel-execution capacity (default: 5), flag for REVISE (split or sequence).
101
+
102
+ **Pass:** topological sort succeeds, no broken refs, wave widths reasonable.
103
+
104
+ ### Dimension 4: Artifact Wiring
105
+
106
+ **Question:** Are artifacts created by one task actually consumed by downstream tasks?
107
+
108
+ **Process:**
109
+ 1. For each task, identify what it produces (new file, exported symbol, new endpoint)
110
+ 2. For each downstream task, identify what it consumes
111
+ 3. Cross-reference: every produced artifact should be consumed by at least one downstream task (or be a leaf deliverable referenced in PRD's "User Stories")
112
+
113
+ **Pass:** no orphan artifacts.
114
+ **Revise:** ≥1 artifact created without being wired anywhere — likely incomplete plan.
115
+
116
+ ### Dimension 5: Context Budget
117
+
118
+ **Question:** Will execution fit within practical context limits?
119
+
120
+ **Process:**
121
+ 1. Count tasks: > 12 tasks per phase = quality degrades. REVISE: split into 2 phases.
122
+ 2. Sum estimated file changes per task. If aggregate > 30 files in a single phase, REVISE.
123
+ 3. Check that tasks.md frontmatter sets `parallel: true` for waves with ≥2 tasks (otherwise context still adds up sequentially).
124
+
125
+ **Pass:** ≤12 tasks AND ≤30 files aggregate.
126
+
127
+ ### Dimension 6: Constraint Compliance
128
+
129
+ **Question:** Do tasks honor locked decisions and conventions?
130
+
131
+ **Process:**
132
+ 1. Read `.dw/rules/index.md` and `.dw/rules/<module>.md` for relevant modules
133
+ 2. Read `CONTEXT.md` if exists for `## Decisions` (LOCKED)
134
+ 3. Read `./CLAUDE.md` for project hard constraints
135
+ 4. For each task, check if it would violate any of the above
136
+
137
+ Examples of violations:
138
+ - Task says "use Express" but `.dw/rules/index.md` says "framework: Fastify"
139
+ - Task says "store secrets in .env.example" but security policy in CLAUDE.md forbids
140
+ - Task uses a deprecated pattern from anti-patterns section of `.dw/rules/`
141
+
142
+ **Pass:** no violations detected.
143
+ **Block:** ≥1 hard violation that requires re-planning.
144
+
145
+ ## Verdict
146
+
147
+ After running all 6 dimensions:
148
+
149
+ - **PASS**: all 6 pass with no issues. Tasks are ready for `/dw-execute-phase`.
150
+ - **REVISE**: 1+ dimensions flagged fixable issues. List them; planner re-runs.
151
+ - **BLOCK**: hard architectural conflict, cycle, or unverifiable goal. Surface to user; require manual intervention.
152
+
153
+ ## Output Format
154
+
155
+ ```markdown
156
+ # Plan Verification — <prd-slug>
157
+
158
+ **Verdict:** PASS | REVISE | BLOCK
159
+ **Date:** YYYY-MM-DD
160
+ **Verified file:** `<prd_path>/tasks.md` (<N> tasks across <M> waves)
161
+
162
+ ## Dimensions
163
+
164
+ | # | Dimension | Status | Issues |
165
+ |---|-----------|--------|--------|
166
+ | 1 | Requirement Coverage | ✓ / ✗ | <count> |
167
+ | 2 | Task Completeness | ✓ / ✗ | <count> |
168
+ | 3 | Dependency Soundness | ✓ / ✗ | <count> |
169
+ | 4 | Artifact Wiring | ✓ / ✗ | <count> |
170
+ | 5 | Context Budget | ✓ / ✗ | <count> |
171
+ | 6 | Constraint Compliance | ✓ / ✗ | <count> |
172
+
173
+ ## Issues (if REVISE or BLOCK)
174
+
175
+ ### REVISE — Dimension 1: Requirement Coverage
176
+
177
+ - **RF-04** ("user can reset password via email link") has no task. Suggested: add task between 05 and 06.
178
+
179
+ ### REVISE — Dimension 2: Task Completeness
180
+
181
+ - Task 03 "Wire auth middleware" has no `Verification:` section. Add what tests/checks should pass.
182
+
183
+ ### BLOCK — Dimension 6: Constraint Compliance
184
+
185
+ - Task 02 says "use Express" but `.dw/rules/index.md` line 12 sets framework as Fastify (LOCKED). Re-plan task to use Fastify routes.
186
+
187
+ ## Recommendation
188
+
189
+ - PASS → proceed to `/dw-execute-phase .dw/spec/prd-<slug>/`
190
+ - REVISE → re-run `/dw-create-tasks` with the issues above as input
191
+ - BLOCK → resolve the locked-decision conflict before re-planning
192
+
193
+ ## Status Marker
194
+
195
+ (final line of agent output)
196
+
197
+ `## PLAN-CHECK PASS` | `## PLAN-CHECK REVISE` | `## PLAN-CHECK BLOCK`
198
+ ```
199
+
200
+ ## Critical Rules
201
+
202
+ - <critical>Run all 6 dimensions every time. Don't skip dimensions to save context — incomplete verification masks real issues.</critical>
203
+ - <critical>BLOCK is reserved for hard conflicts. Coverage gaps and dependency issues are REVISE.</critical>
204
+ - <critical>Cite file paths and line numbers in every issue. The planner re-running needs to know exactly where to look.</critical>
205
+ - <critical>The status marker is the final line. Orchestrators pattern-match on it.</critical>
206
+ - Do NOT modify files. Plan-checker is read-only.
207
+ - Do NOT verify implementation correctness. That's the executor's job and `/dw-run-qa`'s job. You only verify the PLAN.
208
+
209
+ ## Anti-Patterns
210
+
211
+ 1. DO NOT skip dimensions because the plan "looks fine"
212
+ 2. DO NOT classify locked-decision conflicts as REVISE — they are BLOCK
213
+ 3. DO NOT include code-quality nitpicks (linting, formatting) — that's `/dw-code-review`'s domain
214
+ 4. DO NOT modify `tasks.md`; only verify it
215
+ 5. DO NOT silently downgrade BLOCK to REVISE because "the user might fix it later"
@@ -0,0 +1,143 @@
1
+ # Atomic commits — one commit per task, no exceptions
2
+
3
+ Every task in a phase commits exactly once. This drives traceability (a task's diff is `git show <sha>`), revert safety (`git revert <sha>` undoes one task without affecting others), and PR clarity (`/dw-generate-pr` builds a clean changelog from the per-task commits).
4
+
5
+ ## Commit message format
6
+
7
+ Strict format. No deviations.
8
+
9
+ ```
10
+ <type>(<scope>): <task title> (RF-XX)
11
+
12
+ <one-line summary>
13
+
14
+ - Files added: <comma-separated list, or "none">
15
+ - Files modified: <comma-separated list, or "none">
16
+ - Tests added/updated: <comma-separated list, or "none">
17
+ - Deviations: <link to deviations.md entry, or "none">
18
+
19
+ Closes RF-XX (partial — full close on tasks.md completion).
20
+ ```
21
+
22
+ ### Field rules
23
+
24
+ **`<type>`** — Conventional Commits:
25
+
26
+ | Type | Use |
27
+ |------|-----|
28
+ | `feat` | New user-facing capability (default for most PRD tasks) |
29
+ | `fix` | Bug fix discovered during the phase (rare in `/dw-execute-phase`; common in `/dw-fix-qa`) |
30
+ | `refactor` | Code reshape without behavior change |
31
+ | `test` | Tests-only task |
32
+ | `docs` | Docs-only task |
33
+ | `chore` | Tooling, config, build (rare in PRD-driven phases) |
34
+
35
+ **`<scope>`** — module name from project rules. If the task touches `src/auth/`, scope is `auth`. If the task touches multiple modules, pick the dominant one or use a coarse scope (`api`, `core`, `web`).
36
+
37
+ **`<task title>`** — copy from `tasks.md` task line. Imperative, concise. "Add login endpoint", not "Added login endpoint" or "Adding login endpoint".
38
+
39
+ **`(RF-XX)`** — the requirement this task closes. If the task contributes to multiple, list the primary; mention the others in the body.
40
+
41
+ **`<one-line summary>`** — one sentence answering "what does this commit deliver?". Different from the title (which is the task title); this is the OUTCOME.
42
+
43
+ **File lists** — explicit. `src/routes/users.ts, src/services/users.ts, src/schemas/user.ts`, not "user-related files".
44
+
45
+ **Deviations link** — `.dw/spec/prd-<slug>/deviations.md#deviation-03-1` if the task triggered a Rule 1 or 2 deviation.
46
+
47
+ **Closes line** — `Closes RF-XX (partial — full close on tasks.md completion)` because one task usually doesn't fully close a requirement; the whole phase does. Final task in the phase changes "(partial — ...)" to "(full)".
48
+
49
+ ## Examples
50
+
51
+ ```
52
+ feat(auth): wire JWT middleware to all /api/* routes (RF-04)
53
+
54
+ Authenticated routes now reject requests without valid Bearer tokens.
55
+
56
+ - Files added: src/middleware/auth.ts, src/middleware/auth.test.ts
57
+ - Files modified: src/server.ts, src/routes/index.ts
58
+ - Tests added/updated: src/middleware/auth.test.ts (12 cases — happy path, expired, malformed, missing)
59
+ - Deviations: none
60
+
61
+ Closes RF-04 (partial — full close on tasks.md completion).
62
+ ```
63
+
64
+ ```
65
+ test(orders): add integration tests for order creation flow (RF-07)
66
+
67
+ Covers happy path, payment failure, inventory mismatch.
68
+
69
+ - Files added: tests/integration/orders.test.ts
70
+ - Files modified: none
71
+ - Tests added/updated: tests/integration/orders.test.ts (8 cases)
72
+ - Deviations: .dw/spec/prd-checkout-v2/deviations.md#deviation-08-1
73
+
74
+ Closes RF-07 (partial — full close on tasks.md completion).
75
+ ```
76
+
77
+ ## Verification before commit
78
+
79
+ The executor MUST run, in order:
80
+
81
+ 1. **Linter** — project's lint command (`pnpm lint`, `ruff check`, `dotnet format --verify-no-changes`, `cargo clippy`).
82
+ 2. **Tests** — at minimum the tests touched by this task. Full suite if practical.
83
+ 3. **Build** — typecheck/compile (`pnpm tsc --noEmit`, `mypy`, `dotnet build`, `cargo check`).
84
+
85
+ All three must pass. If any fails:
86
+ - If the failure is in a test the task added → fix and retry (1 retry, then deviation)
87
+ - If the failure is in unrelated code → deviation Rule 2 (ambiguity: does this task own the regression?)
88
+
89
+ The executor does NOT commit unverified code. Period.
90
+
91
+ ## Edit vs Write
92
+
93
+ When implementing the task:
94
+
95
+ | Use Edit when | Use Write when |
96
+ |---------------|----------------|
97
+ | Modifying an existing file | Creating a new file |
98
+ | Changing 1-30 lines | Replacing a file completely |
99
+ | You have line context (the file is in your context) | The file is small and a Write is cleaner than 5 Edits |
100
+
101
+ Never use `cat <<'EOF' > file` heredocs from Bash to create files. Always use Write tool.
102
+
103
+ ## Multi-file tasks
104
+
105
+ If a task touches 5+ files, that's still one commit. Stage all files (`git add <list>`) then `git commit`. The body's `Files added:` / `Files modified:` lists must include every file.
106
+
107
+ If a task should logically be split into separate commits (e.g., "create schema then wire it"), that's a sign the planner under-decomposed. The executor flags as Rule 2 deviation, not silently split.
108
+
109
+ ## Commit signing
110
+
111
+ If `git config commit.gpgsign true` is set, signing is on by default — let it run. Do NOT pass `--no-gpg-sign` from the executor. If signing fails (key missing), surface the error; do NOT bypass.
112
+
113
+ ## What NOT to commit
114
+
115
+ - `.env` files (even if the task touched them — they should be gitignored already; if not, that's a separate task)
116
+ - IDE artifacts (`.vscode/settings.json` user prefs, `.idea/`)
117
+ - OS junk (`.DS_Store`, `Thumbs.db`)
118
+ - Unrelated changes accidentally in the working tree (executor should `git status` before adding to confirm only the task's files)
119
+
120
+ If unrelated changes are present, deviation Rule 2: pause and ask — the executor doesn't know if those are user's WIP or expected from a prior task.
121
+
122
+ ## Deviation entry format (referenced from commits)
123
+
124
+ `.dw/spec/prd-<slug>/deviations.md`:
125
+
126
+ ```markdown
127
+ # Deviations — <prd-slug>
128
+
129
+ ## DEVIATION-<TASK_NN>-<RULE_NUMBER>: <title>
130
+
131
+ - **Task:** <NN> — <task title>
132
+ - **Rule:** 1 (auto-add) | 2 (ambiguity) | 3 (architectural conflict)
133
+ - **Description:** <1-3 sentences>
134
+ - **Files affected:** <list>
135
+ - **Resolution:** <what was done; "PAUSED awaiting input" for Rule 2; "BLOCKED — re-plan" for Rule 3>
136
+ - **Commit:** <SHA, filled when task commits; empty if Rule 2/3>
137
+ ```
138
+
139
+ The plan-checker reads `deviations.md` from the previous run when re-verifying after revision — patterns of recurring Rule 1 deviations indicate the planner is missing a project convention that should be in `.dw/rules/`.
140
+
141
+ ## Final phase commit (handled by `/dw-commit`, not executor)
142
+
143
+ After all per-task commits, `/dw-generate-pr` (NOT the executor) reads them and builds the PR body. The executor never makes a "wrap-up" commit. If the phase needs a final commit (e.g., updating CHANGELOG.md), that should be the LAST task in `tasks.md` — atomic like every other.
@@ -0,0 +1,156 @@
1
+ # Plan verification — the 6-dimension goal-backward analysis
2
+
3
+ The `dw-plan-checker` agent verifies that a `tasks.md` will achieve the PRD goal BEFORE execution starts. This document details each dimension's checks, examples, and pass/fail criteria.
4
+
5
+ ## Why pre-execution verification
6
+
7
+ Mid-execution discovery of plan flaws is expensive: context burned, partial commits to revert, deviation logs to resolve. Pre-execution verification catches the same flaws at zero implementation cost. The trade-off: 1-2 minutes of plan-checker time vs. potentially 30+ minutes of mid-execution rework.
8
+
9
+ ## The 6 dimensions
10
+
11
+ ### 1. Requirement Coverage
12
+
13
+ **Goal:** every PRD requirement (RF-XX) has at least one task addressing it.
14
+
15
+ **Steps:**
16
+ 1. Extract numbered requirements from `prd.md`. Pattern: `### RF-NN` or `**RF-NN:**` or numbered list under "Functional Requirements".
17
+ 2. Build `Set<RF>` of expected requirements.
18
+ 3. Scan `tasks.md` and `<NN>_task.md` files for `Closes RF-XX` / `RF: RF-XX` / `Requirement: RF-XX` markers.
19
+ 4. Compute `uncovered = expected - addressed`.
20
+
21
+ **Pass:** `uncovered` is empty.
22
+ **Revise:** uncovered non-empty AND fixable by adding tasks.
23
+ **Block:** PRD has no numbered requirements (`expected` is empty) — verifying intent is impossible.
24
+
25
+ **Common failures:**
26
+ - Planner forgot a non-obvious requirement (e.g., audit logging) buried in PRD prose
27
+ - Compound requirement ("user can sign up AND verify email") only addressed for one half
28
+ - Requirement covered indirectly but no task explicitly marks the closure
29
+
30
+ ### 2. Task Completeness
31
+
32
+ **Goal:** each task has all four parts: files, action, verification, done criteria.
33
+
34
+ **Steps:**
35
+ For each task in `tasks.md`:
36
+ - Open `<NN>_task.md` (or inline section)
37
+ - Check for required sections:
38
+ - `## Files` (or `Files to create/modify:`) — explicit paths
39
+ - `## Action` (or `Implement:`) — what to do, concrete
40
+ - `## Verification` (or `Verify:`) — how to know it worked (linter, tests, build, manual)
41
+ - `## Done` (or `Done when:`) — criteria for marking `[x]`
42
+
43
+ **Pass:** all four sections present in every task.
44
+ **Revise:** ≥1 task missing one section.
45
+
46
+ **Common failures:**
47
+ - "Files: TBD" or "Files: see techspec" — too vague
48
+ - No verification → executor can't decide when to commit
49
+ - Done criteria absent → executor commits but can't mark `[x]` confidently
50
+
51
+ ### 3. Dependency Soundness
52
+
53
+ **Goal:** `Depends on:` graph is acyclic, references valid, waves are reasonable.
54
+
55
+ **Steps:**
56
+ 1. Parse every task's `Depends on:` field (none / comma-separated task numbers).
57
+ 2. Build directed graph (node = task, edge = depends-on relation).
58
+ 3. Topological sort:
59
+ - Cycle → BLOCK with the cycle path
60
+ - Reference to non-existent task number → REVISE with the dangling ref
61
+ 4. Compute wave widths. Any wave > 8 tasks → REVISE (split with synthetic barrier).
62
+
63
+ **Pass:** topological sort succeeds, all refs valid, waves ≤ 8 wide.
64
+
65
+ **Common failures:**
66
+ - Bidirectional dependency (`02 depends on 03; 03 depends on 02`) — likely planner confusion; needs re-think
67
+ - Typo in `Depends on: 02` when the task is actually numbered `2.5` or `03`
68
+ - 10 independent test files all in wave 1 → split into smaller waves
69
+
70
+ ### 4. Artifact Wiring
71
+
72
+ **Goal:** every artifact produced by a task is consumed by a downstream task OR is a leaf deliverable referenced in PRD's user stories.
73
+
74
+ **Steps:**
75
+ 1. For each task, identify what it PRODUCES:
76
+ - New files (from `Files: + src/foo.ts`)
77
+ - New exports (from `Implement: export function bar()`)
78
+ - New endpoints (from `Action: add POST /api/baz`)
79
+ 2. For each downstream task (later in topo order), identify what it CONSUMES:
80
+ - Imports (from `Files: src/quux.ts (modify) — imports bar`)
81
+ - References (from `Action: call /api/baz`)
82
+ 3. Cross-reference: every produced artifact should be either consumed downstream OR explicitly mentioned in PRD as a user-facing deliverable.
83
+
84
+ **Pass:** zero orphan artifacts.
85
+ **Revise:** ≥1 artifact created without consumer or PRD reference — likely incomplete plan.
86
+
87
+ **Common failures:**
88
+ - Task creates a service but no task wires it into the router
89
+ - Task creates a migration file but no task runs it (`prisma migrate deploy`)
90
+ - Task creates a config but no task reads it
91
+
92
+ ### 5. Context Budget
93
+
94
+ **Goal:** the phase fits in a practical execution window.
95
+
96
+ **Steps:**
97
+ 1. Count tasks. Practical limit: 12 tasks per phase before quality degrades.
98
+ 2. Estimate aggregate file changes: sum of files mentioned in `Files:` across all tasks. Limit: 30 files per phase.
99
+ 3. Check parallelism setup: are wave-1 tasks running in parallel? (frontmatter `parallel: true` or default).
100
+
101
+ **Pass:** ≤12 tasks, ≤30 aggregate files, wave 1 has parallel execution if multi-task.
102
+
103
+ **Revise:** > 12 tasks → suggest splitting into 2 phases. > 30 files → reduce scope or split.
104
+
105
+ **Common failures:**
106
+ - Mega-phase with 20 tasks because the planner couldn't decompose
107
+ - Single-task waves where parallelism was forgotten
108
+
109
+ ### 6. Constraint Compliance
110
+
111
+ **Goal:** tasks honor locked decisions and project conventions.
112
+
113
+ **Steps:**
114
+ 1. Read `.dw/rules/index.md` and `.dw/rules/<module>.md` for relevant modules.
115
+ 2. Read `CONTEXT.md` if exists; extract `## Decisions` (LOCKED) section.
116
+ 3. Read `./CLAUDE.md` for project hard constraints.
117
+ 4. For each task, check if its `Action` or `Files` violate:
118
+ - A locked decision
119
+ - A project rule (forbidden pattern, mandated tool)
120
+ - A CLAUDE.md directive
121
+
122
+ **Pass:** zero violations.
123
+ **Block:** ≥1 hard violation. The plan must change before execution.
124
+
125
+ **Common failures:**
126
+ - Locked decision says "framework: Fastify" but task says "use Express"
127
+ - Project rules forbid raw SQL; task uses `pg.query()` directly
128
+ - CLAUDE.md says "no env files committed"; task adds `.env.production`
129
+
130
+ ## Verdict resolution
131
+
132
+ After running all 6 dimensions:
133
+
134
+ | Outcome | Verdict |
135
+ |---------|---------|
136
+ | All 6 PASS | PASS — proceed to execution |
137
+ | Any REVISE, no BLOCK | REVISE — re-plan |
138
+ | Any BLOCK | BLOCK — surface to user, no auto-replan |
139
+
140
+ `PASS` is the only state that allows `/dw-execute-phase` to proceed.
141
+
142
+ ## Bounded revision loop
143
+
144
+ The plan-checker is part of a bounded quality loop:
145
+
146
+ 1. `/dw-create-tasks` produces v1 of `tasks.md`
147
+ 2. `/dw-plan-checker` runs → REVISE
148
+ 3. `/dw-create-tasks --revise` produces v2 (consumes plan-checker's issues as input)
149
+ 4. `/dw-plan-checker` runs → PASS or REVISE again
150
+ 5. After 3 revisions without reaching PASS → escalate to user (something fundamental is wrong)
151
+
152
+ The escalation cap prevents infinite loops where the planner can't satisfy the verifier. At 3 strikes, the user sees the diff between PRD and the failing tasks.md and decides next step.
153
+
154
+ ## Time budget
155
+
156
+ Plan-checker target: 1-2 minutes. The 6 dimensions are mostly file reads and grep operations; no heavy analysis. If plan-checker exceeds 5 minutes, it's a sign the agent is over-thinking — bias toward issuing REVISE for ambiguous cases rather than analyzing them deeply.
@@ -0,0 +1,102 @@
1
+ # Wave coordination — how the executor parallelizes tasks
2
+
3
+ Tasks within a phase have dependencies. Some can run in parallel; others must wait. The executor groups tasks into **waves** and runs each wave as parallel subagent dispatches, with sequential ordering between waves.
4
+
5
+ ## Wave computation
6
+
7
+ Input: `tasks.md` with each task carrying a `Depends on:` field (none, or comma-separated task numbers).
8
+
9
+ Algorithm: topological sort.
10
+
11
+ 1. Build dependency graph: node per task, edge from each `Depends on:` to the dependent task.
12
+ 2. Cycle check: if a cycle exists → abort with `EXEC-FAILED: dependency cycle`.
13
+ 3. Wave assignment:
14
+ - Wave 1 = tasks with zero dependencies
15
+ - Wave N = tasks whose all dependencies are in waves 1..N-1
16
+ 4. Output: ordered list of waves, each wave a list of task numbers.
17
+
18
+ ## Example
19
+
20
+ ```
21
+ tasks.md:
22
+ - 01 Create user schema Depends on: none
23
+ - 02 Create user model Depends on: 01
24
+ - 03 Create order schema Depends on: none
25
+ - 04 Wire auth middleware Depends on: 02
26
+ - 05 Add login endpoint Depends on: 04
27
+ - 06 Add order endpoint Depends on: 02, 03
28
+ - 07 Wire validation rules Depends on: 04, 06
29
+
30
+ Computed waves:
31
+ Wave 1: [01, 03] (no deps; can run in parallel)
32
+ Wave 2: [02] (depends on 01)
33
+ Wave 3: [04, 06] (depend on wave 2)
34
+ Wave 4: [05, 07] (depend on wave 3)
35
+ ```
36
+
37
+ ## Parallel execution within a wave
38
+
39
+ Within a wave, the executor dispatches tasks in parallel via subagent calls (one subagent per task). Each subagent:
40
+
41
+ 1. Reads its `<NN>_task.md`
42
+ 2. Implements
43
+ 3. Verifies (lint/tests/build)
44
+ 4. Commits atomically (per `atomic-commits.md`)
45
+ 5. Marks `[x]` in `tasks.md`
46
+ 6. Returns success or deviation status to the orchestrating executor
47
+
48
+ The orchestrating executor:
49
+
50
+ - Spawns N subagents in parallel (single message, N tool calls)
51
+ - Waits for all to return
52
+ - If all PASS → proceed to next wave
53
+ - If ANY return deviation/blocked → resolve before next wave (see deviation rules in `agents/executor.md`)
54
+
55
+ ## Wave width limits
56
+
57
+ Practical caps to keep context budget sane:
58
+
59
+ - **Soft cap: 5 tasks per wave** — tested as the upper bound where parallel execution stays efficient
60
+ - **Hard cap: 8 tasks per wave** — beyond this, the orchestrator's context fills with subagent results faster than tasks complete
61
+
62
+ If a wave exceeds the hard cap, the planner should split: introduce a synthetic dependency to bisect the wave. Example: if Wave 3 has 10 independent tasks, force tasks 06-10 to depend on a "wave 3a barrier" so they go to Wave 3.5.
63
+
64
+ The plan-checker (Dimension 5) flags wide waves before execution.
65
+
66
+ ## Cross-wave atomicity
67
+
68
+ Each wave is a checkpoint:
69
+
70
+ - After all tasks in a wave commit, run a `git status` check — should be clean (everything committed).
71
+ - If any task in a wave failed permanently (Rule 3 deviation), abort BEFORE starting the next wave. Leave the partial work committed; surface to user via `EXEC-BLOCKED`.
72
+ - Don't run waves N+1 with broken commits in wave N. The dependencies aren't satisfied.
73
+
74
+ ## Order within a wave
75
+
76
+ Within a wave, order doesn't matter logically (no deps between same-wave tasks). But for **commit history readability**, the executor should commit in numeric order of task number (01 commit before 02 even if both are wave 1). The parallel subagent results may arrive out of order; the executor collects and commits sequentially.
77
+
78
+ This means: subagents return their changes (files written, but NOT committed). The executor commits them in numeric order.
79
+
80
+ (Alternative: subagents commit independently and accept commit interleaving. Pick this if commit-order doesn't matter for the project; the orchestrator sets a flag.)
81
+
82
+ ## When to NOT use waves
83
+
84
+ Single-task changes (`/dw-quick`, `/dw-run-task`) bypass waves entirely. Waves are for `/dw-run-plan` and `/dw-execute-phase` — phase-scale execution.
85
+
86
+ ## Verification of wave structure (pre-execution)
87
+
88
+ The plan-checker (Dimension 3 in `plan-checker.md`) verifies:
89
+ - Topological sort succeeds (no cycles)
90
+ - All `Depends on:` references point to existing tasks
91
+ - No wave exceeds the hard cap (8 tasks)
92
+
93
+ If these fail, plan-checker returns REVISE before any code is touched.
94
+
95
+ ## Resume after checkpoint
96
+
97
+ If the executor checkpoints mid-phase, `active-session.md` records:
98
+ - `last_completed_task`
99
+ - `last_wave_completed`
100
+ - `remaining_tasks`
101
+
102
+ `/dw-resume` reads this, recomputes waves from `tasks.md`, skips already-committed tasks, and resumes from the wave containing `last_completed_task + 1`.