devflow-kit 3.4.0 → 3.6.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 (221) hide show
  1. package/CHANGELOG.md +127 -0
  2. package/README.md +12 -8
  3. package/dist/agents/code.md +39 -182
  4. package/dist/agents/{diagnose.md → debug.md} +4 -4
  5. package/dist/agents/design.md +0 -1
  6. package/dist/agents/fix.md +165 -0
  7. package/dist/agents/git.md +31 -693
  8. package/dist/agents/{scrutinize.md → harden.md} +9 -6
  9. package/dist/agents/knowledge.md +8 -2
  10. package/dist/agents/refactor.md +133 -0
  11. package/dist/agents/research.md +6 -0
  12. package/dist/agents/review.md +0 -4
  13. package/dist/agents/skim.md +4 -0
  14. package/dist/agents/triage.md +8 -1
  15. package/dist/cli/agents-view/render.js +1 -1
  16. package/dist/cli/commands/behavior-prompts.js +77 -0
  17. package/dist/cli/commands/behavior.js +123 -0
  18. package/dist/cli/commands/flags.js +8 -2
  19. package/dist/cli/commands/init-seed.js +7 -3
  20. package/dist/cli/commands/init.js +75 -8
  21. package/dist/cli/commands/learning.js +12 -12
  22. package/dist/cli/commands/legacy-hooks.js +1 -1
  23. package/dist/cli/commands/rules.js +16 -0
  24. package/dist/cli/commands/tracker.js +112 -15
  25. package/dist/cli/commands/uninstall.js +111 -5
  26. package/dist/cli.js +2 -0
  27. package/dist/commands/bug-analysis.md +22 -18
  28. package/dist/commands/code-review.md +25 -29
  29. package/dist/commands/debug.md +36 -15
  30. package/dist/commands/dynamic-build.md +64 -78
  31. package/dist/commands/dynamic-plan.md +18 -14
  32. package/dist/commands/dynamic-profile.md +8 -6
  33. package/dist/commands/dynamic-tickets.md +19 -15
  34. package/dist/commands/explore.md +14 -14
  35. package/dist/commands/implement.md +122 -225
  36. package/dist/commands/plan.md +32 -47
  37. package/dist/commands/release.md +12 -7
  38. package/dist/commands/research.md +26 -15
  39. package/dist/commands/resolve.md +53 -92
  40. package/dist/commands/self-review.md +42 -42
  41. package/dist/core/agent-frontmatter.js +101 -0
  42. package/dist/core/agent-models.js +47 -11
  43. package/dist/core/compliance-compose.js +6 -4
  44. package/dist/core/{learning-tuning-config.js → curate-tuning-config.js} +14 -14
  45. package/dist/core/feature-switch.js +23 -2
  46. package/dist/core/flags.js +111 -0
  47. package/dist/core/learning-queue-cleanup.js +1 -1
  48. package/dist/core/manifest.js +11 -3
  49. package/dist/core/mds-variants.js +68 -26
  50. package/dist/core/migrations.js +63 -44
  51. package/dist/core/plugins.js +49 -70
  52. package/dist/core/project-paths.js +3 -7
  53. package/dist/core/proxy-log.js +1 -1
  54. package/dist/core/proxy-state.js +1 -1
  55. package/dist/core/tracker.js +120 -2
  56. package/dist/hud/codex-usage.js +247 -0
  57. package/dist/hud/components/codex-quota.js +37 -0
  58. package/dist/hud/components/usage-quota.js +1 -1
  59. package/dist/hud/config.js +1 -0
  60. package/dist/hud/index.js +16 -3
  61. package/dist/hud/render.js +3 -1
  62. package/dist/learning-off/agents/code.md +37 -180
  63. package/dist/learning-off/agents/{diagnose.md → debug.md} +4 -4
  64. package/dist/learning-off/agents/design.md +0 -1
  65. package/dist/learning-off/agents/fix.md +161 -0
  66. package/dist/learning-off/agents/{scrutinize.md → harden.md} +9 -6
  67. package/dist/learning-off/agents/knowledge.md +8 -2
  68. package/dist/learning-off/agents/refactor.md +129 -0
  69. package/dist/learning-off/agents/research.md +6 -0
  70. package/dist/learning-off/agents/review.md +0 -4
  71. package/dist/learning-off/agents/skim.md +4 -0
  72. package/dist/learning-off/agents/triage.md +8 -1
  73. package/dist/learning-off/commands/bug-analysis.md +12 -12
  74. package/dist/learning-off/commands/code-review.md +14 -22
  75. package/dist/learning-off/commands/debug.md +24 -8
  76. package/dist/learning-off/commands/dynamic-build.md +58 -74
  77. package/dist/learning-off/commands/dynamic-plan.md +12 -10
  78. package/dist/learning-off/commands/dynamic-profile.md +2 -2
  79. package/dist/learning-off/commands/dynamic-tickets.md +13 -11
  80. package/dist/learning-off/commands/explore.md +3 -7
  81. package/dist/learning-off/commands/implement.md +110 -217
  82. package/dist/learning-off/commands/plan.md +21 -39
  83. package/dist/learning-off/commands/release.md +7 -4
  84. package/dist/learning-off/commands/research.md +16 -9
  85. package/dist/learning-off/commands/resolve.md +42 -85
  86. package/dist/learning-off/commands/self-review.md +30 -34
  87. package/dist/skills/git/references/learn-conventions.md +27 -3
  88. package/dist/skills/git/references/pr/check-ci-status.md +19 -0
  89. package/dist/skills/git/references/pr/check-merge-readiness.md +21 -0
  90. package/dist/skills/git/references/pr/fetch-review-threads.md +30 -0
  91. package/dist/skills/git/references/pr/post-resolution-summary.md +18 -0
  92. package/dist/skills/git/references/pr/post-review-summary.md +20 -0
  93. package/dist/skills/git/references/pr/resolve-review-threads.md +28 -4
  94. package/dist/skills/git/references/pr/update-pr-evidence.md +17 -6
  95. package/dist/skills/git/references/pr/validate-branch.md +26 -0
  96. package/dist/skills/git/references/tracker/github/associate-release.md +24 -0
  97. package/dist/skills/git/references/tracker/github/backlink-shipped-issues.md +31 -1
  98. package/dist/skills/git/references/tracker/github/create-release.md +30 -1
  99. package/dist/skills/git/references/tracker/github/ensure-pr-ready.md +89 -2
  100. package/dist/skills/git/references/tracker/github/ensure-traceable-issue.md +16 -1
  101. package/dist/skills/git/references/tracker/github/fetch-issue.md +36 -1
  102. package/dist/skills/git/references/tracker/github/fetch-issues-batch.md +47 -1
  103. package/dist/skills/git/references/tracker/github/gather-release-evidence.md +25 -0
  104. package/dist/skills/git/references/tracker/github/manage-debt.md +21 -1
  105. package/dist/skills/git/references/tracker/github/post-wave-report.md +15 -1
  106. package/dist/skills/git/references/tracker/github/setup-task.md +41 -1
  107. package/dist/skills/git/references/tracker/jira/associate-release.md +24 -0
  108. package/dist/skills/git/references/tracker/jira/backlink-shipped-issues.md +31 -1
  109. package/dist/skills/git/references/tracker/jira/create-release.md +30 -1
  110. package/dist/skills/git/references/tracker/jira/ensure-pr-ready.md +89 -2
  111. package/dist/skills/git/references/tracker/jira/ensure-traceable-issue.md +16 -1
  112. package/dist/skills/git/references/tracker/jira/fetch-issue.md +36 -1
  113. package/dist/skills/git/references/tracker/jira/fetch-issues-batch.md +47 -1
  114. package/dist/skills/git/references/tracker/jira/gather-release-evidence.md +25 -0
  115. package/dist/skills/git/references/tracker/jira/manage-debt.md +21 -1
  116. package/dist/skills/git/references/tracker/jira/post-wave-report.md +15 -1
  117. package/dist/skills/git/references/tracker/jira/setup-task.md +41 -1
  118. package/dist/skills/git/references/tracker/linear/associate-release.md +24 -0
  119. package/dist/skills/git/references/tracker/linear/backlink-shipped-issues.md +31 -1
  120. package/dist/skills/git/references/tracker/linear/create-release.md +30 -1
  121. package/dist/skills/git/references/tracker/linear/ensure-pr-ready.md +89 -2
  122. package/dist/skills/git/references/tracker/linear/ensure-traceable-issue.md +16 -1
  123. package/dist/skills/git/references/tracker/linear/fetch-issue.md +36 -1
  124. package/dist/skills/git/references/tracker/linear/fetch-issues-batch.md +47 -1
  125. package/dist/skills/git/references/tracker/linear/gather-release-evidence.md +25 -0
  126. package/dist/skills/git/references/tracker/linear/manage-debt.md +21 -1
  127. package/dist/skills/git/references/tracker/linear/post-wave-report.md +15 -1
  128. package/dist/skills/git/references/tracker/linear/setup-task.md +41 -1
  129. package/dist/targets/claude-code/agent-type-owner.js +164 -0
  130. package/dist/targets/claude-code/behavior-install.js +111 -0
  131. package/dist/targets/claude-code/installer.js +177 -77
  132. package/dist/targets/claude-code/learning-install.js +9 -1
  133. package/dist/targets/claude-code/tracker-install.js +33 -16
  134. package/dist/targets/claude-code/tracker-servers.js +107 -0
  135. package/package.json +4 -3
  136. package/src/assets/agents/_partials/_code.mds +109 -0
  137. package/src/assets/agents/code.mds +18 -222
  138. package/src/assets/agents/{learning.md → curate.md} +22 -72
  139. package/src/assets/agents/{diagnose.mds → debug.mds} +4 -4
  140. package/src/assets/agents/design.mds +0 -1
  141. package/src/assets/agents/evaluate.md +11 -5
  142. package/src/assets/agents/explore.md +58 -0
  143. package/src/assets/agents/fix.mds +113 -0
  144. package/src/assets/agents/git.mds +31 -693
  145. package/src/assets/agents/{scrutinize.mds → harden.mds} +9 -6
  146. package/src/assets/agents/knowledge.mds +8 -2
  147. package/src/assets/agents/{simplify.md → polish.md} +7 -4
  148. package/src/assets/agents/refactor.mds +81 -0
  149. package/src/assets/agents/research.mds +6 -0
  150. package/src/assets/agents/review.mds +0 -4
  151. package/src/assets/agents/skim.mds +4 -0
  152. package/src/assets/agents/synthesize.md +26 -352
  153. package/src/assets/agents/test.md +10 -2
  154. package/src/assets/agents/tracker.md +20 -7
  155. package/src/assets/agents/triage.mds +8 -1
  156. package/src/assets/agents/validate.md +5 -0
  157. package/src/assets/commands/_partials/_compliance.mds +36 -0
  158. package/src/assets/commands/_partials/_decisions.mds +26 -6
  159. package/src/assets/commands/_partials/_engine.mds +17 -17
  160. package/src/assets/commands/_partials/_evidence_policy.mds +0 -17
  161. package/src/assets/commands/_partials/_knowledge.mds +14 -9
  162. package/src/assets/commands/_partials/_preamble.mds +5 -3
  163. package/src/assets/commands/_partials/_roster.mds +6 -5
  164. package/src/assets/commands/_partials/_wave.mds +2 -2
  165. package/src/assets/commands/bug-analysis.mds +10 -10
  166. package/src/assets/commands/code-review.mds +12 -22
  167. package/src/assets/commands/debug.mds +24 -2
  168. package/src/assets/commands/dynamic-build.mds +34 -51
  169. package/src/assets/commands/dynamic-plan.mds +4 -3
  170. package/src/assets/commands/dynamic-tickets.mds +5 -4
  171. package/src/assets/commands/explore.mds +1 -1
  172. package/src/assets/commands/implement.mds +108 -201
  173. package/src/assets/commands/plan.mds +19 -44
  174. package/src/assets/commands/release.mds +8 -3
  175. package/src/assets/commands/research.mds +14 -7
  176. package/src/assets/commands/resolve.mds +37 -82
  177. package/src/assets/commands/self-review.mds +27 -27
  178. package/src/assets/mds/.mdsroot +4 -0
  179. package/src/assets/mds/git/_ops.mds +383 -0
  180. package/src/assets/mds/git/_ops_pr.mds +201 -0
  181. package/src/assets/mds/git/_ops_steps.mds +147 -0
  182. package/src/assets/mds/git/_pr.mds +45 -50
  183. package/src/assets/mds/git/_references.mds +6 -3
  184. package/src/assets/mds/tracker/_common.mds +5 -5
  185. package/src/assets/mds/tracker/_contract.mds +4 -3
  186. package/src/assets/mds/tracker/_github.mds +60 -14
  187. package/src/assets/mds/tracker/_jira.mds +60 -14
  188. package/src/assets/mds/tracker/_linear.mds +60 -14
  189. package/src/assets/mds/tracker/_steps.mds +10 -9
  190. package/src/assets/rules/behavior.md +6 -0
  191. package/src/assets/scripts/hooks/assets/orchestrator-charter.md +5 -3
  192. package/src/assets/scripts/hooks/capture-prompt +1 -1
  193. package/src/assets/scripts/hooks/capture-question +1 -1
  194. package/src/assets/scripts/hooks/capture-turn +1 -1
  195. package/src/assets/scripts/hooks/json-helper.cjs +2 -2
  196. package/src/assets/scripts/hooks/lib/learning-store.cjs +1 -1
  197. package/src/assets/scripts/hooks/lib/project-paths.cjs +4 -10
  198. package/src/assets/scripts/hooks/preamble +1 -1
  199. package/src/assets/scripts/hooks/session-start-context +58 -45
  200. package/src/assets/scripts/verify-evidence.cjs +726 -9
  201. package/src/assets/skills/agent-references/SKILL.md +37 -0
  202. package/src/assets/skills/agent-references/references/commands/implement-evidence-asks.md +35 -0
  203. package/src/assets/skills/agent-references/references/commands/implement-revalidate.md +15 -0
  204. package/src/assets/skills/agent-references/references/curate/maintain.md +71 -0
  205. package/src/assets/skills/agent-references/references/synthesize/bug-analysis.md +71 -0
  206. package/src/assets/skills/agent-references/references/synthesize/design.md +36 -0
  207. package/src/assets/skills/agent-references/references/synthesize/exploration.md +38 -0
  208. package/src/assets/skills/agent-references/references/synthesize/planning.md +60 -0
  209. package/src/assets/skills/agent-references/references/synthesize/research.md +61 -0
  210. package/src/assets/skills/agent-references/references/synthesize/review.md +76 -0
  211. package/src/assets/skills/apply-decisions/SKILL.md +6 -4
  212. package/src/assets/skills/compliance/SKILL.md +1 -1
  213. package/src/assets/skills/docs-framework/SKILL.md +81 -84
  214. package/src/assets/skills/docs-framework/references/patterns.md +14 -25
  215. package/src/assets/skills/docs-framework/references/violations.md +7 -7
  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/qa/SKILL.md +1 -1
  219. package/src/assets/skills/quality-gates/SKILL.md +7 -7
  220. package/src/assets/skills/quality-gates/references/report-template.md +7 -7
  221. package/dist/skills/git/references/pr/ensure-pr-ready.md +0 -24
@@ -5,7 +5,7 @@ output-dir: dist/commands
5
5
  @import { knowledge_load, knowledge_writeback } from "./_partials/_knowledge.mds"
6
6
  @import { decisions_load } from "./_partials/_decisions.mds"
7
7
  @import { docs_root } from "./_partials/_docs_root.mds"
8
- @import { evidence_policy, evidence_exception } from "./_partials/_evidence_policy.mds"
8
+ @import { evidence_policy } from "./_partials/_evidence_policy.mds"
9
9
  @import { issue_ref_grammar, issue_capture_contract } from "./_partials/_tracker.mds"
10
10
  @import { test_plan_line } from "./_partials/_plan_contract.mds"
11
11
  @import { publication_gate } from "./_partials/_publication.mds"
@@ -46,22 +46,14 @@ $ARGUMENTS
46
46
 
47
47
  ### Re-validation Continuation Path
48
48
 
49
- When the user explicitly asks to re-validate, re-check, or re-run quality gates after making their own changes:
50
-
51
- 1. **Branch safety check**: If on a protected branch (main, master, develop, etc.), run Phase 1 to create/switch to a work branch. If already on a work branch, skip Phase 1.
52
- 2. **Skip Phase 2** — no Code agent needed, user already made changes.
53
- 3. **Detect FILES_CHANGED**: `git diff --name-only {base_branch}...HEAD`
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.
55
- 5. **Proceed to Phase 10** (Create PR), **Phase 10b** (Evidence) and **Phase 11** (Report).
56
-
57
- If the user prompt does NOT match re-validation, proceed with the full pipeline below.
49
+ When the user explicitly asks to re-validate, re-check, or re-run quality gates after making their own changes, resolve `${CLAUDE_CONFIG_DIR:-$HOME/.claude}` in Bash, Read `<that directory>/skills/devflow:agent-references/references/commands/implement-revalidate.md` with the Read tool and follow it. Otherwise proceed with the full pipeline below.
58
50
 
59
51
  ### Phase 1: Setup
60
52
 
61
53
  <!-- learning:on -->
62
- **Produces:** TASK_ID, BASE_BRANCH, EXECUTION_PLAN, DECISIONS_CONTEXT, FEATURE_KNOWLEDGE, FEATURE_KNOWLEDGE_RULES, 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
54
+ **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
55
  <!-- learning:off -->
64
- **Produces:** TASK_ID, BASE_BRANCH, EXECUTION_PLAN, FEATURE_KNOWLEDGE, FEATURE_KNOWLEDGE_RULES, 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
56
+ **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
57
  <!-- learning:end -->
66
58
 
67
59
  Record the current branch name as `BASE_BRANCH` - this will be the PR target.
@@ -131,16 +123,11 @@ visible, a silently discarded request is not.
131
123
  - `TASK_ID`: The branch name created by Git agent (use as TASK_ID for rest of flow)
132
124
  - `BASE_BRANCH`: Branch this feature was created from (for PR target)
133
125
  - `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)
126
+ - `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.
134
127
 
135
128
  {{issue_capture_contract()}}
136
129
 
137
- **Ticket link, only when `ISSUE_REQUIRED` is `true`:** when the capture above holds no `ISSUE_PR_LINK` (absent, or `(none)`), ask with AskUserQuestion before any Code spawn — "No tracker issue is linked to this task. Record a self-attested exception, or stop?" — offering exactly these two options:
138
- - **Record an exception** — the user gives the reason as free text. Render it with the grammar below, as kind `ticket-link`; when the rendered reason is empty, ask for it once more, and stop as below if it is empty again.
139
- - **Stop** — report `BLOCKED (no ticket link)`, name the branch setup-task created (`TASK_ID`) and `BASE_BRANCH` so it can be reused or removed, and give the remedy: create or link the tracker issue and re-run `/implement` with its reference, or — for a team that does not want ticket links — 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.
140
-
141
- {{evidence_exception()}}
142
-
143
- **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)`.
130
+ **Ticket link, only when `ISSUE_REQUIRED` is `true`:** when the capture above holds no `ISSUE_PR_LINK` (absent, or `(none)`), resolve `${CLAUDE_CONFIG_DIR:-$HOME/.claude}` in Bash, Read `<that directory>/skills/devflow:agent-references/references/commands/implement-evidence-asks.md` with the Read tool (once per run), then run its ticket link ask and **Record the exception at once** as it directs, before any Code spawn. `PR_EXCEPTIONS` is `(none)` until an exception is recorded.
144
131
 
145
132
  **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.
146
133
 
@@ -156,11 +143,9 @@ node "$HOME/.devflow/scripts/verify-evidence.cjs" check tp "{worktree}/.devflow/
156
143
 
157
144
  `exit=0` passes. On any other result, rewrite the section once — the script names the failing line and its code on stderr — and check again. Still failing, or no line to write, means the test plan is **missing**: drop the `## Test Plan` section from the file.
158
145
 
159
- **Missing test plan, only when `EVIDENCE_POLICY` is `required`:** when the check above leaves the test plan missing, ask with AskUserQuestion before any Code spawn — "No test plan could be written for this task. Record a self-attested exception, or stop?" — offering exactly these two options:
160
- - **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.
161
- - **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.
146
+ **Missing test plan, only when `EVIDENCE_POLICY` is `required`:** when the check above leaves the test plan missing, Read the evidence-asks reference as in the ticket link step (when this run has not) and run its missing test plan ask before any Code spawn.
162
147
 
163
- When `EVIDENCE_POLICY` is `standard`, a missing test plan is never asked about: carry `Test plan: missing` to the Phase 11 report.
148
+ When `EVIDENCE_POLICY` is `standard`, a missing test plan is never asked about: carry `Test plan: missing` to the Phase 12 report.
164
149
 
165
150
  **Test-plan outputs**, set once before any Code spawn:
166
151
  - `TEST_PLAN` — the TP lines of the evidence file's `## Test Plan` section, or `(none)` when the test plan is missing.
@@ -175,19 +160,23 @@ node "$HOME/.devflow/scripts/verify-evidence.cjs" render --plan "{worktree}/.dev
175
160
  {{settings.settings_resolve()}}
176
161
 
177
162
  {{publication_gate()}}
178
- 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.
163
+ Phase 11 passes the resolved value to the evidence script (`publish`), which decides what each value means for the evidence comment. From the same line: {{compliance.compliance_frameworks()}}
164
+
165
+ {{compliance.compliance_inject()}}
166
+
167
+ Pass `COMPLIANCE_DIRECTIVE` to every Code and Fix spawn, on a line of its own.
179
168
 
180
169
  {{decisions_load()}}
181
170
  <!-- learning:on -->
182
- Pass `DECISIONS_CONTEXT` to Code agent (Phase 2) and Scrutinize agent (Phase 4).
171
+ Pass `DECISIONS_CONTEXT` to Code agent (Phase 2) and Harden agent (Phase 4).
183
172
 
184
173
  <!-- learning:end -->
185
174
  {{knowledge_load()}}
186
175
 
187
176
  ### Phase 2: Implement
188
177
 
189
- **Produces:** CODE_AGENT_OUTPUT, FILES_CHANGED, PR_URL
190
- **Requires:** TASK_ID, BASE_BRANCH, EXECUTION_PLAN, PR_DESCRIPTION_GUIDANCE, PR_EXCEPTIONS, PR_TEST_PLAN_BLOCK
178
+ **Produces:** CODE_AGENT_OUTPUT, FILES_CHANGED
179
+ **Requires:** TASK_ID, BASE_BRANCH, EXECUTION_PLAN
191
180
 
192
181
  Based on Setup context (plan document, issue body, or conversation context), use the three-strategy framework:
193
182
 
@@ -213,18 +202,11 @@ TASK_DESCRIPTION: {description}
213
202
  BASE_BRANCH: {base branch}
214
203
  EXECUTION_PLAN: {full plan from setup context}
215
204
  PATTERNS: {patterns from plan document or empty}
216
- CREATE_PR: true
217
- DOMAIN: {detected domain or 'fullstack'}
218
205
  FEATURE_KNOWLEDGE: {feature_knowledge}
219
206
  <!-- learning:on -->
220
207
  DECISIONS_CONTEXT: {decisions_context}
221
208
  <!-- learning:end -->
222
- COMPLIANCE_FRAMEWORKS: {COMPLIANCE_FRAMEWORKS}
223
- PR_DESCRIPTION_GUIDANCE: {pr_description_guidance}
224
- ISSUE_NUMBER: {ISSUE_ID captured in Phase 1, or (none)}
225
- ISSUE_PR_LINK: {ISSUE_PR_LINK captured in Phase 1, or (none)}
226
- PR_EXCEPTIONS: {the ## Evidence Exceptions section of {worktree}/.devflow/docs/handoff-{branch_slug}.md verbatim, or (none)}
227
- PR_TEST_PLAN_BLOCK: {PR_TEST_PLAN_BLOCK from Phase 1 verbatim, or (none)}"
209
+ {COMPLIANCE_DIRECTIVE}"
228
210
  ```
229
211
 
230
212
  ---
@@ -242,16 +224,11 @@ TASK_DESCRIPTION: {phase 1 description}
242
224
  BASE_BRANCH: {base branch}
243
225
  EXECUTION_PLAN: {phase 1 steps}
244
226
  PATTERNS: {patterns from plan document or empty}
245
- CREATE_PR: false
246
- DOMAIN: {phase 1 domain, e.g., 'backend'}
247
227
  FEATURE_KNOWLEDGE: {feature_knowledge}
248
228
  <!-- learning:on -->
249
229
  DECISIONS_CONTEXT: {decisions_context}
250
230
  <!-- learning:end -->
251
- COMPLIANCE_FRAMEWORKS: {COMPLIANCE_FRAMEWORKS}
252
- PR_DESCRIPTION_GUIDANCE: {pr_description_guidance}
253
- ISSUE_NUMBER: {ISSUE_ID captured in Phase 1, or (none)}
254
- ISSUE_PR_LINK: {ISSUE_PR_LINK captured in Phase 1, or (none)}
231
+ {COMPLIANCE_DIRECTIVE}
255
232
  HANDOFF_REQUIRED: true
256
233
  HANDOFF_FILE: {worktree}/.devflow/docs/handoff-{branch_slug}.md"
257
234
  ```
@@ -265,25 +242,18 @@ TASK_DESCRIPTION: {phase N description}
265
242
  BASE_BRANCH: {base branch}
266
243
  EXECUTION_PLAN: {phase N steps}
267
244
  PATTERNS: {patterns from plan document or empty}
268
- CREATE_PR: {true if last phase, false otherwise}
269
- DOMAIN: {phase N domain, e.g., 'frontend'}
270
245
  PRIOR_PHASE_SUMMARY: {summary from previous Code agent}
271
246
  FILES_FROM_PRIOR_PHASE: {list of files created}
272
247
  FEATURE_KNOWLEDGE: {feature_knowledge}
273
248
  <!-- learning:on -->
274
249
  DECISIONS_CONTEXT: {decisions_context}
275
250
  <!-- learning:end -->
276
- COMPLIANCE_FRAMEWORKS: {COMPLIANCE_FRAMEWORKS}
277
- PR_DESCRIPTION_GUIDANCE: {pr_description_guidance}
278
- ISSUE_NUMBER: {ISSUE_ID captured in Phase 1, or (none)}
279
- ISSUE_PR_LINK: {ISSUE_PR_LINK captured in Phase 1, or (none)}
280
- PR_EXCEPTIONS: {the ## Evidence Exceptions section of {worktree}/.devflow/docs/handoff-{branch_slug}.md verbatim, or (none)}
281
- PR_TEST_PLAN_BLOCK: {PR_TEST_PLAN_BLOCK from Phase 1 verbatim, or (none)}
251
+ {COMPLIANCE_DIRECTIVE}
282
252
  HANDOFF_REQUIRED: {true if not last phase}
283
253
  HANDOFF_FILE: {worktree}/.devflow/docs/handoff-{branch_slug}.md"
284
254
  ```
285
255
 
286
- **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 the final Code agent, which creates it, completes (cleanup).
256
+ **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).
287
257
 
288
258
  ---
289
259
 
@@ -299,16 +269,11 @@ TASK_DESCRIPTION: {independent subtask 1}
299
269
  BASE_BRANCH: {base branch}
300
270
  EXECUTION_PLAN: {subtask 1 steps}
301
271
  PATTERNS: {patterns}
302
- CREATE_PR: false
303
- DOMAIN: {subtask 1 domain}
304
272
  FEATURE_KNOWLEDGE: {feature_knowledge}
305
273
  <!-- learning:on -->
306
274
  DECISIONS_CONTEXT: {decisions_context}
307
275
  <!-- learning:end -->
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)}"
276
+ {COMPLIANCE_DIRECTIVE}"
312
277
 
313
278
  Agent(subagent_type="Code"): # Code agent 2 (same message)
314
279
  "OPERATION: implement
@@ -317,16 +282,11 @@ TASK_DESCRIPTION: {independent subtask 2}
317
282
  BASE_BRANCH: {base branch}
318
283
  EXECUTION_PLAN: {subtask 2 steps}
319
284
  PATTERNS: {patterns}
320
- CREATE_PR: false
321
- DOMAIN: {subtask 2 domain}
322
285
  FEATURE_KNOWLEDGE: {feature_knowledge}
323
286
  <!-- learning:on -->
324
287
  DECISIONS_CONTEXT: {decisions_context}
325
288
  <!-- learning:end -->
326
- COMPLIANCE_FRAMEWORKS: {COMPLIANCE_FRAMEWORKS}
327
- PR_DESCRIPTION_GUIDANCE: {pr_description_guidance}
328
- ISSUE_NUMBER: {ISSUE_ID captured in Phase 1, or (none)}
329
- ISSUE_PR_LINK: {ISSUE_PR_LINK captured in Phase 1, or (none)}"
289
+ {COMPLIANCE_DIRECTIVE}"
330
290
  ```
331
291
 
332
292
  **Independence criteria** (all must be true for PARALLEL_CODE_AGENTS):
@@ -335,16 +295,16 @@ ISSUE_PR_LINK: {ISSUE_PR_LINK captured in Phase 1, or (none)}"
335
295
  - Different files/modules with no imports between them
336
296
  - Each subtask is self-contained
337
297
 
338
- ### Phase 3: Simplify
298
+ ### Phase 3: Polish
339
299
 
340
- **Produces:** SIMPLIFY_OUTPUT
300
+ **Produces:** POLISH_OUTPUT
341
301
  **Requires:** FILES_CHANGED
342
302
 
343
- After the Code agent completes, spawn Simplify agent to polish the code. The Phase 6 Validate covers its commits.
303
+ After the Code agent completes, spawn Polish agent to polish the code. The Phase 6 Validate covers its commits.
344
304
 
345
305
  ```
346
- Agent(subagent_type="Simplify"):
347
- "Simplify recently implemented code
306
+ Agent(subagent_type="Polish"):
307
+ "Polish recently implemented code
348
308
  Task: {task description}
349
309
  FILES_CHANGED: {list of files from Code agent output}
350
310
  Focus on code modified by Code agent, apply project standards, enhance clarity
@@ -353,13 +313,13 @@ Commit any improvements with a conventional-commit message."
353
313
 
354
314
  ### Phase 4: Self-Review
355
315
 
356
- **Produces:** SCRUTINIZE_OUTPUT
316
+ **Produces:** HARDEN_OUTPUT
357
317
  **Requires:** FILES_CHANGED
358
318
 
359
- After Simplify agent completes, spawn Scrutinize agent as the quality gate:
319
+ After Polish agent completes, spawn Harden agent as the quality gate:
360
320
 
361
321
  ```
362
- Agent(subagent_type="Scrutinize"):
322
+ Agent(subagent_type="Harden"):
363
323
  "TASK_DESCRIPTION: {task description}
364
324
  FILES_CHANGED: {list of files from Code agent output}
365
325
  <!-- learning:on -->
@@ -369,14 +329,14 @@ FEATURE_KNOWLEDGE: {feature_knowledge_rules}
369
329
  Evaluate 9 pillars, fix P0/P1 issues, report status"
370
330
  ```
371
331
 
372
- Scrutinize agent reports `### Status: PASS | FIXED | BLOCKED`. **If BLOCKED:** report to user and halt. **If PASS or FIXED:** continue to Phase 5. A FIXED status commits fixes and starts no Validate of its own: the Phase 6 run covers them.
332
+ Harden agent reports `### Status: PASS | FIXED | BLOCKED`. **If BLOCKED:** report to user and halt. **If PASS or FIXED:** continue to Phase 5. A FIXED status commits fixes and starts no Validate of its own: the Phase 6 run covers them.
373
333
 
374
334
  ### Phase 5: Alignment Check
375
335
 
376
336
  **Produces:** ALIGNMENT_RESULT
377
337
  **Requires:** FILES_CHANGED, EXECUTION_PLAN
378
338
 
379
- 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:
339
+ After Harden 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 Harden agent:
380
340
 
381
341
  ```
382
342
  Agent(subagent_type="Evaluate"):
@@ -394,21 +354,18 @@ Validate alignment with request and plan. Report ALIGNED or MISALIGNED with deta
394
354
  1. Extract misalignment details from Evaluate agent output
395
355
  2. Increment `alignment_fix_count`
396
356
  3. If `alignment_fix_count <= 2`:
397
- - Spawn Code agent to fix misalignments:
357
+ - Spawn Fix agent to fix misalignments:
398
358
  ```
399
- Agent(subagent_type="Code"):
359
+ Agent(subagent_type="Fix"):
400
360
  "OPERATION: alignment-fix
401
361
  TASK_ID: {task-id}
402
362
  TASK_DESCRIPTION: Fix alignment issues
403
363
  MISALIGNMENTS: {structured misalignments from Evaluate agent}
404
364
  SCOPE: Fix only the listed misalignments, no other changes
405
- CREATE_PR: false
406
365
  <!-- learning:on -->
407
366
  DECISIONS_CONTEXT: {decisions_context}
408
367
  <!-- learning:end -->
409
- ISSUE_NUMBER: {ISSUE_ID captured in Phase 1, or (none)}
410
- ISSUE_PR_LINK: {ISSUE_PR_LINK captured in Phase 1, or (none)}
411
- COMPLIANCE_FRAMEWORKS: {COMPLIANCE_FRAMEWORKS}"
368
+ {COMPLIANCE_DIRECTIVE}"
412
369
  ```
413
370
  - Loop back to Phase 5 (re-check alignment). The fix is not validated here: the Phase 6 run covers it.
414
371
  4. If `alignment_fix_count > 2`: Report misalignments to user for decision
@@ -418,7 +375,7 @@ Validate alignment with request and plan. Report ALIGNED or MISALIGNED with deta
418
375
  **Produces:** VALIDATION_RESULT, VALIDATED_HEAD
419
376
  **Requires:** BASE_BRANCH
420
377
 
421
- Validate takes the one full-suite slot, after every commit it must cover: Code, Simplify, Scrutinize and the alignment fixes. After Evaluate agent passes, spawn Validate agent. `FILES_CHANGED` is the branch diff, because the Code agent's own list misses the Simplify, Scrutinize and fix commits (`{base}` is `BASE_BRANCH`):
378
+ Validate takes the one full-suite slot, after every commit it must cover: Code, Polish, Harden and the alignment fixes. After Evaluate agent passes, spawn Validate agent. `FILES_CHANGED` is the branch diff, because the Code agent's own list misses the Polish, Harden and fix commits (`{base}` is `BASE_BRANCH`):
422
379
 
423
380
  ```
424
381
  Agent(subagent_type="Validate"):
@@ -431,21 +388,18 @@ Run build, typecheck, lint, test. Report pass/fail with failure details."
431
388
  1. Extract failure details from Validate agent output
432
389
  2. Increment `validation_retry_count`
433
390
  3. If `validation_retry_count <= 2`:
434
- - Spawn Code agent with fix context:
391
+ - Spawn Fix agent with fix context:
435
392
  ```
436
- Agent(subagent_type="Code"):
393
+ Agent(subagent_type="Fix"):
437
394
  "OPERATION: validation-fix
438
395
  TASK_ID: {task-id}
439
396
  TASK_DESCRIPTION: Fix validation failures
440
397
  VALIDATION_FAILURES: {parsed failures from Validate agent}
441
398
  SCOPE: Fix only the listed failures, no other changes
442
- CREATE_PR: false
443
399
  <!-- learning:on -->
444
400
  DECISIONS_CONTEXT: {decisions_context}
445
401
  <!-- learning:end -->
446
- ISSUE_NUMBER: {ISSUE_ID captured in Phase 1, or (none)}
447
- ISSUE_PR_LINK: {ISSUE_PR_LINK captured in Phase 1, or (none)}
448
- COMPLIANCE_FRAMEWORKS: {COMPLIANCE_FRAMEWORKS}"
402
+ {COMPLIANCE_DIRECTIVE}"
449
403
  ```
450
404
  - Loop back to Phase 6 (re-validate at the new HEAD, full scope)
451
405
  4. If `validation_retry_count > 2`: Report failures to user and halt
@@ -461,7 +415,7 @@ Run build, typecheck, lint, test. Report pass/fail with failure details."
461
415
 
462
416
  - `gate:validate` — after a Phase 6 or Phase 8 PASS.
463
417
  - `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.
464
- - 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.
418
+ - 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.
465
419
 
466
420
  ### Phase 7: QA Testing
467
421
 
@@ -488,24 +442,21 @@ After every Test agent run — PASS or FAIL, first run or retry — append its T
488
442
  1. Extract failure details from Test agent output
489
443
  2. Increment `qa_retry_count`
490
444
  3. If `qa_retry_count <= 2`:
491
- - Spawn Code agent to fix QA failures:
445
+ - Spawn Fix agent to fix QA failures:
492
446
  ```
493
- Agent(subagent_type="Code"):
447
+ Agent(subagent_type="Fix"):
494
448
  "OPERATION: qa-fix
495
449
  TASK_ID: {task-id}
496
450
  TASK_DESCRIPTION: Fix QA test failures
497
451
  QA_FAILURES: {structured failures from Test agent}
498
452
  SCOPE: Fix only the listed failures, no other changes
499
- CREATE_PR: false
500
453
  <!-- learning:on -->
501
454
  DECISIONS_CONTEXT: {decisions_context}
502
455
  <!-- learning:end -->
503
- ISSUE_NUMBER: {ISSUE_ID captured in Phase 1, or (none)}
504
- ISSUE_PR_LINK: {ISSUE_PR_LINK captured in Phase 1, or (none)}
505
- COMPLIANCE_FRAMEWORKS: {COMPLIANCE_FRAMEWORKS}"
456
+ {COMPLIANCE_DIRECTIVE}"
506
457
  ```
507
458
  - Loop back to Phase 7 (re-run Test agent). The fix is not validated here: Phase 8 covers it.
508
- 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.
459
+ 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.
509
460
 
510
461
  ### Phase 8: Re-Validate (only if a qa-fix committed)
511
462
 
@@ -525,99 +476,94 @@ Verify the qa-fix commits did not break anything."
525
476
 
526
477
  **If PASS:** append a `gate:validate` claim (Phase 6's **Evidence claims**), then continue to Phase 9.
527
478
 
528
- ### Phase 9: CI Status Gate
479
+ ### Phase 9: Open PR
480
+
481
+ **Produces:** PR_NUMBER
482
+ **Requires:** BASE_BRANCH, TASK_ID, ISSUE_NUMBER, ISSUE_PR_LINK, PR_EXCEPTIONS, PR_TEST_PLAN_BLOCK, PR_DESCRIPTION_GUIDANCE, APPLY_CONVENTIONS, CODE_AGENT_OUTPUT
483
+
484
+ 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.
485
+
486
+ ```
487
+ Agent(subagent_type="Git"):
488
+ "OPERATION: ensure-pr-ready
489
+ WORKTREE_PATH: {worktree}
490
+ BASE_BRANCH: {base branch}
491
+ TASK_ID: {task-id}
492
+ ISSUE_NUMBER: {ISSUE_ID captured in Phase 1, or (none)}
493
+ ISSUE_PR_LINK: {ISSUE_PR_LINK captured in Phase 1, or (none)}
494
+ PR_EXCEPTIONS: {the ## Evidence Exceptions section of {worktree}/.devflow/docs/handoff-{branch_slug}.md verbatim, or (none)}
495
+ PR_TEST_PLAN_BLOCK: {PR_TEST_PLAN_BLOCK verbatim, or (none)}
496
+ 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}
497
+ APPLY_CONVENTIONS: {APPLY_CONVENTIONS}
498
+ COMMIT_UNCOMMITTED: false
499
+ Open the pull request for this branch and return the pre-flight summary."
500
+ ```
501
+
502
+ `COMMIT_UNCOMMITTED: false` keeps the Git agent from committing a stray file: the Code, Polish, Harden 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.
503
+
504
+ ### Phase 10: CI Status Gate
529
505
 
530
506
  **Produces:** CI_STATUS
531
- **Requires:** PR_URL, FILES_CHANGED
507
+ **Requires:** PR_NUMBER, FILES_CHANGED
532
508
 
533
- 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).
509
+ Run under every strategy: Phase 9 opened the PR.
534
510
 
535
- **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:
511
+ **Push first, outside the gate block.** The gate reads CI for the pushed head, and the Polish, Harden and Fix commits reach the PR only by a push. Push once — never force, and no retry:
536
512
 
537
513
  ```bash
538
514
  git push origin HEAD; echo "exit=$?"
539
515
  ```
540
516
 
541
- `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`.
517
+ `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.
542
518
 
543
519
  <!-- PATTERN: ci-status-gate -->
544
520
  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.
545
- 2. **If PASSING** → proceed to Phase 10.
546
- 3. **If NO_PR or NO_CI** → skip: "No PR/CI configured, skipping CI validation." Proceed to Phase 10.
521
+ 2. **If PASSING** → proceed to Phase 11.
522
+ 3. **If NO_PR or NO_CI** → skip: "No PR/CI configured, skipping CI validation." Proceed to Phase 11.
547
523
  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.
548
524
  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.
549
525
  <!-- learning:on -->
550
- 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`, `DECISIONS_CONTEXT` 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.
526
+ 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`, `DECISIONS_CONTEXT` 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.
551
527
  <!-- learning:off -->
552
- 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.
528
+ 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.
553
529
  <!-- learning:end -->
554
530
  7. **Budget**: at most 3 waits and 2 fixes in all. When one is spent, report the current status and proceed.
555
531
  <!-- /PATTERN: ci-status-gate -->
556
532
 
557
- ### Phase 10: Create PR
558
-
559
- **Produces:** PR_URL
560
- **Requires:** BASE_BRANCH, TASK_ID, PR_EXCEPTIONS, PR_TEST_PLAN_BLOCK
561
-
562
- **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.
563
-
564
- **For PARALLEL_CODE_AGENTS**: spawn one Code agent to create the unified PR:
565
-
566
- ```
567
- Agent(subagent_type="Code"):
568
- "OPERATION: pr-create
569
- TASK_ID: {task-id}
570
- TASK_DESCRIPTION: Create the unified PR for the parallel implementation
571
- BASE_BRANCH: {base branch}
572
- CREATE_PR: true
573
- PR_DESCRIPTION_GUIDANCE: {pr_description_guidance}
574
- ISSUE_NUMBER: {ISSUE_ID captured in Phase 1, or (none)}
575
- ISSUE_PR_LINK: {ISSUE_PR_LINK captured in Phase 1, or (none)}
576
- PR_EXCEPTIONS: {the ## Evidence Exceptions section of {worktree}/.devflow/docs/handoff-{branch_slug}.md verbatim, or (none)}
577
- PR_TEST_PLAN_BLOCK: {PR_TEST_PLAN_BLOCK from Phase 1 verbatim, or (none)}
578
- COMPLIANCE_FRAMEWORKS: {COMPLIANCE_FRAMEWORKS}"
579
- ```
580
-
581
- 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.
582
-
583
- **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.
584
-
585
- ### Phase 10b: Evidence
533
+ ### Phase 11: Evidence
586
534
 
587
535
  **Produces:** EVIDENCE_RESULT
588
- **Requires:** PR_URL, EVIDENCE_FILE, REVIEW_PUBLICATION
536
+ **Requires:** PR_NUMBER, EVIDENCE_FILE, REVIEW_PUBLICATION
589
537
 
590
- 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.
538
+ 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.
591
539
 
592
- **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:
540
+ **Push first.** Every claim is keyed to the HEAD an agent reported, and a Harden 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 script — never force, and no retry:
593
541
 
594
542
  ```bash
595
543
  git push origin HEAD; echo "exit=$?"
596
544
  ```
597
545
 
598
- `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.
546
+ `exit=0` continues to the script. 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 run the script anyway.
599
547
 
600
- ```
601
- Agent(subagent_type="Git"):
602
- "OPERATION: update-pr-evidence
603
- PR_NUMBER: {number from PR_URL}
604
- EVIDENCE_FILE: .devflow/docs/evidence-{branch_slug}.md
605
- REVIEW_PUBLICATION: {REVIEW_PUBLICATION resolved in Phase 1, or auto}
606
- WORKTREE_PATH: {worktree}
607
- Update the PR's test-plan block and post its evidence comment."
548
+ **Then refresh, inline.** The refresh is plumbing, so no Git agent runs it: `verify-evidence.cjs publish` is the whole `update-pr-evidence` operation — verify, the scrubbed block edit with its read-back, the scrubbed evidence comment — in one call. Use the Bash tool with `timeout: 180000`:
549
+
550
+ ```bash
551
+ cd "{worktree}" && node "$HOME/.devflow/scripts/verify-evidence.cjs" publish --pr {PR_NUMBER} --evidence ".devflow/docs/evidence-{branch_slug}.md" --publication {REVIEW_PUBLICATION resolved in Phase 1, or auto}; echo "exit=$?"
608
552
  ```
609
553
 
610
- 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.
554
+ Drop the `--evidence` pair when that file does not exist or its path does not match `^[A-Za-z0-9._/-]{1,255}$`. `{PR_NUMBER}` is digits only, and the publication value is `auto`, `full`, `off` or `stub`. Capture its stdout as `EVIDENCE_RESULT`: the `## PR Evidence` block — its `EVIDENCE` line and its `**Body**:` / `**Comment**:` line — and any `TRACEABILITY: DEGRADED ({reason})` lines after it (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: whatever it returns, continue to Phase 12.
611
555
 
612
- ### Phase 11: Report
556
+ ### Phase 12: Report
613
557
 
614
- **Requires:** VALIDATION_RESULT, ALIGNMENT_RESULT, QA_RESULT, PR_URL, EVIDENCE_RESULT
558
+ **Requires:** VALIDATION_RESULT, ALIGNMENT_RESULT, QA_RESULT, PR_NUMBER, EVIDENCE_RESULT
615
559
 
616
560
  Display completion summary with phase status, PR info, and next steps.
617
561
 
618
- 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`.
562
+ 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`.
563
+
564
+ If any Git agent output emitted `TRACEABILITY: DEGRADED ({reason})` lines during the run, or Phase 10's push, Phase 11's push or Phase 11's script output carried one, surface them verbatim in the report under a `### Traceability` subsection so the user can act on them.
619
565
 
620
- 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.
566
+ If Phase 9 listed uncommitted files, show them as a `### Uncommitted files` subsection: the user commits them or discards them.
621
567
 
622
568
  If Phase 1 recorded an evidence exception, show its `## Evidence Exceptions` lines in the report.
623
569
 
@@ -629,73 +575,34 @@ If Phase 1 recorded an evidence exception, show its `## Evidence Exceptions` lin
629
575
  /implement (orchestrator - spawns agents only)
630
576
  │
631
577
  ├─ Re-validation Path (when user says "re-validate"/"re-check"/"re-run gates")
632
- │ └─ Branch safety → skip Phase 2 → detect FILES_CHANGED → Phases 3-8 → Phase 10, 10b, 11
578
+ │ └─ Branch safety → skip Phase 2 → detect FILES_CHANGED → Phases 3-8 → Phase 9, 11, 12
633
579
  │
634
580
  ├─ Phase 1: Setup
635
- │ └─ Plan document parsing (if .md path provided) - extracts execution plan, strategy, frontmatter issue
636
- │ └─ Git agent (operation: setup-task) - creates feature branch, fetches issue
637
- │ └─ Ticket-link ask (no linked ticket, issue required) - record a self-attested exception or stop
638
- │ └─ 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
639
- │
640
581
  ├─ Phase 2: Implement (3-strategy framework)
641
- │ ├─ SINGLE_CODE_AGENT (80%): One Code agent, full plan, CREATE_PR: true
642
- │ ├─ SEQUENTIAL_CODE_AGENTS (15%): N Code agents with handoff summaries
643
- │ └─ PARALLEL_CODE_AGENTS (5%): N Code agents in single message (rare)
644
- │
645
- ├─ Phase 3: Simplify
646
- │ └─ Simplify agent (refines code clarity and consistency)
647
- │
582
+ ├─ Phase 3: Polish
648
583
  ├─ Phase 4: Self-Review
649
- │ └─ Scrutinize agent (quality gate, fixes P0/P1; status PASS | FIXED | BLOCKED)
650
- │
651
584
  ├─ Phase 5: Alignment Check
652
- │ └─ Evaluate agent (validates alignment - reports only, no fixes)
653
- │ └─ If MISALIGNED: Code agent fix loop (max 2 iterations) → re-check alignment
654
- │
655
585
  ├─ Phase 6: Validate (the one full-suite slot)
656
- │ └─ Validate agent (build, typecheck, lint, test over the branch diff)
657
- │ └─ If FAIL: Code agent fix loop (max 2 retries) → re-validate at the new HEAD
658
- │ └─ If PASS: record VALIDATED_HEAD, gate:validate claim → evidence file
659
- │
660
586
  ├─ Phase 7: QA Testing
661
- │ └─ Test agent (scenario-based acceptance tests, TEST_PLAN) → one claim per TP row → evidence file
662
- │ └─ If FAIL: Code agent fix loop (max 2 retries) → re-test
663
- │
664
587
  ├─ Phase 8: Re-Validate (only if a qa-fix committed)
665
- │ └─ Validate agent (changed-only over VALIDATED_HEAD..HEAD) → gate:validate claim
666
- │
667
- ├─ Phase 9: CI Status Gate (SINGLE_CODE_AGENT + SEQUENTIAL_CODE_AGENTS; skipped for PARALLEL_CODE_AGENTS)
668
- │ └─ Push the branch, then ci-wait.cjs (inline, one wait ≤ 570 s) → Code agent on FAILING (3 waits + 2 fixes)
669
- │
670
- ├─ Phase 10: Create PR (if needed)
671
- │ └─ SINGLE_CODE_AGENT: already created by the Phase 2 Code agent
672
- │ └─ SEQUENTIAL: already created by the last Phase 2 Code agent
673
- │ └─ PARALLEL: Code agent (pr-create) creates unified PR
674
- │
675
- ├─ Phase 10b: Evidence (every strategy, once the PR exists)
676
- │ └─ Push the branch (never force; a failure is DEGRADED, not a stop)
677
- │ └─ Git agent (update-pr-evidence) - test-plan block + evidence comment; never blocks
678
- │
679
- ├─ Phase 11: Report
588
+ ├─ Phase 9: Open PR (every strategy, outside the strategy branches)
589
+ ├─ Phase 10: CI Status Gate (every strategy)
590
+ ├─ Phase 11: Evidence (every strategy, once the PR exists)
591
+ ├─ Phase 12: Report
680
592
  │
681
593
  └─ Feature Knowledge Write-Back (Conditional)
682
- └─ Knowledge agent (if documented area changed AND knowledge enabled)
683
594
  ```
684
595
 
685
596
  ## Principles
686
597
 
687
- 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
688
- 2. **Plan-first** - Plan documents from `/plan` skip exploration/planning overhead entirely
689
- 3. **Coherence-first** - Single Code agent produces more consistent code (default ~80% of tasks)
690
- 4. **Agent ownership** - Each agent owns its output completely
691
- 5. **Clean handoffs** - Each phase passes structured data to next; sequential Code agents pass implementation summaries
692
- 6. **Honest reporting** - Display agent outputs directly
693
- 7. **Simplification pass** - Code refined for clarity before PR
694
- 8. **Strict delegation** - Never perform agent work in main session. "Spawn X" means call Agent tool with X, not do X's work yourself
695
- 9. **Validate agent owns validation** - Never run `npm test`, `npm run build`, or similar in main session; always delegate to Validate agent
696
- 10. **Code agent owns fixes** - Never implement fixes in main session; spawn Code agent for validation failures and alignment fixes
697
- 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
698
- 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
598
+ 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, the Phase 11 evidence publish call and the evidence script checks
599
+ 2. **Agent ownership** - Each agent owns its output completely
600
+ 3. **Honest reporting** - Display agent outputs directly
601
+ 4. **Strict delegation** - Never perform agent work in main session. "Spawn X" means call Agent tool with X, not do X's work yourself
602
+ 5. **Validate agent owns validation** - Never run `npm test`, `npm run build`, or similar in main session; always delegate to Validate agent
603
+ 6. **Fix agent owns fixes** - Never implement fixes in main session; spawn Fix agent for validation failures and alignment fixes
604
+ 7. **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
605
+ 8. **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
699
606
 
700
607
  ## Error Handling
701
608