devflow-kit 3.3.0 → 3.5.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 (220) hide show
  1. package/CHANGELOG.md +47 -0
  2. package/README.md +8 -4
  3. package/dist/agents/code-edit.md +133 -0
  4. package/dist/agents/code-fix.md +165 -0
  5. package/dist/agents/code.md +187 -0
  6. package/{src/assets → dist}/agents/design.md +1 -2
  7. package/{src/assets → dist}/agents/diagnose.md +1 -2
  8. package/dist/agents/git.md +33 -722
  9. package/{src/assets → dist}/agents/knowledge.md +12 -5
  10. package/{src/assets → dist}/agents/research.md +8 -2
  11. package/{src/assets → dist}/agents/review.md +8 -11
  12. package/{src/assets → dist}/agents/scrutinize.md +4 -1
  13. package/dist/agents/skim.md +152 -0
  14. package/{src/assets → dist}/agents/triage.md +9 -2
  15. package/dist/cli/commands/behavior-prompts.js +77 -0
  16. package/dist/cli/commands/behavior.js +123 -0
  17. package/dist/cli/commands/flags.js +8 -2
  18. package/dist/cli/commands/init-seed.js +7 -3
  19. package/dist/cli/commands/init.js +134 -5
  20. package/dist/cli/commands/learning.js +38 -3
  21. package/dist/cli/commands/rules.js +16 -0
  22. package/dist/cli/commands/tracker.js +112 -15
  23. package/dist/cli/commands/uninstall.js +42 -1
  24. package/dist/cli.js +2 -0
  25. package/dist/commands/bug-analysis.md +35 -13
  26. package/dist/commands/code-review.md +155 -69
  27. package/dist/commands/debug.md +39 -16
  28. package/dist/commands/dynamic-build.md +61 -72
  29. package/dist/commands/dynamic-plan.md +39 -25
  30. package/dist/commands/dynamic-profile.md +28 -14
  31. package/dist/commands/dynamic-tickets.md +38 -22
  32. package/dist/commands/explore.md +18 -16
  33. package/dist/commands/implement.md +121 -150
  34. package/dist/commands/plan.md +51 -31
  35. package/dist/commands/release.md +72 -6
  36. package/dist/commands/research.md +49 -20
  37. package/dist/commands/resolve.md +54 -46
  38. package/dist/commands/self-review.md +38 -25
  39. package/dist/core/agent-frontmatter.js +101 -0
  40. package/dist/core/agent-models.js +43 -0
  41. package/dist/core/assets.js +55 -10
  42. package/dist/core/claude-md-audit.js +190 -0
  43. package/dist/core/compliance-compose.js +6 -4
  44. package/dist/core/feature-switch.js +41 -1
  45. package/dist/core/flags.js +139 -0
  46. package/dist/core/fs-atomic.js +8 -3
  47. package/dist/core/learning-variants.js +213 -0
  48. package/dist/core/manifest.js +73 -3
  49. package/dist/core/mds-variants.js +98 -19
  50. package/dist/core/plugins.js +111 -72
  51. package/dist/core/project-paths.js +0 -4
  52. package/dist/core/proxy-log.js +1 -1
  53. package/dist/core/proxy-state.js +1 -1
  54. package/dist/core/tracker.js +120 -2
  55. package/dist/learning-off/agents/code-edit.md +129 -0
  56. package/dist/learning-off/agents/code-fix.md +161 -0
  57. package/dist/learning-off/agents/code.md +183 -0
  58. package/dist/learning-off/agents/design.md +118 -0
  59. package/dist/learning-off/agents/diagnose.md +210 -0
  60. package/dist/learning-off/agents/knowledge.md +96 -0
  61. package/dist/learning-off/agents/research.md +155 -0
  62. package/dist/learning-off/agents/review.md +224 -0
  63. package/dist/learning-off/agents/scrutinize.md +120 -0
  64. package/{src/assets → dist/learning-off}/agents/skim.md +5 -8
  65. package/dist/learning-off/agents/triage.md +170 -0
  66. package/dist/learning-off/commands/bug-analysis.md +420 -0
  67. package/dist/learning-off/commands/code-review.md +530 -0
  68. package/dist/learning-off/commands/debug.md +314 -0
  69. package/dist/learning-off/commands/dynamic-build.md +1245 -0
  70. package/dist/learning-off/commands/dynamic-plan.md +426 -0
  71. package/dist/learning-off/commands/dynamic-profile.md +214 -0
  72. package/dist/learning-off/commands/dynamic-tickets.md +634 -0
  73. package/dist/learning-off/commands/explore.md +210 -0
  74. package/dist/learning-off/commands/implement.md +774 -0
  75. package/dist/learning-off/commands/plan.md +671 -0
  76. package/dist/learning-off/commands/release.md +311 -0
  77. package/dist/learning-off/commands/research.md +229 -0
  78. package/dist/learning-off/commands/resolve.md +842 -0
  79. package/dist/learning-off/commands/self-review.md +266 -0
  80. package/dist/skills/git/references/learn-conventions.md +27 -3
  81. package/dist/skills/git/references/pr/check-ci-status.md +19 -0
  82. package/dist/skills/git/references/pr/check-merge-readiness.md +19 -0
  83. package/dist/skills/git/references/pr/fetch-review-threads.md +30 -0
  84. package/dist/skills/git/references/pr/post-resolution-summary.md +18 -0
  85. package/dist/skills/git/references/pr/post-review-summary.md +20 -0
  86. package/dist/skills/git/references/pr/resolve-review-threads.md +28 -4
  87. package/dist/skills/git/references/pr/update-pr-evidence.md +13 -0
  88. package/dist/skills/git/references/pr/validate-branch.md +26 -0
  89. package/dist/skills/git/references/tracker/_contract.md +33 -0
  90. package/dist/skills/git/references/tracker/github/associate-release.md +24 -0
  91. package/dist/skills/git/references/tracker/github/backlink-shipped-issues.md +31 -1
  92. package/dist/skills/git/references/tracker/github/create-release.md +30 -1
  93. package/dist/skills/git/references/tracker/github/ensure-pr-ready.md +89 -2
  94. package/dist/skills/git/references/tracker/github/ensure-traceable-issue.md +16 -1
  95. package/dist/skills/git/references/tracker/github/fetch-issue.md +38 -1
  96. package/dist/skills/git/references/tracker/github/fetch-issues-batch.md +49 -1
  97. package/dist/skills/git/references/tracker/github/gather-release-evidence.md +29 -0
  98. package/dist/skills/git/references/tracker/github/manage-debt.md +21 -1
  99. package/dist/skills/git/references/tracker/github/post-wave-report.md +17 -1
  100. package/dist/skills/git/references/tracker/github/setup-task.md +53 -1
  101. package/dist/skills/git/references/tracker/jira/associate-release.md +25 -1
  102. package/dist/skills/git/references/tracker/jira/backlink-shipped-issues.md +31 -1
  103. package/dist/skills/git/references/tracker/jira/create-release.md +30 -1
  104. package/dist/skills/git/references/tracker/jira/ensure-pr-ready.md +89 -2
  105. package/dist/skills/git/references/tracker/jira/ensure-traceable-issue.md +16 -1
  106. package/dist/skills/git/references/tracker/jira/fetch-issue.md +38 -1
  107. package/dist/skills/git/references/tracker/jira/fetch-issues-batch.md +49 -1
  108. package/dist/skills/git/references/tracker/jira/gather-release-evidence.md +29 -0
  109. package/dist/skills/git/references/tracker/jira/manage-debt.md +21 -1
  110. package/dist/skills/git/references/tracker/jira/post-wave-report.md +17 -1
  111. package/dist/skills/git/references/tracker/jira/setup-task.md +55 -3
  112. package/dist/skills/git/references/tracker/linear/associate-release.md +25 -1
  113. package/dist/skills/git/references/tracker/linear/backlink-shipped-issues.md +31 -1
  114. package/dist/skills/git/references/tracker/linear/create-release.md +30 -1
  115. package/dist/skills/git/references/tracker/linear/ensure-pr-ready.md +89 -2
  116. package/dist/skills/git/references/tracker/linear/ensure-traceable-issue.md +16 -1
  117. package/dist/skills/git/references/tracker/linear/fetch-issue.md +38 -1
  118. package/dist/skills/git/references/tracker/linear/fetch-issues-batch.md +49 -1
  119. package/dist/skills/git/references/tracker/linear/gather-release-evidence.md +29 -0
  120. package/dist/skills/git/references/tracker/linear/manage-debt.md +21 -1
  121. package/dist/skills/git/references/tracker/linear/post-wave-report.md +17 -1
  122. package/dist/skills/git/references/tracker/linear/setup-task.md +55 -3
  123. package/dist/targets/claude-code/agent-type-owner.js +164 -0
  124. package/dist/targets/claude-code/behavior-install.js +111 -0
  125. package/dist/targets/claude-code/installer.js +140 -37
  126. package/dist/targets/claude-code/language-stamp.js +185 -0
  127. package/dist/targets/claude-code/learning-install.js +497 -0
  128. package/dist/targets/claude-code/tracker-install.js +33 -16
  129. package/dist/targets/claude-code/tracker-servers.js +107 -0
  130. package/package.json +4 -3
  131. package/src/assets/agents/_partials/_code.mds +109 -0
  132. package/src/assets/agents/code-edit.mds +81 -0
  133. package/src/assets/agents/code-fix.mds +113 -0
  134. package/src/assets/agents/code.mds +135 -0
  135. package/src/assets/agents/design.mds +148 -0
  136. package/src/assets/agents/diagnose.mds +225 -0
  137. package/src/assets/agents/evaluate.md +8 -4
  138. package/src/assets/agents/explore.md +58 -0
  139. package/src/assets/agents/git.mds +33 -722
  140. package/src/assets/agents/knowledge.mds +131 -0
  141. package/src/assets/agents/learning.md +19 -69
  142. package/src/assets/agents/research.mds +182 -0
  143. package/src/assets/agents/review.mds +282 -0
  144. package/src/assets/agents/scrutinize.mds +135 -0
  145. package/src/assets/agents/simplify.md +3 -0
  146. package/src/assets/agents/skim.mds +165 -0
  147. package/src/assets/agents/synthesize.md +26 -352
  148. package/src/assets/agents/test.md +8 -0
  149. package/src/assets/agents/tracker.md +20 -7
  150. package/src/assets/agents/triage.mds +201 -0
  151. package/src/assets/agents/validate.md +13 -6
  152. package/src/assets/commands/_partials/_compliance.mds +41 -4
  153. package/src/assets/commands/_partials/_decisions.mds +33 -2
  154. package/src/assets/commands/_partials/_engine.mds +14 -6
  155. package/src/assets/commands/_partials/_knowledge.mds +25 -12
  156. package/src/assets/commands/_partials/_preamble.mds +34 -10
  157. package/src/assets/commands/_partials/_publication.mds +5 -4
  158. package/src/assets/commands/_partials/_roster.mds +4 -3
  159. package/src/assets/commands/_partials/_settings.mds +13 -5
  160. package/src/assets/commands/_partials/_wave.mds +9 -1
  161. package/src/assets/commands/bug-analysis.mds +27 -5
  162. package/src/assets/commands/code-review.mds +158 -52
  163. package/src/assets/commands/debug.mds +41 -3
  164. package/src/assets/commands/dynamic-build.mds +47 -27
  165. package/src/assets/commands/dynamic-plan.mds +40 -9
  166. package/src/assets/commands/dynamic-profile.mds +9 -1
  167. package/src/assets/commands/dynamic-tickets.mds +21 -6
  168. package/src/assets/commands/explore.mds +28 -2
  169. package/src/assets/commands/implement.mds +126 -129
  170. package/src/assets/commands/plan.mds +58 -14
  171. package/src/assets/commands/{release.md → release.mds} +30 -26
  172. package/src/assets/commands/research.mds +42 -11
  173. package/src/assets/commands/resolve.mds +59 -15
  174. package/src/assets/commands/self-review.mds +30 -5
  175. package/src/assets/mds/.mdsroot +4 -0
  176. package/src/assets/mds/git/_ops.mds +383 -0
  177. package/src/assets/mds/git/_ops_pr.mds +201 -0
  178. package/src/assets/mds/git/_ops_steps.mds +147 -0
  179. package/src/assets/mds/git/_pr.mds +39 -44
  180. package/src/assets/mds/git/_references.mds +6 -3
  181. package/src/assets/mds/tracker/_common.mds +5 -5
  182. package/src/assets/mds/tracker/_contract.mds +73 -0
  183. package/src/assets/mds/tracker/_github.mds +73 -16
  184. package/src/assets/mds/tracker/_jira.mds +77 -19
  185. package/src/assets/mds/tracker/_linear.mds +77 -19
  186. package/src/assets/mds/tracker/_mcp.mds +2 -2
  187. package/src/assets/mds/tracker/_steps.mds +98 -0
  188. package/src/assets/rules/behavior.md +6 -0
  189. package/src/assets/rules/context-economy.md +10 -0
  190. package/src/assets/rules/go.md +1 -0
  191. package/src/assets/rules/java.md +1 -0
  192. package/src/assets/rules/python.md +1 -0
  193. package/src/assets/rules/rust.md +1 -0
  194. package/src/assets/rules/typescript.md +1 -0
  195. package/src/assets/scripts/claude-md-audit.cjs +611 -0
  196. package/src/assets/scripts/hooks/assets/orchestrator-charter.md +3 -3
  197. package/src/assets/scripts/hooks/json-helper.cjs +13 -5
  198. package/src/assets/scripts/hooks/json-parse +34 -10
  199. package/src/assets/scripts/hooks/lib/project-paths.cjs +0 -6
  200. package/src/assets/scripts/hooks/session-start-context +315 -7
  201. package/src/assets/skills/agent-references/SKILL.md +33 -0
  202. package/src/assets/skills/agent-references/references/learning/maintain.md +71 -0
  203. package/src/assets/skills/agent-references/references/synthesize/bug-analysis.md +71 -0
  204. package/src/assets/skills/agent-references/references/synthesize/design.md +36 -0
  205. package/src/assets/skills/agent-references/references/synthesize/exploration.md +38 -0
  206. package/src/assets/skills/agent-references/references/synthesize/planning.md +60 -0
  207. package/src/assets/skills/agent-references/references/synthesize/research.md +61 -0
  208. package/src/assets/skills/agent-references/references/synthesize/review.md +76 -0
  209. package/src/assets/skills/apply-decisions/SKILL.md +1 -1
  210. package/src/assets/skills/apply-feature-knowledge/SKILL.md +5 -5
  211. package/src/assets/skills/compliance/SKILL.md +1 -1
  212. package/src/assets/skills/docs-framework/SKILL.md +80 -83
  213. package/src/assets/skills/docs-framework/references/patterns.md +14 -25
  214. package/src/assets/skills/docs-framework/references/violations.md +7 -7
  215. package/src/assets/skills/feature-knowledge/SKILL.md +43 -12
  216. package/src/assets/skills/gap-analysis/SKILL.md +0 -16
  217. package/src/assets/skills/gap-analysis/references/compliance.md +19 -0
  218. package/src/assets/skills/quality-gates/SKILL.md +1 -1
  219. package/dist/skills/git/references/pr/ensure-pr-ready.md +0 -24
  220. package/src/assets/agents/code.md +0 -330
@@ -10,6 +10,7 @@ output-dir: dist/commands
10
10
  @import { test_plan_line } from "./_partials/_plan_contract.mds"
11
11
  @import { publication_gate } from "./_partials/_publication.mds"
12
12
  @import "./_partials/_compliance.mds" as compliance
13
+ @import "./_partials/_settings.mds" as settings
13
14
  # Implement Command
14
15
 
15
16
  Orchestrate a single task through implementation by spawning specialized agents. The orchestrator only spawns agents and passes context - all work is done by agents.
@@ -51,13 +52,17 @@ When the user explicitly asks to re-validate, re-check, or re-run quality gates
51
52
  2. **Skip Phase 2** — no Code agent needed, user already made changes.
52
53
  3. **Detect FILES_CHANGED**: `git diff --name-only {base_branch}...HEAD`
53
54
  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
- 5. **Proceed to Phase 10** (Create PR), **Phase 10b** (Evidence) and **Phase 11** (Report).
55
+ 5. **Proceed to Phase 9** (Open PR), **Phase 11** (Evidence) and **Phase 12** (Report).
55
56
 
56
57
  If the user prompt does NOT match re-validation, proceed with the full pipeline below.
57
58
 
58
59
  ### Phase 1: Setup
59
60
 
60
- **Produces:** TASK_ID, BASE_BRANCH, EXECUTION_PLAN, DECISIONS_CONTEXT, FEATURE_KNOWLEDGE, PR_DESCRIPTION_GUIDANCE, ISSUE_NUMBER, EVIDENCE_POLICY, ISSUE_REQUIRED, APPLY_CONVENTIONS, REQUIRE_NON_AUTHOR_APPROVAL, PR_EXCEPTIONS, TEST_PLAN, EVIDENCE_FILE, PR_TEST_PLAN_BLOCK, REVIEW_PUBLICATION
61
+ <!-- learning:on -->
62
+ **Produces:** TASK_ID, BASE_BRANCH, EXECUTION_PLAN, DECISIONS_CONTEXT, FEATURE_KNOWLEDGE, FEATURE_KNOWLEDGE_RULES, PR_DESCRIPTION_GUIDANCE, ISSUE_NUMBER, ISSUE_PR_LINK, EVIDENCE_POLICY, ISSUE_REQUIRED, APPLY_CONVENTIONS, REQUIRE_NON_AUTHOR_APPROVAL, PR_EXCEPTIONS, TEST_PLAN, EVIDENCE_FILE, PR_TEST_PLAN_BLOCK, REVIEW_PUBLICATION
63
+ <!-- learning:off -->
64
+ **Produces:** TASK_ID, BASE_BRANCH, EXECUTION_PLAN, FEATURE_KNOWLEDGE, FEATURE_KNOWLEDGE_RULES, PR_DESCRIPTION_GUIDANCE, ISSUE_NUMBER, ISSUE_PR_LINK, EVIDENCE_POLICY, ISSUE_REQUIRED, APPLY_CONVENTIONS, REQUIRE_NON_AUTHOR_APPROVAL, PR_EXCEPTIONS, TEST_PLAN, EVIDENCE_FILE, PR_TEST_PLAN_BLOCK, REVIEW_PUBLICATION
65
+ <!-- learning:end -->
61
66
 
62
67
  Record the current branch name as `BASE_BRANCH` - this will be the PR target.
63
68
 
@@ -126,6 +131,7 @@ visible, a silently discarded request is not.
126
131
  - `TASK_ID`: The branch name created by Git agent (use as TASK_ID for rest of flow)
127
132
  - `BASE_BRANCH`: Branch this feature was created from (for PR target)
128
133
  - `ISSUE_NUMBER`: the provider-canonical issue identifier for this task — the same value the Git agent emits as `ISSUE_ID` (if provided, or created by the Git agent's issue-first step in setup-task)
134
+ - `branch_slug`: `TASK_ID` with every `/` replaced by `-`. It names `handoff-{branch_slug}.md` and `evidence-{branch_slug}.md` only when it matches `^[A-Za-z0-9._-]{1,200}$`; any other branch name stops the run here, telling the user it cannot name those files.
129
135
 
130
136
  {{issue_capture_contract()}}
131
137
 
@@ -135,7 +141,7 @@ visible, a silently discarded request is not.
135
141
 
136
142
  {{evidence_exception()}}
137
143
 
138
- **Record the exception at once**, before any Code spawn: write the rendered section as the `## Evidence Exceptions` section of `{worktree}/.devflow/docs/handoff-{branch_slug}.md`, creating the file if absent, and set `PR_EXCEPTIONS` to that section. The file is its one home until the PR exists: every later write to the file keeps the section byte-identical, every PR-creating Code spawn passes it verbatim as `PR_EXCEPTIONS`, and the file is deleted only once the PR exists — after the PR-creating Phase 2 Code agent under SINGLE_CODE_AGENT and SEQUENTIAL_CODE_AGENTS, after Phase 10 under PARALLEL_CODE_AGENTS. With no exception recorded, `PR_EXCEPTIONS` is `(none)`.
144
+ **Record the exception at once**, before any Code spawn: write the rendered section as the `## Evidence Exceptions` section of `{worktree}/.devflow/docs/handoff-{branch_slug}.md`, creating the file if absent, and set `PR_EXCEPTIONS` to that section. The file is its one home until the PR exists: every later write to the file keeps the section byte-identical, the Phase 9 Git spawn passes it verbatim as `PR_EXCEPTIONS`, and the file is deleted only once the PR exists — after Phase 9, under every strategy. With no exception recorded, `PR_EXCEPTIONS` is `(none)`.
139
145
 
140
146
  **Test plan.** Before any Code spawn, give the task a test plan in the evidence file `{worktree}/.devflow/docs/evidence-{branch_slug}.md` (`EVIDENCE_FILE`) — unlike the handoff file, it stays after the PR exists. It holds up to three sections, in this order and nothing else: `## Test Plan`; `## Evidence Exceptions`, a byte copy of `PR_EXCEPTIONS` present only while that is not `(none)`; and `## Claims`, always last, so every claim is appended at the end of the file. Create the file if absent; if it exists, replace its `## Test Plan` and `## Evidence Exceptions` sections and keep `## Claims` byte-identical.
141
147
 
@@ -155,7 +161,7 @@ node "$HOME/.devflow/scripts/verify-evidence.cjs" check tp "{worktree}/.devflow/
155
161
  - **Record an exception** — the user gives the reason as free text. Render it with the exception grammar above, as kind `test-plan`; when the rendered reason is empty, ask for it once more, and stop as below if it is empty again. Add the rendered line to the `## Evidence Exceptions` section of `{worktree}/.devflow/docs/handoff-{branch_slug}.md` — after any `ticket-link` line, creating the section and the file when absent — and set `PR_EXCEPTIONS` to that section, under the same rules as the record above.
156
162
  - **Stop** — report `BLOCKED (no test plan)`, name `TASK_ID` and `BASE_BRANCH` so the branch can be reused or removed, and give the remedy: state the acceptance criteria in the task, the issue or a `/plan` document (its `## Test Plan` section is copied) and re-run `/implement`, or — for a team that does not want test plans enforced — commit `.devflow/project.json` as `{"version":1,"evidence":"standard"}` on the default branch; a machine with compliance enabled still resolves `required` whatever that file says. Spawn nothing further.
157
163
 
158
- When `EVIDENCE_POLICY` is `standard`, a missing test plan is never asked about: carry `Test plan: missing` to the Phase 11 report.
164
+ When `EVIDENCE_POLICY` is `standard`, a missing test plan is never asked about: carry `Test plan: missing` to the Phase 12 report.
159
165
 
160
166
  **Test-plan outputs**, set once before any Code spawn:
161
167
  - `TEST_PLAN` — the TP lines of the evidence file's `## Test Plan` section, or `(none)` when the test plan is missing.
@@ -167,19 +173,26 @@ node "$HOME/.devflow/scripts/verify-evidence.cjs" render --plan "{worktree}/.dev
167
173
 
168
174
  - `EVIDENCE_FILE` — `{worktree}/.devflow/docs/evidence-{branch_slug}.md`, its `## Evidence Exceptions` section now a byte copy of `PR_EXCEPTIONS` (absent when that is `(none)`).
169
175
 
176
+ {{settings.settings_resolve()}}
177
+
170
178
  {{publication_gate()}}
171
- Phase 10b passes the resolved value to `update-pr-evidence`, which decides what each value means for the evidence comment. From the same line: {{compliance.compliance_frameworks()}} Pass it to every Code spawn.
179
+ Phase 11 passes the resolved value to `update-pr-evidence`, which decides what each value means for the evidence comment. From the same line: {{compliance.compliance_frameworks()}}
172
180
 
173
- {{decisions_load()}}
181
+ {{compliance.compliance_inject()}}
182
+
183
+ Pass `COMPLIANCE_DIRECTIVE` to every Code and Code-fix spawn, on a line of its own.
174
184
 
175
- Pass to Code agent (Phase 2) and Scrutinize agent (Phase 4).
185
+ {{decisions_load()}}
186
+ <!-- learning:on -->
187
+ Pass `DECISIONS_CONTEXT` to Code agent (Phase 2) and Scrutinize agent (Phase 4).
176
188
 
189
+ <!-- learning:end -->
177
190
  {{knowledge_load()}}
178
191
 
179
192
  ### Phase 2: Implement
180
193
 
181
- **Produces:** CODE_AGENT_OUTPUT, FILES_CHANGED, PR_URL
182
- **Requires:** TASK_ID, BASE_BRANCH, EXECUTION_PLAN, PR_DESCRIPTION_GUIDANCE, PR_EXCEPTIONS, PR_TEST_PLAN_BLOCK
194
+ **Produces:** CODE_AGENT_OUTPUT, FILES_CHANGED
195
+ **Requires:** TASK_ID, BASE_BRANCH, EXECUTION_PLAN
183
196
 
184
197
  Based on Setup context (plan document, issue body, or conversation context), use the three-strategy framework:
185
198
 
@@ -205,23 +218,18 @@ TASK_DESCRIPTION: {description}
205
218
  BASE_BRANCH: {base branch}
206
219
  EXECUTION_PLAN: {full plan from setup context}
207
220
  PATTERNS: {patterns from plan document or empty}
208
- CREATE_PR: true
209
- DOMAIN: {detected domain or 'fullstack'}
210
221
  FEATURE_KNOWLEDGE: {feature_knowledge}
222
+ <!-- learning:on -->
211
223
  DECISIONS_CONTEXT: {decisions_context}
212
- COMPLIANCE_FRAMEWORKS: {COMPLIANCE_FRAMEWORKS}
213
- PR_DESCRIPTION_GUIDANCE: {pr_description_guidance}
214
- ISSUE_NUMBER: {ISSUE_ID captured in Phase 1, or (none)}
215
- ISSUE_PR_LINK: {ISSUE_PR_LINK captured in Phase 1, or (none)}
216
- PR_EXCEPTIONS: {the ## Evidence Exceptions section of {worktree}/.devflow/docs/handoff-{branch_slug}.md verbatim, or (none)}
217
- PR_TEST_PLAN_BLOCK: {PR_TEST_PLAN_BLOCK from Phase 1 verbatim, or (none)}"
224
+ <!-- learning:end -->
225
+ {COMPLIANCE_DIRECTIVE}"
218
226
  ```
219
227
 
220
228
  ---
221
229
 
222
230
  **SEQUENTIAL_CODE_AGENTS** (for HIGH/CRITICAL context risk):
223
231
 
224
- Spawn Code agents one at a time, passing handoff summaries between phases:
232
+ Spawn Code agents one at a time. Each appends its own phase section to the handoff file, and the next reads only the section before it:
225
233
 
226
234
  **Phase 1 Code agent:**
227
235
  ```
@@ -232,14 +240,11 @@ TASK_DESCRIPTION: {phase 1 description}
232
240
  BASE_BRANCH: {base branch}
233
241
  EXECUTION_PLAN: {phase 1 steps}
234
242
  PATTERNS: {patterns from plan document or empty}
235
- CREATE_PR: false
236
- DOMAIN: {phase 1 domain, e.g., 'backend'}
237
243
  FEATURE_KNOWLEDGE: {feature_knowledge}
244
+ <!-- learning:on -->
238
245
  DECISIONS_CONTEXT: {decisions_context}
239
- COMPLIANCE_FRAMEWORKS: {COMPLIANCE_FRAMEWORKS}
240
- PR_DESCRIPTION_GUIDANCE: {pr_description_guidance}
241
- ISSUE_NUMBER: {ISSUE_ID captured in Phase 1, or (none)}
242
- ISSUE_PR_LINK: {ISSUE_PR_LINK captured in Phase 1, or (none)}
246
+ <!-- learning:end -->
247
+ {COMPLIANCE_DIRECTIVE}
243
248
  HANDOFF_REQUIRED: true
244
249
  HANDOFF_FILE: {worktree}/.devflow/docs/handoff-{branch_slug}.md"
245
250
  ```
@@ -253,23 +258,18 @@ TASK_DESCRIPTION: {phase N description}
253
258
  BASE_BRANCH: {base branch}
254
259
  EXECUTION_PLAN: {phase N steps}
255
260
  PATTERNS: {patterns from plan document or empty}
256
- CREATE_PR: {true if last phase, false otherwise}
257
- DOMAIN: {phase N domain, e.g., 'frontend'}
258
261
  PRIOR_PHASE_SUMMARY: {summary from previous Code agent}
259
262
  FILES_FROM_PRIOR_PHASE: {list of files created}
260
263
  FEATURE_KNOWLEDGE: {feature_knowledge}
264
+ <!-- learning:on -->
261
265
  DECISIONS_CONTEXT: {decisions_context}
262
- COMPLIANCE_FRAMEWORKS: {COMPLIANCE_FRAMEWORKS}
263
- PR_DESCRIPTION_GUIDANCE: {pr_description_guidance}
264
- ISSUE_NUMBER: {ISSUE_ID captured in Phase 1, or (none)}
265
- ISSUE_PR_LINK: {ISSUE_PR_LINK captured in Phase 1, or (none)}
266
- PR_EXCEPTIONS: {the ## Evidence Exceptions section of {worktree}/.devflow/docs/handoff-{branch_slug}.md verbatim, or (none)}
267
- PR_TEST_PLAN_BLOCK: {PR_TEST_PLAN_BLOCK from Phase 1 verbatim, or (none)}
266
+ <!-- learning:end -->
267
+ {COMPLIANCE_DIRECTIVE}
268
268
  HANDOFF_REQUIRED: {true if not last phase}
269
269
  HANDOFF_FILE: {worktree}/.devflow/docs/handoff-{branch_slug}.md"
270
270
  ```
271
271
 
272
- **Handoff Protocol**: Each sequential Code agent receives the prior Code agent's implementation summary via PRIOR_PHASE_SUMMARY and FILES_FROM_PRIOR_PHASE. The Code agent's built-in branch orientation step handles git log scanning, file reading, and pattern discovery automatically. After each Code agent with HANDOFF_REQUIRED=true completes, write its phase summary to `{worktree}/.devflow/docs/handoff-{branch_slug}.md` using the Write tool (survives context compaction), keeping any `## Evidence Exceptions` section byte-identical. Delete `{worktree}/.devflow/docs/handoff-{branch_slug}.md` once the PR exists — after the final Code agent, which creates it, completes (cleanup).
272
+ **Handoff Protocol**: Each sequential Code agent receives the prior Code agent's implementation summary via PRIOR_PHASE_SUMMARY and FILES_FROM_PRIOR_PHASE. The Code agent's built-in branch orientation step handles git log scanning, file reading, and pattern discovery automatically. Each Code agent with HANDOFF_REQUIRED=true appends its own `## Phase {N} Implementation Summary` section, at most 8,192 bytes, to `{worktree}/.devflow/docs/handoff-{branch_slug}.md` (survives context compaction), never rewriting an earlier section and keeping any `## Evidence Exceptions` section byte-identical; the next Code agent reads only the section of the phase immediately before its own through HANDOFF_FILE. The orchestrator writes no phase section. Delete `{worktree}/.devflow/docs/handoff-{branch_slug}.md` once the PR exists — after Phase 9 (cleanup).
273
273
 
274
274
  ---
275
275
 
@@ -285,14 +285,11 @@ TASK_DESCRIPTION: {independent subtask 1}
285
285
  BASE_BRANCH: {base branch}
286
286
  EXECUTION_PLAN: {subtask 1 steps}
287
287
  PATTERNS: {patterns}
288
- CREATE_PR: false
289
- DOMAIN: {subtask 1 domain}
290
288
  FEATURE_KNOWLEDGE: {feature_knowledge}
289
+ <!-- learning:on -->
291
290
  DECISIONS_CONTEXT: {decisions_context}
292
- COMPLIANCE_FRAMEWORKS: {COMPLIANCE_FRAMEWORKS}
293
- PR_DESCRIPTION_GUIDANCE: {pr_description_guidance}
294
- ISSUE_NUMBER: {ISSUE_ID captured in Phase 1, or (none)}
295
- ISSUE_PR_LINK: {ISSUE_PR_LINK captured in Phase 1, or (none)}"
291
+ <!-- learning:end -->
292
+ {COMPLIANCE_DIRECTIVE}"
296
293
 
297
294
  Agent(subagent_type="Code"): # Code agent 2 (same message)
298
295
  "OPERATION: implement
@@ -301,14 +298,11 @@ TASK_DESCRIPTION: {independent subtask 2}
301
298
  BASE_BRANCH: {base branch}
302
299
  EXECUTION_PLAN: {subtask 2 steps}
303
300
  PATTERNS: {patterns}
304
- CREATE_PR: false
305
- DOMAIN: {subtask 2 domain}
306
301
  FEATURE_KNOWLEDGE: {feature_knowledge}
302
+ <!-- learning:on -->
307
303
  DECISIONS_CONTEXT: {decisions_context}
308
- COMPLIANCE_FRAMEWORKS: {COMPLIANCE_FRAMEWORKS}
309
- PR_DESCRIPTION_GUIDANCE: {pr_description_guidance}
310
- ISSUE_NUMBER: {ISSUE_ID captured in Phase 1, or (none)}
311
- ISSUE_PR_LINK: {ISSUE_PR_LINK captured in Phase 1, or (none)}"
304
+ <!-- learning:end -->
305
+ {COMPLIANCE_DIRECTIVE}"
312
306
  ```
313
307
 
314
308
  **Independence criteria** (all must be true for PARALLEL_CODE_AGENTS):
@@ -344,8 +338,10 @@ After Simplify agent completes, spawn Scrutinize agent as the quality gate:
344
338
  Agent(subagent_type="Scrutinize"):
345
339
  "TASK_DESCRIPTION: {task description}
346
340
  FILES_CHANGED: {list of files from Code agent output}
341
+ <!-- learning:on -->
347
342
  DECISIONS_CONTEXT: {decisions_context}
348
- FEATURE_KNOWLEDGE: {feature_knowledge}
343
+ <!-- learning:end -->
344
+ FEATURE_KNOWLEDGE: {feature_knowledge_rules}
349
345
  Evaluate 9 pillars, fix P0/P1 issues, report status"
350
346
  ```
351
347
 
@@ -356,7 +352,7 @@ Scrutinize agent reports `### Status: PASS | FIXED | BLOCKED`. **If BLOCKED:** r
356
352
  **Produces:** ALIGNMENT_RESULT
357
353
  **Requires:** FILES_CHANGED, EXECUTION_PLAN
358
354
 
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:
355
+ After Scrutinize agent passes, spawn Evaluate agent to validate alignment. Evaluate agent receives `FEATURE_KNOWLEDGE_RULES` as acceptance context only; pattern and anti-pattern judgments belong to Scrutinize agent:
360
356
 
361
357
  ```
362
358
  Agent(subagent_type="Evaluate"):
@@ -364,7 +360,7 @@ Agent(subagent_type="Evaluate"):
364
360
  EXECUTION_PLAN: {execution plan from Phase 1}
365
361
  FILES_CHANGED: {list of files from Code agent output}
366
362
  ACCEPTANCE_CRITERIA: {extracted criteria if available}
367
- FEATURE_KNOWLEDGE: {feature_knowledge}
363
+ FEATURE_KNOWLEDGE: {feature_knowledge_rules}
368
364
  Validate alignment with request and plan. Report ALIGNED or MISALIGNED with details."
369
365
  ```
370
366
 
@@ -374,18 +370,18 @@ Validate alignment with request and plan. Report ALIGNED or MISALIGNED with deta
374
370
  1. Extract misalignment details from Evaluate agent output
375
371
  2. Increment `alignment_fix_count`
376
372
  3. If `alignment_fix_count <= 2`:
377
- - Spawn Code agent to fix misalignments:
373
+ - Spawn Code-fix agent to fix misalignments:
378
374
  ```
379
- Agent(subagent_type="Code"):
375
+ Agent(subagent_type="Code-fix"):
380
376
  "OPERATION: alignment-fix
381
377
  TASK_ID: {task-id}
382
378
  TASK_DESCRIPTION: Fix alignment issues
383
379
  MISALIGNMENTS: {structured misalignments from Evaluate agent}
384
380
  SCOPE: Fix only the listed misalignments, no other changes
385
- CREATE_PR: false
386
- ISSUE_NUMBER: {ISSUE_ID captured in Phase 1, or (none)}
387
- ISSUE_PR_LINK: {ISSUE_PR_LINK captured in Phase 1, or (none)}
388
- COMPLIANCE_FRAMEWORKS: {COMPLIANCE_FRAMEWORKS}"
381
+ <!-- learning:on -->
382
+ DECISIONS_CONTEXT: {decisions_context}
383
+ <!-- learning:end -->
384
+ {COMPLIANCE_DIRECTIVE}"
389
385
  ```
390
386
  - Loop back to Phase 5 (re-check alignment). The fix is not validated here: the Phase 6 run covers it.
391
387
  4. If `alignment_fix_count > 2`: Report misalignments to user for decision
@@ -408,18 +404,18 @@ Run build, typecheck, lint, test. Report pass/fail with failure details."
408
404
  1. Extract failure details from Validate agent output
409
405
  2. Increment `validation_retry_count`
410
406
  3. If `validation_retry_count <= 2`:
411
- - Spawn Code agent with fix context:
407
+ - Spawn Code-fix agent with fix context:
412
408
  ```
413
- Agent(subagent_type="Code"):
409
+ Agent(subagent_type="Code-fix"):
414
410
  "OPERATION: validation-fix
415
411
  TASK_ID: {task-id}
416
412
  TASK_DESCRIPTION: Fix validation failures
417
413
  VALIDATION_FAILURES: {parsed failures from Validate agent}
418
414
  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}"
415
+ <!-- learning:on -->
416
+ DECISIONS_CONTEXT: {decisions_context}
417
+ <!-- learning:end -->
418
+ {COMPLIANCE_DIRECTIVE}"
423
419
  ```
424
420
  - Loop back to Phase 6 (re-validate at the new HEAD, full scope)
425
421
  4. If `validation_retry_count > 2`: Report failures to user and halt
@@ -435,7 +431,7 @@ Run build, typecheck, lint, test. Report pass/fail with failure details."
435
431
 
436
432
  - `gate:validate` — after a Phase 6 or Phase 8 PASS.
437
433
  - `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.
434
+ - 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 12 report.
439
435
 
440
436
  ### Phase 7: QA Testing
441
437
 
@@ -462,21 +458,21 @@ After every Test agent run — PASS or FAIL, first run or retry — append its T
462
458
  1. Extract failure details from Test agent output
463
459
  2. Increment `qa_retry_count`
464
460
  3. If `qa_retry_count <= 2`:
465
- - Spawn Code agent to fix QA failures:
461
+ - Spawn Code-fix agent to fix QA failures:
466
462
  ```
467
- Agent(subagent_type="Code"):
463
+ Agent(subagent_type="Code-fix"):
468
464
  "OPERATION: qa-fix
469
465
  TASK_ID: {task-id}
470
466
  TASK_DESCRIPTION: Fix QA test failures
471
467
  QA_FAILURES: {structured failures from Test agent}
472
468
  SCOPE: Fix only the listed failures, no other changes
473
- CREATE_PR: false
474
- ISSUE_NUMBER: {ISSUE_ID captured in Phase 1, or (none)}
475
- ISSUE_PR_LINK: {ISSUE_PR_LINK captured in Phase 1, or (none)}
476
- COMPLIANCE_FRAMEWORKS: {COMPLIANCE_FRAMEWORKS}"
469
+ <!-- learning:on -->
470
+ DECISIONS_CONTEXT: {decisions_context}
471
+ <!-- learning:end -->
472
+ {COMPLIANCE_DIRECTIVE}"
477
473
  ```
478
474
  - 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.
475
+ 4. If `qa_retry_count > 2`: Report QA failures to user for decision. The run stops at the report (Phase 12), so Phases 8 to 11 do not run.
480
476
 
481
477
  ### Phase 8: Re-Validate (only if a qa-fix committed)
482
478
 
@@ -496,12 +492,37 @@ Verify the qa-fix commits did not break anything."
496
492
 
497
493
  **If PASS:** append a `gate:validate` claim (Phase 6's **Evidence claims**), then continue to Phase 9.
498
494
 
499
- ### Phase 9: CI Status Gate
495
+ ### Phase 9: Open PR
496
+
497
+ **Produces:** PR_NUMBER
498
+ **Requires:** BASE_BRANCH, TASK_ID, ISSUE_NUMBER, ISSUE_PR_LINK, PR_EXCEPTIONS, PR_TEST_PLAN_BLOCK, PR_DESCRIPTION_GUIDANCE, APPLY_CONVENTIONS, CODE_AGENT_OUTPUT
499
+
500
+ Run once, after the gates, under every strategy. This phase sits outside the strategy branches, so no run reaches the end with commits and no PR. No Code agent opens a PR: the Git agent does, and it pastes `ISSUE_PR_LINK`, `PR_EXCEPTIONS` and `PR_TEST_PLAN_BLOCK` through their paste gates and scrubs the body (D11) before `gh pr create`. This command renders no link line and creates no PR itself: the Git agent's Phase-1 rendering is the only one, forwarded verbatim.
501
+
502
+ ```
503
+ Agent(subagent_type="Git"):
504
+ "OPERATION: ensure-pr-ready
505
+ WORKTREE_PATH: {worktree}
506
+ BASE_BRANCH: {base branch}
507
+ TASK_ID: {task-id}
508
+ ISSUE_NUMBER: {ISSUE_ID captured in Phase 1, or (none)}
509
+ ISSUE_PR_LINK: {ISSUE_PR_LINK captured in Phase 1, or (none)}
510
+ PR_EXCEPTIONS: {the ## Evidence Exceptions section of {worktree}/.devflow/docs/handoff-{branch_slug}.md verbatim, or (none)}
511
+ PR_TEST_PLAN_BLOCK: {PR_TEST_PLAN_BLOCK verbatim, or (none)}
512
+ PR_DESCRIPTION_GUIDANCE: {pr_description_guidance from Phase 1 unless it is (none), then the Code agents' reports from CODE_AGENT_OUTPUT in spawn order — Implementation, Commits and Key Decisions, and a sequential agent's ## Phase {N} Implementation Summary}
513
+ APPLY_CONVENTIONS: {APPLY_CONVENTIONS}
514
+ COMMIT_UNCOMMITTED: false
515
+ Open the pull request for this branch and return the pre-flight summary."
516
+ ```
517
+
518
+ `COMMIT_UNCOMMITTED: false` keeps the Git agent from committing a stray file: the Code, Simplify, Scrutinize and fix agents commit their own work. Capture the `- **PR**: #{number}` line of its `### Branch` as `PR_NUMBER`, its `### Uncommitted files` list and its `TRACEABILITY: DEGRADED ({reason})` lines for the Phase 12 report. If it returns `### Status: BLOCKED` or no PR number, report its reason to the user and stop at the report (Phase 12); Phases 10 and 11 do not run.
519
+
520
+ ### Phase 10: CI Status Gate
500
521
 
501
522
  **Produces:** CI_STATUS
502
- **Requires:** PR_URL, FILES_CHANGED
523
+ **Requires:** PR_NUMBER, FILES_CHANGED
503
524
 
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).
525
+ Run under every strategy: Phase 9 opened the PR.
505
526
 
506
527
  **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
528
 
@@ -509,52 +530,28 @@ Strategy-conditional: run when the PR already exists — **SINGLE_CODE_AGENT** a
509
530
  git push origin HEAD; echo "exit=$?"
510
531
  ```
511
532
 
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`.
533
+ `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 12 report, reports "CI status unknown — verify manually before merging" and proceeds to Phase 11 without waiting.
513
534
 
514
535
  <!-- PATTERN: ci-status-gate -->
515
536
  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
- 2. **If PASSING** → proceed to Phase 10.
517
- 3. **If NO_PR or NO_CI** → skip: "No PR/CI configured, skipping CI validation." Proceed to Phase 10.
537
+ 2. **If PASSING** → proceed to Phase 11.
538
+ 3. **If NO_PR or NO_CI** → skip: "No PR/CI configured, skipping CI validation." Proceed to Phase 11.
518
539
  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
540
  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.
541
+ <!-- learning:on -->
542
+ 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`, `DECISIONS_CONTEXT` 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.
543
+ <!-- learning:off -->
544
+ 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.
545
+ <!-- learning:end -->
521
546
  7. **Budget**: at most 3 waits and 2 fixes in all. When one is spent, report the current status and proceed.
522
547
  <!-- /PATTERN: ci-status-gate -->
523
548
 
524
- ### Phase 10: Create PR
525
-
526
- **Produces:** PR_URL
527
- **Requires:** BASE_BRANCH, TASK_ID, PR_EXCEPTIONS, PR_TEST_PLAN_BLOCK
528
-
529
- **For SEQUENTIAL_CODE_AGENTS**: the PR already exists — the last Phase 2 Code agent (`CREATE_PR: true`) created it, and Phase 9 has gated its CI.
530
-
531
- **For PARALLEL_CODE_AGENTS**: spawn one Code agent to create the unified PR:
532
-
533
- ```
534
- Agent(subagent_type="Code"):
535
- "OPERATION: pr-create
536
- TASK_ID: {task-id}
537
- TASK_DESCRIPTION: Create the unified PR for the parallel implementation
538
- BASE_BRANCH: {base branch}
539
- CREATE_PR: true
540
- PR_DESCRIPTION_GUIDANCE: {pr_description_guidance}
541
- ISSUE_NUMBER: {ISSUE_ID captured in Phase 1, or (none)}
542
- ISSUE_PR_LINK: {ISSUE_PR_LINK captured in Phase 1, or (none)}
543
- PR_EXCEPTIONS: {the ## Evidence Exceptions section of {worktree}/.devflow/docs/handoff-{branch_slug}.md verbatim, or (none)}
544
- PR_TEST_PLAN_BLOCK: {PR_TEST_PLAN_BLOCK from Phase 1 verbatim, or (none)}
545
- COMPLIANCE_FRAMEWORKS: {COMPLIANCE_FRAMEWORKS}"
546
- ```
547
-
548
- Its Responsibility 7 composes the body, pastes `ISSUE_PR_LINK`, `PR_EXCEPTIONS` and `PR_TEST_PLAN_BLOCK` through their paste gates and scrubs the body (D11) before `gh pr create`. This command renders no link line and creates no PR itself: the Git agent's Phase-1 rendering is the only one, forwarded verbatim.
549
-
550
- **For SINGLE_CODE_AGENT**: PR is created by the Code agent (CREATE_PR: true) — the Code agent's Responsibility 7 handles Related Issues inclusion when ISSUE_NUMBER is provided.
551
-
552
- ### Phase 10b: Evidence
549
+ ### Phase 11: Evidence
553
550
 
554
551
  **Produces:** EVIDENCE_RESULT
555
- **Requires:** PR_URL, EVIDENCE_FILE, REVIEW_PUBLICATION
552
+ **Requires:** PR_NUMBER, EVIDENCE_FILE, REVIEW_PUBLICATION
556
553
 
557
- Run once, after Phase 10, under every strategy: the PR exists by now under all three — from Phase 2 for SINGLE_CODE_AGENT and SEQUENTIAL_CODE_AGENTS, from Phase 10 for PARALLEL_CODE_AGENTS. Skip it only when no PR was created. PARALLEL_CODE_AGENTS ran no CI gate, so its `ci` TPs usually read `INDETERMINATE` until a later refresh.
554
+ Run once, after Phase 10, under every strategy: the PR exists by now, opened in Phase 9. The re-validation path has no CI gate and runs this phase straight after Phase 9. Skip it only when Phase 9 stopped the run. A `ci` TP reads `INDETERMINATE` only when the CI gate could not tell or did not run.
558
555
 
559
556
  **Push first.** Every claim is keyed to the HEAD an agent reported, and a Scrutinize or fix agent may have committed without pushing; a claim whose SHA is not in the PR reads `UNVERIFIED`. So push the branch once before the spawn — never force, and no retry:
560
557
 
@@ -562,29 +559,31 @@ Run once, after Phase 10, under every strategy: the PR exists by now under all t
562
559
  git push origin HEAD; echo "exit=$?"
563
560
  ```
564
561
 
565
- `exit=0` continues to the spawn. Any other result, a rejected non-fast-forward push included, does not block: record `TRACEABILITY: DEGRADED (evidence push failed)` for the Phase 11 report and spawn anyway.
562
+ `exit=0` continues to the spawn. Any other result, a rejected non-fast-forward push included, does not block: record `TRACEABILITY: DEGRADED (evidence push failed)` for the Phase 12 report and spawn anyway.
566
563
 
567
564
  ```
568
565
  Agent(subagent_type="Git"):
569
566
  "OPERATION: update-pr-evidence
570
- PR_NUMBER: {number from PR_URL}
567
+ PR_NUMBER: {PR_NUMBER}
571
568
  EVIDENCE_FILE: .devflow/docs/evidence-{branch_slug}.md
572
569
  REVIEW_PUBLICATION: {REVIEW_PUBLICATION resolved in Phase 1, or auto}
573
570
  WORKTREE_PATH: {worktree}
574
571
  Update the PR's test-plan block and post its evidence comment."
575
572
  ```
576
573
 
577
- Omit the `EVIDENCE_FILE` line when that file does not exist. Capture the op's `## PR Evidence` block — its `EVIDENCE` line and its `**Body**:` / `**Comment**:` line — as `EVIDENCE_RESULT`, or its `TRACEABILITY: DEGRADED ({reason})` line. It never blocks: whatever it returns, continue to Phase 11.
574
+ Omit the `EVIDENCE_FILE` line when that file does not exist. Capture the op's `## PR Evidence` block — its `EVIDENCE` line and its `**Body**:` / `**Comment**:` line — as `EVIDENCE_RESULT`, or its `TRACEABILITY: DEGRADED ({reason})` line. It never blocks: whatever it returns, continue to Phase 12.
578
575
 
579
- ### Phase 11: Report
576
+ ### Phase 12: Report
580
577
 
581
- **Requires:** VALIDATION_RESULT, ALIGNMENT_RESULT, QA_RESULT, PR_URL, EVIDENCE_RESULT
578
+ **Requires:** VALIDATION_RESULT, ALIGNMENT_RESULT, QA_RESULT, PR_NUMBER, EVIDENCE_RESULT
582
579
 
583
580
  Display completion summary with phase status, PR info, and next steps.
584
581
 
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`.
582
+ Show the test plan's evidence from Phase 11: `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`.
583
+
584
+ If any Git agent output emitted `TRACEABILITY: DEGRADED ({reason})` lines during the run, or Phase 10's push or Phase 11's push recorded one, surface them verbatim in the report under a `### Traceability` subsection so the user can act on them.
586
585
 
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.
586
+ If Phase 9 listed uncommitted files, show them as a `### Uncommitted files` subsection: the user commits them or discards them.
588
587
 
589
588
  If Phase 1 recorded an evidence exception, show its `## Evidence Exceptions` lines in the report.
590
589
 
@@ -596,7 +595,7 @@ If Phase 1 recorded an evidence exception, show its `## Evidence Exceptions` lin
596
595
  /implement (orchestrator - spawns agents only)
597
596
  │
598
597
  ├─ Re-validation Path (when user says "re-validate"/"re-check"/"re-run gates")
599
- │ └─ Branch safety → skip Phase 2 → detect FILES_CHANGED → Phases 3-8 → Phase 10, 10b, 11
598
+ │ └─ Branch safety → skip Phase 2 → detect FILES_CHANGED → Phases 3-8 → Phase 9, 11, 12
600
599
  │
601
600
  ├─ Phase 1: Setup
602
601
  │ └─ Plan document parsing (if .md path provided) - extracts execution plan, strategy, frontmatter issue
@@ -605,7 +604,7 @@ If Phase 1 recorded an evidence exception, show its `## Evidence Exceptions` lin
605
604
  │ └─ Test plan (evidence file) - copy or author TP lines, check them, render the PR block; missing under a required policy: record a test-plan exception or stop
606
605
  │
607
606
  ├─ Phase 2: Implement (3-strategy framework)
608
- │ ├─ SINGLE_CODE_AGENT (80%): One Code agent, full plan, CREATE_PR: true
607
+ │ ├─ SINGLE_CODE_AGENT (80%): One Code agent, full plan
609
608
  │ ├─ SEQUENTIAL_CODE_AGENTS (15%): N Code agents with handoff summaries
610
609
  │ └─ PARALLEL_CODE_AGENTS (5%): N Code agents in single message (rare)
611
610
  │
@@ -617,33 +616,31 @@ If Phase 1 recorded an evidence exception, show its `## Evidence Exceptions` lin
617
616
  │
618
617
  ├─ Phase 5: Alignment Check
619
618
  │ └─ Evaluate agent (validates alignment - reports only, no fixes)
620
- │ └─ If MISALIGNED: Code agent fix loop (max 2 iterations) → re-check alignment
619
+ │ └─ If MISALIGNED: Code-fix agent loop (max 2 iterations) → re-check alignment
621
620
  │
622
621
  ├─ Phase 6: Validate (the one full-suite slot)
623
622
  │ └─ 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
623
+ │ └─ If FAIL: Code-fix agent loop (max 2 retries) → re-validate at the new HEAD
625
624
  │ └─ If PASS: record VALIDATED_HEAD, gate:validate claim → evidence file
626
625
  │
627
626
  ├─ Phase 7: QA Testing
628
627
  │ └─ Test agent (scenario-based acceptance tests, TEST_PLAN) → one claim per TP row → evidence file
629
- │ └─ If FAIL: Code agent fix loop (max 2 retries) → re-test
628
+ │ └─ If FAIL: Code-fix agent loop (max 2 retries) → re-test
630
629
  │
631
630
  ├─ Phase 8: Re-Validate (only if a qa-fix committed)
632
631
  │ └─ Validate agent (changed-only over VALIDATED_HEAD..HEAD) → gate:validate claim
633
632
  │
634
- ├─ Phase 9: CI Status Gate (SINGLE_CODE_AGENT + SEQUENTIAL_CODE_AGENTS; skipped for PARALLEL_CODE_AGENTS)
635
- │ └─ Push the branch, then ci-wait.cjs (inline, one wait ≤ 570 s) → Code agent on FAILING (3 waits + 2 fixes)
633
+ ├─ Phase 9: Open PR (every strategy, outside the strategy branches)
634
+ │ └─ Git agent (operation: ensure-pr-ready) - commits nothing (COMMIT_UNCOMMITTED: false), pushes, opens the PR with the pasted link line, exceptions and test-plan block, D11-scrubbed body
636
635
  │
637
- ├─ Phase 10: Create PR (if needed)
638
- │ └─ SINGLE_CODE_AGENT: already created by the Phase 2 Code agent
639
- │ └─ SEQUENTIAL: already created by the last Phase 2 Code agent
640
- │ └─ PARALLEL: Code agent (pr-create) creates unified PR
636
+ ├─ Phase 10: CI Status Gate (every strategy)
637
+ │ └─ Push the branch, then ci-wait.cjs (inline, one wait ≤ 570 s) → Code-fix agent on FAILING (3 waits + 2 fixes)
641
638
  │
642
- ├─ Phase 10b: Evidence (every strategy, once the PR exists)
639
+ ├─ Phase 11: Evidence (every strategy, once the PR exists)
643
640
  │ └─ Push the branch (never force; a failure is DEGRADED, not a stop)
644
641
  │ └─ Git agent (update-pr-evidence) - test-plan block + evidence comment; never blocks
645
642
  │
646
- ├─ Phase 11: Report
643
+ ├─ Phase 12: Report
647
644
  │
648
645
  └─ Feature Knowledge Write-Back (Conditional)
649
646
  └─ Knowledge agent (if documented area changed AND knowledge enabled)
@@ -651,7 +648,7 @@ If Phase 1 recorded an evidence exception, show its `## Evidence Exceptions` lin
651
648
 
652
649
  ## Principles
653
650
 
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
651
+ 1. **Orchestration only** - Command spawns agents, never does work itself; the inline calls are the bounded plumbing the charter allows: the Phase 10 and Phase 11 pushes, the Phase 10 ci-wait call and the evidence script checks
655
652
  2. **Plan-first** - Plan documents from `/plan` skip exploration/planning overhead entirely
656
653
  3. **Coherence-first** - Single Code agent produces more consistent code (default ~80% of tasks)
657
654
  4. **Agent ownership** - Each agent owns its output completely
@@ -660,9 +657,9 @@ If Phase 1 recorded an evidence exception, show its `## Evidence Exceptions` lin
660
657
  7. **Simplification pass** - Code refined for clarity before PR
661
658
  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
659
  9. **Validate agent owns validation** - Never run `npm test`, `npm run build`, or similar in main session; always delegate to Validate agent
663
- 10. **Code agent owns fixes** - Never implement fixes in main session; spawn Code agent for validation failures and alignment fixes
660
+ 10. **Code-fix agent owns fixes** - Never implement fixes in main session; spawn Code-fix agent for validation failures and alignment fixes
664
661
  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
- 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
662
+ 12. **CI awareness** - CI status is checked before merge under every strategy, once Phase 9 has opened the PR; test-plan evidence (Phase 11) is recorded under every strategy once the PR exists
666
663
 
667
664
  ## Error Handling
668
665