devflow-kit 3.5.0 → 3.7.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 (146) hide show
  1. package/CHANGELOG.md +178 -1
  2. package/README.md +10 -6
  3. package/dist/agents/code.md +7 -11
  4. package/dist/agents/{diagnose.md → debug.md} +4 -4
  5. package/dist/agents/{code-fix.md → fix.md} +7 -8
  6. package/dist/agents/{scrutinize.md → harden.md} +6 -6
  7. package/dist/agents/{code-edit.md → refactor.md} +8 -9
  8. package/dist/agents/review.md +2 -0
  9. package/dist/cli/agents-view/render.js +1 -1
  10. package/dist/cli/commands/gates.js +276 -0
  11. package/dist/cli/commands/init-seed.js +9 -1
  12. package/dist/cli/commands/init.js +34 -11
  13. package/dist/cli/commands/learning.js +12 -12
  14. package/dist/cli/commands/legacy-hooks.js +1 -1
  15. package/dist/cli/commands/memory.js +18 -0
  16. package/dist/cli/commands/uninstall.js +111 -5
  17. package/dist/cli.js +2 -0
  18. package/dist/commands/bug-analysis.md +21 -17
  19. package/dist/commands/code-review.md +65 -66
  20. package/dist/commands/debug.md +17 -17
  21. package/dist/commands/dynamic-build.md +104 -116
  22. package/dist/commands/dynamic-plan.md +13 -11
  23. package/dist/commands/dynamic-profile.md +9 -7
  24. package/dist/commands/dynamic-tickets.md +13 -11
  25. package/dist/commands/explore.md +15 -15
  26. package/dist/commands/implement.md +80 -154
  27. package/dist/commands/plan.md +34 -66
  28. package/dist/commands/release.md +11 -7
  29. package/dist/commands/research.md +14 -10
  30. package/dist/commands/resolve.md +44 -88
  31. package/dist/commands/self-review.md +44 -44
  32. package/dist/core/agent-models.js +47 -11
  33. package/dist/core/{learning-tuning-config.js → curate-tuning-config.js} +14 -14
  34. package/dist/core/echo-value.js +42 -0
  35. package/dist/core/evidence-policy.js +17 -5
  36. package/dist/core/gate-level.js +213 -0
  37. package/dist/core/learning-queue-cleanup.js +1 -1
  38. package/dist/core/manifest.js +26 -10
  39. package/dist/core/migrations.js +63 -44
  40. package/dist/core/model-discovery.js +7 -1
  41. package/dist/core/plugins.js +14 -12
  42. package/dist/core/project-paths.js +3 -3
  43. package/dist/core/tracker.js +5 -33
  44. package/dist/hud/codex-usage.js +247 -0
  45. package/dist/hud/components/codex-quota.js +37 -0
  46. package/dist/hud/components/usage-quota.js +1 -1
  47. package/dist/hud/config.js +1 -0
  48. package/dist/hud/index.js +16 -3
  49. package/dist/hud/render.js +3 -1
  50. package/dist/learning-off/agents/code.md +7 -11
  51. package/dist/learning-off/agents/{diagnose.md → debug.md} +4 -4
  52. package/dist/learning-off/agents/{code-fix.md → fix.md} +7 -8
  53. package/dist/learning-off/agents/{scrutinize.md → harden.md} +6 -6
  54. package/dist/learning-off/agents/{code-edit.md → refactor.md} +8 -9
  55. package/dist/learning-off/agents/review.md +2 -0
  56. package/dist/learning-off/commands/bug-analysis.md +9 -9
  57. package/dist/learning-off/commands/code-review.md +54 -59
  58. package/dist/learning-off/commands/debug.md +6 -10
  59. package/dist/learning-off/commands/dynamic-build.md +98 -112
  60. package/dist/learning-off/commands/dynamic-plan.md +5 -5
  61. package/dist/learning-off/commands/dynamic-profile.md +1 -1
  62. package/dist/learning-off/commands/dynamic-tickets.md +5 -5
  63. package/dist/learning-off/commands/explore.md +4 -8
  64. package/dist/learning-off/commands/implement.md +68 -146
  65. package/dist/learning-off/commands/plan.md +23 -58
  66. package/dist/learning-off/commands/release.md +4 -2
  67. package/dist/learning-off/commands/research.md +2 -2
  68. package/dist/learning-off/commands/resolve.md +33 -81
  69. package/dist/learning-off/commands/self-review.md +32 -36
  70. package/dist/skills/git/references/pr/check-merge-readiness.md +2 -0
  71. package/dist/skills/git/references/pr/update-pr-evidence.md +4 -6
  72. package/dist/skills/git/references/tracker/github/ensure-pr-ready.md +7 -9
  73. package/dist/skills/git/references/tracker/jira/ensure-pr-ready.md +7 -15
  74. package/dist/skills/git/references/tracker/linear/ensure-pr-ready.md +7 -15
  75. package/dist/targets/claude-code/installer.js +117 -84
  76. package/dist/targets/claude-code/learning-install.js +15 -3
  77. package/dist/targets/claude-code/tracker-servers.js +1 -1
  78. package/package.json +1 -1
  79. package/src/assets/agents/_partials/_code.mds +7 -8
  80. package/src/assets/agents/code.mds +4 -7
  81. package/src/assets/agents/{learning.md → curate.md} +8 -10
  82. package/src/assets/agents/{diagnose.mds → debug.mds} +4 -4
  83. package/src/assets/agents/evaluate.md +4 -4
  84. package/src/assets/agents/{code-fix.mds → fix.mds} +5 -5
  85. package/src/assets/agents/{scrutinize.mds → harden.mds} +6 -6
  86. package/src/assets/agents/{simplify.md → polish.md} +4 -4
  87. package/src/assets/agents/{code-edit.mds → refactor.mds} +6 -6
  88. package/src/assets/agents/review.mds +2 -0
  89. package/src/assets/agents/synthesize.md +2 -2
  90. package/src/assets/agents/test.md +2 -2
  91. package/src/assets/commands/_partials/_compliance.mds +1 -1
  92. package/src/assets/commands/_partials/_decisions.mds +26 -6
  93. package/src/assets/commands/_partials/_engine.mds +15 -15
  94. package/src/assets/commands/_partials/_evidence_policy.mds +0 -17
  95. package/src/assets/commands/_partials/_knowledge.mds +14 -9
  96. package/src/assets/commands/_partials/_preamble.mds +4 -2
  97. package/src/assets/commands/_partials/_roster.mds +4 -4
  98. package/src/assets/commands/_partials/_settings.mds +2 -2
  99. package/src/assets/commands/_partials/_wave.mds +10 -17
  100. package/src/assets/commands/bug-analysis.mds +7 -7
  101. package/src/assets/commands/code-review.mds +51 -56
  102. package/src/assets/commands/debug.mds +2 -2
  103. package/src/assets/commands/dynamic-build.mds +67 -74
  104. package/src/assets/commands/implement.mds +65 -127
  105. package/src/assets/commands/plan.mds +21 -61
  106. package/src/assets/commands/release.mds +5 -1
  107. package/src/assets/commands/resolve.mds +28 -76
  108. package/src/assets/commands/self-review.mds +27 -27
  109. package/src/assets/mds/git/_ops_steps.mds +3 -3
  110. package/src/assets/mds/git/_pr.mds +6 -6
  111. package/src/assets/mds/tracker/_common.mds +23 -12
  112. package/src/assets/mds/tracker/_github.mds +2 -9
  113. package/src/assets/mds/tracker/_jira.mds +2 -15
  114. package/src/assets/mds/tracker/_linear.mds +2 -15
  115. package/src/assets/scripts/ci-wait.cjs +22 -4
  116. package/src/assets/scripts/claude-md-audit.cjs +66 -51
  117. package/src/assets/scripts/hooks/assets/orchestrator-charter.md +4 -3
  118. package/src/assets/scripts/hooks/background-memory-update +404 -95
  119. package/src/assets/scripts/hooks/capture-prompt +1 -1
  120. package/src/assets/scripts/hooks/capture-question +1 -1
  121. package/src/assets/scripts/hooks/capture-turn +1 -1
  122. package/src/assets/scripts/hooks/json-helper.cjs +13 -2
  123. package/src/assets/scripts/hooks/json-parse +18 -3
  124. package/src/assets/scripts/hooks/lib/learning-store.cjs +1 -1
  125. package/src/assets/scripts/hooks/lib/project-paths.cjs +4 -4
  126. package/src/assets/scripts/hooks/memory-permission +358 -0
  127. package/src/assets/scripts/hooks/preamble +1 -1
  128. package/src/assets/scripts/hooks/session-start-context +60 -47
  129. package/src/assets/scripts/hooks/session-start-memory +26 -5
  130. package/src/assets/scripts/lib/project-config.cjs +19 -4
  131. package/src/assets/scripts/resolve-settings.cjs +200 -32
  132. package/src/assets/scripts/verify-evidence.cjs +726 -9
  133. package/src/assets/skills/agent-references/SKILL.md +14 -6
  134. package/src/assets/skills/agent-references/references/commands/code-review-levels.md +19 -0
  135. package/src/assets/skills/agent-references/references/commands/implement-evidence-asks.md +35 -0
  136. package/src/assets/skills/agent-references/references/commands/implement-revalidate.md +15 -0
  137. package/src/assets/skills/agent-references/references/commands/plan-levels.md +40 -0
  138. package/src/assets/skills/agent-references/references/synthesize/bug-analysis.md +1 -1
  139. package/src/assets/skills/agent-references/references/synthesize/planning.md +9 -22
  140. package/src/assets/skills/agent-references/references/synthesize/review.md +11 -11
  141. package/src/assets/skills/apply-decisions/SKILL.md +6 -4
  142. package/src/assets/skills/docs-framework/SKILL.md +3 -3
  143. package/src/assets/skills/qa/SKILL.md +1 -1
  144. package/src/assets/skills/quality-gates/SKILL.md +7 -7
  145. package/src/assets/skills/quality-gates/references/report-template.md +7 -7
  146. /package/src/assets/skills/agent-references/references/{learning → curate}/maintain.md +0 -0
@@ -5,8 +5,6 @@ description: Unified design planning - combines requirements discovery, gap anal
5
5
 
6
6
  Orchestrate design planning from requirements discovery through gap analysis to implementation design. Produces a machine-readable design artifact consumed by `/implement`.
7
7
 
8
- The orchestrator only spawns agents and gates — all analytical work is done by agents.
9
-
10
8
  ## Usage
11
9
 
12
10
  ```
@@ -38,8 +36,6 @@ Note: a bare digit run is a reference **only** under `github`, and that adjudica
38
36
 
39
37
  ## Clarification Gates
40
38
 
41
- **MANDATORY**: Three gates that must complete before proceeding.
42
-
43
39
  | Gate | Phase | Purpose |
44
40
  |------|-------|---------|
45
41
  | Gate 0 | Phase 1 | Requirements discovery before exploration |
@@ -109,7 +105,7 @@ If the user says "skip" or "just proceed" — skip remaining questions, present
109
105
 
110
106
  #### Phase 2: Orient
111
107
 
112
- **Produces:** SKIM_CONTEXT, FEATURE_KNOWLEDGE, FEATURE_KNOWLEDGE_RULES
108
+ **Produces:** SKIM_CONTEXT, FEATURE_KNOWLEDGE, FEATURE_KNOWLEDGE_RULES, GATE_LEVEL
113
109
  **Requires:** CONFIRMED_SCOPE
114
110
 
115
111
  **Resolve the settings line** once per worktree root, reusing a line this run already resolved for the same root. `{root}` is the worktree the values are for — the repository root when the run has one worktree:
@@ -118,9 +114,9 @@ If the user says "skip" or "just proceed" — skip remaining questions, present
118
114
  node "$HOME/.devflow/scripts/resolve-settings.cjs" "{root}" 2>/dev/null; echo "exit=$?"
119
115
  ```
120
116
 
121
- Accept the output only when it is exactly two lines: `exit=0` last and, before it, one line of the form `TRACKER=<github|jira|linear> TRACKER_SOURCE=<project|personal|machine|default> TRACKER_WARN=<none|mismatch|invalid> SITE=<none|https://<host>> KEY=<none|<key>> REVIEW_PUBLICATION=<off|auto|full> COMPLIANCE=<off|generic|<id>[,<id>…]> MEMORY=<on|off> LEARNING=<on|off> KNOWLEDGE=<on|off>` — these fields, in this order, nothing else, where `<host>` is a lowercase dotted host name alone, `<key>` is 2–10 of `A-Z`, `0-9` and `_` starting with a letter, and each `<id>` is one of `gdpr`, `hipaa`, `pci-dss`, `soc2`, `iso-27001`, `sox`. **Anything else** (a non-zero exit, no line, extra text, or a missing, reordered or unlisted field or value) ⇒ use `TRACKER=github TRACKER_SOURCE=default TRACKER_WARN=invalid SITE=none KEY=none REVIEW_PUBLICATION=off COMPLIANCE=generic MEMORY=on LEARNING=on KNOWLEDGE=off` instead.
117
+ Accept the output only when it is exactly two lines: `exit=0` last and, before it, one line of the form `TRACKER=<github|jira|linear> TRACKER_SOURCE=<project|personal|machine|default> TRACKER_WARN=<none|mismatch|invalid> SITE=<none|https://<host>> KEY=<none|<key>> REVIEW_PUBLICATION=<off|auto|full> COMPLIANCE=<off|generic|<id>[,<id>…]> MEMORY=<on|off> LEARNING=<on|off> KNOWLEDGE=<on|off> GATE_LEVEL=<full|standard|lean>` — these fields, in this order, nothing else, where `<host>` is a lowercase dotted host name alone, `<key>` is 2–10 of `A-Z`, `0-9` and `_` starting with a letter, and each `<id>` is one of `gdpr`, `hipaa`, `pci-dss`, `soc2`, `iso-27001`, `sox`. **Anything else** (a non-zero exit, no line, extra text, or a missing, reordered or unlisted field or value) ⇒ use `TRACKER=github TRACKER_SOURCE=default TRACKER_WARN=invalid SITE=none KEY=none REVIEW_PUBLICATION=off COMPLIANCE=generic MEMORY=on LEARNING=on KNOWLEDGE=off GATE_LEVEL=full` instead.
122
118
 
123
- The accepted line is the only source of these values: the script alone folds the committed `.devflow/project.json`, the personal `.devflow/config.json` and the machine manifest.
119
+ The accepted line is the only source of these values.
124
120
 
125
121
  Spawn Skim agent for codebase context:
126
122
 
@@ -165,7 +161,7 @@ If `index.md` exists and contains at least one entry line, use it for relevance
165
161
 
166
162
  **Step 2 — Fallback: glob frontmatter (if `index.md` is absent or empty):**
167
163
 
168
- Glob `{worktree}/.devflow/features/*/KNOWLEDGE.md`. For each file found, read only its YAML frontmatter block (between the opening and closing `---` delimiters). The frontmatter fields `name`, `description`, and `directories` are the authoritative relevance surface — `index.md` is only a cache.
164
+ Glob `{worktree}/.devflow/features/*/KNOWLEDGE.md`. For each file found, read only its YAML frontmatter block (between the opening and closing `---` delimiters).
169
165
 
170
166
  **Step 3 — Pick relevant KBs:**
171
167
 
@@ -196,14 +192,20 @@ Headings: L5 Rules · L40 Overview · L62 Anti-Patterns · L118 Key Files
196
192
 
197
193
  A KB with no Rules section labels its entries `Rules ({section name}):` and gives them no ID. `FEATURE_KNOWLEDGE` is these blocks; `FEATURE_KNOWLEDGE_RULES` is the same blocks without the `Headings:` line. Both come from this one selection, and each spawn names the variable its recipient takes. If no KBs exist, no KBs are relevant, or `.devflow/features/` is absent, set both to `(none)`.
198
194
 
199
- **One git call, then direct reads — no `.cjs` script.** After resolving `{worktree}`, this step is 1 index read (or N frontmatter reads on fallback), plus one heading listing and one Rules read per selected KB, bounded by KB count.
195
+ **One git call, then direct reads — no `.cjs` script.**
200
196
 
201
197
  Pass `FEATURE_KNOWLEDGE` to Explore and Design agents.
202
198
 
199
+ **Gate level.** At `standard` or `lean`, once per run, run `d="${CLAUDE_CONFIG_DIR:-}"; case "$d" in /*) ;; *) d="$HOME/.claude" ;; esac; printf '%s\n' "$d"` in Bash and Read `<that directory>/skills/devflow:agent-references/references/commands/plan-levels.md` with the Read tool, and apply it to Phases 3-14.
200
+
201
+ - No row or rule overrides the next two lines.
202
+ - If the Read fails, or a row is missing or malformed, set `GATE_LEVEL` to `full` and say `level reference unreadable: full applied`.
203
+ - Security runs as its own Design spawn, and the design review runs, at every level and on every Revise pass.
204
+
203
205
  #### Phase 3: Explore Requirements (Parallel)
204
206
 
205
207
  **Produces:** EXPLORE_OUTPUTS
206
- **Requires:** SKIM_CONTEXT
208
+ **Requires:** SKIM_CONTEXT, GATE_LEVEL
207
209
 
208
210
  Spawn 4 `Agent(subagent_type="Explore")` agents **in a single message**, each with Skim agent context and `FEATURE_KNOWLEDGE: {feature_knowledge}` (from Phase 2). Include the instruction: "The FEATURE_KNOWLEDGE is a baseline — VALIDATE, EXTEND, and CORRECT it. For anything it already covers, cite its KB IDs (`{slug} KB-AP-n`) instead of restating the text. Focus on areas the feature knowledge doesn't cover and changes since it was last updated." Ask each agent for a final report of at most about 1,500 tokens: findings with file:line references, not file dumps.
209
211
 
@@ -219,8 +221,6 @@ Spawn 4 `Agent(subagent_type="Explore")` agents **in a single message**, each wi
219
221
  **Produces:** EXPLORATION_SYNTHESIS
220
222
  **Requires:** EXPLORE_OUTPUTS
221
223
 
222
- **WAIT** for Phase 3 to complete.
223
-
224
224
  ```
225
225
  Agent(subagent_type="Synthesize"):
226
226
  "Synthesize EXPLORATION outputs for: {feature/issues}
@@ -279,7 +279,7 @@ Agent(subagent_type="Design"):
279
279
  Focus: {completeness|architecture|security|performance|compliance|consistency|dependencies}
280
280
  FEATURE_KNOWLEDGE: {feature_knowledge}
281
281
  {COMPLIANCE_FOCUS_DIRECTIVE} (compliance focus only)
282
- Resolve `${CLAUDE_CONFIG_DIR:-$HOME/.claude}` in Bash, then Read `<that directory>/skills/devflow:gap-analysis/references/compliance.md` with the Read tool and apply it as your focus patterns. (compliance focus only)
282
+ Run `d="${CLAUDE_CONFIG_DIR:-}"; case "$d" in /*) ;; *) d="$HOME/.claude" ;; esac; printf '%s\n' "$d"` in Bash, then Read `<that directory>/skills/devflow:gap-analysis/references/compliance.md` with the Read tool and apply it as your focus patterns. (compliance focus only)
283
283
  Artifacts:
284
284
  Feature/Issues: {feature description or issue bodies}
285
285
  Exploration synthesis: {Phase 4 output}
@@ -293,8 +293,6 @@ Cite evidence from provided artifacts."
293
293
  **Produces:** GAP_SYNTHESIS
294
294
  **Requires:** GAP_OUTPUTS
295
295
 
296
- **WAIT** for Phase 5 to complete.
297
-
298
296
  ```
299
297
  Agent(subagent_type="Synthesize"):
300
298
  "Synthesize GAP ANALYSIS outputs for: {feature/issues}
@@ -355,8 +353,6 @@ Spawn 4 `Agent(subagent_type="Explore")` agents **in a single message**, each wi
355
353
  **Produces:** IMPL_EXPLORATION_SYNTHESIS
356
354
  **Requires:** IMPL_EXPLORE_OUTPUTS
357
355
 
358
- **WAIT** for Phase 8 to complete.
359
-
360
356
  ```
361
357
  Agent(subagent_type="Synthesize"):
362
358
  "Synthesize IMPLEMENTATION EXPLORATION outputs for: {feature/issues}
@@ -370,7 +366,7 @@ Combine into: patterns to follow, integration points, reusable code, edge cases"
370
366
  **Produces:** PLAN_OUTPUTS
371
367
  **Requires:** IMPL_EXPLORATION_SYNTHESIS, GAP_SYNTHESIS
372
368
 
373
- Spawn 3 Plan agents **in a single message**, each with implementation exploration synthesis. Ask each agent for a final report of at most about 1,500 tokens: the plan itself, not a restatement of the exploration.
369
+ Spawn 3 `Agent(subagent_type="Plan")` agents **in a single message**, each with implementation exploration synthesis. Ask each agent for a final report of at most about 1,500 tokens: the plan itself, not a restatement of the exploration.
374
370
 
375
371
  | Focus | Output |
376
372
  |-------|--------|
@@ -385,8 +381,6 @@ Implementation steps planner: include explicit gap mitigations (from Phase 6) in
385
381
  **Produces:** PLANNING_SYNTHESIS
386
382
  **Requires:** PLAN_OUTPUTS
387
383
 
388
- **WAIT** for Phase 10 to complete.
389
-
390
384
  ```
391
385
  Agent(subagent_type="Synthesize"):
392
386
  "Synthesize PLANNING outputs for: {feature/issues}
@@ -449,8 +443,9 @@ Use AskUserQuestion to present:
449
443
 
450
444
  User can:
451
445
  - **Accept** — proceed to output phases
452
- - **Revise** — re-run phases 10-12 with new constraints (loop back, no limit on revisions)
446
+ - **Revise** — when fewer than 2 revisions have run, re-run phases 10-12 with new constraints. Budget: at most 2 revisions, counted over the whole run
453
447
  - **Cancel** — stop gracefully, no artifact written
448
+ - **Restart /plan with these constraints** — offered in place of Revise once 2 revisions have run: stop gracefully, write no artifact, and print the constraints given so far for a fresh `/plan` run
454
449
 
455
450
  **MANDATORY**: Do not write design artifact until Gate 2 is confirmed.
456
451
 
@@ -586,6 +581,7 @@ Display completion summary:
586
581
  - Issue URL (if created or enriched) — and any `TRACEABILITY: DEGRADED ({reason})` lines from the Git agent
587
582
  - Gap analysis summary (N blocking, M should-address)
588
583
  - Design review summary (N anti-patterns found, M mitigated in plan)
584
+ - Gate level: {GATE_LEVEL}, with any level note
589
585
  - Suggested next step: `/implement {artifact-path}` or `/implement #{issue-number}`
590
586
 
591
587
  ---
@@ -597,75 +593,44 @@ Display completion summary:
597
593
  │
598
594
  ├─ Block 1: Requirements Discovery
599
595
  │ ├─ Phase 1: GATE 0 - Requirements Discovery ⛔ MANDATORY
596
+ │ │ ├─ Git agent (fetch-issue / fetch-issues-batch) - issue mode only
600
597
  │ │ └─ AskUserQuestion: Validate interpretation
601
598
  │ ├─ Phase 2: Orient
602
- │ │ └─ Skim agent (codebase context)
603
599
  │ ├─ Phase 3: Explore Requirements (PARALLEL)
604
- │ │ ├─ Explore: User perspective
605
- │ │ ├─ Explore: Similar features
606
- │ │ ├─ Explore: Constraints
607
- │ │ └─ Explore: Failure modes
608
600
  │ └─ Phase 4: Synthesize Exploration
609
- │ └─ Synthesize agent (mode: exploration)
610
601
  │
611
602
  ├─ Block 2: Gap Analysis
612
603
  │ ├─ Phase 5: Gap Analysis (PARALLEL)
613
- │ │ ├─ Design agent: completeness
614
- │ │ ├─ Design agent: architecture
615
- │ │ ├─ Design agent: security
616
- │ │ ├─ Design agent: performance
617
- │ │ ├─ Design agent: compliance (only when COMPLIANCE_ACTIVE)
618
- │ │ ├─ Design agent: consistency (multi-issue only)
619
- │ │ └─ Design agent: dependencies (multi-issue only)
620
604
  │ └─ Phase 6: Synthesize Gap Analysis
621
- │ └─ Synthesize agent (mode: design)
622
605
  │
623
606
  ├─ Block 3: Scope Approval
624
607
  │ └─ Phase 7: GATE 1 - Validate Scope + Gaps ⛔ MANDATORY
625
- │ └─ AskUserQuestion: Confirm scope and gap resolutions
626
608
  │
627
609
  ├─ Block 4: Implementation Design
628
610
  │ ├─ Phase 8: Explore Implementation (PARALLEL)
629
- │ │ ├─ Explore: Architecture
630
- │ │ ├─ Explore: Integration
631
- │ │ ├─ Explore: Reusable code
632
- │ │ └─ Explore: Edge cases
633
611
  │ ├─ Phase 9: Synthesize Implementation Exploration
634
- │ │ └─ Synthesize agent (mode: exploration)
635
612
  │ ├─ Phase 10: Plan Implementation (PARALLEL)
636
- │ │ ├─ Plan: Implementation steps
637
- │ │ ├─ Plan: Testing strategy
638
- │ │ └─ Plan: Execution strategy
639
613
  │ └─ Phase 11: Synthesize Planning
640
- │ └─ Synthesize agent (mode: planning)
641
614
  │
642
615
  ├─ Block 5: Design Review + Approval
643
616
  │ ├─ Phase 12: Design Review
644
- │ │ └─ Design agent (mode: design-review)
645
617
  │ └─ Phase 13: GATE 2 - Confirm Plan + Design Review ⛔ MANDATORY
646
- │ └─ AskUserQuestion: Final plan approval
618
+ │ └─ Revise ≤ 2 → back to Phase 10; after 2: Accept / Cancel / Restart /plan
647
619
  │
648
620
  ├─ Block 6: Output
649
621
  │ └─ Phase 14: Output
650
- │ ├─ Store design artifact ({worktree}/.devflow/docs/design/)
651
- │ ├─ Create tracker issue (optional)
652
- │ └─ Report summary + next step
622
+ │ └─ Git agent (ensure-traceable-issue) - create or enrich tracker issue (optional)
653
623
  │
654
624
  ```
655
625
 
656
626
  ## Principles
657
627
 
658
- 1. **Orchestration only** — Command spawns agents, never does agent work itself
659
- 2. **Three mandatory gates** — Gate 0 (understand), Gate 1 (scope+gaps), Gate 2 (plan+review); none may be skipped
660
- 3. **Parallel execution** — Explore phases and gap analysis run in parallel; synthesis phases wait
661
- 4. **Evidence-based gaps** — Every gap cites specific text; no speculation
662
- 5. **Scope ruthlessly** — Small, focused plans ship faster; gate 1 enforces scope discipline
663
- 6. **Strict delegation** — Never synthesize, analyze, or plan in main session; always spawn agents
664
- 7. **Design artifacts are machine-readable** — `/implement` can consume the YAML frontmatter directly
628
+ 1. **Scope ruthlessly** — Small, focused plans ship faster; gate 1 enforces scope discipline
629
+ 2. **Strict delegation** — Never synthesize, analyze, or plan in main session; always spawn agents
665
630
 
666
631
  ## Error Handling
667
632
 
668
633
  - If any agent fails, report the phase, agent type, and error
669
- - If user selects "Revise" at Gate 2, loop back to Phase 10 with user's constraints
634
+ - If user selects "Revise" at Gate 2 and fewer than 2 revisions have run, loop back to Phase 10 with user's constraints; after the second revision Gate 2 offers Accept, Cancel or "Restart /plan with these constraints" only
670
635
  - If user selects "Cancel" at any gate, stop gracefully without writing artifact
671
636
  - If `{worktree}/.devflow/docs/design/` does not exist, create it in Phase 14
@@ -74,7 +74,7 @@ If `index.md` exists and contains at least one entry line, use it for relevance
74
74
 
75
75
  **Step 2 — Fallback: glob frontmatter (if `index.md` is absent or empty):**
76
76
 
77
- Glob `{worktree}/.devflow/features/*/KNOWLEDGE.md`. For each file found, read only its YAML frontmatter block (between the opening and closing `---` delimiters). The frontmatter fields `name`, `description`, and `directories` are the authoritative relevance surface — `index.md` is only a cache.
77
+ Glob `{worktree}/.devflow/features/*/KNOWLEDGE.md`. For each file found, read only its YAML frontmatter block (between the opening and closing `---` delimiters).
78
78
 
79
79
  **Step 3 — Pick relevant KBs:**
80
80
 
@@ -105,7 +105,7 @@ Headings: L5 Rules · L40 Overview · L62 Anti-Patterns · L118 Key Files
105
105
 
106
106
  A KB with no Rules section labels its entries `Rules ({section name}):` and gives them no ID. `FEATURE_KNOWLEDGE` is these blocks; `FEATURE_KNOWLEDGE_RULES` is the same blocks without the `Headings:` line. Both come from this one selection, and each spawn names the variable its recipient takes. If no KBs exist, no KBs are relevant, or `.devflow/features/` is absent, set both to `(none)`.
107
107
 
108
- **One git call, then direct reads — no `.cjs` script.** After resolving `{worktree}`, this step is 1 index read (or N frontmatter reads on fallback), plus one heading listing and one Rules read per selected KB, bounded by KB count.
108
+ **One git call, then direct reads — no `.cjs` script.**
109
109
 
110
110
  Pass `FEATURE_KNOWLEDGE` only to agents whose contract declares it; the Validate and Git agents this command spawns do not.
111
111
 
@@ -201,10 +201,12 @@ Arm 1 or 2 ⇒ ask once, via AskUserQuestion: "{u} untraced commits{, coverage u
201
201
  ## Traceability exceptions
202
202
  - `untraced` <sha12> (<author>) self-attested by @<login> at <utc>: <reason>
203
203
  - `coverage` <bound-hit|trace-unavailable|gather-indeterminate|untraced-beyond-list> self-attested by @<login> at <utc>: <reason>
204
+
204
205
  Exempt (not attested): release <n> · revert <n> · bot <n> — <sha12>, …
205
206
  ```
206
207
 
207
208
  - One `untraced` line per listed untraced commit (≤100), its `<sha12>` and `<author>` copied from that `### TRACE_MAP` line. One `coverage` line per arm-1 cause — `bound-hit` for `bound:hit`, `gather-indeterminate` for status `INDETERMINATE` or none of the five, `trace-unavailable` for any other — plus `untraced-beyond-list` when an `…and <n> more` line closes the untraced list. The `Exempt` line counts each exempt kind (its listed lines plus its `…and <n> more`) and names every listed exempt SHA.
209
+ - A blank line separates the last bullet from the `Exempt` line, so Markdown renders that line as its own paragraph and not inside the bullet. Compose the block with that blank line every time.
208
210
  - `@<login>` is `@` followed by the output of `gh api user --jq .login` when that output matches `^[A-Za-z0-9][A-Za-z0-9-]{0,38}$`. On any other output, or a failed call, it is `(login unavailable)` instead, with no `@`.
209
211
  - `<utc>` is the output of `date -u +%Y-%m-%dT%H:%M:%SZ`.
210
212
  - `<reason>` is the user's own words, made inert: replace every character outside printable ASCII (newlines and tabs included) with a space, remove every `<`, `>`, `` ` ``, `[`, `]`, `\`, `/`, `#`, `@`, `&` and `$`, collapse runs of spaces, trim, keep the first 200 characters, and trim again. A reason that is empty after this is no reason.
@@ -63,7 +63,7 @@ If `index.md` exists and contains at least one entry line, use it for relevance
63
63
 
64
64
  **Step 2 — Fallback: glob frontmatter (if `index.md` is absent or empty):**
65
65
 
66
- Glob `{worktree}/.devflow/features/*/KNOWLEDGE.md`. For each file found, read only its YAML frontmatter block (between the opening and closing `---` delimiters). The frontmatter fields `name`, `description`, and `directories` are the authoritative relevance surface — `index.md` is only a cache.
66
+ Glob `{worktree}/.devflow/features/*/KNOWLEDGE.md`. For each file found, read only its YAML frontmatter block (between the opening and closing `---` delimiters).
67
67
 
68
68
  **Step 3 — Pick relevant KBs:**
69
69
 
@@ -94,7 +94,7 @@ Headings: L5 Rules · L40 Overview · L62 Anti-Patterns · L118 Key Files
94
94
 
95
95
  A KB with no Rules section labels its entries `Rules ({section name}):` and gives them no ID. `FEATURE_KNOWLEDGE` is these blocks; `FEATURE_KNOWLEDGE_RULES` is the same blocks without the `Headings:` line. Both come from this one selection, and each spawn names the variable its recipient takes. If no KBs exist, no KBs are relevant, or `.devflow/features/` is absent, set both to `(none)`.
96
96
 
97
- **One git call, then direct reads — no `.cjs` script.** After resolving `{worktree}`, this step is 1 index read (or N frontmatter reads on fallback), plus one heading listing and one Rules read per selected KB, bounded by KB count.
97
+ **One git call, then direct reads — no `.cjs` script.**
98
98
 
99
99
  Use `FEATURE_KNOWLEDGE` **locally** for research framing. Pass to each Research agent in Phase 4.
100
100
 
@@ -94,9 +94,9 @@ Set `TARGET_DIR` to the selected review or bug-analysis directory path, and `TAR
94
94
  node "$HOME/.devflow/scripts/resolve-settings.cjs" "{root}" 2>/dev/null; echo "exit=$?"
95
95
  ```
96
96
 
97
- Accept the output only when it is exactly two lines: `exit=0` last and, before it, one line of the form `TRACKER=<github|jira|linear> TRACKER_SOURCE=<project|personal|machine|default> TRACKER_WARN=<none|mismatch|invalid> SITE=<none|https://<host>> KEY=<none|<key>> REVIEW_PUBLICATION=<off|auto|full> COMPLIANCE=<off|generic|<id>[,<id>…]> MEMORY=<on|off> LEARNING=<on|off> KNOWLEDGE=<on|off>` — these fields, in this order, nothing else, where `<host>` is a lowercase dotted host name alone, `<key>` is 2–10 of `A-Z`, `0-9` and `_` starting with a letter, and each `<id>` is one of `gdpr`, `hipaa`, `pci-dss`, `soc2`, `iso-27001`, `sox`. **Anything else** (a non-zero exit, no line, extra text, or a missing, reordered or unlisted field or value) ⇒ use `TRACKER=github TRACKER_SOURCE=default TRACKER_WARN=invalid SITE=none KEY=none REVIEW_PUBLICATION=off COMPLIANCE=generic MEMORY=on LEARNING=on KNOWLEDGE=off` instead.
97
+ Accept the output only when it is exactly two lines: `exit=0` last and, before it, one line of the form `TRACKER=<github|jira|linear> TRACKER_SOURCE=<project|personal|machine|default> TRACKER_WARN=<none|mismatch|invalid> SITE=<none|https://<host>> KEY=<none|<key>> REVIEW_PUBLICATION=<off|auto|full> COMPLIANCE=<off|generic|<id>[,<id>…]> MEMORY=<on|off> LEARNING=<on|off> KNOWLEDGE=<on|off> GATE_LEVEL=<full|standard|lean>` — these fields, in this order, nothing else, where `<host>` is a lowercase dotted host name alone, `<key>` is 2–10 of `A-Z`, `0-9` and `_` starting with a letter, and each `<id>` is one of `gdpr`, `hipaa`, `pci-dss`, `soc2`, `iso-27001`, `sox`. **Anything else** (a non-zero exit, no line, extra text, or a missing, reordered or unlisted field or value) ⇒ use `TRACKER=github TRACKER_SOURCE=default TRACKER_WARN=invalid SITE=none KEY=none REVIEW_PUBLICATION=off COMPLIANCE=generic MEMORY=on LEARNING=on KNOWLEDGE=off GATE_LEVEL=full` instead.
98
98
 
99
- The accepted line is the only source of these values: the script alone folds the committed `.devflow/project.json`, the personal `.devflow/config.json` and the machine manifest.
99
+ The accepted line is the only source of these values.
100
100
 
101
101
  ### Load Feature Knowledge
102
102
 
@@ -120,7 +120,7 @@ If `index.md` exists and contains at least one entry line, use it for relevance
120
120
 
121
121
  **Step 2 — Fallback: glob frontmatter (if `index.md` is absent or empty):**
122
122
 
123
- Glob `{worktree}/.devflow/features/*/KNOWLEDGE.md`. For each file found, read only its YAML frontmatter block (between the opening and closing `---` delimiters). The frontmatter fields `name`, `description`, and `directories` are the authoritative relevance surface — `index.md` is only a cache.
123
+ Glob `{worktree}/.devflow/features/*/KNOWLEDGE.md`. For each file found, read only its YAML frontmatter block (between the opening and closing `---` delimiters).
124
124
 
125
125
  **Step 3 — Pick relevant KBs:**
126
126
 
@@ -151,7 +151,7 @@ Headings: L5 Rules · L40 Overview · L62 Anti-Patterns · L118 Key Files
151
151
 
152
152
  A KB with no Rules section labels its entries `Rules ({section name}):` and gives them no ID. `FEATURE_KNOWLEDGE` is these blocks; `FEATURE_KNOWLEDGE_RULES` is the same blocks without the `Headings:` line. Both come from this one selection, and each spawn names the variable its recipient takes. If no KBs exist, no KBs are relevant, or `.devflow/features/` is absent, set both to `(none)`.
153
153
 
154
- **One git call, then direct reads — no `.cjs` script.** After resolving `{worktree}`, this step is 1 index read (or N frontmatter reads on fallback), plus one heading listing and one Rules read per selected KB, bounded by KB count.
154
+ **One git call, then direct reads — no `.cjs` script.**
155
155
 
156
156
  Pass `FEATURE_KNOWLEDGE` to the Triage agent in Phase 2.
157
157
 
@@ -177,7 +177,7 @@ Resolve this per worktree — unlike the evidence policy above, the settings lin
177
177
 
178
178
  > When the task touches regulated surface (data models, auth flows, logging/observability, payments, IaC, retention), invoke Skill(skill="devflow:compliance") and load references/{id}.md only for the ids in <ids> (none: generic controls only); never fabricate guidance for a framework you were not given.
179
179
 
180
- Set it per worktree, from that worktree's lens, and pass that worktree's `COMPLIANCE_DIRECTIVE` to each of its Code and Code-fix spawns, on a line of its own.
180
+ Set it per worktree, from that worktree's lens, and pass that worktree's `COMPLIANCE_DIRECTIVE` to each of its Code and Fix spawns, on a line of its own.
181
181
 
182
182
  **Mint `RESOLUTION_TS` once per run:** `date -u +%Y-%m-%dT%H:%M:%SZ`. Every worktree reuses it — the resolution comment's dedup marker is searched per PR, so one run key keeps a retry of this run deduplicated while the next /resolve on the same PR posts. Phase 5 writes it as the summary's `**Date**:` and Phase 9b-2 passes it, so the local file and the posted marker agree.
183
183
 
@@ -308,7 +308,7 @@ Collect from each Code agent:
308
308
  **Produces:** RESOLUTION_FILE (early write for compaction safety)
309
309
  **Requires:** TRIAGE_RESULTS, CODE_AGENT_RESULTS, TARGET_DIR, TARGET_DIR_REL, BRANCH_INFO, RESOLUTION_TS
310
310
 
311
- **Immediately write `resolution-summary.md`** to `{TARGET_DIR}` using the Write tool. Do this now — not in Phase 9 — while results are fresh in context. This ensures the record is persisted even if later phases (Simplify, Verification Gate, CI gate, Tech Debt) trigger context compaction.
311
+ **Immediately write `resolution-summary.md`** to `{TARGET_DIR}` using the Write tool. Do this now — not in Phase 9 — while results are fresh in context. This ensures the record is persisted even if later phases (Polish, Verification Gate, CI gate, Tech Debt) trigger context compaction.
312
312
 
313
313
  Set `Tracked` for FIX_SEPARATE and TECH_DEBT items to `(pending)` — to be backfilled after Phase 9 manage-debt (or `TRACEABILITY: DEGRADED ({reason})` if manage-debt degrades).
314
314
 
@@ -316,19 +316,19 @@ DUPLICATE issues are listed **only** in `## Duplicates` — never in `## Fixed I
316
316
 
317
317
  Use the template from the Output Artifact section below.
318
318
 
319
- ### Phase 6: Simplify
319
+ ### Phase 6: Polish
320
320
 
321
- **Produces:** SIMPLIFICATION_RESULT
321
+ **Produces:** POLISH_RESULT
322
322
  **Requires:** CODE_AGENT_RESULTS
323
323
 
324
- If any fixes were made, spawn Simplify agent to refine the changed code:
324
+ If any fixes were made, spawn Polish agent to refine the changed code:
325
325
 
326
326
  ```
327
- Agent(subagent_type="Simplify", run_in_background=false):
327
+ Agent(subagent_type="Polish", run_in_background=false):
328
328
  "TASK_DESCRIPTION: Issue resolution fixes
329
329
  WORKTREE_PATH: {worktree_path} (omit if cwd)
330
330
  FILES_CHANGED: {list of files modified by Code agents}
331
- Simplify and refine the fixes for clarity and consistency
331
+ Polish and refine the fixes for clarity and consistency
332
332
  Commit any improvements with a conventional-commit message."
333
333
  ```
334
334
 
@@ -354,9 +354,9 @@ Run build, typecheck, lint, test. Report pass/fail with failure details."
354
354
  1. Extract failure details from Validate agent output
355
355
  2. Increment `validation_retry_count`
356
356
  3. If `validation_retry_count <= 2`:
357
- - Spawn Code-fix agent with fix context:
357
+ - Spawn Fix agent with fix context:
358
358
  ```
359
- Agent(subagent_type="Code-fix"):
359
+ Agent(subagent_type="Fix"):
360
360
  "OPERATION: validation-fix
361
361
  TASK_ID: resolve-{batch-id}-valfix-{count}
362
362
  VALIDATION_FAILURES: {parsed failures from Validate agent}
@@ -373,7 +373,7 @@ Run build, typecheck, lint, test. Report pass/fail with failure details."
373
373
  Record `## Verification` outcome in resolution-summary.md (runs unconditionally after the validation loop exits):
374
374
  - Rewrite the `## Verification` section with | Command | Result | table + `Final gate: PASS | FAILED after N attempts`
375
375
 
376
- Push all commits to remote once (Code and Code-fix agents ran with PUSH: false — runs whether the gate PASSED or FAILED, so the branch is always visible before Phase 9 or CI runs):
376
+ Push all commits to remote once (Code and Fix agents ran with PUSH: false — runs whether the gate PASSED or FAILED, so the branch is always visible before Phase 9 or CI runs):
377
377
  ```bash
378
378
  git -C {worktree} push
379
379
  ```
@@ -411,7 +411,7 @@ Phase 7 has pushed already, so this is a no-op unless the head moved since. `exi
411
411
  3. **If NO_PR or NO_CI** → skip: "No PR/CI configured, skipping CI validation." Proceed to next phase.
412
412
  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.
413
413
  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.
414
- 6. **If FAILING** and fewer than 2 fixes have run → report the failing checks from the line. Spawn `Agent(subagent_type="Code-fix")` whose prompt opens with `OPERATION: ci-fix`, with `COMPLIANCE_DIRECTIVE` (when it is not empty), `CI_FAILURES` and `PUSH: false`; `CI_FAILURES` holds the failing-check names from the line and nothing else, because the Code-fix 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.
414
+ 6. **If FAILING** and fewer than 2 fixes have run → report the failing checks from the line. Spawn `Agent(subagent_type="Fix")` whose prompt opens with `OPERATION: ci-fix`, with `COMPLIANCE_DIRECTIVE` (when it is not empty), `CI_FAILURES` and `PUSH: false`; `CI_FAILURES` holds the failing-check names from the line and nothing else, because the Fix 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.
415
415
  7. **Budget**: at most 3 waits and 2 fixes in all, per worktree. When one is spent, report the current status and proceed.
416
416
  <!-- /PATTERN: ci-status-gate -->
417
417
 
@@ -521,19 +521,13 @@ Capture the Git agent's `**Publication**:` and `**Status**:` lines as `PR_COMMEN
521
521
 
522
522
  **Step 9b-3: Refresh the test-plan evidence**
523
523
 
524
- Run this step only when Step 9b-0 ran — the head moved — and its `EVIDENCE` line did not read `total:0` with `exceptions:none` (nothing to record); otherwise record `EVIDENCE_REFRESH` as `SKIPPED ({reason})`. Spawn Git agent:
524
+ Run this step only when Step 9b-0 ran — the head moved — and its `EVIDENCE` line did not read `total:0` with `exceptions:none` (nothing to record); otherwise record `EVIDENCE_REFRESH` as `SKIPPED ({reason})`. Run the script inline — it is the whole `update-pr-evidence` operation, with no Git agent spawn — through the Bash tool with `timeout: 180000`:
525
525
 
526
- ```
527
- Agent(subagent_type="Git"):
528
- "OPERATION: update-pr-evidence
529
- PR_NUMBER: {pr_number}
530
- EVIDENCE_FILE: {TARGET_DIR_REL}/evidence.md
531
- REVIEW_PUBLICATION: {9b-2's publication mode}
532
- WORKTREE_PATH: {worktree_path} (omit if cwd)
533
- Refresh the PR's test-plan block and post its evidence comment."
526
+ ```bash
527
+ cd {worktree} && node "$HOME/.devflow/scripts/verify-evidence.cjs" publish --pr {pr_number} --evidence "{TARGET_DIR_REL}/evidence.md" --publication {9b-2's publication mode}; echo "exit=$?"
534
528
  ```
535
529
 
536
- Omit the `EVIDENCE_FILE` line when Step 9b-0 appended no claim. `REVIEW_PUBLICATION` is the mode 9b-2 reported on its `**Publication**:` line — `FULL…` → `full`, `STUB…` → `stub`, `OFF…` → `off` — else `{REVIEW_PUBLICATION}` as resolved in Step 0d. Capture its `EVIDENCE` line and its `**Body**:` / `**Comment**:` line, or its `TRACEABILITY: DEGRADED ({reason})` line, as `EVIDENCE_REFRESH`. It never blocks.
530
+ Drop the `--evidence` pair when Step 9b-0 appended no claim. Run it only when `TARGET_DIR_REL` matches `^[A-Za-z0-9._/-]+$` — it carries the branch name, which a fork author picks — and `{pr_number}` is digits only; treat any other value as a failed run. The publication value is the mode 9b-2 reported on its `**Publication**:` line — `FULL…` → `full`, `STUB…` → `stub`, `OFF…` → `off` — else `{REVIEW_PUBLICATION}` as resolved in Step 0d. Capture its stdout as `EVIDENCE_REFRESH`: the `## PR Evidence` block's `EVIDENCE` line and its `**Body**:` / `**Comment**:` line, with any `TRACEABILITY: DEGRADED ({reason})` lines after them (exit 0), or the one line `TRACEABILITY: DEGRADED (evidence unavailable)` (exit 2). Empty stdout or any other exit is `TRACEABILITY: DEGRADED (evidence unavailable)`. It never blocks.
537
531
 
538
532
  ### Phase 9c: Merge Readiness (Report-only)
539
533
 
@@ -542,19 +536,17 @@ Omit the `EVIDENCE_FILE` line when Step 9b-0 appended no claim. `REVIEW_PUBLICAT
542
536
 
543
537
  Run this phase only when `REQUIRE_NON_AUTHOR_APPROVAL` is `true`; otherwise skip it and report it as SKIPPED.
544
538
 
545
- Spawn Git agent:
539
+ Run the script inline — it is the whole `check-merge-readiness` operation, with no Git agent spawn — through the Bash tool with `timeout: 180000`:
546
540
 
541
+ ```bash
542
+ cd {worktree} && node "$HOME/.devflow/scripts/verify-evidence.cjs" readiness --pr {pr_number} --require-non-author-approval true; echo "exit=$?"
547
543
  ```
548
- Agent(subagent_type="Git"):
549
- "OPERATION: check-merge-readiness
550
- PR_NUMBER: {pr_number}
551
- REQUIRE_NON_AUTHOR_APPROVAL: {REQUIRE_NON_AUTHOR_APPROVAL}
552
- WORKTREE_PATH: {worktree_path} (omit if cwd)"
553
- ```
544
+
545
+ Pass `--require-non-author-approval true`: `REQUIRE_NON_AUTHOR_APPROVAL` is `true` here, or this phase would not run. `{pr_number}` is digits only. Its stdout is the `## Merge Readiness` block (exit 0), or the same block with `**Status**: DEGRADED ({reason})` and a `TRACEABILITY: DEGRADED ({reason})` line after it (exit 2); empty stdout or any other exit is `TRACEABILITY: DEGRADED (readiness unavailable)`.
554
546
 
555
547
  Include merge readiness verdict (READY / NOT_READY / DEGRADED) and its `- Test plan:` detail line in Phase 10 report. Never block on this result — report-only.
556
548
 
557
- If Git agent returns `TRACEABILITY: DEGRADED`: warn, proceed to Phase 10.
549
+ If the script prints a `TRACEABILITY: DEGRADED` line: warn, proceed to Phase 10.
558
550
 
559
551
  ### Phase 10: Report
560
552
 
@@ -647,16 +639,12 @@ FILES_CHANGED: {list of files changed}
647
639
  Write the knowledge base to:
648
640
  {worktree}/.devflow/features/{slug}/KNOWLEDGE.md
649
641
 
650
- Then update the index cache by performing a read-modify-write on:
642
+ Then update the index cache:
651
643
  {worktree}/.devflow/features/index.md
652
644
 
653
645
  Index line format: `- **{slug}** — {areas} — {Use-when description}` — at most 300 characters, the description at most 220; reword a longer one, never cut it.
654
646
 
655
- If the line for this slug already exists in index.md, replace it. If it does not exist, append it. If index.md does not exist, create it with just this line.
656
-
657
- The frontmatter in KNOWLEDGE.md is the source of truth — index.md is only a cache. Write the two files directly — no intermediate result JSON files, no external scripts.
658
-
659
- After writing, commit the two files to the current worktree branch yourself by running git via your Bash tool (do not use a script). Stage ONLY .devflow/features/index.md and .devflow/features/{slug}/KNOWLEDGE.md, then commit just those paths with a docs(knowledge): message. Do NOT push, do NOT force, do NOT stage anything else. Follow your Commit Protocol — it is non-blocking, so if any git step fails, report KB_COMMIT and finish normally."
647
+ Then commit the two files as your Commit Protocol directs."
660
648
  ```
661
649
 
662
650
  **Step 4 — Surface an uncommitted knowledge base:**
@@ -671,44 +659,24 @@ When the Knowledge agent reports `KB_COMMIT: skipped (detached HEAD)`, the files
671
659
  /resolve (orchestrator - spawns agents only)
672
660
  │
673
661
  ├─ Phase 0: Worktree Discovery & Pre-flight
674
- │ ├─ Step 0a: git worktree list → filter resolvable
675
- │ ├─ Step 0b: Git agent (validate-branch) per worktree [parallel] ← + DIFF_FILES
676
- │ ├─ Step 0c: Target latest review directory per worktree
677
- │ └─ Step 0d: Load project context → EVIDENCE_POLICY + REVIEW_PUBLICATION
678
- │
679
662
  ├─ Phase 1: Parse issues from TARGET_DIR + extract confidence %
680
- │
681
663
  ├─ Phase 1b: Fetch external threads (evidence policy required)
682
- │ └─ Git agent (fetch-review-threads) → THREAD_MAP
683
- │
684
664
  ├─ Phase 2: Global Triage [Triage agent, opus, single agent]
685
- │ └─ ALL issues → verdict ledger by disposition (incl. DUPLICATE with duplicate_of)
686
- │
687
665
  ├─ Phase 3: Batch FIX_NOW issues (skip if empty; DUPLICATE issues never dispatched)
688
- │ └─ same-file sequential, distinct-file parallel, max 5/batch
689
- │
690
666
  ├─ Phase 4: Fix [Code agent × N, OPERATION: issue-fix, PUSH: false]
691
- │ └─ Returns Verification block per batch
692
- │
693
667
  ├─ Phase 5: Write resolution-summary.md (compaction safety; Tracked = "(pending)" or "(pending — TRACEABILITY: DEGRADED)" if manage-debt degrades)
694
- │
695
- ├─ Phase 6: Simplify [Simplify agent]
696
- │
697
- ├─ Phase 7: Verification Gate [Validate agent, haiku] + push + Code-fix agent validation-fix loop ≤2
698
- │
668
+ ├─ Phase 6: Polish [Polish agent]
669
+ ├─ Phase 7: Verification Gate [Validate agent, haiku] + push + Fix agent validation-fix loop ≤2
699
670
  ├─ Phase 8: CI Status Gate (conditional — skipped if no fixes or verification FAILED)
700
- │ └─ push, then ci-wait.cjs (inline, one wait ≤ 570 s) → Code-fix agent on FAILING (3 waits + 2 fixes per worktree)
701
- │
702
671
  ├─ Phase 9: Git agent (manage-debt) — FIX_SEPARATE + TECH_DEBT → backfill Tracked={ISSUE_REF} (or TRACEABILITY: DEGRADED on failure)
703
- │ SEQUENTIAL across worktrees
704
672
  │
705
673
  ├─ Phase 9b: Thread resolution + resolution comment
706
674
  │ ├─ Step 9b-0: verify-evidence.cjs --stale-out → ≤1 Test agent on the stale TPs (wrapped) — only after this run's push
707
675
  │ ├─ Step 9b-1: Git agent (resolve-review-threads) — evidence policy required
708
676
  │ ├─ Step 9b-2: Git agent (post-resolution-summary, REVIEW_PUBLICATION) — always-on
709
- │ └─ Step 9b-3: Git agent (update-pr-evidence) — only when the head moved
677
+ │ └─ Step 9b-3: verify-evidence.cjs publish (inline, no Git spawn) — only when the head moved
710
678
  │
711
- ├─ Phase 9c: Git agent (check-merge-readiness) — non-author approval required, report-only
679
+ ├─ Phase 9c: verify-evidence.cjs readiness (inline, no Git spawn) — non-author approval required, report-only
712
680
  │
713
681
  └─ Phase 10: Display results (resolution-summary.md written in Phase 5)
714
682
  ```
@@ -722,21 +690,11 @@ When the Knowledge agent reports `KB_COMMIT: skipped (detached HEAD)`, the files
722
690
  | Fix attempt fails | Revert changes, mark BLOCKED, continue others |
723
691
  | Issue dependencies | Sequential chain, skip dependents if predecessor blocked |
724
692
  | No actionable issues | Report "No issues to resolve" |
725
- | Incomplete review directory (no review-summary.md) | Skip — resolve only targets complete reviews |
726
693
  | Latest review already resolved | Check bug-analysis fallback (Step 0c-5b); if also absent, skip worktree and suggest `/code-review` or `/bug-analysis` |
727
- | Legacy flat layout (no subdirectories) | Read flat *.md files directly (backwards compatible) |
728
694
  | `--review {timestamp}` in multi-worktree mode | Not supported — use `--path` + `--review` to target specific worktree + review |
729
- | Worktree pre-flight fails | Report failure, continue with other worktrees |
730
- | Empty FIX_NOW list | Skip Phases 3-4/6-8; still write full summary + run manage-debt if FIX_SEPARATE/TECH_DEBT exist |
731
- | ESCALATED security issues | Surfaced in ## Escalations + display callout; never routed to manage-debt |
732
- | DUPLICATE verdict without duplicate_of, or chained to another DUPLICATE | Treated as Triage failure — same retry-then-abort as a vanished id |
733
- | DUPLICATE issues in THREAD_MAP | Map ext-{N} to primary's verdict/verification status for thread reply |
734
- | Verification Gate FAILED after 2 attempts | Recorded as FAILED in ## Verification + blocking callout; CI gate skipped; proceed to Phase 9 (manage-debt) then Phase 10 (display) |
735
695
  | gh/GitHub absent | manage-debt degrades (`TRACEABILITY: DEGRADED ({reason})`); Tracked stays `(pending — TRACEABILITY: DEGRADED ({reason}))` — recorded, not dropped |
736
696
  | `EVIDENCE_POLICY` is `standard` | Phases 1b and 9b-step-1 are skipped; post-resolution-summary (Phase 9b step 2) still runs if a PR is known |
737
697
  | `REQUIRE_NON_AUTHOR_APPROVAL` is `false` | Phase 9c is skipped and reported as SKIPPED |
738
- | THREAD_MAP empty or DEGRADED | Phase 9b-1 skipped; resolution comment (Phase 9b-2) still posted if PR known |
739
- | No PR exists for post-resolution-summary | Git agent returns TRACEABILITY: DEGRADED; resolution-summary.md already on disk — not a blocker |
740
698
  | Public repo (`auto` mode) | Git agent probes visibility, posts counts-only STUB comment; full resolution report stays local |
741
699
  | `reviewPublication: off` | Git agent skips posting the resolution comment (OFF) — except that, only when `EVIDENCE_POLICY` is `required`, Step 0d passes `stub` and a counts-only STUB comment posts |
742
700
  | Fork PR this run cannot push to (no maintainer edits, no push access of its own) | validate-branch emits `TRACEABILITY: DEGRADED (cannot push to fork)` → `fork_no_push`: Phase 7 skips the push, Phase 8 is skipped, 9b-1 records FIXED threads as DEGRADED instead of citing unpushed commits; 9b-2 still posts the resolution comment; the head did not move, so 9b-0 and 9b-3 are skipped |
@@ -747,14 +705,8 @@ When the Knowledge agent reports `KB_COMMIT: skipped (detached HEAD)`, the files
747
705
 
748
706
  1. **Orchestration only** - Command spawns agents, doesn't do git/resolve work itself
749
707
  2. **No agent grades its own homework** - Triage agent validates, Code agents fix, Validate agent verifies
750
- 3. **Global triage first** - Single Triage agent sees all issues for cross-issue consistency; no issue may vanish
751
- 4. **Git agent for git work** - All git operations go through Git agent
752
- 5. **Parallel execution** - Distinct-file Code agent batches run in parallel; same-file batches sequential
753
- 6. **Honest reporting** - Verification failure is recorded and displayed, never silenced
754
- 7. **Complete tracking** - Every issue gets exactly one verdict in the ledger
755
- 8. **Latest review by default** - Only process the most recent complete review
756
- 9. **Auto-discover worktrees** - One command handles all resolvable branches
757
- 10. **Traceability-aware** - Policy-gated ops (thread fetch/resolve, merge readiness) are skipped cleanly when the evidence policy does not ask for them; resolution comment (Phase 9b-2) is always-on; test-plan evidence is re-verified (≤1 Test agent) and refreshed only when this run moved the head (Steps 9b-0, 9b-3)
708
+ 3. **Git agent for git work** - All git operations go through Git agent; the CI wait, the evidence refresh and the merge-readiness check are inline scripts (plumbing, no model work)
709
+ 4. **Traceability-aware** - Policy-gated ops (thread fetch/resolve, merge readiness) are skipped cleanly when the evidence policy does not ask for them; resolution comment (Phase 9b-2) is always-on; test-plan evidence is re-verified (≤1 Test agent) and refreshed only when this run moved the head (Steps 9b-0, 9b-3)
758
710
 
759
711
  ## Output Artifact
760
712