devflow-kit 2.4.0 → 3.0.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 (213) hide show
  1. package/CHANGELOG.md +229 -0
  2. package/README.md +111 -18
  3. package/dist/agents/git.md +822 -0
  4. package/dist/cli/commands/agents.js +6 -1
  5. package/dist/cli/commands/ambient.js +160 -145
  6. package/dist/cli/commands/attribution-prompts.js +1 -1
  7. package/dist/cli/commands/capture.js +29 -55
  8. package/dist/cli/commands/compliance-prompts.js +1 -1
  9. package/dist/cli/commands/compliance.js +48 -55
  10. package/dist/cli/commands/context.js +17 -32
  11. package/dist/cli/commands/debug.js +65 -26
  12. package/dist/cli/commands/flags.js +3 -3
  13. package/dist/cli/commands/hud.js +34 -10
  14. package/dist/cli/commands/init-seed.js +61 -27
  15. package/dist/cli/commands/init.js +649 -240
  16. package/dist/cli/commands/install-report.js +200 -0
  17. package/dist/cli/commands/knowledge/index.js +2 -2
  18. package/dist/cli/commands/knowledge/toggle.js +35 -37
  19. package/dist/cli/commands/learning.js +79 -57
  20. package/dist/cli/commands/legacy-hooks.js +11 -14
  21. package/dist/cli/commands/memory.js +134 -135
  22. package/dist/cli/commands/prompt-io.js +4 -4
  23. package/dist/cli/commands/proxy.js +23 -41
  24. package/dist/cli/commands/security.js +81 -29
  25. package/dist/cli/commands/skills.js +71 -7
  26. package/dist/cli/commands/tracker-prompts.js +145 -0
  27. package/dist/cli/commands/tracker.js +277 -0
  28. package/dist/cli/commands/uninstall.js +520 -169
  29. package/dist/cli.js +2 -0
  30. package/dist/commands/bug-analysis.md +58 -14
  31. package/dist/commands/code-review.md +110 -32
  32. package/dist/commands/debug.md +55 -11
  33. package/dist/commands/dynamic-build.md +344 -73
  34. package/dist/commands/dynamic-plan.md +77 -27
  35. package/dist/commands/dynamic-profile.md +25 -11
  36. package/dist/commands/dynamic-tickets.md +76 -15
  37. package/dist/commands/explore.md +37 -7
  38. package/dist/commands/implement.md +314 -62
  39. package/dist/commands/plan.md +146 -32
  40. package/dist/commands/release.md +64 -17
  41. package/dist/commands/research.md +34 -8
  42. package/dist/commands/resolve.md +196 -68
  43. package/dist/commands/self-review.md +45 -9
  44. package/dist/core/agent-models.js +55 -12
  45. package/dist/core/assets.js +58 -2
  46. package/dist/core/compliance-compose.js +27 -27
  47. package/dist/core/evidence-policy.js +363 -0
  48. package/dist/core/feature-config.js +200 -65
  49. package/dist/core/feature-switch.js +112 -0
  50. package/dist/core/flags.js +34 -6
  51. package/dist/core/fs-atomic.js +27 -0
  52. package/dist/core/hook-log-dirs.js +104 -0
  53. package/dist/core/learning-tuning-config.js +5 -3
  54. package/dist/core/ledger-root.js +102 -0
  55. package/dist/core/manifest.js +38 -10
  56. package/dist/core/mds-variants.js +798 -0
  57. package/dist/core/migrations.js +49 -23
  58. package/dist/core/model-discovery.js +12 -1
  59. package/dist/core/plugins.js +361 -12
  60. package/dist/core/project-paths.js +1 -18
  61. package/dist/core/proxy-log.js +8 -6
  62. package/dist/core/proxy-state.js +11 -8
  63. package/dist/core/reference-sweep.js +136 -0
  64. package/dist/core/same-location.js +25 -0
  65. package/dist/core/tracker.js +494 -0
  66. package/dist/hud/components/config-counts.js +15 -4
  67. package/dist/hud/components/learning-counts.js +14 -0
  68. package/dist/hud/config.js +2 -1
  69. package/dist/hud/cost-history.js +2 -4
  70. package/dist/hud/git.js +52 -7
  71. package/dist/hud/index.js +7 -9
  72. package/dist/skills/git/references/decision-markers.md +19 -0
  73. package/dist/skills/git/references/learn-conventions.md +56 -0
  74. package/dist/skills/git/references/pr/check-ci-status.md +14 -0
  75. package/dist/skills/git/references/pr/check-merge-readiness.md +28 -0
  76. package/dist/skills/git/references/pr/ensure-pr-ready.md +24 -0
  77. package/dist/skills/git/references/pr/fetch-review-threads.md +22 -0
  78. package/dist/skills/git/references/pr/post-resolution-summary.md +40 -0
  79. package/dist/skills/git/references/pr/post-review-summary.md +42 -0
  80. package/dist/skills/git/references/pr/resolve-review-threads.md +35 -0
  81. package/dist/skills/git/references/pr/update-pr-evidence.md +14 -0
  82. package/dist/skills/git/references/pr/validate-branch.md +18 -0
  83. package/dist/skills/git/references/publication-gate.md +13 -0
  84. package/dist/skills/git/references/tracker/_mcp.md +153 -0
  85. package/dist/skills/git/references/tracker/github/associate-release.md +18 -0
  86. package/dist/skills/git/references/tracker/github/backlink-shipped-issues.md +40 -0
  87. package/dist/skills/git/references/tracker/github/create-release.md +11 -0
  88. package/dist/skills/git/references/tracker/github/ensure-pr-ready.md +16 -0
  89. package/dist/skills/git/references/tracker/github/ensure-traceable-issue.md +69 -0
  90. package/dist/skills/git/references/tracker/github/fetch-issue.md +32 -0
  91. package/dist/skills/git/references/tracker/github/fetch-issues-batch.md +17 -0
  92. package/dist/skills/git/references/tracker/github/gather-release-evidence.md +19 -0
  93. package/dist/skills/git/references/tracker/github/manage-debt.md +101 -0
  94. package/dist/skills/git/references/tracker/github/post-wave-report.md +28 -0
  95. package/dist/skills/git/references/tracker/github/setup-task.md +26 -0
  96. package/dist/skills/git/references/tracker/jira/associate-release.md +18 -0
  97. package/dist/skills/git/references/tracker/jira/backlink-shipped-issues.md +49 -0
  98. package/dist/skills/git/references/tracker/jira/create-release.md +17 -0
  99. package/dist/skills/git/references/tracker/jira/ensure-pr-ready.md +22 -0
  100. package/dist/skills/git/references/tracker/jira/ensure-traceable-issue.md +53 -0
  101. package/dist/skills/git/references/tracker/jira/fetch-issue.md +14 -0
  102. package/dist/skills/git/references/tracker/jira/fetch-issues-batch.md +15 -0
  103. package/dist/skills/git/references/tracker/jira/gather-release-evidence.md +18 -0
  104. package/dist/skills/git/references/tracker/jira/manage-debt.md +37 -0
  105. package/dist/skills/git/references/tracker/jira/post-wave-report.md +33 -0
  106. package/dist/skills/git/references/tracker/jira/setup-task.md +31 -0
  107. package/dist/skills/git/references/tracker/linear/associate-release.md +18 -0
  108. package/dist/skills/git/references/tracker/linear/backlink-shipped-issues.md +53 -0
  109. package/dist/skills/git/references/tracker/linear/create-release.md +17 -0
  110. package/dist/skills/git/references/tracker/linear/ensure-pr-ready.md +22 -0
  111. package/dist/skills/git/references/tracker/linear/ensure-traceable-issue.md +53 -0
  112. package/dist/skills/git/references/tracker/linear/fetch-issue.md +14 -0
  113. package/dist/skills/git/references/tracker/linear/fetch-issues-batch.md +15 -0
  114. package/dist/skills/git/references/tracker/linear/gather-release-evidence.md +18 -0
  115. package/dist/skills/git/references/tracker/linear/manage-debt.md +37 -0
  116. package/dist/skills/git/references/tracker/linear/post-wave-report.md +33 -0
  117. package/dist/skills/git/references/tracker/linear/setup-task.md +32 -0
  118. package/dist/skills/git/references/trust-rule.md +7 -0
  119. package/dist/targets/claude-code/claude-paths.js +59 -57
  120. package/dist/targets/claude-code/compliance-install.js +49 -65
  121. package/dist/targets/claude-code/hooks.js +108 -3
  122. package/dist/targets/claude-code/installer.js +1187 -32
  123. package/dist/targets/claude-code/legacy.js +5 -0
  124. package/dist/targets/claude-code/post-install.js +366 -151
  125. package/dist/targets/claude-code/tracker-install.js +134 -0
  126. package/package.json +8 -6
  127. package/src/assets/agents/code.md +45 -6
  128. package/src/assets/agents/design.md +2 -1
  129. package/src/assets/agents/git.mds +825 -0
  130. package/src/assets/agents/knowledge.md +3 -3
  131. package/src/assets/agents/learning.md +11 -0
  132. package/src/assets/agents/review.md +3 -1
  133. package/src/assets/agents/synthesize.md +1 -1
  134. package/src/assets/agents/test.md +16 -5
  135. package/src/assets/agents/tracker.md +474 -0
  136. package/src/assets/agents/validate.md +7 -5
  137. package/src/assets/commands/_partials/_compliance.mds +19 -1
  138. package/src/assets/commands/_partials/_decisions.mds +15 -3
  139. package/src/assets/commands/_partials/_docs_root.mds +35 -0
  140. package/src/assets/commands/_partials/_engine.mds +13 -11
  141. package/src/assets/commands/_partials/_evidence_policy.mds +30 -0
  142. package/src/assets/commands/_partials/_factory.mds +1 -1
  143. package/src/assets/commands/_partials/_knowledge.mds +27 -9
  144. package/src/assets/commands/_partials/_plan_contract.mds +22 -7
  145. package/src/assets/commands/_partials/_preamble.mds +2 -2
  146. package/src/assets/commands/_partials/_publication.mds +8 -2
  147. package/src/assets/commands/_partials/_settings.mds +28 -0
  148. package/src/assets/commands/_partials/_ticket_template.mds +3 -2
  149. package/src/assets/commands/_partials/_tracker.mds +18 -0
  150. package/src/assets/commands/_partials/_wave.mds +16 -10
  151. package/src/assets/commands/bug-analysis.mds +31 -19
  152. package/src/assets/commands/code-review.mds +67 -41
  153. package/src/assets/commands/debug.mds +13 -7
  154. package/src/assets/commands/dynamic-build.mds +274 -66
  155. package/src/assets/commands/dynamic-plan.mds +50 -23
  156. package/src/assets/commands/dynamic-profile.mds +24 -11
  157. package/src/assets/commands/dynamic-tickets.mds +63 -16
  158. package/src/assets/commands/explore.mds +4 -5
  159. package/src/assets/commands/implement.mds +234 -67
  160. package/src/assets/commands/plan.mds +91 -33
  161. package/src/assets/commands/release.md +64 -17
  162. package/src/assets/commands/research.mds +11 -9
  163. package/src/assets/commands/resolve.mds +150 -78
  164. package/src/assets/commands/self-review.mds +24 -25
  165. package/src/assets/mds/git/_pr.mds +331 -0
  166. package/src/assets/mds/git/_references.mds +135 -0
  167. package/src/assets/mds/tracker/_common.mds +156 -0
  168. package/src/assets/mds/tracker/_github.mds +472 -0
  169. package/src/assets/mds/tracker/_jira.mds +407 -0
  170. package/src/assets/mds/tracker/_linear.mds +449 -0
  171. package/src/assets/mds/tracker/_mcp.mds +305 -0
  172. package/src/assets/scripts/hooks/assets/orchestrator-charter.md +5 -8
  173. package/src/assets/scripts/hooks/background-memory-update +40 -19
  174. package/src/assets/scripts/hooks/capture-prompt +18 -8
  175. package/src/assets/scripts/hooks/capture-question +18 -8
  176. package/src/assets/scripts/hooks/capture-turn +27 -13
  177. package/src/assets/scripts/hooks/debug-trace +11 -6
  178. package/src/assets/scripts/hooks/ensure-devflow-init +33 -6
  179. package/src/assets/scripts/hooks/ensure-proxy +9 -8
  180. package/src/assets/scripts/hooks/ensure-root-gitignore +236 -60
  181. package/src/assets/scripts/hooks/git-marker +48 -0
  182. package/src/assets/scripts/hooks/hook-log-init +3 -1
  183. package/src/assets/scripts/hooks/json-helper.cjs +228 -5
  184. package/src/assets/scripts/hooks/lib/project-paths.cjs +1 -20
  185. package/src/assets/scripts/hooks/log-paths +80 -0
  186. package/src/assets/scripts/hooks/memory-worker +22 -13
  187. package/src/assets/scripts/hooks/pre-compact-memory +44 -15
  188. package/src/assets/scripts/hooks/preamble +1 -4
  189. package/src/assets/scripts/hooks/queue-append +146 -28
  190. package/src/assets/scripts/hooks/resolve-project-root +101 -7
  191. package/src/assets/scripts/hooks/session-start-context +534 -20
  192. package/src/assets/scripts/hooks/session-start-memory +38 -15
  193. package/src/assets/scripts/lib/project-config.cjs +633 -0
  194. package/src/assets/scripts/pr-evidence.cjs +1961 -0
  195. package/src/assets/scripts/redact-secrets.cjs +490 -62
  196. package/src/assets/scripts/release-trace.cjs +1143 -0
  197. package/src/assets/scripts/resolve-evidence-policy.cjs +1145 -0
  198. package/src/assets/scripts/resolve-settings.cjs +1054 -0
  199. package/src/assets/scripts/verify-evidence.cjs +1822 -0
  200. package/src/assets/skills/compliance/SKILL.md +4 -2
  201. package/src/assets/skills/docs-framework/SKILL.md +11 -10
  202. package/src/assets/skills/docs-framework/references/patterns.md +10 -17
  203. package/src/assets/skills/gap-analysis/SKILL.md +2 -2
  204. package/src/assets/skills/git/SKILL.md +8 -78
  205. package/src/assets/skills/git/references/github-api.md +179 -141
  206. package/src/assets/skills/git/references/patterns.md +11 -6
  207. package/src/assets/skills/review-methodology/SKILL.md +1 -1
  208. package/src/assets/skills/review-methodology/references/patterns.md +6 -61
  209. package/src/assets/skills/review-methodology/references/violations.md +14 -22
  210. package/src/assets/skills/worktree-support/SKILL.md +1 -1
  211. package/src/assets/skills/worktree-support/references/roots.md +29 -0
  212. package/src/targets/claude-code/templates/managed-settings.json +25 -9
  213. package/src/assets/agents/git.md +0 -938
@@ -4,8 +4,12 @@ output-dir: dist/commands
4
4
  ---
5
5
  @import { knowledge_load, knowledge_writeback } from "./_partials/_knowledge.mds"
6
6
  @import { decisions_load } from "./_partials/_decisions.mds"
7
- @import { compliance_gate } from "./_partials/_compliance.mds"
8
-
7
+ @import { docs_root } from "./_partials/_docs_root.mds"
8
+ @import { evidence_policy, evidence_exception } from "./_partials/_evidence_policy.mds"
9
+ @import { issue_ref_grammar, issue_capture_contract } from "./_partials/_tracker.mds"
10
+ @import { test_plan_line } from "./_partials/_plan_contract.mds"
11
+ @import { publication_gate } from "./_partials/_publication.mds"
12
+ @import "./_partials/_compliance.mds" as compliance
9
13
  # Implement Command
10
14
 
11
15
  Orchestrate a single task through implementation by spawning specialized agents. The orchestrator only spawns agents and passes context - all work is done by agents.
@@ -23,10 +27,12 @@ Orchestrate a single task through implementation by spawning specialized agents.
23
27
 
24
28
  `$ARGUMENTS` contains whatever follows `/implement`:
25
29
  - Plan document path: `.devflow/docs/design/42-jwt-auth.2026-04-07_1430.md` (path to an existing `.md` file)
26
- - GitHub issue: `#42`
30
+ - Issue reference: `#42`
27
31
  - Task description: "implement JWT auth"
28
32
  - Empty: use conversation context
29
33
 
34
+ {{issue_ref_grammar()}}
35
+
30
36
  > **Tip**: For best results, run `/plan` first to produce a design artifact, then pass it to `/implement`.
31
37
 
32
38
  ## Phases
@@ -37,21 +43,34 @@ When the user explicitly asks to re-validate, re-check, or re-run quality gates
37
43
 
38
44
  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.
39
45
  2. **Skip Phase 2** — no Code agent needed, user already made changes.
40
- 3. **Detect FILES_CHANGED**: `git diff --name-only \{base_branch\}...HEAD`
46
+ 3. **Detect FILES_CHANGED**: `git diff --name-only {base_branch}...HEAD`
41
47
  4. **Run Phases 3-8** — full quality gate pipeline on detected changes.
42
- 5. **Proceed to Phase 10** (Create PR) / **Phase 11** (Report).
48
+ 5. **Proceed to Phase 10** (Create PR), **Phase 10b** (Evidence) and **Phase 11** (Report).
43
49
 
44
50
  If the user prompt does NOT match re-validation, proceed with the full pipeline below.
45
51
 
46
52
  ### Phase 1: Setup
47
53
 
48
- **Produces:** TASK_ID, BASE_BRANCH, EXECUTION_PLAN, DECISIONS_CONTEXT, FEATURE_KNOWLEDGE, PR_DESCRIPTION_GUIDANCE, ISSUE_NUMBER
54
+ **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
49
55
 
50
56
  **Load Companion Skills** — Load via Skill tool: `devflow:test-driven-development`, `devflow:patterns`, `devflow:dependency-research`. If a skill fails to load, continue without it.
51
57
 
52
58
  Record the current branch name as `BASE_BRANCH` - this will be the PR target.
53
59
 
54
- {compliance_gate()}
60
+ {{docs_root()}}
61
+
62
+ {{evidence_policy()}}
63
+
64
+ **Plan Document Handling** (when $ARGUMENTS is a path ending in `.md`):
65
+ 1. Read the plan document from the path provided
66
+ 2. Extract from YAML frontmatter: `execution-strategy`, `context-risk`, `issue` number
67
+ 3. Extract from body: Subtask Breakdown, Implementation Plan, Patterns to Follow, Acceptance Criteria
68
+ 4. If the frontmatter `issue` is present and is not `pending`: forward it verbatim as the setup-task `ISSUE_INPUT` (`pending` means /plan's issue step degraded or was declined — treat it as absent)
69
+ 5. Use extracted content as EXECUTION_PLAN for the Code agent phase (replaces exploration/planning output)
70
+ 6. Captured values override defaults from Git agent where present
71
+ 7. Extract `## PR Description Guidance` section (if present) → set `PR_DESCRIPTION_GUIDANCE` to its full content. If section not found, set `PR_DESCRIPTION_GUIDANCE` to `(none)`.
72
+
73
+ If `PR_DESCRIPTION_GUIDANCE` was not set above (non-plan paths: issue input or task description), set it to `(none)`.
55
74
 
56
75
  Spawn Git agent to set up task environment. The Git agent derives the branch name automatically from the issue or task description:
57
76
 
@@ -59,42 +78,102 @@ Spawn Git agent to set up task environment. The Git agent derives the branch nam
59
78
  Agent(subagent_type="Git"):
60
79
  "OPERATION: setup-task
61
80
  BASE_BRANCH: {current branch name}
62
- ISSUE_INPUT: {issue number if $ARGUMENTS starts with #, otherwise omit}
63
- TASK_DESCRIPTION: {task description from $ARGUMENTS if not an issue number or .md path, otherwise omit}
64
- COMPLIANCE: {enabled if COMPLIANCE_SKILL_INSTALLED, otherwise (none)}
81
+ ISSUE_INPUT: {$ARGUMENTS verbatim, when it is a single whitespace-delimited token that does not end in .md; when it ends in .md, the plan frontmatter's issue value verbatim unless absent or pending — otherwise omit}
82
+ TASK_DESCRIPTION: {$ARGUMENTS verbatim, when it is two or more whitespace-delimited tokens — otherwise omit}
83
+ ISSUE_REQUIRED: {ISSUE_REQUIRED}
84
+ APPLY_CONVENTIONS: {APPLY_CONVENTIONS}
65
85
  PLAN_ARTIFACT_PATH: {path to plan document if $ARGUMENTS ends in .md, otherwise (none)}
66
86
  Derive branch name from issue or description, create feature branch, and fetch issue if specified.
67
87
  Return the branch setup summary."
68
88
  ```
69
89
 
90
+ The issue token is forwarded **unclassified**, and the routing is decided by
91
+ SHAPE alone — how many tokens `$ARGUMENTS` has, and whether it ends in `.md`.
92
+
93
+ `setup-task` is the one step that has resolved a provider, and therefore the only
94
+ one that knows what an issue reference looks like on this machine: `#123`,
95
+ `PROJ-12` and `ENG-12` are three providers' spellings of the same thing. A
96
+ `starts with #` test here would be a github test wearing a neutral name — it
97
+ reclassifies every other provider's reference as a task description, so the
98
+ branch is derived from prose and no issue is ever fetched, with nothing reporting
99
+ a problem. Token COUNT is the gate that stays provider-neutral: every one of
100
+ those spellings is a single token, and no free-text task description is.
101
+
102
+ The two tests this command does make are its own under every provider:
103
+
104
+ - **Extension.** A path ending in `.md` is a plan document, never an issue
105
+ reference — it goes to `PLAN_ARTIFACT_PATH` and neither of the other two keys.
106
+ `ISSUE_INPUT` then carries the plan's frontmatter `issue` instead, never the
107
+ path (Plan Document Handling step 4).
108
+ - **Token count.** A single token is an issue reference. Two or more is prose:
109
+ forwarding only its FIRST token would send `/implement fix the login bug` to
110
+ the Git agent as `ISSUE_INPUT: fix` with no description at all, and
111
+ `setup-task` fetches whatever it is handed — so the command would derive a
112
+ branch from a failed lookup and drop the request on the floor.
113
+
114
+ The cost of the count gate is a one-word task description (`/implement refactor`)
115
+ reaching `setup-task` as an issue reference, where it fails the lookup and is
116
+ reported. That is the direction the failure has to fall: an unfetched issue is
117
+ visible, a silently discarded request is not.
118
+
70
119
  **Capture from Git agent output** (used throughout flow):
71
120
  - `TASK_ID`: The branch name created by Git agent (use as TASK_ID for rest of flow)
72
121
  - `BASE_BRANCH`: Branch this feature was created from (for PR target)
73
- - `ISSUE_NUMBER`: GitHub issue number (if provided or created by the issue-first gate in step 1c)
74
- - `ISSUE_CONTENT`: Full issue body including description (if provided)
75
- - `ACCEPTANCE_CRITERIA`: Extracted acceptance criteria from issue (if provided)
122
+ - `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)
76
123
 
77
- **Plan Document Handling** (when $ARGUMENTS is a path ending in `.md`):
78
- 1. Read the plan document from the path provided
79
- 2. Extract from YAML frontmatter: `execution-strategy`, `context-risk`, `issue` number
80
- 3. Extract from body: Subtask Breakdown, Implementation Plan, Patterns to Follow, Acceptance Criteria
81
- 4. If `issue` field present in frontmatter: pass to Git agent as ISSUE_INPUT
82
- 5. Use extracted content as EXECUTION_PLAN for the Code agent phase (replaces exploration/planning output)
83
- 6. Captured values override defaults from Git agent where present
84
- 7. Extract `## PR Description Guidance` section (if present) → set `PR_DESCRIPTION_GUIDANCE` to its full content. If section not found, set `PR_DESCRIPTION_GUIDANCE` to `(none)`.
124
+ {{issue_capture_contract()}}
85
125
 
86
- If `PR_DESCRIPTION_GUIDANCE` was not set above (non-plan paths: issue input or task description), set it to `(none)`.
126
+ **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:
127
+ - **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.
128
+ - **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.
129
+
130
+ {{evidence_exception()}}
131
+
132
+ **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)`.
133
+
134
+ **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.
135
+
136
+ Write the `## Test Plan` section: when `$ARGUMENTS` is a plan document with a `## Test Plan` section, copy that section's lines verbatim; otherwise write one TP line per acceptance criterion the plan, the issue or the task text states, numbered from `TP-1`. Never invent a criterion, and word every scenario yourself in plain words: the lines reach the PR body, so a scenario holds no `#`, `@` or `/` — no issue reference, mention, closing keyword target or URL — and the files a TP covers go in its `files:` field. Each line follows the TP-line contract:
137
+
138
+ {{test_plan_line()}}
139
+
140
+ Check the section:
141
+
142
+ ```bash
143
+ node "$HOME/.devflow/scripts/verify-evidence.cjs" check tp "{worktree}/.devflow/docs/evidence-{branch_slug}.md"; echo "exit=$?"
144
+ ```
145
+
146
+ `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.
147
+
148
+ **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:
149
+ - **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.
150
+ - **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.
151
+
152
+ When `EVIDENCE_POLICY` is `standard`, a missing test plan is never asked about: carry `Test plan: missing` to the Phase 11 report.
153
+
154
+ **Test-plan outputs**, set once before any Code spawn:
155
+ - `TEST_PLAN` — the TP lines of the evidence file's `## Test Plan` section, or `(none)` when the test plan is missing.
156
+ - `PR_TEST_PLAN_BLOCK` — when the test plan is present and this render ends in `exit=0`, its stdout byte for byte without that `exit=` line; `(none)` otherwise:
87
157
 
88
- {decisions_load()}
158
+ ```bash
159
+ node "$HOME/.devflow/scripts/verify-evidence.cjs" render --plan "{worktree}/.devflow/docs/evidence-{branch_slug}.md"; echo "exit=$?"
160
+ ```
161
+
162
+ - `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)`).
163
+
164
+ {{publication_gate()}}
165
+ 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.
166
+
167
+ {{decisions_load()}}
89
168
 
90
169
  Pass to Code agent (Phase 2) and Scrutinize agent (Phase 5).
91
170
 
92
- {knowledge_load()}
171
+ {{knowledge_load()}}
93
172
 
94
173
  ### Phase 2: Implement
95
174
 
96
- **Produces:** CODE_AGENT_OUTPUT, FILES_CHANGED
97
- **Requires:** TASK_ID, BASE_BRANCH, EXECUTION_PLAN, PR_DESCRIPTION_GUIDANCE
175
+ **Produces:** CODE_AGENT_OUTPUT, FILES_CHANGED, PR_URL
176
+ **Requires:** TASK_ID, BASE_BRANCH, EXECUTION_PLAN, PR_DESCRIPTION_GUIDANCE, PR_EXCEPTIONS, PR_TEST_PLAN_BLOCK
98
177
 
99
178
  Based on Setup context (plan document, issue body, or conversation context), use the three-strategy framework:
100
179
 
@@ -123,8 +202,12 @@ CREATE_PR: true
123
202
  DOMAIN: {detected domain or 'fullstack'}
124
203
  FEATURE_KNOWLEDGE: {feature_knowledge}
125
204
  DECISIONS_CONTEXT: {decisions_context}
205
+ COMPLIANCE_FRAMEWORKS: {COMPLIANCE_FRAMEWORKS}
126
206
  PR_DESCRIPTION_GUIDANCE: {pr_description_guidance}
127
- ISSUE_NUMBER: {issue number or (none)}"
207
+ ISSUE_NUMBER: {ISSUE_ID captured in Phase 1, or (none)}
208
+ ISSUE_PR_LINK: {ISSUE_PR_LINK captured in Phase 1, or (none)}
209
+ PR_EXCEPTIONS: {the ## Evidence Exceptions section of {worktree}/.devflow/docs/handoff-{branch_slug}.md verbatim, or (none)}
210
+ PR_TEST_PLAN_BLOCK: {PR_TEST_PLAN_BLOCK from Phase 1 verbatim, or (none)}"
128
211
  ```
129
212
 
130
213
  ---
@@ -145,10 +228,12 @@ CREATE_PR: false
145
228
  DOMAIN: {phase 1 domain, e.g., 'backend'}
146
229
  FEATURE_KNOWLEDGE: {feature_knowledge}
147
230
  DECISIONS_CONTEXT: {decisions_context}
231
+ COMPLIANCE_FRAMEWORKS: {COMPLIANCE_FRAMEWORKS}
148
232
  PR_DESCRIPTION_GUIDANCE: {pr_description_guidance}
149
- ISSUE_NUMBER: {issue number or (none)}
233
+ ISSUE_NUMBER: {ISSUE_ID captured in Phase 1, or (none)}
234
+ ISSUE_PR_LINK: {ISSUE_PR_LINK captured in Phase 1, or (none)}
150
235
  HANDOFF_REQUIRED: true
151
- HANDOFF_FILE: .devflow/docs/handoff-{branch_slug}.md"
236
+ HANDOFF_FILE: {worktree}/.devflow/docs/handoff-{branch_slug}.md"
152
237
  ```
153
238
 
154
239
  **Phase 2+ Code agents** (after prior phase completes):
@@ -165,13 +250,17 @@ PRIOR_PHASE_SUMMARY: {summary from previous Code agent}
165
250
  FILES_FROM_PRIOR_PHASE: {list of files created}
166
251
  FEATURE_KNOWLEDGE: {feature_knowledge}
167
252
  DECISIONS_CONTEXT: {decisions_context}
253
+ COMPLIANCE_FRAMEWORKS: {COMPLIANCE_FRAMEWORKS}
168
254
  PR_DESCRIPTION_GUIDANCE: {pr_description_guidance}
169
- ISSUE_NUMBER: {issue number or (none)}
255
+ ISSUE_NUMBER: {ISSUE_ID captured in Phase 1, or (none)}
256
+ ISSUE_PR_LINK: {ISSUE_PR_LINK captured in Phase 1, or (none)}
257
+ PR_EXCEPTIONS: {the ## Evidence Exceptions section of {worktree}/.devflow/docs/handoff-{branch_slug}.md verbatim, or (none)}
258
+ PR_TEST_PLAN_BLOCK: {PR_TEST_PLAN_BLOCK from Phase 1 verbatim, or (none)}
170
259
  HANDOFF_REQUIRED: {true if not last phase}
171
- HANDOFF_FILE: .devflow/docs/handoff-{branch_slug}.md"
260
+ HANDOFF_FILE: {worktree}/.devflow/docs/handoff-{branch_slug}.md"
172
261
  ```
173
262
 
174
- **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 `.devflow/docs/handoff-\{branch_slug\}.md` using the Write tool (survives context compaction). Delete `.devflow/docs/handoff-\{branch_slug\}.md` after the final Code agent completes (cleanup).
263
+ **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).
175
264
 
176
265
  ---
177
266
 
@@ -190,8 +279,10 @@ CREATE_PR: false
190
279
  DOMAIN: {subtask 1 domain}
191
280
  FEATURE_KNOWLEDGE: {feature_knowledge}
192
281
  DECISIONS_CONTEXT: {decisions_context}
282
+ COMPLIANCE_FRAMEWORKS: {COMPLIANCE_FRAMEWORKS}
193
283
  PR_DESCRIPTION_GUIDANCE: {pr_description_guidance}
194
- ISSUE_NUMBER: {issue number or (none)}"
284
+ ISSUE_NUMBER: {ISSUE_ID captured in Phase 1, or (none)}
285
+ ISSUE_PR_LINK: {ISSUE_PR_LINK captured in Phase 1, or (none)}"
195
286
 
196
287
  Agent(subagent_type="Code"): # Code agent 2 (same message)
197
288
  "TASK_ID: {task-id}-part2
@@ -203,8 +294,10 @@ CREATE_PR: false
203
294
  DOMAIN: {subtask 2 domain}
204
295
  FEATURE_KNOWLEDGE: {feature_knowledge}
205
296
  DECISIONS_CONTEXT: {decisions_context}
297
+ COMPLIANCE_FRAMEWORKS: {COMPLIANCE_FRAMEWORKS}
206
298
  PR_DESCRIPTION_GUIDANCE: {pr_description_guidance}
207
- ISSUE_NUMBER: {issue number or (none)}"
299
+ ISSUE_NUMBER: {ISSUE_ID captured in Phase 1, or (none)}
300
+ ISSUE_PR_LINK: {ISSUE_PR_LINK captured in Phase 1, or (none)}"
208
301
  ```
209
302
 
210
303
  **Independence criteria** (all must be true for PARALLEL_CODE_AGENTS):
@@ -234,18 +327,31 @@ Run build, typecheck, lint, test. Report pass/fail with failure details."
234
327
  - Spawn Code agent with fix context:
235
328
  ```
236
329
  Agent(subagent_type="Code"):
237
- "TASK_ID: \{task-id\}
330
+ "TASK_ID: {task-id}
238
331
  TASK_DESCRIPTION: Fix validation failures
239
332
  OPERATION: validation-fix
240
- VALIDATION_FAILURES: \{parsed failures from Validate agent\}
333
+ VALIDATION_FAILURES: {parsed failures from Validate agent}
241
334
  SCOPE: Fix only the listed failures, no other changes
242
335
  CREATE_PR: false
243
- ISSUE_NUMBER: \{issue number or (none)\}"
336
+ ISSUE_NUMBER: {ISSUE_ID captured in Phase 1, or (none)}
337
+ ISSUE_PR_LINK: {ISSUE_PR_LINK captured in Phase 1, or (none)}
338
+ COMPLIANCE_FRAMEWORKS: {COMPLIANCE_FRAMEWORKS}"
244
339
  ```
245
340
  - Loop back to Phase 3 (re-validate)
246
341
  4. If `validation_retry_count > 2`: Report failures to user and halt
247
342
 
248
- **If PASS:** Continue to Phase 4
343
+ **If PASS:** append a `gate:validate` claim, then continue to Phase 4.
344
+
345
+ **Evidence claims** are lines appended to the `## Claims` section of `EVIDENCE_FILE` — the file's last section, created when absent. Append only: never edit or remove a claim; the last valid one per target wins. Each line takes exactly one of these shapes, where `<head>` is the 40-hex `HEAD:` the agent's report shows:
346
+
347
+ ```
348
+ - gate:validate PASS sha:<head> by:validate
349
+ - TP-<n> <PASS|FAIL|SKIP> sha:<head> by:test exit:<0-255>
350
+ ```
351
+
352
+ - `gate:validate` — after a Phase 3 or Phase 6 PASS.
353
+ - `TP-<n>` — after every Phase 8 run, one line per `### Test Plan Evidence` row whose TP is in `TEST_PLAN`, with the row's outcome; the line ends at `by:test` when the row's Exit is not a number from 0 to 255.
354
+ - 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.
249
355
 
250
356
  ### Phase 4: Simplify
251
357
 
@@ -296,7 +402,7 @@ Verify Scrutinize agent's fixes didn't break anything."
296
402
 
297
403
  **If FAIL:** Report to user - Scrutinize agent broke tests, needs manual intervention.
298
404
 
299
- **If PASS:** Continue to Phase 7
405
+ **If PASS:** append a `gate:validate` claim (Phase 3's **Evidence claims**), then continue to Phase 7.
300
406
 
301
407
  ### Phase 7: Alignment Check
302
408
 
@@ -324,18 +430,20 @@ Validate alignment with request and plan. Report ALIGNED or MISALIGNED with deta
324
430
  - Spawn Code agent to fix misalignments:
325
431
  ```
326
432
  Agent(subagent_type="Code"):
327
- "TASK_ID: \{task-id\}
433
+ "TASK_ID: {task-id}
328
434
  TASK_DESCRIPTION: Fix alignment issues
329
435
  OPERATION: alignment-fix
330
- MISALIGNMENTS: \{structured misalignments from Evaluate agent\}
436
+ MISALIGNMENTS: {structured misalignments from Evaluate agent}
331
437
  SCOPE: Fix only the listed misalignments, no other changes
332
438
  CREATE_PR: false
333
- ISSUE_NUMBER: \{issue number or (none)\}"
439
+ ISSUE_NUMBER: {ISSUE_ID captured in Phase 1, or (none)}
440
+ ISSUE_PR_LINK: {ISSUE_PR_LINK captured in Phase 1, or (none)}
441
+ COMPLIANCE_FRAMEWORKS: {COMPLIANCE_FRAMEWORKS}"
334
442
  ```
335
443
  - Spawn Validate agent to verify fix didn't break tests:
336
444
  ```
337
445
  Agent(subagent_type="Validate", model="haiku"):
338
- "FILES_CHANGED: \{files modified by fix Code agent\}
446
+ "FILES_CHANGED: {files modified by fix Code agent}
339
447
  VALIDATION_SCOPE: changed-only"
340
448
  ```
341
449
  - If Validate agent FAIL: Report to user
@@ -345,7 +453,7 @@ Validate alignment with request and plan. Report ALIGNED or MISALIGNED with deta
345
453
  ### Phase 8: QA Testing
346
454
 
347
455
  **Produces:** QA_RESULT
348
- **Requires:** FILES_CHANGED, EXECUTION_PLAN
456
+ **Requires:** FILES_CHANGED, EXECUTION_PLAN, TEST_PLAN
349
457
 
350
458
  After Evaluate agent passes, spawn Test agent for scenario-based acceptance testing:
351
459
 
@@ -355,9 +463,12 @@ Agent(subagent_type="Test"):
355
463
  EXECUTION_PLAN: {execution plan from Phase 1}
356
464
  FILES_CHANGED: {list of files from Code agent output}
357
465
  ACCEPTANCE_CRITERIA: {extracted criteria if available}
466
+ TEST_PLAN: {the TP lines of the evidence file's ## Test Plan section, or (none)}
358
467
  Design and execute scenario-based acceptance tests. Report PASS or FAIL with evidence."
359
468
  ```
360
469
 
470
+ After every Test agent run — PASS or FAIL, first run or retry — append its TP claims (Phase 3's **Evidence claims**).
471
+
361
472
  **If PASS:** Continue to Phase 9
362
473
 
363
474
  **If FAIL:**
@@ -367,18 +478,20 @@ Design and execute scenario-based acceptance tests. Report PASS or FAIL with evi
367
478
  - Spawn Code agent to fix QA failures:
368
479
  ```
369
480
  Agent(subagent_type="Code"):
370
- "TASK_ID: \{task-id\}
481
+ "TASK_ID: {task-id}
371
482
  TASK_DESCRIPTION: Fix QA test failures
372
483
  OPERATION: qa-fix
373
- QA_FAILURES: \{structured failures from Test agent\}
484
+ QA_FAILURES: {structured failures from Test agent}
374
485
  SCOPE: Fix only the listed failures, no other changes
375
486
  CREATE_PR: false
376
- ISSUE_NUMBER: \{issue number or (none)\}"
487
+ ISSUE_NUMBER: {ISSUE_ID captured in Phase 1, or (none)}
488
+ ISSUE_PR_LINK: {ISSUE_PR_LINK captured in Phase 1, or (none)}
489
+ COMPLIANCE_FRAMEWORKS: {COMPLIANCE_FRAMEWORKS}"
377
490
  ```
378
491
  - Spawn Validate agent to verify fix didn't break tests:
379
492
  ```
380
493
  Agent(subagent_type="Validate", model="haiku"):
381
- "FILES_CHANGED: \{files modified by fix Code agent\}
494
+ "FILES_CHANGED: {files modified by fix Code agent}
382
495
  VALIDATION_SCOPE: changed-only"
383
496
  ```
384
497
  - If Validate agent FAIL: Report to user
@@ -390,39 +503,86 @@ Design and execute scenario-based acceptance tests. Report PASS or FAIL with evi
390
503
  **Produces:** CI_STATUS
391
504
  **Requires:** PR_URL, FILES_CHANGED
392
505
 
393
- Strategy-conditional: run for **SINGLE_CODE_AGENT** (PR exists from Phase 2), skip for **SEQUENTIAL_CODE_AGENTS** / **PARALLEL_CODE_AGENTS** (PR not yet created).
506
+ 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).
394
507
 
395
508
  <!-- PATTERN: ci-status-gate -->
396
509
  1. Spawn `Agent(subagent_type="Git")` with `OPERATION: check-ci-status` and `PR_NUMBER` from PR_URL.
397
510
  2. **If PASSING** → proceed to Phase 10.
398
511
  3. **If NO_PR or NO_CI** → skip: "No PR/CI configured, skipping CI validation." Proceed to Phase 10.
399
- 4. **If PENDING** → poll every 60 seconds (global budget, see step 6). Re-spawn Git agent each poll. If PASSING → proceed. If still PENDING after budget exhausted → report "CI still running — verify manually before merging" and proceed.
400
- 5. **If FAILING** → report failing checks. Spawn `Agent(subagent_type="Code")` to fix CI failures based on check names and failure context. After fix, push and re-check. Max 2 fix attempts. If still failing → report failures and proceed.
401
- 6. **Total budget**: max 10 polls and max 2 fix attempts across all check/fix cycles combined. If budget exhausted, report current status and proceed.
512
+ 4. **If PENDING** → poll every 60 seconds (global budget, see step 7). Re-spawn Git agent each poll. If PASSING → proceed. If still PENDING after budget exhausted → report "CI still running — verify manually before merging" and proceed.
513
+ 5. **If INDETERMINATE** → poll as PENDING within the same budget. If still INDETERMINATE after budget exhausted → report "CI status unknown — verify manually before merging" and proceed.
514
+ 6. **If FAILING** → report failing checks. Spawn `Agent(subagent_type="Code")` with `COMPLIANCE_FRAMEWORKS` to fix CI failures based on check names and failure context. After fix, push and re-check. Max 2 fix attempts. If still failing → report failures and proceed.
515
+ 7. **Total budget**: max 10 polls and max 2 fix attempts across all check/fix cycles combined. If budget exhausted, report current status and proceed.
402
516
  <!-- /PATTERN: ci-status-gate -->
403
517
 
404
518
  ### Phase 10: Create PR
405
519
 
406
520
  **Produces:** PR_URL
407
- **Requires:** BASE_BRANCH, TASK_ID
521
+ **Requires:** BASE_BRANCH, TASK_ID, PR_EXCEPTIONS, PR_TEST_PLAN_BLOCK
408
522
 
409
- **For SEQUENTIAL_CODE_AGENTS or PARALLEL_CODE_AGENTS**: The last sequential Code agent (with CREATE_PR: true) handles PR creation. For parallel Code agents, create unified PR using `devflow:git` skill patterns. Push branch and run `gh pr create` with comprehensive description, targeting `BASE_BRANCH`.
523
+ **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.
410
524
 
411
- If `PR_DESCRIPTION_GUIDANCE` is not `(none)`, use it to compose the PR body (see Code agent Responsibility 7 for field-to-section mapping).
525
+ **For PARALLEL_CODE_AGENTS**: spawn one Code agent to create the unified PR:
526
+
527
+ ```
528
+ Agent(subagent_type="Code"):
529
+ "TASK_ID: {task-id}
530
+ TASK_DESCRIPTION: Create the unified PR for the parallel implementation
531
+ OPERATION: pr-create
532
+ BASE_BRANCH: {base branch}
533
+ CREATE_PR: true
534
+ PR_DESCRIPTION_GUIDANCE: {pr_description_guidance}
535
+ ISSUE_NUMBER: {ISSUE_ID captured in Phase 1, or (none)}
536
+ ISSUE_PR_LINK: {ISSUE_PR_LINK captured in Phase 1, or (none)}
537
+ PR_EXCEPTIONS: {the ## Evidence Exceptions section of {worktree}/.devflow/docs/handoff-{branch_slug}.md verbatim, or (none)}
538
+ PR_TEST_PLAN_BLOCK: {PR_TEST_PLAN_BLOCK from Phase 1 verbatim, or (none)}
539
+ COMPLIANCE_FRAMEWORKS: {COMPLIANCE_FRAMEWORKS}"
540
+ ```
412
541
 
413
- When `ISSUE_NUMBER` is known, ensure the PR body includes a `## Related Issues` section with `Closes #\{ISSUE_NUMBER\}`.
542
+ 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.
414
543
 
415
544
  **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.
416
545
 
546
+ ### Phase 10b: Evidence
547
+
548
+ **Produces:** EVIDENCE_RESULT
549
+ **Requires:** PR_URL, EVIDENCE_FILE, REVIEW_PUBLICATION
550
+
551
+ 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.
552
+
553
+ **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:
554
+
555
+ ```bash
556
+ git push origin HEAD; echo "exit=$?"
557
+ ```
558
+
559
+ `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.
560
+
561
+ ```
562
+ Agent(subagent_type="Git"):
563
+ "OPERATION: update-pr-evidence
564
+ PR_NUMBER: {number from PR_URL}
565
+ EVIDENCE_FILE: .devflow/docs/evidence-{branch_slug}.md
566
+ REVIEW_PUBLICATION: {REVIEW_PUBLICATION resolved in Phase 1, or auto}
567
+ WORKTREE_PATH: {worktree}
568
+ Update the PR's test-plan block and post its evidence comment."
569
+ ```
570
+
571
+ 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.
572
+
417
573
  ### Phase 11: Report
418
574
 
419
- **Requires:** VALIDATION_RESULT, ALIGNMENT_RESULT, QA_RESULT, PR_URL
575
+ **Requires:** VALIDATION_RESULT, ALIGNMENT_RESULT, QA_RESULT, PR_URL, EVIDENCE_RESULT
420
576
 
421
577
  Display completion summary with phase status, PR info, and next steps.
422
578
 
423
- If any Git agent output emitted `TRACEABILITY: DEGRADED (\{reason\})` lines during the run, surface them verbatim in the report under a `### Traceability` subsection so the user can act on them.
579
+ 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`.
580
+
581
+ If any Git agent output emitted `TRACEABILITY: DEGRADED ({reason})` lines during the run, or Phase 10b's push recorded one, surface them verbatim in the report under a `### Traceability` subsection so the user can act on them.
424
582
 
425
- {knowledge_writeback()}
583
+ If Phase 1 recorded an evidence exception, show its `## Evidence Exceptions` lines in the report.
584
+
585
+ {{knowledge_writeback()}}
426
586
 
427
587
  ## Architecture
428
588
 
@@ -430,11 +590,13 @@ If any Git agent output emitted `TRACEABILITY: DEGRADED (\{reason\})` lines duri
430
590
  /implement (orchestrator - spawns agents only)
431
591
  │
432
592
  ├─ Re-validation Path (when user says "re-validate"/"re-check"/"re-run gates")
433
- │ └─ Branch safety → skip Phase 2 → detect FILES_CHANGED → Phases 3-8 → Phase 10-11
593
+ │ └─ Branch safety → skip Phase 2 → detect FILES_CHANGED → Phases 3-8 → Phase 10, 10b, 11
434
594
  │
435
595
  ├─ Phase 1: Setup
596
+ │ └─ Plan document parsing (if .md path provided) - extracts execution plan, strategy, frontmatter issue
436
597
  │ └─ Git agent (operation: setup-task) - creates feature branch, fetches issue
437
- │ └─ Plan document parsing (if .md path provided) - extracts execution plan, strategy
598
+ │ └─ Ticket-link ask (no linked ticket, issue required) - record a self-attested exception or stop
599
+ │ └─ 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
438
600
  │
439
601
  ├─ Phase 2: Implement (3-strategy framework)
440
602
  │ ├─ SINGLE_CODE_AGENT (80%): One Code agent, full plan, CREATE_PR: true
@@ -444,6 +606,7 @@ If any Git agent output emitted `TRACEABILITY: DEGRADED (\{reason\})` lines duri
444
606
  ├─ Phase 3: Validate
445
607
  │ └─ Validate agent (build, typecheck, lint, test)
446
608
  │ └─ If FAIL: Code agent fix loop (max 2 retries) → re-validate
609
+ │ └─ If PASS: gate:validate claim → evidence file
447
610
  │
448
611
  ├─ Phase 4: Simplify
449
612
  │ └─ Simplify agent (refines code clarity and consistency)
@@ -459,16 +622,20 @@ If any Git agent output emitted `TRACEABILITY: DEGRADED (\{reason\})` lines duri
459
622
  │ └─ If MISALIGNED: Code agent fix loop (max 2 iterations) → Validate agent → re-check
460
623
  │
461
624
  ├─ Phase 8: QA Testing
462
- │ └─ Test agent (scenario-based acceptance tests)
625
+ │ └─ Test agent (scenario-based acceptance tests, TEST_PLAN) → one claim per TP row → evidence file
463
626
  │ └─ If FAIL: Code agent fix loop (max 2 retries) → Validate agent → re-test
464
627
  │
465
- ├─ Phase 9: CI Status Gate (SINGLE_CODE_AGENT only)
628
+ ├─ Phase 9: CI Status Gate (SINGLE_CODE_AGENT + SEQUENTIAL_CODE_AGENTS; skipped for PARALLEL_CODE_AGENTS)
466
629
  │ └─ Git agent (check-ci-status) → poll/fix cycle (10 polls + 2 fix budget)
467
630
  │
468
631
  ├─ Phase 10: Create PR (if needed)
469
- │ └─ SINGLE_CODE_AGENT: handled by Code agent
470
- │ └─ SEQUENTIAL: handled by last Code agent
471
- │ └─ PARALLEL: orchestrator creates unified PR
632
+ │ └─ SINGLE_CODE_AGENT: already created by the Phase 2 Code agent
633
+ │ └─ SEQUENTIAL: already created by the last Phase 2 Code agent
634
+ │ └─ PARALLEL: Code agent (pr-create) creates unified PR
635
+ │
636
+ ├─ Phase 10b: Evidence (every strategy, once the PR exists)
637
+ │ └─ Push the branch (never force; a failure is DEGRADED, not a stop)
638
+ │ └─ Git agent (update-pr-evidence) - test-plan block + evidence comment; never blocks
472
639
  │
473
640
  ├─ Phase 11: Report
474
641
  │
@@ -489,7 +656,7 @@ If any Git agent output emitted `TRACEABILITY: DEGRADED (\{reason\})` lines duri
489
656
  9. **Validate agent owns validation** - Never run `npm test`, `npm run build`, or similar in main session; always delegate to Validate agent
490
657
  10. **Code agent owns fixes** - Never implement fixes in main session; spawn Code agent for validation failures and alignment fixes
491
658
  11. **Loop limits** - Max 2 validation retries, max 2 alignment fix iterations before escalating to user
492
- 12. **CI awareness** - CI status is checked before merge for SINGLE_CODE_AGENT strategy
659
+ 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
493
660
 
494
661
  ## Error Handling
495
662