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
@@ -22,9 +22,10 @@ Process issues from code review reports: triage every issue through the blast-ra
22
22
 
23
23
  **Produces:** WORKTREES
24
24
 
25
- 1. **Discover resolvable worktrees** using the `devflow:worktree-support` skill discovery algorithm:
26
- - Run `git worktree list --porcelain` → parse, filter (skip protected/detached/mid-rebase), dedup by branch, sort by recent commit
27
- - Invoke the `devflow:worktree-support` skill, then Read its `references/discovery.md` from the skill's base directory for the full 7-step algorithm; the canonical protected branch list stays in the skill
25
+ 1. **Discover resolvable worktrees**:
26
+ - Run `git worktree list --porcelain` and count the worktrees it lists
27
+ - **More than one listed:** Invoke the `devflow:worktree-support` skill, then Read its `references/discovery.md` from the skill's base directory for the full 7-step algorithm; the canonical protected branch list stays in the skill. Parse the list, filter (skip protected/detached/mid-rebase), dedup by branch, sort by recent commit
28
+ - **Exactly one listed:** load neither the skill nor the reference — that worktree is the only candidate, and Step 0b's Git agent validates its branch
28
29
  - Additional filter: must have unresolved reviews (latest review directory has no `resolution-summary.md`)
29
30
  2. **If `--path` flag provided:** use only that worktree, skip discovery
30
31
  **`--path` validation**: Before proceeding, verify the path exists as a directory and appears in `git worktree list` output. If not: report error and stop.
@@ -101,19 +102,19 @@ The accepted line is the only source of these values: the script alone folds the
101
102
 
102
103
  When the settings line says `LEARNING=off`, set `DECISIONS_CONTEXT` to `(none)` and skip this step, locating no ledger and reading no index.
103
104
 
104
- The decisions ledger belongs to the repository, not to one checkout: in a linked worktree it lives in the main worktree, and a session started in a subdirectory reads the copy at the repository root. Locate it with ONE git call, run from the start directory — `WORKTREE_PATH` if provided, otherwise cwd (`devflow:worktree-support`):
105
+ The decisions ledger belongs to the repository, not to one checkout: a linked worktree reads the main worktree's copy, a subdirectory session the repository root's. Locate it with ONE git call, run from the start directory — `WORKTREE_PATH` if provided, otherwise cwd (`devflow:worktree-support`):
105
106
 
106
107
  ```bash
107
108
  git -C "{start}" rev-parse --path-format=absolute --show-toplevel --git-common-dir
108
109
  ```
109
110
 
110
- Line 1 is the checkout's toplevel, line 2 the repository's common git directory. A git older than 2.31 echoes `--path-format=absolute` back as a line of its own first. `{ledger}` is the first of these that applies:
111
+ Line 1 is the checkout's toplevel, line 2 the common git directory. A git older than 2.31 echoes `--path-format=absolute` back as a line of its own first. `{ledger}` is the first that applies:
111
112
 
112
113
  1. **The main worktree** — line 2 without its trailing `/.git`, when the output is exactly two lines each beginning with `/`, line 2 ends in `/.git`, and the directory left once it is removed is not your home directory and contains a `.devflow/` directory.
113
114
  2. **The toplevel** — line 1, or on an older git the line after the echoed flag.
114
115
  3. **The start directory itself** — when the command failed or printed no absolute toplevel (outside a git repository).
115
116
 
116
- This is the rule the learning hooks apply (D-LEDGER-MAIN-WORKTREE, D-PROMPT-ROOT), so you read the index the Learning agent writes.
117
+ This is the rule the learning hooks apply, so you read the index the Curate agent writes.
117
118
 
118
119
  **Step 1 — Read the pre-rendered index:**
119
120
 
@@ -122,11 +123,15 @@ Attempt to read `{ledger}/.devflow/learning/index.md`.
122
123
  - If the file exists and contains non-empty content: use that content as `DECISIONS_CONTEXT`.
123
124
  - If the file is absent or empty: set `DECISIONS_CONTEXT` to `(none)`.
124
125
 
125
- The index is one direct file read, written at render time by `render-decisions.cjs` alongside `decisions.md`/`pitfalls.md` — no `.cjs` script runs here, and the index's own footer names the files that hold each entry's full body.
126
+ The index is one direct file read, written at render time by `render-decisions.cjs` — no `.cjs` script runs here.
126
127
 
127
- **Step 2 — Apply decisions using `devflow:apply-decisions`:**
128
+ **Step 2 — Slice the index, then hand it on:**
128
129
 
129
- When `DECISIONS_CONTEXT` is not `(none)`, follow `devflow:apply-decisions` to scan the index, identify plausibly-relevant entries, Read full entry bodies on demand, and cite verbatim IDs in downstream agent prompts and reasoning.
130
+ When `DECISIONS_CONTEXT` is not `(none)`, hand it only to the agents whose contract declares it.
131
+
132
+ Hand each agent that takes `DECISIONS_CONTEXT` a slice, not the whole index: the index lines whose title, scope or area touch the files and task it works on, verbatim, led by `(slice: N of M entries — full index: <absolute index path>)` and closed by the index footer. When unsure, include the line. Siblings over one diff share ONE slice.
133
+
134
+ Those agents follow `devflow:apply-decisions`. A host that uses the index in its own thread says so in its own step.
130
135
 
131
136
  This produces a compact index of active ADR/PF entries written at render time — Deprecated/Superseded entries are already stripped. Pass `DECISIONS_CONTEXT` to the Triage agent in Phase 2 and to Code agents in Phase 4.
132
137
 
@@ -152,7 +157,7 @@ If `index.md` exists and contains at least one entry line, use it for relevance
152
157
 
153
158
  **Step 2 — Fallback: glob frontmatter (if `index.md` is absent or empty):**
154
159
 
155
- Glob `{worktree}/.devflow/features/*/KNOWLEDGE.md`. For each file found, read only its YAML frontmatter block (between the opening and closing `---` delimiters). The frontmatter fields `name`, `description`, and `directories` are the authoritative relevance surface — `index.md` is only a cache.
160
+ Glob `{worktree}/.devflow/features/*/KNOWLEDGE.md`. For each file found, read only its YAML frontmatter block (between the opening and closing `---` delimiters).
156
161
 
157
162
  **Step 3 — Pick relevant KBs:**
158
163
 
@@ -183,7 +188,7 @@ Headings: L5 Rules · L40 Overview · L62 Anti-Patterns · L118 Key Files
183
188
 
184
189
  A KB with no Rules section labels its entries `Rules ({section name}):` and gives them no ID. `FEATURE_KNOWLEDGE` is these blocks; `FEATURE_KNOWLEDGE_RULES` is the same blocks without the `Headings:` line. Both come from this one selection, and each spawn names the variable its recipient takes. If no KBs exist, no KBs are relevant, or `.devflow/features/` is absent, set both to `(none)`.
185
190
 
186
- **One git call, then direct reads — no `.cjs` script.** After resolving `{worktree}`, this step is 1 index read (or N frontmatter reads on fallback), plus one heading listing and one Rules read per selected KB, bounded by KB count.
191
+ **One git call, then direct reads — no `.cjs` script.**
187
192
 
188
193
  Pass `FEATURE_KNOWLEDGE` to the Triage agent in Phase 2.
189
194
 
@@ -205,6 +210,12 @@ Reuse this result for every worktree.
205
210
  Note: `auto` is NOT fail-open — under `auto`, the Git agent probes the repository visibility and treats any error or unrecognised value as PUBLIC (mode STUB). What each value does is decided by the Git agent's publication gate (`references/publication-gate.md` step 2); this partial only resolves the value.
206
211
  Resolve this per worktree — unlike the evidence policy above, the settings line is per worktree root. From the same line: `COMPLIANCE_FRAMEWORKS` is the settings line's `COMPLIANCE` with `generic` written `none`: `off`, `none`, or the framework ids the machine and this repository declare.
207
212
 
213
+ **Set the compliance directive** from `COMPLIANCE_FRAMEWORKS`. `COMPLIANCE_DIRECTIVE` is empty when `COMPLIANCE_FRAMEWORKS` is `off`: a spawn line that holds only `{COMPLIANCE_DIRECTIVE}` is then left out, so a lens-off spawn carries nothing about compliance. Otherwise `COMPLIANCE_DIRECTIVE` is this one line, with `<ids>` replaced by the value of `COMPLIANCE_FRAMEWORKS`:
214
+
215
+ > When the task touches regulated surface (data models, auth flows, logging/observability, payments, IaC, retention), invoke Skill(skill="devflow:compliance") and load references/{id}.md only for the ids in <ids> (none: generic controls only); never fabricate guidance for a framework you were not given.
216
+
217
+ Set it per worktree, from that worktree's lens, and pass that worktree's `COMPLIANCE_DIRECTIVE` to each of its Code and Fix spawns, on a line of its own.
218
+
208
219
  **Mint `RESOLUTION_TS` once per run:** `date -u +%Y-%m-%dT%H:%M:%SZ`. Every worktree reuses it — the resolution comment's dedup marker is searched per PR, so one run key keeps a retry of this run deduplicated while the next /resolve on the same PR posts. Phase 5 writes it as the summary's `**Date**:` and Phase 9b-2 passes it, so the local file and the posted marker agree.
209
220
 
210
221
  ### Phase 1: Parse Issues
@@ -319,11 +330,10 @@ TASK_ID: resolve-{batch-id}
319
330
  ISSUES: {fix_now_issues_in_batch}
320
331
  SCOPE: {risk_tier_per_issue}
321
332
  PUSH: false
322
- CREATE_PR: false
323
333
  WORKTREE_PATH: {worktree_path} (omit if cwd)
324
334
  DECISIONS_CONTEXT: {decisions_context}
325
335
  FEATURE_KNOWLEDGE: {feature_knowledge}
326
- COMPLIANCE_FRAMEWORKS: {COMPLIANCE_FRAMEWORKS}
336
+ {COMPLIANCE_DIRECTIVE}
327
337
  Fix only the listed pre-classified FIX_NOW issues. Do not re-litigate dispositions.
328
338
  Same-file issues → one commit. Include ## Verification block in report.
329
339
  Regression fix without failing-then-passing regression test → BLOCKED."
@@ -340,7 +350,7 @@ Collect from each Code agent:
340
350
  **Produces:** RESOLUTION_FILE (early write for compaction safety)
341
351
  **Requires:** TRIAGE_RESULTS, CODE_AGENT_RESULTS, TARGET_DIR, TARGET_DIR_REL, BRANCH_INFO, RESOLUTION_TS
342
352
 
343
- **Immediately write `resolution-summary.md`** to `{TARGET_DIR}` using the Write tool. Do this now — not in Phase 9 — while results are fresh in context. This ensures the record is persisted even if later phases (Simplify, Verification Gate, CI gate, Tech Debt) trigger context compaction.
353
+ **Immediately write `resolution-summary.md`** to `{TARGET_DIR}` using the Write tool. Do this now — not in Phase 9 — while results are fresh in context. This ensures the record is persisted even if later phases (Polish, Verification Gate, CI gate, Tech Debt) trigger context compaction.
344
354
 
345
355
  Set `Tracked` for FIX_SEPARATE and TECH_DEBT items to `(pending)` — to be backfilled after Phase 9 manage-debt (or `TRACEABILITY: DEGRADED ({reason})` if manage-debt degrades).
346
356
 
@@ -348,19 +358,19 @@ DUPLICATE issues are listed **only** in `## Duplicates` — never in `## Fixed I
348
358
 
349
359
  Use the template from the Output Artifact section below.
350
360
 
351
- ### Phase 6: Simplify
361
+ ### Phase 6: Polish
352
362
 
353
- **Produces:** SIMPLIFICATION_RESULT
363
+ **Produces:** POLISH_RESULT
354
364
  **Requires:** CODE_AGENT_RESULTS
355
365
 
356
- If any fixes were made, spawn Simplify agent to refine the changed code:
366
+ If any fixes were made, spawn Polish agent to refine the changed code:
357
367
 
358
368
  ```
359
- Agent(subagent_type="Simplify", run_in_background=false):
369
+ Agent(subagent_type="Polish", run_in_background=false):
360
370
  "TASK_DESCRIPTION: Issue resolution fixes
361
371
  WORKTREE_PATH: {worktree_path} (omit if cwd)
362
372
  FILES_CHANGED: {list of files modified by Code agents}
363
- Simplify and refine the fixes for clarity and consistency
373
+ Polish and refine the fixes for clarity and consistency
364
374
  Commit any improvements with a conventional-commit message."
365
375
  ```
366
376
 
@@ -386,18 +396,17 @@ Run build, typecheck, lint, test. Report pass/fail with failure details."
386
396
  1. Extract failure details from Validate agent output
387
397
  2. Increment `validation_retry_count`
388
398
  3. If `validation_retry_count <= 2`:
389
- - Spawn Code agent with fix context:
399
+ - Spawn Fix agent with fix context:
390
400
  ```
391
- Agent(subagent_type="Code"):
401
+ Agent(subagent_type="Fix"):
392
402
  "OPERATION: validation-fix
393
403
  TASK_ID: resolve-{batch-id}-valfix-{count}
394
404
  VALIDATION_FAILURES: {parsed failures from Validate agent}
395
405
  SCOPE: Fix only the listed failures, no other changes
396
406
  PUSH: false
397
- CREATE_PR: false
398
407
  WORKTREE_PATH: {worktree_path} (omit if cwd)
399
408
  DECISIONS_CONTEXT: {decisions_context}
400
- COMPLIANCE_FRAMEWORKS: {COMPLIANCE_FRAMEWORKS}"
409
+ {COMPLIANCE_DIRECTIVE}"
401
410
  ```
402
411
  - Loop back to re-validate
403
412
  4. If `validation_retry_count > 2`: set VERIFICATION_STATUS = FAILED and exit the validation loop — record a blocking callout in the `## Verification` section (never a silent pass).
@@ -407,7 +416,7 @@ Run build, typecheck, lint, test. Report pass/fail with failure details."
407
416
  Record `## Verification` outcome in resolution-summary.md (runs unconditionally after the validation loop exits):
408
417
  - Rewrite the `## Verification` section with | Command | Result | table + `Final gate: PASS | FAILED after N attempts`
409
418
 
410
- Push all commits to remote once (Code agents and validation-fix Code agents ran with PUSH: false — runs whether the gate PASSED or FAILED, so the branch is always visible before Phase 9 or CI runs):
419
+ Push all commits to remote once (Code and Fix agents ran with PUSH: false — runs whether the gate PASSED or FAILED, so the branch is always visible before Phase 9 or CI runs):
411
420
  ```bash
412
421
  git -C {worktree} push
413
422
  ```
@@ -445,7 +454,7 @@ Phase 7 has pushed already, so this is a no-op unless the head moved since. `exi
445
454
  3. **If NO_PR or NO_CI** → skip: "No PR/CI configured, skipping CI validation." Proceed to next phase.
446
455
  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.
447
456
  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.
448
- 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.
457
+ 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.
449
458
  7. **Budget**: at most 3 waits and 2 fixes in all, per worktree. When one is spent, report the current status and proceed.
450
459
  <!-- /PATTERN: ci-status-gate -->
451
460
 
@@ -555,19 +564,13 @@ Capture the Git agent's `**Publication**:` and `**Status**:` lines as `PR_COMMEN
555
564
 
556
565
  **Step 9b-3: Refresh the test-plan evidence**
557
566
 
558
- Run this step only when Step 9b-0 ran — the head moved — and its `EVIDENCE` line did not read `total:0` with `exceptions:none` (nothing to record); otherwise record `EVIDENCE_REFRESH` as `SKIPPED ({reason})`. Spawn Git agent:
567
+ Run this step only when Step 9b-0 ran — the head moved — and its `EVIDENCE` line did not read `total:0` with `exceptions:none` (nothing to record); otherwise record `EVIDENCE_REFRESH` as `SKIPPED ({reason})`. Run the script inline — it is the whole `update-pr-evidence` operation, with no Git agent spawn — through the Bash tool with `timeout: 180000`:
559
568
 
560
- ```
561
- Agent(subagent_type="Git"):
562
- "OPERATION: update-pr-evidence
563
- PR_NUMBER: {pr_number}
564
- EVIDENCE_FILE: {TARGET_DIR_REL}/evidence.md
565
- REVIEW_PUBLICATION: {9b-2's publication mode}
566
- WORKTREE_PATH: {worktree_path} (omit if cwd)
567
- Refresh the PR's test-plan block and post its evidence comment."
569
+ ```bash
570
+ cd {worktree} && node "$HOME/.devflow/scripts/verify-evidence.cjs" publish --pr {pr_number} --evidence "{TARGET_DIR_REL}/evidence.md" --publication {9b-2's publication mode}; echo "exit=$?"
568
571
  ```
569
572
 
570
- Omit the `EVIDENCE_FILE` line when Step 9b-0 appended no claim. `REVIEW_PUBLICATION` is the mode 9b-2 reported on its `**Publication**:` line — `FULL…` → `full`, `STUB…` → `stub`, `OFF…` → `off` — else `{REVIEW_PUBLICATION}` as resolved in Step 0d. Capture its `EVIDENCE` line and its `**Body**:` / `**Comment**:` line, or its `TRACEABILITY: DEGRADED ({reason})` line, as `EVIDENCE_REFRESH`. It never blocks.
573
+ Drop the `--evidence` pair when Step 9b-0 appended no claim. Run it only when `TARGET_DIR_REL` matches `^[A-Za-z0-9._/-]+$` — it carries the branch name, which a fork author picks — and `{pr_number}` is digits only; treat any other value as a failed run. The publication value is the mode 9b-2 reported on its `**Publication**:` line — `FULL…` → `full`, `STUB…` → `stub`, `OFF…` → `off` — else `{REVIEW_PUBLICATION}` as resolved in Step 0d. Capture its stdout as `EVIDENCE_REFRESH`: the `## PR Evidence` block's `EVIDENCE` line and its `**Body**:` / `**Comment**:` line, with any `TRACEABILITY: DEGRADED ({reason})` lines after them (exit 0), or the one line `TRACEABILITY: DEGRADED (evidence unavailable)` (exit 2). Empty stdout or any other exit is `TRACEABILITY: DEGRADED (evidence unavailable)`. It never blocks.
571
574
 
572
575
  ### Phase 9c: Merge Readiness (Report-only)
573
576
 
@@ -576,19 +579,17 @@ Omit the `EVIDENCE_FILE` line when Step 9b-0 appended no claim. `REVIEW_PUBLICAT
576
579
 
577
580
  Run this phase only when `REQUIRE_NON_AUTHOR_APPROVAL` is `true`; otherwise skip it and report it as SKIPPED.
578
581
 
579
- Spawn Git agent:
582
+ Run the script inline — it is the whole `check-merge-readiness` operation, with no Git agent spawn — through the Bash tool with `timeout: 180000`:
580
583
 
584
+ ```bash
585
+ cd {worktree} && node "$HOME/.devflow/scripts/verify-evidence.cjs" readiness --pr {pr_number} --require-non-author-approval true; echo "exit=$?"
581
586
  ```
582
- Agent(subagent_type="Git"):
583
- "OPERATION: check-merge-readiness
584
- PR_NUMBER: {pr_number}
585
- REQUIRE_NON_AUTHOR_APPROVAL: {REQUIRE_NON_AUTHOR_APPROVAL}
586
- WORKTREE_PATH: {worktree_path} (omit if cwd)"
587
- ```
587
+
588
+ Pass `--require-non-author-approval true`: `REQUIRE_NON_AUTHOR_APPROVAL` is `true` here, or this phase would not run. `{pr_number}` is digits only. Its stdout is the `## Merge Readiness` block (exit 0), or the same block with `**Status**: DEGRADED ({reason})` and a `TRACEABILITY: DEGRADED ({reason})` line after it (exit 2); empty stdout or any other exit is `TRACEABILITY: DEGRADED (readiness unavailable)`.
588
589
 
589
590
  Include merge readiness verdict (READY / NOT_READY / DEGRADED) and its `- Test plan:` detail line in Phase 10 report. Never block on this result — report-only.
590
591
 
591
- If Git agent returns `TRACEABILITY: DEGRADED`: warn, proceed to Phase 10.
592
+ If the script prints a `TRACEABILITY: DEGRADED` line: warn, proceed to Phase 10.
592
593
 
593
594
  ### Phase 10: Report
594
595
 
@@ -677,21 +678,17 @@ FEATURE_SLUG: {slug derived from primary changed directory, kebab-case}
677
678
  FEATURE_NAME: {human-readable name}
678
679
  DIRECTORIES: {list of primary directories touched by this workflow}
679
680
  FILES_CHANGED: {list of files changed}
680
- DECISIONS_CONTEXT: {DECISIONS_CONTEXT if available, else (none)}
681
+ DECISIONS_CONTEXT: {the slice for these directories, else (none)}
681
682
 
682
683
  Write the knowledge base to:
683
684
  {worktree}/.devflow/features/{slug}/KNOWLEDGE.md
684
685
 
685
- Then update the index cache by performing a read-modify-write on:
686
+ Then update the index cache:
686
687
  {worktree}/.devflow/features/index.md
687
688
 
688
689
  Index line format: `- **{slug}** — {areas} — {Use-when description}` — at most 300 characters, the description at most 220; reword a longer one, never cut it.
689
690
 
690
- If the line for this slug already exists in index.md, replace it. If it does not exist, append it. If index.md does not exist, create it with just this line.
691
-
692
- The frontmatter in KNOWLEDGE.md is the source of truth — index.md is only a cache. Write the two files directly — no intermediate result JSON files, no external scripts.
693
-
694
- After writing, commit the two files to the current worktree branch yourself by running git via your Bash tool (do not use a script). Stage ONLY .devflow/features/index.md and .devflow/features/{slug}/KNOWLEDGE.md, then commit just those paths with a docs(knowledge): message. Do NOT push, do NOT force, do NOT stage anything else. Follow your Commit Protocol — it is non-blocking, so if any git step fails, report KB_COMMIT and finish normally."
691
+ Then commit the two files as your Commit Protocol directs."
695
692
  ```
696
693
 
697
694
  **Step 4 — Surface an uncommitted knowledge base:**
@@ -706,44 +703,24 @@ When the Knowledge agent reports `KB_COMMIT: skipped (detached HEAD)`, the files
706
703
  /resolve (orchestrator - spawns agents only)
707
704
  │
708
705
  ├─ Phase 0: Worktree Discovery & Pre-flight
709
- │ ├─ Step 0a: git worktree list → filter resolvable
710
- │ ├─ Step 0b: Git agent (validate-branch) per worktree [parallel] ← + DIFF_FILES
711
- │ ├─ Step 0c: Target latest review directory per worktree
712
- │ └─ Step 0d: Load project decisions → DECISIONS_CONTEXT + EVIDENCE_POLICY + REVIEW_PUBLICATION
713
- │
714
706
  ├─ Phase 1: Parse issues from TARGET_DIR + extract confidence %
715
- │
716
707
  ├─ Phase 1b: Fetch external threads (evidence policy required)
717
- │ └─ Git agent (fetch-review-threads) → THREAD_MAP
718
- │
719
708
  ├─ Phase 2: Global Triage [Triage agent, opus, single agent]
720
- │ └─ ALL issues → verdict ledger by disposition (incl. DUPLICATE with duplicate_of)
721
- │
722
709
  ├─ Phase 3: Batch FIX_NOW issues (skip if empty; DUPLICATE issues never dispatched)
723
- │ └─ same-file sequential, distinct-file parallel, max 5/batch
724
- │
725
710
  ├─ Phase 4: Fix [Code agent × N, OPERATION: issue-fix, PUSH: false]
726
- │ └─ Returns Verification block per batch
727
- │
728
711
  ├─ Phase 5: Write resolution-summary.md (compaction safety; Tracked = "(pending)" or "(pending — TRACEABILITY: DEGRADED)" if manage-debt degrades)
729
- │
730
- ├─ Phase 6: Simplify [Simplify agent]
731
- │
732
- ├─ Phase 7: Verification Gate [Validate agent, haiku] + push + Code agent validation-fix loop ≤2
733
- │
712
+ ├─ Phase 6: Polish [Polish agent]
713
+ ├─ Phase 7: Verification Gate [Validate agent, haiku] + push + Fix agent validation-fix loop ≤2
734
714
  ├─ Phase 8: CI Status Gate (conditional — skipped if no fixes or verification FAILED)
735
- │ └─ push, then ci-wait.cjs (inline, one wait ≤ 570 s) → Code agent on FAILING (3 waits + 2 fixes per worktree)
736
- │
737
715
  ├─ Phase 9: Git agent (manage-debt) — FIX_SEPARATE + TECH_DEBT → backfill Tracked={ISSUE_REF} (or TRACEABILITY: DEGRADED on failure)
738
- │ SEQUENTIAL across worktrees
739
716
  │
740
717
  ├─ Phase 9b: Thread resolution + resolution comment
741
718
  │ ├─ Step 9b-0: verify-evidence.cjs --stale-out → ≤1 Test agent on the stale TPs (wrapped) — only after this run's push
742
719
  │ ├─ Step 9b-1: Git agent (resolve-review-threads) — evidence policy required
743
720
  │ ├─ Step 9b-2: Git agent (post-resolution-summary, REVIEW_PUBLICATION) — always-on
744
- │ └─ Step 9b-3: Git agent (update-pr-evidence) — only when the head moved
721
+ │ └─ Step 9b-3: verify-evidence.cjs publish (inline, no Git spawn) — only when the head moved
745
722
  │
746
- ├─ Phase 9c: Git agent (check-merge-readiness) — non-author approval required, report-only
723
+ ├─ Phase 9c: verify-evidence.cjs readiness (inline, no Git spawn) — non-author approval required, report-only
747
724
  │
748
725
  └─ Phase 10: Display results (resolution-summary.md written in Phase 5)
749
726
  ```
@@ -757,21 +734,11 @@ When the Knowledge agent reports `KB_COMMIT: skipped (detached HEAD)`, the files
757
734
  | Fix attempt fails | Revert changes, mark BLOCKED, continue others |
758
735
  | Issue dependencies | Sequential chain, skip dependents if predecessor blocked |
759
736
  | No actionable issues | Report "No issues to resolve" |
760
- | Incomplete review directory (no review-summary.md) | Skip — resolve only targets complete reviews |
761
737
  | Latest review already resolved | Check bug-analysis fallback (Step 0c-5b); if also absent, skip worktree and suggest `/code-review` or `/bug-analysis` |
762
- | Legacy flat layout (no subdirectories) | Read flat *.md files directly (backwards compatible) |
763
738
  | `--review {timestamp}` in multi-worktree mode | Not supported — use `--path` + `--review` to target specific worktree + review |
764
- | Worktree pre-flight fails | Report failure, continue with other worktrees |
765
- | Empty FIX_NOW list | Skip Phases 3-4/6-8; still write full summary + run manage-debt if FIX_SEPARATE/TECH_DEBT exist |
766
- | ESCALATED security issues | Surfaced in ## Escalations + display callout; never routed to manage-debt |
767
- | DUPLICATE verdict without duplicate_of, or chained to another DUPLICATE | Treated as Triage failure — same retry-then-abort as a vanished id |
768
- | DUPLICATE issues in THREAD_MAP | Map ext-{N} to primary's verdict/verification status for thread reply |
769
- | Verification Gate FAILED after 2 attempts | Recorded as FAILED in ## Verification + blocking callout; CI gate skipped; proceed to Phase 9 (manage-debt) then Phase 10 (display) |
770
739
  | gh/GitHub absent | manage-debt degrades (`TRACEABILITY: DEGRADED ({reason})`); Tracked stays `(pending — TRACEABILITY: DEGRADED ({reason}))` — recorded, not dropped |
771
740
  | `EVIDENCE_POLICY` is `standard` | Phases 1b and 9b-step-1 are skipped; post-resolution-summary (Phase 9b step 2) still runs if a PR is known |
772
741
  | `REQUIRE_NON_AUTHOR_APPROVAL` is `false` | Phase 9c is skipped and reported as SKIPPED |
773
- | THREAD_MAP empty or DEGRADED | Phase 9b-1 skipped; resolution comment (Phase 9b-2) still posted if PR known |
774
- | No PR exists for post-resolution-summary | Git agent returns TRACEABILITY: DEGRADED; resolution-summary.md already on disk — not a blocker |
775
742
  | Public repo (`auto` mode) | Git agent probes visibility, posts counts-only STUB comment; full resolution report stays local |
776
743
  | `reviewPublication: off` | Git agent skips posting the resolution comment (OFF) — except that, only when `EVIDENCE_POLICY` is `required`, Step 0d passes `stub` and a counts-only STUB comment posts |
777
744
  | Fork PR this run cannot push to (no maintainer edits, no push access of its own) | validate-branch emits `TRACEABILITY: DEGRADED (cannot push to fork)` → `fork_no_push`: Phase 7 skips the push, Phase 8 is skipped, 9b-1 records FIXED threads as DEGRADED instead of citing unpushed commits; 9b-2 still posts the resolution comment; the head did not move, so 9b-0 and 9b-3 are skipped |
@@ -782,14 +749,8 @@ When the Knowledge agent reports `KB_COMMIT: skipped (detached HEAD)`, the files
782
749
 
783
750
  1. **Orchestration only** - Command spawns agents, doesn't do git/resolve work itself
784
751
  2. **No agent grades its own homework** - Triage agent validates, Code agents fix, Validate agent verifies
785
- 3. **Global triage first** - Single Triage agent sees all issues for cross-issue consistency; no issue may vanish
786
- 4. **Git agent for git work** - All git operations go through Git agent
787
- 5. **Parallel execution** - Distinct-file Code agent batches run in parallel; same-file batches sequential
788
- 6. **Honest reporting** - Verification failure is recorded and displayed, never silenced
789
- 7. **Complete tracking** - Every issue gets exactly one verdict in the ledger
790
- 8. **Latest review by default** - Only process the most recent complete review
791
- 9. **Auto-discover worktrees** - One command handles all resolvable branches
792
- 10. **Traceability-aware** - Policy-gated ops (thread fetch/resolve, merge readiness) are skipped cleanly when the evidence policy does not ask for them; resolution comment (Phase 9b-2) is always-on; test-plan evidence is re-verified (≤1 Test agent) and refreshed only when this run moved the head (Steps 9b-0, 9b-3)
752
+ 3. **Git agent for git work** - All git operations go through Git agent; the CI wait, the evidence refresh and the merge-readiness check are inline scripts (plumbing, no model work)
753
+ 4. **Traceability-aware** - Policy-gated ops (thread fetch/resolve, merge readiness) are skipped cleanly when the evidence policy does not ask for them; resolution comment (Phase 9b-2) is always-on; test-plan evidence is re-verified (≤1 Test agent) and refreshed only when this run moved the head (Steps 9b-0, 9b-3)
793
754
 
794
755
  ## Output Artifact
795
756
 
@@ -1,9 +1,9 @@
1
1
  ---
2
- description: Self-review workflow - Simplify agent (code clarity) then Scrutinize agent (9-pillar quality gate)
2
+ description: Self-review workflow - Polish agent (code clarity) then Harden agent (9-pillar quality gate)
3
3
  ---
4
4
  # Self-Review Command
5
5
 
6
- Run Simplify agent and Scrutinize agent sequentially on changed files for post-implementation quality refinement.
6
+ Run Polish agent and Harden agent sequentially on changed files for post-implementation quality refinement.
7
7
 
8
8
  ## Usage
9
9
 
@@ -22,7 +22,7 @@ Detect changed files and build context:
22
22
  2. Else run `git diff --name-only HEAD` + `git diff --name-only --cached` to get staged + unstaged
23
23
  3. If no changes found, report "No changes to review" and exit
24
24
  4. Build TASK_DESCRIPTION from recent commit messages or branch name
25
- 5. Record `HEAD_BEFORE` (`git rev-parse HEAD`) now, before Simplify runs — Phase 3 compares against it
25
+ 5. Record `HEAD_BEFORE` (`git rev-parse HEAD`) now, before Polish runs — Phase 3 compares against it
26
26
 
27
27
  **Resolve the settings line** once per worktree root, reusing a line this run already resolved for the same root. `{root}` is the worktree the values are for — the repository root when the run has one worktree:
28
28
 
@@ -38,19 +38,19 @@ The accepted line is the only source of these values: the script alone folds the
38
38
 
39
39
  When the settings line says `LEARNING=off`, set `DECISIONS_CONTEXT` to `(none)` and skip this step, locating no ledger and reading no index.
40
40
 
41
- The decisions ledger belongs to the repository, not to one checkout: in a linked worktree it lives in the main worktree, and a session started in a subdirectory reads the copy at the repository root. Locate it with ONE git call, run from the start directory — `WORKTREE_PATH` if provided, otherwise cwd (`devflow:worktree-support`):
41
+ The decisions ledger belongs to the repository, not to one checkout: a linked worktree reads the main worktree's copy, a subdirectory session the repository root's. Locate it with ONE git call, run from the start directory — `WORKTREE_PATH` if provided, otherwise cwd (`devflow:worktree-support`):
42
42
 
43
43
  ```bash
44
44
  git -C "{start}" rev-parse --path-format=absolute --show-toplevel --git-common-dir
45
45
  ```
46
46
 
47
- Line 1 is the checkout's toplevel, line 2 the repository's common git directory. A git older than 2.31 echoes `--path-format=absolute` back as a line of its own first. `{ledger}` is the first of these that applies:
47
+ Line 1 is the checkout's toplevel, line 2 the common git directory. A git older than 2.31 echoes `--path-format=absolute` back as a line of its own first. `{ledger}` is the first that applies:
48
48
 
49
49
  1. **The main worktree** — line 2 without its trailing `/.git`, when the output is exactly two lines each beginning with `/`, line 2 ends in `/.git`, and the directory left once it is removed is not your home directory and contains a `.devflow/` directory.
50
50
  2. **The toplevel** — line 1, or on an older git the line after the echoed flag.
51
51
  3. **The start directory itself** — when the command failed or printed no absolute toplevel (outside a git repository).
52
52
 
53
- This is the rule the learning hooks apply (D-LEDGER-MAIN-WORKTREE, D-PROMPT-ROOT), so you read the index the Learning agent writes.
53
+ This is the rule the learning hooks apply, so you read the index the Curate agent writes.
54
54
 
55
55
  **Step 1 — Read the pre-rendered index:**
56
56
 
@@ -59,13 +59,17 @@ Attempt to read `{ledger}/.devflow/learning/index.md`.
59
59
  - If the file exists and contains non-empty content: use that content as `DECISIONS_CONTEXT`.
60
60
  - If the file is absent or empty: set `DECISIONS_CONTEXT` to `(none)`.
61
61
 
62
- The index is one direct file read, written at render time by `render-decisions.cjs` alongside `decisions.md`/`pitfalls.md` — no `.cjs` script runs here, and the index's own footer names the files that hold each entry's full body.
62
+ The index is one direct file read, written at render time by `render-decisions.cjs` — no `.cjs` script runs here.
63
63
 
64
- **Step 2 — Apply decisions using `devflow:apply-decisions`:**
64
+ **Step 2 — Slice the index, then hand it on:**
65
65
 
66
- When `DECISIONS_CONTEXT` is not `(none)`, follow `devflow:apply-decisions` to scan the index, identify plausibly-relevant entries, Read full entry bodies on demand, and cite verbatim IDs in downstream agent prompts and reasoning.
66
+ When `DECISIONS_CONTEXT` is not `(none)`, hand it only to the agents whose contract declares it.
67
67
 
68
- Pass `DECISIONS_CONTEXT` to Scrutinize agent — the compact index lists active ADR/PF entries; Scrutinize agent uses `devflow:apply-decisions` to Read full entry bodies on demand. Known pitfalls help identify reintroduced issues, prior decisions help validate architectural consistency. (Simplify agent does not consume decisions — it operates at code-shape level and Scrutinize agent runs after to catch any architectural drift.)
68
+ Hand each agent that takes `DECISIONS_CONTEXT` a slice, not the whole index: the index lines whose title, scope or area touch the files and task it works on, verbatim, led by `(slice: N of M entries — full index: <absolute index path>)` and closed by the index footer. When unsure, include the line. Siblings over one diff share ONE slice.
69
+
70
+ Those agents follow `devflow:apply-decisions`. A host that uses the index in its own thread says so in its own step.
71
+
72
+ Pass `DECISIONS_CONTEXT` to Harden agent — the compact index lists active ADR/PF entries; Harden agent uses `devflow:apply-decisions` to Read full entry bodies on demand. Known pitfalls help identify reintroduced issues, prior decisions help validate architectural consistency. (Polish agent does not consume decisions — it operates at code-shape level and Harden agent runs after to catch any architectural drift.)
69
73
 
70
74
  ### Load Feature Knowledge
71
75
 
@@ -89,7 +93,7 @@ If `index.md` exists and contains at least one entry line, use it for relevance
89
93
 
90
94
  **Step 2 — Fallback: glob frontmatter (if `index.md` is absent or empty):**
91
95
 
92
- Glob `{worktree}/.devflow/features/*/KNOWLEDGE.md`. For each file found, read only its YAML frontmatter block (between the opening and closing `---` delimiters). The frontmatter fields `name`, `description`, and `directories` are the authoritative relevance surface — `index.md` is only a cache.
96
+ Glob `{worktree}/.devflow/features/*/KNOWLEDGE.md`. For each file found, read only its YAML frontmatter block (between the opening and closing `---` delimiters).
93
97
 
94
98
  **Step 3 — Pick relevant KBs:**
95
99
 
@@ -120,35 +124,35 @@ Headings: L5 Rules · L40 Overview · L62 Anti-Patterns · L118 Key Files
120
124
 
121
125
  A KB with no Rules section labels its entries `Rules ({section name}):` and gives them no ID. `FEATURE_KNOWLEDGE` is these blocks; `FEATURE_KNOWLEDGE_RULES` is the same blocks without the `Headings:` line. Both come from this one selection, and each spawn names the variable its recipient takes. If no KBs exist, no KBs are relevant, or `.devflow/features/` is absent, set both to `(none)`.
122
126
 
123
- **One git call, then direct reads — no `.cjs` script.** After resolving `{worktree}`, this step is 1 index read (or N frontmatter reads on fallback), plus one heading listing and one Rules read per selected KB, bounded by KB count.
127
+ **One git call, then direct reads — no `.cjs` script.**
124
128
 
125
- Pass `FEATURE_KNOWLEDGE_RULES` to Scrutinize agent.
129
+ Pass `FEATURE_KNOWLEDGE_RULES` to Harden agent.
126
130
 
127
131
  **Extract:** FILES_CHANGED (list), TASK_DESCRIPTION (string), DECISIONS_CONTEXT (string, optional), FEATURE_KNOWLEDGE (string, optional), FEATURE_KNOWLEDGE_RULES (string, optional), HEAD_BEFORE (40-hex SHA)
128
132
 
129
- ### Phase 1: Simplify agent (Code Refinement)
133
+ ### Phase 1: Polish agent (Code Refinement)
130
134
 
131
- **Produces:** SIMPLIFY_COMMITS
135
+ **Produces:** POLISH_COMMITS
132
136
  **Requires:** FILES_CHANGED, TASK_DESCRIPTION
133
137
 
134
- Spawn Simplify agent to refine code for clarity and consistency:
138
+ Spawn Polish agent to refine code for clarity and consistency:
135
139
 
136
- Agent(subagent_type="Simplify", run_in_background=false):
140
+ Agent(subagent_type="Polish", run_in_background=false):
137
141
  "TASK_DESCRIPTION: {task_description}
138
142
  FILES_CHANGED: {files_changed}
139
- Simplify and refine the code for clarity and consistency while preserving functionality.
143
+ Polish and refine the code for clarity and consistency while preserving functionality.
140
144
  Commit any improvements with a conventional-commit message."
141
145
 
142
- **Wait for completion.** Simplify agent commits changes directly.
146
+ **Wait for completion.** Polish agent commits changes directly.
143
147
 
144
- ### Phase 2: Scrutinize agent (9-Pillar Quality Gate)
148
+ ### Phase 2: Harden agent (9-Pillar Quality Gate)
145
149
 
146
- **Produces:** SCRUTINIZE_STATUS
150
+ **Produces:** HARDEN_STATUS
147
151
  **Requires:** FILES_CHANGED, TASK_DESCRIPTION, DECISIONS_CONTEXT
148
152
 
149
- Spawn Scrutinize agent for quality evaluation and fixing:
153
+ Spawn Harden agent for quality evaluation and fixing:
150
154
 
151
- Agent(subagent_type="Scrutinize", run_in_background=false):
155
+ Agent(subagent_type="Harden", run_in_background=false):
152
156
  "TASK_DESCRIPTION: {task_description}
153
157
  FILES_CHANGED: {files_changed}
154
158
  DECISIONS_CONTEXT: {decisions_context}
@@ -162,11 +166,11 @@ Follow devflow:apply-feature-knowledge for FEATURE_KNOWLEDGE. Skip if (none)."
162
166
  ### Phase 3: Conditional Validation
163
167
 
164
168
  **Produces:** VALIDATION_RESULT
165
- **Requires:** HEAD_BEFORE, SCRUTINIZE_STATUS
169
+ **Requires:** HEAD_BEFORE, HARDEN_STATUS
166
170
 
167
171
  If STATUS is BLOCKED, skip this phase: the report (Phase 4) names the blocker.
168
172
 
169
- Run this phase only if HEAD moved — `git rev-parse HEAD` differs from `HEAD_BEFORE`, meaning Simplify or Scrutinize committed (Simplify alone counts, whatever Scrutinize's STATUS is). Otherwise skip it. Its scope is changed-only over what the two agents changed:
173
+ Run this phase only if HEAD moved — `git rev-parse HEAD` differs from `HEAD_BEFORE`, meaning Polish or Harden committed (Polish alone counts, whatever Harden's STATUS is). Otherwise skip it. Its scope is changed-only over what the two agents changed:
170
174
 
171
175
  Agent(subagent_type="Validate", run_in_background=false):
172
176
  "FILES_CHANGED: {output of `git diff --name-only HEAD_BEFORE..HEAD`}
@@ -178,7 +182,7 @@ Run build, typecheck, lint, test on modified files"
178
182
 
179
183
  ### Phase 4: Report
180
184
 
181
- **Requires:** SCRUTINIZE_STATUS, VALIDATION_RESULT
185
+ **Requires:** HARDEN_STATUS, VALIDATION_RESULT
182
186
 
183
187
  Display summary:
184
188
 
@@ -187,10 +191,10 @@ Display summary:
187
191
  **Files Reviewed**: {n}
188
192
  **Status**: {PASS|FIXED|BLOCKED}
189
193
 
190
- ### Simplify agent
194
+ ### Polish agent
191
195
  - {n} files refined for clarity
192
196
 
193
- ### Scrutinize agent (9-Pillar Evaluation)
197
+ ### Harden agent (9-Pillar Evaluation)
194
198
  | Pillar | Status |
195
199
  |--------|--------|
196
200
  | Design | {status} |
@@ -240,21 +244,17 @@ FEATURE_SLUG: {slug derived from primary changed directory, kebab-case}
240
244
  FEATURE_NAME: {human-readable name}
241
245
  DIRECTORIES: {list of primary directories touched by this workflow}
242
246
  FILES_CHANGED: {list of files changed}
243
- DECISIONS_CONTEXT: {DECISIONS_CONTEXT if available, else (none)}
247
+ DECISIONS_CONTEXT: {the slice for these directories, else (none)}
244
248
 
245
249
  Write the knowledge base to:
246
250
  {worktree}/.devflow/features/{slug}/KNOWLEDGE.md
247
251
 
248
- Then update the index cache by performing a read-modify-write on:
252
+ Then update the index cache:
249
253
  {worktree}/.devflow/features/index.md
250
254
 
251
255
  Index line format: `- **{slug}** — {areas} — {Use-when description}` — at most 300 characters, the description at most 220; reword a longer one, never cut it.
252
256
 
253
- If the line for this slug already exists in index.md, replace it. If it does not exist, append it. If index.md does not exist, create it with just this line.
254
-
255
- The frontmatter in KNOWLEDGE.md is the source of truth — index.md is only a cache. Write the two files directly — no intermediate result JSON files, no external scripts.
256
-
257
- After writing, commit the two files to the current worktree branch yourself by running git via your Bash tool (do not use a script). Stage ONLY .devflow/features/index.md and .devflow/features/{slug}/KNOWLEDGE.md, then commit just those paths with a docs(knowledge): message. Do NOT push, do NOT force, do NOT stage anything else. Follow your Commit Protocol — it is non-blocking, so if any git step fails, report KB_COMMIT and finish normally."
257
+ Then commit the two files as your Commit Protocol directs."
258
258
  ```
259
259
 
260
260
  **Step 4 — Surface an uncommitted knowledge base:**
@@ -272,14 +272,14 @@ When the Knowledge agent reports `KB_COMMIT: skipped (detached HEAD)`, the files
272
272
  │ ├─ Record HEAD_BEFORE
273
273
  │ └─ Read index.md → DECISIONS_CONTEXT
274
274
  │
275
- ├─ Phase 1: Simplify agent
275
+ ├─ Phase 1: Polish agent
276
276
  │ └─ Code refinement (commits directly)
277
277
  │
278
- ├─ Phase 2: Scrutinize agent
278
+ ├─ Phase 2: Harden agent
279
279
  │ └─ 9-pillar quality gate (may fix and commit)
280
280
  │
281
281
  ├─ Phase 3: Validate agent (conditional)
282
- │ └─ If HEAD moved since HEAD_BEFORE (Simplify or Scrutinize committed), changed-only Validate over HEAD_BEFORE..HEAD
282
+ │ └─ If HEAD moved since HEAD_BEFORE (Polish or Harden committed), changed-only Validate over HEAD_BEFORE..HEAD
283
283
  │
284
284
  └─ Phase 4: Report
285
285
  └─ Display summary with pillar status
@@ -289,15 +289,15 @@ When the Knowledge agent reports `KB_COMMIT: skipped (detached HEAD)`, the files
289
289
  | Case | Handling |
290
290
  |------|----------|
291
291
  | No changes | Report "No changes to review" and exit |
292
- | Simplify agent finds nothing | Normal, continue to Scrutinize agent |
293
- | Scrutinize agent BLOCKED | Report blocking issue, halt workflow |
292
+ | Polish agent finds nothing | Normal, continue to Harden agent |
293
+ | Harden agent BLOCKED | Report blocking issue, halt workflow |
294
294
  | Validation fails | Report failures, halt (don't create broken state) |
295
295
  | Not in git repo | Report error, suggest running in git repo |
296
296
 
297
297
  ## Principles
298
298
 
299
299
  1. **Orchestration only** - Command spawns agents, doesn't do the work
300
- 2. **Sequential execution** - Simplify agent must complete before Scrutinize agent
301
- 3. **Validation gate** - If Simplify agent or Scrutinize agent committed, the changes must pass validation
300
+ 2. **Sequential execution** - Polish agent must complete before Harden agent
301
+ 3. **Validation gate** - If Polish agent or Harden agent committed, the changes must pass validation
302
302
  4. **Honest reporting** - Display actual agent outputs
303
303
  5. **Fail fast** - Stop on BLOCKED or validation failure