devflow-kit 3.2.0 → 3.3.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 (89) hide show
  1. package/CHANGELOG.md +16 -0
  2. package/README.md +1 -1
  3. package/dist/cli/commands/learning.js +25 -5
  4. package/dist/commands/code-review.md +1 -1
  5. package/dist/commands/debug.md +1 -1
  6. package/dist/commands/dynamic-build.md +141 -94
  7. package/dist/commands/dynamic-plan.md +1 -1
  8. package/dist/commands/explore.md +1 -1
  9. package/dist/commands/implement.md +133 -133
  10. package/dist/commands/resolve.md +27 -16
  11. package/dist/commands/self-review.md +16 -11
  12. package/dist/core/agent-models.js +10 -7
  13. package/dist/core/learning-tuning-config.js +8 -0
  14. package/dist/core/plugins.js +7 -2
  15. package/dist/skills/git/references/tracker/github/gather-release-evidence.md +1 -1
  16. package/dist/skills/git/references/tracker/jira/gather-release-evidence.md +1 -1
  17. package/dist/skills/git/references/tracker/linear/gather-release-evidence.md +1 -1
  18. package/package.json +1 -1
  19. package/src/assets/agents/code.md +71 -18
  20. package/src/assets/agents/design.md +10 -0
  21. package/src/assets/agents/diagnose.md +16 -11
  22. package/src/assets/agents/evaluate.md +14 -25
  23. package/src/assets/agents/knowledge.md +5 -3
  24. package/src/assets/agents/learning.md +4 -6
  25. package/src/assets/agents/research.md +19 -0
  26. package/src/assets/agents/review.md +10 -0
  27. package/src/assets/agents/scrutinize.md +34 -10
  28. package/src/assets/agents/simplify.md +20 -0
  29. package/src/assets/agents/skim.md +4 -2
  30. package/src/assets/agents/synthesize.md +12 -0
  31. package/src/assets/agents/test.md +2 -2
  32. package/src/assets/agents/triage.md +7 -1
  33. package/src/assets/agents/validate.md +7 -2
  34. package/src/assets/commands/_partials/_engine.mds +21 -24
  35. package/src/assets/commands/_partials/_knowledge.mds +1 -1
  36. package/src/assets/commands/_partials/_plan_contract.mds +1 -1
  37. package/src/assets/commands/_partials/_wave.mds +8 -6
  38. package/src/assets/commands/code-review.mds +1 -1
  39. package/src/assets/commands/dynamic-build.mds +111 -63
  40. package/src/assets/commands/implement.mds +132 -132
  41. package/src/assets/commands/resolve.mds +26 -15
  42. package/src/assets/commands/self-review.mds +15 -10
  43. package/src/assets/mds/tracker/_common.mds +1 -1
  44. package/src/assets/scripts/ci-wait.cjs +636 -0
  45. package/src/assets/scripts/hooks/assets/orchestrator-charter.md +1 -1
  46. package/src/assets/scripts/hooks/background-memory-update +290 -9
  47. package/src/assets/scripts/release-trace.cjs +27 -10
  48. package/src/assets/skills/accessibility/SKILL.md +1 -1
  49. package/src/assets/skills/apply-decisions/SKILL.md +12 -82
  50. package/src/assets/skills/apply-feature-knowledge/SKILL.md +8 -42
  51. package/src/assets/skills/architecture/SKILL.md +1 -1
  52. package/src/assets/skills/boundary-validation/SKILL.md +1 -1
  53. package/src/assets/skills/complexity/SKILL.md +1 -1
  54. package/src/assets/skills/compliance/SKILL.md +1 -1
  55. package/src/assets/skills/consistency/SKILL.md +1 -1
  56. package/src/assets/skills/database/SKILL.md +1 -1
  57. package/src/assets/skills/dependencies/SKILL.md +1 -1
  58. package/src/assets/skills/dependency-research/SKILL.md +3 -6
  59. package/src/assets/skills/design-review/SKILL.md +1 -1
  60. package/src/assets/skills/docs-framework/SKILL.md +1 -1
  61. package/src/assets/skills/documentation/SKILL.md +1 -1
  62. package/src/assets/skills/gap-analysis/SKILL.md +1 -1
  63. package/src/assets/skills/git/SKILL.md +1 -1
  64. package/src/assets/skills/go/SKILL.md +1 -1
  65. package/src/assets/skills/java/SKILL.md +1 -1
  66. package/src/assets/skills/patterns/SKILL.md +1 -1
  67. package/src/assets/skills/performance/SKILL.md +1 -1
  68. package/src/assets/skills/python/SKILL.md +1 -1
  69. package/src/assets/skills/qa/SKILL.md +1 -3
  70. package/src/assets/skills/quality-gates/SKILL.md +9 -12
  71. package/src/assets/skills/quality-gates/references/report-template.md +20 -20
  72. package/src/assets/skills/react/SKILL.md +1 -1
  73. package/src/assets/skills/regression/SKILL.md +1 -1
  74. package/src/assets/skills/reliability/SKILL.md +1 -1
  75. package/src/assets/skills/research-codebase/SKILL.md +1 -1
  76. package/src/assets/skills/research-competitor/SKILL.md +1 -1
  77. package/src/assets/skills/research-external/SKILL.md +1 -1
  78. package/src/assets/skills/research-technology/SKILL.md +1 -1
  79. package/src/assets/skills/review-methodology/SKILL.md +1 -1
  80. package/src/assets/skills/rust/SKILL.md +1 -1
  81. package/src/assets/skills/security/SKILL.md +1 -1
  82. package/src/assets/skills/software-design/SKILL.md +1 -1
  83. package/src/assets/skills/test-driven-development/SKILL.md +9 -29
  84. package/src/assets/skills/testing/SKILL.md +1 -1
  85. package/src/assets/skills/typescript/SKILL.md +1 -1
  86. package/src/assets/skills/ui-design/SKILL.md +1 -1
  87. package/src/assets/skills/worktree-support/SKILL.md +3 -55
  88. package/src/assets/skills/worktree-support/references/discovery.md +48 -0
  89. package/src/assets/skills/worktree-support/references/roots.md +2 -2
@@ -50,7 +50,7 @@ When the user explicitly asks to re-validate, re-check, or re-run quality gates
50
50
  1. **Branch safety check**: If on a protected branch (main, master, develop, etc.), run Phase 1 to create/switch to a work branch. If already on a work branch, skip Phase 1.
51
51
  2. **Skip Phase 2** — no Code agent needed, user already made changes.
52
52
  3. **Detect FILES_CHANGED**: `git diff --name-only {base_branch}...HEAD`
53
- 4. **Run Phases 3-8** — full quality gate pipeline on detected changes.
53
+ 4. **Run Phases 3-8** — Simplify, Self-Review, Alignment, the one full Validate, QA Testing and the conditional Re-Validate, on the detected changes.
54
54
  5. **Proceed to Phase 10** (Create PR), **Phase 10b** (Evidence) and **Phase 11** (Report).
55
55
 
56
56
  If the user prompt does NOT match re-validation, proceed with the full pipeline below.
@@ -172,7 +172,7 @@ Phase 10b passes the resolved value to `update-pr-evidence`, which decides what
172
172
 
173
173
  {{decisions_load()}}
174
174
 
175
- Pass to Code agent (Phase 2) and Scrutinize agent (Phase 5).
175
+ Pass to Code agent (Phase 2) and Scrutinize agent (Phase 4).
176
176
 
177
177
  {{knowledge_load()}}
178
178
 
@@ -199,7 +199,8 @@ Based on Setup context (plan document, issue body, or conversation context), use
199
199
 
200
200
  ```
201
201
  Agent(subagent_type="Code"):
202
- "TASK_ID: {task-id}
202
+ "OPERATION: implement
203
+ TASK_ID: {task-id}
203
204
  TASK_DESCRIPTION: {description}
204
205
  BASE_BRANCH: {base branch}
205
206
  EXECUTION_PLAN: {full plan from setup context}
@@ -225,7 +226,8 @@ Spawn Code agents one at a time, passing handoff summaries between phases:
225
226
  **Phase 1 Code agent:**
226
227
  ```
227
228
  Agent(subagent_type="Code"):
228
- "TASK_ID: {task-id}
229
+ "OPERATION: implement
230
+ TASK_ID: {task-id}
229
231
  TASK_DESCRIPTION: {phase 1 description}
230
232
  BASE_BRANCH: {base branch}
231
233
  EXECUTION_PLAN: {phase 1 steps}
@@ -245,7 +247,8 @@ HANDOFF_FILE: {worktree}/.devflow/docs/handoff-{branch_slug}.md"
245
247
  **Phase 2+ Code agents** (after prior phase completes):
246
248
  ```
247
249
  Agent(subagent_type="Code"):
248
- "TASK_ID: {task-id}
250
+ "OPERATION: implement
251
+ TASK_ID: {task-id}
249
252
  TASK_DESCRIPTION: {phase N description}
250
253
  BASE_BRANCH: {base branch}
251
254
  EXECUTION_PLAN: {phase N steps}
@@ -276,7 +279,8 @@ Spawn multiple Code agents **in a single message**, each with independent subtas
276
279
 
277
280
  ```
278
281
  Agent(subagent_type="Code"): # Code agent 1
279
- "TASK_ID: {task-id}-part1
282
+ "OPERATION: implement
283
+ TASK_ID: {task-id}-part1
280
284
  TASK_DESCRIPTION: {independent subtask 1}
281
285
  BASE_BRANCH: {base branch}
282
286
  EXECUTION_PLAN: {subtask 1 steps}
@@ -291,7 +295,8 @@ ISSUE_NUMBER: {ISSUE_ID captured in Phase 1, or (none)}
291
295
  ISSUE_PR_LINK: {ISSUE_PR_LINK captured in Phase 1, or (none)}"
292
296
 
293
297
  Agent(subagent_type="Code"): # Code agent 2 (same message)
294
- "TASK_ID: {task-id}-part2
298
+ "OPERATION: implement
299
+ TASK_ID: {task-id}-part2
295
300
  TASK_DESCRIPTION: {independent subtask 2}
296
301
  BASE_BRANCH: {base branch}
297
302
  EXECUTION_PLAN: {subtask 2 steps}
@@ -312,74 +317,28 @@ ISSUE_PR_LINK: {ISSUE_PR_LINK captured in Phase 1, or (none)}"
312
317
  - Different files/modules with no imports between them
313
318
  - Each subtask is self-contained
314
319
 
315
- ### Phase 3: Validate
316
-
317
- **Produces:** VALIDATION_RESULT
318
- **Requires:** FILES_CHANGED
319
-
320
- After Code agent completes, spawn Validate agent to verify correctness:
321
-
322
- ```
323
- Agent(subagent_type="Validate"):
324
- "FILES_CHANGED: {list of files from Code agent output}
325
- VALIDATION_SCOPE: full
326
- Run build, typecheck, lint, test. Report pass/fail with failure details."
327
- ```
328
-
329
- **If FAIL:**
330
- 1. Extract failure details from Validate agent output
331
- 2. Increment `validation_retry_count`
332
- 3. If `validation_retry_count <= 2`:
333
- - Spawn Code agent with fix context:
334
- ```
335
- Agent(subagent_type="Code"):
336
- "TASK_ID: {task-id}
337
- TASK_DESCRIPTION: Fix validation failures
338
- OPERATION: validation-fix
339
- VALIDATION_FAILURES: {parsed failures from Validate agent}
340
- SCOPE: Fix only the listed failures, no other changes
341
- CREATE_PR: false
342
- ISSUE_NUMBER: {ISSUE_ID captured in Phase 1, or (none)}
343
- ISSUE_PR_LINK: {ISSUE_PR_LINK captured in Phase 1, or (none)}
344
- COMPLIANCE_FRAMEWORKS: {COMPLIANCE_FRAMEWORKS}"
345
- ```
346
- - Loop back to Phase 3 (re-validate)
347
- 4. If `validation_retry_count > 2`: Report failures to user and halt
348
-
349
- **If PASS:** append a `gate:validate` claim, then continue to Phase 4.
350
-
351
- **Evidence claims** are lines appended to the `## Claims` section of `EVIDENCE_FILE` — the file's last section, created when absent. Append only: never edit or remove a claim; the last valid one per target wins. Each line takes exactly one of these shapes, where `<head>` is the 40-hex `HEAD:` the agent's report shows:
352
-
353
- ```
354
- - gate:validate PASS sha:<head> by:validate
355
- - TP-<n> <PASS|FAIL|SKIP> sha:<head> by:test exit:<0-255>
356
- ```
357
-
358
- - `gate:validate` — after a Phase 3 or Phase 6 PASS.
359
- - `TP-<n>` — after every Phase 8 run, one line per `### Test Plan Evidence` row whose TP is in `TEST_PLAN`, with the row's outcome; the line ends at `by:test` when the row's Exit is not a number from 0 to 255.
360
- - Append nothing from a report whose `HEAD:` is not a single 40-hex SHA — a reported before/after change included — and say so in the Phase 11 report.
361
-
362
- ### Phase 4: Simplify
320
+ ### Phase 3: Simplify
363
321
 
364
322
  **Produces:** SIMPLIFY_OUTPUT
365
323
  **Requires:** FILES_CHANGED
366
324
 
367
- After validation passes, spawn Simplify agent to polish the code:
325
+ After the Code agent completes, spawn Simplify agent to polish the code. The Phase 6 Validate covers its commits.
368
326
 
369
327
  ```
370
328
  Agent(subagent_type="Simplify"):
371
329
  "Simplify recently implemented code
372
330
  Task: {task description}
373
331
  FILES_CHANGED: {list of files from Code agent output}
374
- Focus on code modified by Code agent, apply project standards, enhance clarity"
332
+ Focus on code modified by Code agent, apply project standards, enhance clarity
333
+ Commit any improvements with a conventional-commit message."
375
334
  ```
376
335
 
377
- ### Phase 5: Self-Review
336
+ ### Phase 4: Self-Review
378
337
 
379
338
  **Produces:** SCRUTINIZE_OUTPUT
380
339
  **Requires:** FILES_CHANGED
381
340
 
382
- After Simplify agent completes, spawn Scrutinize agent as final quality gate:
341
+ After Simplify agent completes, spawn Scrutinize agent as the quality gate:
383
342
 
384
343
  ```
385
344
  Agent(subagent_type="Scrutinize"):
@@ -390,32 +349,14 @@ FEATURE_KNOWLEDGE: {feature_knowledge}
390
349
  Evaluate 9 pillars, fix P0/P1 issues, report status"
391
350
  ```
392
351
 
393
- If Scrutinize agent returns BLOCKED, report to user and halt.
352
+ Scrutinize agent reports `### Status: PASS | FIXED | BLOCKED`. **If BLOCKED:** report to user and halt. **If PASS or FIXED:** continue to Phase 5. A FIXED status commits fixes and starts no Validate of its own: the Phase 6 run covers them.
394
353
 
395
- ### Phase 6: Re-Validate (if Scrutinize agent made changes)
396
-
397
- **Produces:** REVALIDATION_RESULT
398
- **Requires:** SCRUTINIZE_OUTPUT
399
-
400
- If Scrutinize agent made code changes (status: FIXED), spawn Validate agent to verify:
401
-
402
- ```
403
- Agent(subagent_type="Validate"):
404
- "FILES_CHANGED: {files modified by Scrutinize agent}
405
- VALIDATION_SCOPE: changed-only
406
- Verify Scrutinize agent's fixes didn't break anything."
407
- ```
408
-
409
- **If FAIL:** Report to user - Scrutinize agent broke tests, needs manual intervention.
410
-
411
- **If PASS:** append a `gate:validate` claim (Phase 3's **Evidence claims**), then continue to Phase 7.
412
-
413
- ### Phase 7: Alignment Check
354
+ ### Phase 5: Alignment Check
414
355
 
415
356
  **Produces:** ALIGNMENT_RESULT
416
357
  **Requires:** FILES_CHANGED, EXECUTION_PLAN
417
358
 
418
- After Scrutinize agent passes (and re-validation if needed), spawn Evaluate agent to validate alignment:
359
+ After Scrutinize agent passes, spawn Evaluate agent to validate alignment. Evaluate agent receives `FEATURE_KNOWLEDGE` as acceptance context only; pattern and anti-pattern judgments belong to Scrutinize agent:
419
360
 
420
361
  ```
421
362
  Agent(subagent_type="Evaluate"):
@@ -427,7 +368,7 @@ FEATURE_KNOWLEDGE: {feature_knowledge}
427
368
  Validate alignment with request and plan. Report ALIGNED or MISALIGNED with details."
428
369
  ```
429
370
 
430
- **If ALIGNED:** Continue to Phase 8
371
+ **If ALIGNED:** Continue to Phase 6
431
372
 
432
373
  **If MISALIGNED:**
433
374
  1. Extract misalignment details from Evaluate agent output
@@ -436,9 +377,9 @@ Validate alignment with request and plan. Report ALIGNED or MISALIGNED with deta
436
377
  - Spawn Code agent to fix misalignments:
437
378
  ```
438
379
  Agent(subagent_type="Code"):
439
- "TASK_ID: {task-id}
380
+ "OPERATION: alignment-fix
381
+ TASK_ID: {task-id}
440
382
  TASK_DESCRIPTION: Fix alignment issues
441
- OPERATION: alignment-fix
442
383
  MISALIGNMENTS: {structured misalignments from Evaluate agent}
443
384
  SCOPE: Fix only the listed misalignments, no other changes
444
385
  CREATE_PR: false
@@ -446,22 +387,62 @@ Validate alignment with request and plan. Report ALIGNED or MISALIGNED with deta
446
387
  ISSUE_PR_LINK: {ISSUE_PR_LINK captured in Phase 1, or (none)}
447
388
  COMPLIANCE_FRAMEWORKS: {COMPLIANCE_FRAMEWORKS}"
448
389
  ```
449
- - Spawn Validate agent to verify fix didn't break tests:
390
+ - Loop back to Phase 5 (re-check alignment). The fix is not validated here: the Phase 6 run covers it.
391
+ 4. If `alignment_fix_count > 2`: Report misalignments to user for decision
392
+
393
+ ### Phase 6: Validate
394
+
395
+ **Produces:** VALIDATION_RESULT, VALIDATED_HEAD
396
+ **Requires:** BASE_BRANCH
397
+
398
+ Validate takes the one full-suite slot, after every commit it must cover: Code, Simplify, Scrutinize and the alignment fixes. After Evaluate agent passes, spawn Validate agent. `FILES_CHANGED` is the branch diff, because the Code agent's own list misses the Simplify, Scrutinize and fix commits (`{base}` is `BASE_BRANCH`):
399
+
400
+ ```
401
+ Agent(subagent_type="Validate"):
402
+ "FILES_CHANGED: {output of `git diff --name-only {base}...HEAD`}
403
+ VALIDATION_SCOPE: full
404
+ Run build, typecheck, lint, test. Report pass/fail with failure details."
405
+ ```
406
+
407
+ **If FAIL:**
408
+ 1. Extract failure details from Validate agent output
409
+ 2. Increment `validation_retry_count`
410
+ 3. If `validation_retry_count <= 2`:
411
+ - Spawn Code agent with fix context:
450
412
  ```
451
- Agent(subagent_type="Validate"):
452
- "FILES_CHANGED: {files modified by fix Code agent}
453
- VALIDATION_SCOPE: changed-only"
413
+ Agent(subagent_type="Code"):
414
+ "OPERATION: validation-fix
415
+ TASK_ID: {task-id}
416
+ TASK_DESCRIPTION: Fix validation failures
417
+ VALIDATION_FAILURES: {parsed failures from Validate agent}
418
+ SCOPE: Fix only the listed failures, no other changes
419
+ CREATE_PR: false
420
+ ISSUE_NUMBER: {ISSUE_ID captured in Phase 1, or (none)}
421
+ ISSUE_PR_LINK: {ISSUE_PR_LINK captured in Phase 1, or (none)}
422
+ COMPLIANCE_FRAMEWORKS: {COMPLIANCE_FRAMEWORKS}"
454
423
  ```
455
- - If Validate agent FAIL: Report to user
456
- - If Validate agent PASS: Loop back to Phase 7 (re-check alignment)
457
- 4. If `alignment_fix_count > 2`: Report misalignments to user for decision
424
+ - Loop back to Phase 6 (re-validate at the new HEAD, full scope)
425
+ 4. If `validation_retry_count > 2`: Report failures to user and halt
426
+
427
+ **If PASS:** append a `gate:validate` claim, run `git rev-parse HEAD` and record the result as `VALIDATED_HEAD`, then continue to Phase 7.
458
428
 
459
- ### Phase 8: QA Testing
429
+ **Evidence claims** are lines appended to the `## Claims` section of `EVIDENCE_FILE` — the file's last section, created when absent. Append only: never edit or remove a claim; the last valid one per target wins. Each line takes exactly one of these shapes, where `<head>` is the 40-hex `HEAD:` the agent's report shows:
430
+
431
+ ```
432
+ - gate:validate PASS sha:<head> by:validate
433
+ - TP-<n> <PASS|FAIL|SKIP> sha:<head> by:test exit:<0-255>
434
+ ```
435
+
436
+ - `gate:validate` — after a Phase 6 or Phase 8 PASS.
437
+ - `TP-<n>` — after every Phase 7 run, one line per `### Test Plan Evidence` row whose TP is in `TEST_PLAN`, with the row's outcome; the line ends at `by:test` when the row's Exit is not a number from 0 to 255.
438
+ - Append nothing from a report whose `HEAD:` is not a single 40-hex SHA — a reported before/after change included — and say so in the Phase 11 report.
439
+
440
+ ### Phase 7: QA Testing
460
441
 
461
442
  **Produces:** QA_RESULT
462
- **Requires:** FILES_CHANGED, EXECUTION_PLAN, TEST_PLAN
443
+ **Requires:** FILES_CHANGED, EXECUTION_PLAN, TEST_PLAN, VALIDATED_HEAD
463
444
 
464
- After Evaluate agent passes, spawn Test agent for scenario-based acceptance testing:
445
+ After Phase 6 passes, spawn Test agent for scenario-based acceptance testing:
465
446
 
466
447
  ```
467
448
  Agent(subagent_type="Test"):
@@ -473,9 +454,9 @@ TEST_PLAN: {the TP lines of the evidence file's ## Test Plan section, or (none)}
473
454
  Design and execute scenario-based acceptance tests. Report PASS or FAIL with evidence."
474
455
  ```
475
456
 
476
- After every Test agent run — PASS or FAIL, first run or retry — append its TP claims (Phase 3's **Evidence claims**).
457
+ After every Test agent run — PASS or FAIL, first run or retry — append its TP claims (Phase 6's **Evidence claims**).
477
458
 
478
- **If PASS:** Continue to Phase 9
459
+ **If PASS:** Continue to Phase 8
479
460
 
480
461
  **If FAIL:**
481
462
  1. Extract failure details from Test agent output
@@ -484,9 +465,9 @@ After every Test agent run — PASS or FAIL, first run or retry — append its T
484
465
  - Spawn Code agent to fix QA failures:
485
466
  ```
486
467
  Agent(subagent_type="Code"):
487
- "TASK_ID: {task-id}
468
+ "OPERATION: qa-fix
469
+ TASK_ID: {task-id}
488
470
  TASK_DESCRIPTION: Fix QA test failures
489
- OPERATION: qa-fix
490
471
  QA_FAILURES: {structured failures from Test agent}
491
472
  SCOPE: Fix only the listed failures, no other changes
492
473
  CREATE_PR: false
@@ -494,15 +475,26 @@ After every Test agent run — PASS or FAIL, first run or retry — append its T
494
475
  ISSUE_PR_LINK: {ISSUE_PR_LINK captured in Phase 1, or (none)}
495
476
  COMPLIANCE_FRAMEWORKS: {COMPLIANCE_FRAMEWORKS}"
496
477
  ```
497
- - Spawn Validate agent to verify fix didn't break tests:
498
- ```
499
- Agent(subagent_type="Validate"):
500
- "FILES_CHANGED: {files modified by fix Code agent}
501
- VALIDATION_SCOPE: changed-only"
502
- ```
503
- - If Validate agent FAIL: Report to user
504
- - If Validate agent PASS: Loop back to Phase 8 (re-run Test agent)
505
- 4. If `qa_retry_count > 2`: Report QA failures to user for decision
478
+ - Loop back to Phase 7 (re-run Test agent). The fix is not validated here: Phase 8 covers it.
479
+ 4. If `qa_retry_count > 2`: Report QA failures to user for decision. The run stops at the report (Phase 11), so Phases 8 and 9 do not run.
480
+
481
+ ### Phase 8: Re-Validate (only if a qa-fix committed)
482
+
483
+ **Produces:** REVALIDATION_RESULT
484
+ **Requires:** QA_RESULT, VALIDATED_HEAD
485
+
486
+ Run this phase only if a qa-fix committed (`git rev-parse HEAD` differs from `VALIDATED_HEAD`); otherwise skip it and continue to Phase 9. Spawn Validate agent over what changed since the Phase 6 run:
487
+
488
+ ```
489
+ Agent(subagent_type="Validate"):
490
+ "FILES_CHANGED: {output of `git diff --name-only VALIDATED_HEAD..HEAD`}
491
+ VALIDATION_SCOPE: changed-only
492
+ Verify the qa-fix commits did not break anything."
493
+ ```
494
+
495
+ **If FAIL:** Report the failures to user and halt.
496
+
497
+ **If PASS:** append a `gate:validate` claim (Phase 6's **Evidence claims**), then continue to Phase 9.
506
498
 
507
499
  ### Phase 9: CI Status Gate
508
500
 
@@ -511,14 +503,22 @@ After every Test agent run — PASS or FAIL, first run or retry — append its T
511
503
 
512
504
  Strategy-conditional: run when the PR already exists — **SINGLE_CODE_AGENT** and **SEQUENTIAL_CODE_AGENTS** (the Phase 2 Code agent with `CREATE_PR: true` creates it); skip for **PARALLEL_CODE_AGENTS** (its unified PR is created in Phase 10).
513
505
 
506
+ **Push first, outside the gate block.** The gate reads CI for the pushed head, and the Simplify, Scrutinize and fix commits reach the PR only by a push. Push once — never force, and no retry:
507
+
508
+ ```bash
509
+ git push origin HEAD; echo "exit=$?"
510
+ ```
511
+
512
+ `exit=0` continues to the gate. Any other result, a rejected non-fast-forward push included, records `TRACEABILITY: DEGRADED (ci push failed)` for the Phase 11 report, reports "CI status unknown — verify manually before merging" and proceeds to Phase 10 without waiting. `PR_NUMBER` is the number in `PR_URL`.
513
+
514
514
  <!-- PATTERN: ci-status-gate -->
515
- 1. Spawn `Agent(subagent_type="Git")` with `OPERATION: check-ci-status` and `PR_NUMBER` from PR_URL.
515
+ 1. Wait: run `cd {worktree} && HEAD_SHA=$(git rev-parse HEAD) && node "$HOME/.devflow/scripts/ci-wait.cjs" --pr {PR_NUMBER} --head "$HEAD_SHA"` through the Bash tool with `timeout: 600000`. Each run is one wait of at most 570 seconds and prints one line, `CI <STATUS> pr=… head=… failing=… pending=… waited=…` (INDETERMINATE adds `reason=…`). A missing or unparseable line, a status outside the six below, or a non-zero exit is INDETERMINATE.
516
516
  2. **If PASSING** → proceed to Phase 10.
517
517
  3. **If NO_PR or NO_CI** → skip: "No PR/CI configured, skipping CI validation." Proceed to Phase 10.
518
- 4. **If PENDING** → poll every 60 seconds (global budget, see step 7). Re-spawn Git agent each poll. If PASSING → proceed. If still PENDING after budget exhausted → report "CI still running — verify manually before merging" and proceed.
519
- 5. **If INDETERMINATE** → poll as PENDING within the same budget. If still INDETERMINATE after budget exhausted → report "CI status unknown — verify manually before merging" and proceed.
520
- 6. **If FAILING** → report failing checks. Spawn `Agent(subagent_type="Code")` with `COMPLIANCE_FRAMEWORKS` to fix CI failures based on check names and failure context. After fix, push and re-check. Max 2 fix attempts. If still failing → report failures and proceed.
521
- 7. **Total budget**: max 10 polls and max 2 fix attempts across all check/fix cycles combined. If budget exhausted, report current status and proceed.
518
+ 4. **If PENDING** and fewer than 3 waits have run → wait again (step 1). After the third wait → report "CI still running — verify manually before merging" and proceed.
519
+ 5. **If INDETERMINATE** and fewer than 3 waits have run → wait again (step 1). After the third wait → report "CI status unknown — verify manually before merging" and proceed.
520
+ 6. **If FAILING** and fewer than 2 fixes have run → report the failing checks from the line. Spawn `Agent(subagent_type="Code")` whose prompt opens with `OPERATION: ci-fix`, with `COMPLIANCE_FRAMEWORKS`, `CI_FAILURES` and `PUSH: false`; `CI_FAILURES` holds the failing-check names from the line and nothing else, because the Code agent fetches the full names and reads the logs itself and this command reads none. After a fix, push with the command above and, if a wait remains, wait again (step 1); a failed push records `TRACEABILITY: DEGRADED (ci push failed)`, reports "CI status unknown — verify manually before merging" and stops waiting. After the second fix still FAILING → report the failing checks and proceed.
521
+ 7. **Budget**: at most 3 waits and 2 fixes in all. When one is spent, report the current status and proceed.
522
522
  <!-- /PATTERN: ci-status-gate -->
523
523
 
524
524
  ### Phase 10: Create PR
@@ -532,9 +532,9 @@ Strategy-conditional: run when the PR already exists — **SINGLE_CODE_AGENT** a
532
532
 
533
533
  ```
534
534
  Agent(subagent_type="Code"):
535
- "TASK_ID: {task-id}
535
+ "OPERATION: pr-create
536
+ TASK_ID: {task-id}
536
537
  TASK_DESCRIPTION: Create the unified PR for the parallel implementation
537
- OPERATION: pr-create
538
538
  BASE_BRANCH: {base branch}
539
539
  CREATE_PR: true
540
540
  PR_DESCRIPTION_GUIDANCE: {pr_description_guidance}
@@ -584,7 +584,7 @@ Display completion summary with phase status, PR info, and next steps.
584
584
 
585
585
  Show the test plan's evidence from Phase 10b: `Test plan: {VERIFIED-CI + ATTESTED-LOCAL}/{total} verified (VERIFIED-CI {n}, ATTESTED-LOCAL {n})`, read from the `EVIDENCE` line and never inferred, then its `**Body**:` / `**Comment**:` line verbatim. Without an `EVIDENCE` line, show `Test plan: evidence unavailable`; with no test plan, `Test plan: missing`.
586
586
 
587
- If any Git agent output emitted `TRACEABILITY: DEGRADED ({reason})` lines during the run, or Phase 10b's push recorded one, surface them verbatim in the report under a `### Traceability` subsection so the user can act on them.
587
+ If any Git agent output emitted `TRACEABILITY: DEGRADED ({reason})` lines during the run, or Phase 9's push or Phase 10b's push recorded one, surface them verbatim in the report under a `### Traceability` subsection so the user can act on them.
588
588
 
589
589
  If Phase 1 recorded an evidence exception, show its `## Evidence Exceptions` lines in the report.
590
590
 
@@ -609,30 +609,30 @@ If Phase 1 recorded an evidence exception, show its `## Evidence Exceptions` lin
609
609
  │ ├─ SEQUENTIAL_CODE_AGENTS (15%): N Code agents with handoff summaries
610
610
  │ └─ PARALLEL_CODE_AGENTS (5%): N Code agents in single message (rare)
611
611
  │
612
- ├─ Phase 3: Validate
613
- │ └─ Validate agent (build, typecheck, lint, test)
614
- │ └─ If FAIL: Code agent fix loop (max 2 retries) → re-validate
615
- │ └─ If PASS: gate:validate claim → evidence file
616
- │
617
- ├─ Phase 4: Simplify
612
+ ├─ Phase 3: Simplify
618
613
  │ └─ Simplify agent (refines code clarity and consistency)
619
614
  │
620
- ├─ Phase 5: Self-Review
621
- │ └─ Scrutinize agent (final quality gate, fixes P0/P1)
615
+ ├─ Phase 4: Self-Review
616
+ │ └─ Scrutinize agent (quality gate, fixes P0/P1; status PASS | FIXED | BLOCKED)
622
617
  │
623
- ├─ Phase 6: Re-Validate (if Scrutinize agent made changes)
624
- │ └─ Validate agent (verify Scrutinize agent fixes)
625
- │
626
- ├─ Phase 7: Alignment Check
618
+ ├─ Phase 5: Alignment Check
627
619
  │ └─ Evaluate agent (validates alignment - reports only, no fixes)
628
- │ └─ If MISALIGNED: Code agent fix loop (max 2 iterations) → Validate agent → re-check
620
+ │ └─ If MISALIGNED: Code agent fix loop (max 2 iterations) → re-check alignment
621
+ │
622
+ ├─ Phase 6: Validate (the one full-suite slot)
623
+ │ └─ Validate agent (build, typecheck, lint, test over the branch diff)
624
+ │ └─ If FAIL: Code agent fix loop (max 2 retries) → re-validate at the new HEAD
625
+ │ └─ If PASS: record VALIDATED_HEAD, gate:validate claim → evidence file
629
626
  │
630
- ├─ Phase 8: QA Testing
627
+ ├─ Phase 7: QA Testing
631
628
  │ └─ Test agent (scenario-based acceptance tests, TEST_PLAN) → one claim per TP row → evidence file
632
- │ └─ If FAIL: Code agent fix loop (max 2 retries) → Validate agent → re-test
629
+ │ └─ If FAIL: Code agent fix loop (max 2 retries) → re-test
630
+ │
631
+ ├─ Phase 8: Re-Validate (only if a qa-fix committed)
632
+ │ └─ Validate agent (changed-only over VALIDATED_HEAD..HEAD) → gate:validate claim
633
633
  │
634
634
  ├─ Phase 9: CI Status Gate (SINGLE_CODE_AGENT + SEQUENTIAL_CODE_AGENTS; skipped for PARALLEL_CODE_AGENTS)
635
- │ └─ Git agent (check-ci-status) → poll/fix cycle (10 polls + 2 fix budget)
635
+ │ └─ Push the branch, then ci-wait.cjs (inline, one wait ≤ 570 s) → Code agent on FAILING (3 waits + 2 fixes)
636
636
  │
637
637
  ├─ Phase 10: Create PR (if needed)
638
638
  │ └─ SINGLE_CODE_AGENT: already created by the Phase 2 Code agent
@@ -651,7 +651,7 @@ If Phase 1 recorded an evidence exception, show its `## Evidence Exceptions` lin
651
651
 
652
652
  ## Principles
653
653
 
654
- 1. **Orchestration only** - Command spawns agents, never does work itself
654
+ 1. **Orchestration only** - Command spawns agents, never does work itself; the inline calls are the bounded plumbing the charter allows: the Phase 9 and Phase 10b pushes, the Phase 9 ci-wait call and the evidence script checks
655
655
  2. **Plan-first** - Plan documents from `/plan` skip exploration/planning overhead entirely
656
656
  3. **Coherence-first** - Single Code agent produces more consistent code (default ~80% of tasks)
657
657
  4. **Agent ownership** - Each agent owns its output completely
@@ -661,7 +661,7 @@ If Phase 1 recorded an evidence exception, show its `## Evidence Exceptions` lin
661
661
  8. **Strict delegation** - Never perform agent work in main session. "Spawn X" means call Agent tool with X, not do X's work yourself
662
662
  9. **Validate agent owns validation** - Never run `npm test`, `npm run build`, or similar in main session; always delegate to Validate agent
663
663
  10. **Code agent owns fixes** - Never implement fixes in main session; spawn Code agent for validation failures and alignment fixes
664
- 11. **Loop limits** - Max 2 validation retries, max 2 alignment fix iterations before escalating to user
664
+ 11. **Loop limits** - Max 2 validation retries, max 2 alignment fix iterations, max 2 QA retries before escalating to user; the CI gate allows at most 3 waits and 2 fixes
665
665
  12. **CI awareness** - CI status is checked before merge for SINGLE_CODE_AGENT and SEQUENTIAL_CODE_AGENTS, whose PR exists from Phase 2; skipped for PARALLEL_CODE_AGENTS, whose PR is created in Phase 10; test-plan evidence (Phase 10b) is recorded under every strategy once the PR exists
666
666
 
667
667
  ## Error Handling
@@ -30,7 +30,7 @@ Process issues from code review reports: triage every issue through the blast-ra
30
30
 
31
31
  1. **Discover resolvable worktrees** using the `devflow:worktree-support` skill discovery algorithm:
32
32
  - Run `git worktree list --porcelain` → parse, filter (skip protected/detached/mid-rebase), dedup by branch, sort by recent commit
33
- - See the `devflow:worktree-support` skill for the full 7-step algorithm and canonical protected branch list
33
+ - Invoke the `devflow:worktree-support` skill, then Read its `references/discovery.md` from the skill's base directory for the full 7-step algorithm; the canonical protected branch list stays in the skill
34
34
  - Additional filter: must have unresolved reviews (latest review directory has no `resolution-summary.md`)
35
35
  2. **If `--path` flag provided:** use only that worktree, skip discovery
36
36
  **`--path` validation**: Before proceeding, verify the path exists as a directory and appears in `git worktree list` output. If not: report error and stop.
@@ -216,8 +216,8 @@ For each batch, spawn Code agent with `OPERATION: issue-fix` and `PUSH: false`:
216
216
 
217
217
  ```
218
218
  Agent(subagent_type="Code"):
219
- "TASK_ID: resolve-{batch-id}
220
- OPERATION: issue-fix
219
+ "OPERATION: issue-fix
220
+ TASK_ID: resolve-{batch-id}
221
221
  ISSUES: {fix_now_issues_in_batch}
222
222
  SCOPE: {risk_tier_per_issue}
223
223
  PUSH: false
@@ -262,7 +262,8 @@ Agent(subagent_type="Simplify", run_in_background=false):
262
262
  "TASK_DESCRIPTION: Issue resolution fixes
263
263
  WORKTREE_PATH: {worktree_path} (omit if cwd)
264
264
  FILES_CHANGED: {list of files modified by Code agents}
265
- Simplify and refine the fixes for clarity and consistency"
265
+ Simplify and refine the fixes for clarity and consistency
266
+ Commit any improvements with a conventional-commit message."
266
267
  ```
267
268
 
268
269
  ### Phase 7: Verification Gate
@@ -290,8 +291,8 @@ Run build, typecheck, lint, test. Report pass/fail with failure details."
290
291
  - Spawn Code agent with fix context:
291
292
  ```
292
293
  Agent(subagent_type="Code"):
293
- "TASK_ID: resolve-{batch-id}-valfix-{count}
294
- OPERATION: validation-fix
294
+ "OPERATION: validation-fix
295
+ TASK_ID: resolve-{batch-id}-valfix-{count}
295
296
  VALIDATION_FAILURES: {parsed failures from Validate agent}
296
297
  SCOPE: Fix only the listed failures, no other changes
297
298
  PUSH: false
@@ -329,14 +330,24 @@ If `fork_no_push` is set → skip: "Cannot push to fork — skipping CI validati
329
330
 
330
331
  Otherwise, for each worktree with fixes:
331
332
 
332
- <!-- PATTERN: ci-status-gate — shared polling/classification/budget logic; context-specific preamble lives outside this block -->
333
- 1. Spawn `Agent(subagent_type="Git")` with `OPERATION: check-ci-status` and `WORKTREE_PATH`.
333
+ `PR_NUMBER` is the worktree's `pr_number` from Phase 0; when it is absent, skip: "No PR/CI configured, skipping CI validation."
334
+
335
+ **Push first, outside the gate block.** The gate waits on the pushed head, so push once more with the gate's own command — never forced, and no retry:
336
+
337
+ ```bash
338
+ git -C {worktree} push; echo "exit=$?"
339
+ ```
340
+
341
+ Phase 7 has pushed already, so this is a no-op unless the head moved since. `exit=0` continues to the gate. Any other result records `TRACEABILITY: DEGRADED (ci push failed)`, reports "CI status unknown — verify manually before merging" and skips the wait for this worktree. Pass `WORKTREE_PATH: {worktree_path}` on the fix spawn below.
342
+
343
+ <!-- PATTERN: ci-status-gate -->
344
+ 1. Wait: run `cd {worktree} && HEAD_SHA=$(git rev-parse HEAD) && node "$HOME/.devflow/scripts/ci-wait.cjs" --pr {PR_NUMBER} --head "$HEAD_SHA"` through the Bash tool with `timeout: 600000`. Each run is one wait of at most 570 seconds and prints one line, `CI <STATUS> pr=… head=… failing=… pending=… waited=…` (INDETERMINATE adds `reason=…`). A missing or unparseable line, a status outside the six below, or a non-zero exit is INDETERMINATE.
334
345
  2. **If PASSING** → proceed to next phase.
335
346
  3. **If NO_PR or NO_CI** → skip: "No PR/CI configured, skipping CI validation." Proceed to next phase.
336
- 4. **If PENDING** → poll every 60 seconds (global budget, see step 7). Re-spawn Git agent each poll. If PASSING → proceed. If still PENDING after budget exhausted → report "CI still running — verify manually before merging" and proceed.
337
- 5. **If INDETERMINATE** → poll as PENDING within the same budget. If still INDETERMINATE after budget exhausted → report "CI status unknown — verify manually before merging" and proceed.
338
- 6. **If FAILING** → report failing checks. Spawn `Agent(subagent_type="Code")` with `COMPLIANCE_FRAMEWORKS` to fix CI failures based on check names and failure context. After fix, push and re-check. Max 2 fix attempts. If still failing → report failures and proceed.
339
- 7. **Total budget**: max 10 polls and max 2 fix attempts across all check/fix cycles combined. If the budget is exhausted, report current status and proceed.
347
+ 4. **If PENDING** and fewer than 3 waits have run → wait again (step 1). After the third wait → report "CI still running — verify manually before merging" and proceed.
348
+ 5. **If INDETERMINATE** and fewer than 3 waits have run → wait again (step 1). After the third wait → report "CI status unknown — verify manually before merging" and proceed.
349
+ 6. **If FAILING** and fewer than 2 fixes have run → report the failing checks from the line. Spawn `Agent(subagent_type="Code")` whose prompt opens with `OPERATION: ci-fix`, with `COMPLIANCE_FRAMEWORKS`, `CI_FAILURES` and `PUSH: false`; `CI_FAILURES` holds the failing-check names from the line and nothing else, because the Code agent fetches the full names and reads the logs itself and this command reads none. After a fix, push with the command above and, if a wait remains, wait again (step 1); a failed push records `TRACEABILITY: DEGRADED (ci push failed)`, reports "CI status unknown — verify manually before merging" and stops waiting. After the second fix still FAILING → report the failing checks and proceed.
350
+ 7. **Budget**: at most 3 waits and 2 fixes in all, per worktree. When one is spent, report the current status and proceed.
340
351
  <!-- /PATTERN: ci-status-gate -->
341
352
 
342
353
  ### Phase 9: Manage Debt (Sequential)
@@ -369,7 +380,7 @@ After manage-debt completes:
369
380
 
370
381
  **Step 9b-0: Re-verify stale test-plan items**
371
382
 
372
- Run this step only when this run's Phase 7 push succeeded — the one way /resolve moves the PR head — and a PR is known; otherwise skip it and Step 9b-3, and record `STALE_REVERIFICATION` as `SKIPPED (head unchanged)`. Detection needs no Git agent: from the worktree root, run the evidence script, which re-derives every test-plan state at the new head and writes the stale TP lines whose text the PR's trusted evidence record vouches for:
383
+ Run this step only when a push of this run succeeded — Phase 7's, or the push of Phase 8's gate — and a PR is known; otherwise skip it and Step 9b-3, and record `STALE_REVERIFICATION` as `SKIPPED (head unchanged)`. Detection needs no Git agent: from the worktree root, run the evidence script, which re-derives every test-plan state at the new head and writes the stale TP lines whose text the PR's trusted evidence record vouches for:
373
384
 
374
385
  ```bash
375
386
  cd {worktree} && node "$HOME/.devflow/scripts/verify-evidence.cjs" verify --pr {pr_number} --stale-out "{TARGET_DIR_REL}/stale-plan.md"; echo "exit=$?"
@@ -521,7 +532,7 @@ Final gate: {PASS | FAILED after N attempts}
521
532
  - Resolution comment: {POSTED | POSTED+TRUNCATED | SKIPPED (already posted) | SKIPPED (publication off) | SKIPPED (no PR) | DEGRADED (reason)}
522
533
  - Publication: {FULL (private repo) | FULL (config override) | STUB (public repository) | OFF (publication disabled by config) | STUB (visibility undeterminable) | STUB (evidence policy)}
523
534
  - Thread replies: {COMPLETE | PARTIAL | TRUNCATED | SKIPPED (reason) | DEGRADED (reason)}
524
- - Push: {pushed | skipped (no fixes) | skipped (cannot push to fork)}
535
+ - Push: {pushed (Phase 7, a CI-fix push, or both) | skipped (no fixes) | skipped (cannot push to fork) | DEGRADED (ci push failed)}
525
536
  - Test-plan re-verification: {Test plan: n stale, m re-verified | SKIPPED (head unchanged) | DEGRADED (reason)}
526
537
  - Test-plan evidence: {the EVIDENCE line's VERIFIED-CI + ATTESTED-LOCAL / total, then the Body / Comment line | SKIPPED (reason) | DEGRADED (reason)}
527
538
 
@@ -569,7 +580,7 @@ In multi-worktree mode, report results per worktree with aggregate summary.
569
580
  ├─ Phase 7: Verification Gate [Validate agent, haiku] + push + Code agent validation-fix loop ≤2
570
581
  │
571
582
  ├─ Phase 8: CI Status Gate (conditional — skipped if no fixes or verification FAILED)
572
- │ └─ Git agent (check-ci-status) → poll/fix loop
583
+ │ └─ push, then ci-wait.cjs (inline, one wait ≤ 570 s) → Code agent on FAILING (3 waits + 2 fixes per worktree)
573
584
  │
574
585
  ├─ Phase 9: Git agent (manage-debt) — FIX_SEPARATE + TECH_DEBT → backfill Tracked={ISSUE_REF} (or TRACEABILITY: DEGRADED on failure)
575
586
  │ SEQUENTIAL across worktrees
@@ -17,7 +17,7 @@ Run Simplify agent and Scrutinize agent sequentially on changed files for post-i
17
17
 
18
18
  ### Phase 0: Context Gathering
19
19
 
20
- **Produces:** FILES_CHANGED, TASK_DESCRIPTION, DECISIONS_CONTEXT, FEATURE_KNOWLEDGE
20
+ **Produces:** FILES_CHANGED, TASK_DESCRIPTION, DECISIONS_CONTEXT, FEATURE_KNOWLEDGE, HEAD_BEFORE
21
21
 
22
22
  Detect changed files and build context:
23
23
 
@@ -25,6 +25,7 @@ Detect changed files and build context:
25
25
  2. Else run `git diff --name-only HEAD` + `git diff --name-only --cached` to get staged + unstaged
26
26
  3. If no changes found, report "No changes to review" and exit
27
27
  4. Build TASK_DESCRIPTION from recent commit messages or branch name
28
+ 5. Record `HEAD_BEFORE` (`git rev-parse HEAD`) now, before Simplify runs — Phase 3 compares against it
28
29
  {{decisions_load()}}
29
30
 
30
31
  Pass `DECISIONS_CONTEXT` to Scrutinize agent — the compact index lists active ADR/PF entries; Scrutinize agent uses `devflow:apply-decisions` to Read full entry bodies on demand. Known pitfalls help identify reintroduced issues, prior decisions help validate architectural consistency. (Simplify agent does not consume decisions — it operates at code-shape level and Scrutinize agent runs after to catch any architectural drift.)
@@ -33,7 +34,7 @@ Pass `DECISIONS_CONTEXT` to Scrutinize agent — the compact index lists active
33
34
 
34
35
  Pass `FEATURE_KNOWLEDGE` to Scrutinize agent.
35
36
 
36
- **Extract:** FILES_CHANGED (list), TASK_DESCRIPTION (string), DECISIONS_CONTEXT (string, optional), FEATURE_KNOWLEDGE (string, optional)
37
+ **Extract:** FILES_CHANGED (list), TASK_DESCRIPTION (string), DECISIONS_CONTEXT (string, optional), FEATURE_KNOWLEDGE (string, optional), HEAD_BEFORE (40-hex SHA)
37
38
 
38
39
  ### Phase 1: Simplify agent (Code Refinement)
39
40
 
@@ -45,13 +46,14 @@ Spawn Simplify agent to refine code for clarity and consistency:
45
46
  Agent(subagent_type="Simplify", run_in_background=false):
46
47
  "TASK_DESCRIPTION: {task_description}
47
48
  FILES_CHANGED: {files_changed}
48
- Simplify and refine the code for clarity and consistency while preserving functionality."
49
+ Simplify and refine the code for clarity and consistency while preserving functionality.
50
+ Commit any improvements with a conventional-commit message."
49
51
 
50
52
  **Wait for completion.** Simplify agent commits changes directly.
51
53
 
52
54
  ### Phase 2: Scrutinize agent (9-Pillar Quality Gate)
53
55
 
54
- **Produces:** SCRUTINIZE_STATUS, SCRUTINIZE_CHANGES
56
+ **Produces:** SCRUTINIZE_STATUS
55
57
  **Requires:** FILES_CHANGED, TASK_DESCRIPTION, DECISIONS_CONTEXT
56
58
 
57
59
  Spawn Scrutinize agent for quality evaluation and fixing:
@@ -65,17 +67,19 @@ Evaluate against 9-pillar framework. Fix P0/P1 issues. Return structured report.
65
67
  Follow devflow:apply-decisions to scan DECISIONS_CONTEXT and Read full ADR/PF bodies on demand. Skip if (none).
66
68
  Follow devflow:apply-feature-knowledge for FEATURE_KNOWLEDGE. Skip if (none)."
67
69
 
68
- **Wait for completion.** Extract: STATUS (PASS|FIXED|BLOCKED), changes_made (bool)
70
+ **Wait for completion.** Extract: STATUS (PASS|FIXED|BLOCKED) from the `### Status` line
69
71
 
70
72
  ### Phase 3: Conditional Validation
71
73
 
72
74
  **Produces:** VALIDATION_RESULT
73
- **Requires:** SCRUTINIZE_CHANGES
75
+ **Requires:** HEAD_BEFORE, SCRUTINIZE_STATUS
74
76
 
75
- If Scrutinize agent made changes (STATUS == FIXED):
77
+ If STATUS is BLOCKED, skip this phase: the report (Phase 4) names the blocker.
78
+
79
+ Run this phase only if HEAD moved — `git rev-parse HEAD` differs from `HEAD_BEFORE`, meaning Simplify or Scrutinize committed (Simplify alone counts, whatever Scrutinize's STATUS is). Otherwise skip it. Its scope is changed-only over what the two agents changed:
76
80
 
77
81
  Agent(subagent_type="Validate", run_in_background=false):
78
- "FILES_CHANGED: {scrutinize_modified_files}
82
+ "FILES_CHANGED: {output of `git diff --name-only HEAD_BEFORE..HEAD`}
79
83
  VALIDATION_SCOPE: changed-only
80
84
  Run build, typecheck, lint, test on modified files"
81
85
 
@@ -122,6 +126,7 @@ Display summary:
122
126
  │
123
127
  ├─ Phase 0: Context gathering
124
128
  │ ├─ Git diff for changed files
129
+ │ ├─ Record HEAD_BEFORE
125
130
  │ └─ Read index.md → DECISIONS_CONTEXT
126
131
  │
127
132
  ├─ Phase 1: Simplify agent
@@ -131,7 +136,7 @@ Display summary:
131
136
  │ └─ 9-pillar quality gate (may fix and commit)
132
137
  │
133
138
  ├─ Phase 3: Validate agent (conditional)
134
- │ └─ If Scrutinize agent made changes, verify tests pass
139
+ │ └─ If HEAD moved since HEAD_BEFORE (Simplify or Scrutinize committed), changed-only Validate over HEAD_BEFORE..HEAD
135
140
  │
136
141
  └─ Phase 4: Report
137
142
  └─ Display summary with pillar status
@@ -150,6 +155,6 @@ Display summary:
150
155
 
151
156
  1. **Orchestration only** - Command spawns agents, doesn't do the work
152
157
  2. **Sequential execution** - Simplify agent must complete before Scrutinize agent
153
- 3. **Validation gate** - If Scrutinize agent changes code, must pass validation
158
+ 3. **Validation gate** - If Simplify agent or Scrutinize agent committed, the changes must pass validation
154
159
  4. **Honest reporting** - Display actual agent outputs
155
160
  5. **Fail fast** - Stop on BLOCKED or validation failure