devflow-kit 3.7.0 → 3.9.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 (205) hide show
  1. package/CHANGELOG.md +479 -1
  2. package/README.md +15 -15
  3. package/dist/agents/code.md +6 -8
  4. package/dist/agents/design.md +1 -1
  5. package/dist/agents/fix.md +7 -8
  6. package/dist/agents/git.md +3 -3
  7. package/dist/agents/harden.md +1 -1
  8. package/dist/agents/refactor.md +2 -4
  9. package/dist/agents/review.md +4 -4
  10. package/dist/agents/skim.md +2 -2
  11. package/dist/agents/triage.md +9 -2
  12. package/dist/cli/commands/capture.js +1 -1
  13. package/dist/cli/commands/curation-move-io.js +102 -0
  14. package/dist/cli/commands/curation-move-step.js +374 -0
  15. package/dist/cli/commands/curation.js +808 -0
  16. package/dist/cli/commands/gate-level-prompts.js +428 -0
  17. package/dist/cli/commands/gates.js +35 -11
  18. package/dist/cli/commands/init-seed.js +11 -8
  19. package/dist/cli/commands/init.js +244 -57
  20. package/dist/cli/commands/memory.js +60 -13
  21. package/dist/cli/commands/prompt-io.js +37 -0
  22. package/dist/cli/commands/uninstall.js +157 -17
  23. package/dist/cli.js +2 -2
  24. package/dist/commands/bug-analysis.md +25 -36
  25. package/dist/commands/code-review.md +40 -44
  26. package/dist/commands/debug.md +5 -5
  27. package/dist/commands/dynamic-build.md +26 -25
  28. package/dist/commands/dynamic-plan.md +5 -5
  29. package/dist/commands/dynamic-profile.md +5 -5
  30. package/dist/commands/dynamic-tickets.md +5 -5
  31. package/dist/commands/explore.md +6 -6
  32. package/dist/commands/implement.md +53 -82
  33. package/dist/commands/plan.md +6 -6
  34. package/dist/commands/release.md +5 -5
  35. package/dist/commands/research.md +6 -6
  36. package/dist/commands/resolve.md +39 -41
  37. package/dist/commands/self-review.md +5 -13
  38. package/dist/core/area-pause-notice.js +44 -0
  39. package/dist/core/assets.js +20 -20
  40. package/dist/core/curate-tuning-config.js +5 -6
  41. package/dist/core/curation-move-notice.js +84 -0
  42. package/dist/core/curation-move-skip.js +35 -0
  43. package/dist/core/curation-move.js +35 -0
  44. package/dist/core/curation-queue-cleanup.js +135 -0
  45. package/dist/core/curation-store.js +99 -0
  46. package/dist/core/{learning-variants.js → curation-variants.js} +65 -41
  47. package/dist/core/echo-value.js +11 -5
  48. package/dist/core/evidence-policy.js +11 -9
  49. package/dist/core/feature-switch.js +95 -19
  50. package/dist/core/fs-atomic.js +1 -1
  51. package/dist/core/gate-level.js +10 -2
  52. package/dist/core/git.js +16 -14
  53. package/dist/core/ledger-root.js +82 -22
  54. package/dist/core/linked-path.js +4 -4
  55. package/dist/core/manifest-lock.js +238 -0
  56. package/dist/core/manifest.js +58 -14
  57. package/dist/core/migrations.js +1 -13
  58. package/dist/core/observations.js +2 -2
  59. package/dist/core/plugins.js +19 -19
  60. package/dist/core/pool.js +26 -0
  61. package/dist/core/project-paths.js +103 -34
  62. package/dist/core/queue-drain.js +2 -2
  63. package/dist/core/tracked-areas.js +159 -0
  64. package/dist/core/tracker.js +1 -1
  65. package/dist/{learning-off → curation-off}/agents/code.md +6 -8
  66. package/dist/{learning-off → curation-off}/agents/fix.md +7 -8
  67. package/dist/{learning-off → curation-off}/agents/refactor.md +2 -4
  68. package/dist/{learning-off → curation-off}/agents/review.md +3 -3
  69. package/dist/{learning-off → curation-off}/agents/triage.md +8 -1
  70. package/dist/{learning-off → curation-off}/commands/bug-analysis.md +20 -31
  71. package/dist/{learning-off → curation-off}/commands/code-review.md +37 -41
  72. package/dist/{learning-off → curation-off}/commands/debug.md +2 -2
  73. package/dist/{learning-off → curation-off}/commands/dynamic-build.md +23 -22
  74. package/dist/{learning-off → curation-off}/commands/explore.md +2 -2
  75. package/dist/{learning-off → curation-off}/commands/implement.md +50 -79
  76. package/dist/{learning-off → curation-off}/commands/plan.md +2 -2
  77. package/dist/{learning-off → curation-off}/commands/resolve.md +36 -38
  78. package/dist/{learning-off → curation-off}/commands/self-review.md +2 -10
  79. package/dist/hud/components/{learning-counts.js → curation-counts.js} +63 -17
  80. package/dist/hud/config.js +1 -1
  81. package/dist/hud/index.js +6 -6
  82. package/dist/hud/render.js +3 -3
  83. package/dist/skills/git/references/pr/post-resolution-summary.md +12 -11
  84. package/dist/skills/git/references/pr/post-review-summary.md +12 -11
  85. package/dist/skills/git/references/pr/update-pr-evidence.md +2 -2
  86. package/dist/skills/git/references/pr/validate-branch.md +8 -5
  87. package/dist/skills/git/references/publication-gate.md +6 -7
  88. package/dist/skills/git/references/tracker/github/ensure-pr-ready.md +13 -5
  89. package/dist/skills/git/references/tracker/github/manage-debt.md +6 -2
  90. package/dist/skills/git/references/tracker/jira/ensure-pr-ready.md +13 -5
  91. package/dist/skills/git/references/tracker/jira/manage-debt.md +6 -2
  92. package/dist/skills/git/references/tracker/linear/ensure-pr-ready.md +13 -5
  93. package/dist/skills/git/references/tracker/linear/manage-debt.md +6 -2
  94. package/dist/targets/claude-code/{learning-install.js → curation-install.js} +85 -65
  95. package/dist/targets/claude-code/installer.js +15 -15
  96. package/dist/targets/claude-code/language-stamp.js +5 -5
  97. package/dist/targets/claude-code/post-install.js +2 -2
  98. package/dist/targets/claude-code/tracker-servers.js +1 -1
  99. package/package.json +3 -2
  100. package/src/assets/agents/_partials/_code.mds +11 -11
  101. package/src/assets/agents/code.mds +6 -6
  102. package/src/assets/agents/curate.md +8 -8
  103. package/src/assets/agents/debug.mds +6 -6
  104. package/src/assets/agents/design.mds +18 -18
  105. package/src/assets/agents/evaluate.md +6 -12
  106. package/src/assets/agents/fix.mds +7 -6
  107. package/src/assets/agents/git.mds +3 -3
  108. package/src/assets/agents/harden.mds +7 -7
  109. package/src/assets/agents/knowledge.mds +23 -23
  110. package/src/assets/agents/refactor.mds +2 -2
  111. package/src/assets/agents/research.mds +15 -15
  112. package/src/assets/agents/review.mds +43 -43
  113. package/src/assets/agents/skim.mds +11 -11
  114. package/src/assets/agents/triage.mds +29 -22
  115. package/src/assets/agents/validate.md +30 -50
  116. package/src/assets/commands/_partials/_decisions.mds +22 -20
  117. package/src/assets/commands/_partials/_engine.mds +8 -8
  118. package/src/assets/commands/_partials/_knowledge.mds +29 -15
  119. package/src/assets/commands/_partials/_preamble.mds +4 -4
  120. package/src/assets/commands/_partials/_settings.mds +3 -3
  121. package/src/assets/commands/_partials/_wave.mds +7 -7
  122. package/src/assets/commands/bug-analysis.mds +37 -48
  123. package/src/assets/commands/code-review.mds +53 -57
  124. package/src/assets/commands/debug.mds +14 -14
  125. package/src/assets/commands/dynamic-build.mds +38 -37
  126. package/src/assets/commands/dynamic-plan.mds +22 -22
  127. package/src/assets/commands/dynamic-profile.mds +2 -2
  128. package/src/assets/commands/dynamic-tickets.mds +8 -8
  129. package/src/assets/commands/explore.mds +20 -20
  130. package/src/assets/commands/implement.mds +77 -98
  131. package/src/assets/commands/plan.mds +27 -27
  132. package/src/assets/commands/release.mds +12 -12
  133. package/src/assets/commands/research.mds +19 -19
  134. package/src/assets/commands/resolve.mds +66 -60
  135. package/src/assets/commands/self-review.mds +20 -20
  136. package/src/assets/mds/git/_ops.mds +9 -2
  137. package/src/assets/mds/git/_ops_pr.mds +21 -11
  138. package/src/assets/mds/git/_ops_steps.mds +20 -4
  139. package/src/assets/mds/git/_pr.mds +21 -18
  140. package/src/assets/mds/git/_references.mds +6 -7
  141. package/src/assets/mds/tracker/_github.mds +1 -4
  142. package/src/assets/mds/tracker/_jira.mds +1 -4
  143. package/src/assets/mds/tracker/_linear.mds +1 -4
  144. package/src/assets/rules/quality.md +1 -0
  145. package/src/assets/scripts/ci-wait.cjs +389 -92
  146. package/src/assets/scripts/hooks/background-memory-update +81 -3
  147. package/src/assets/scripts/hooks/capture-prompt +12 -12
  148. package/src/assets/scripts/hooks/capture-question +11 -11
  149. package/src/assets/scripts/hooks/capture-turn +12 -12
  150. package/src/assets/scripts/hooks/{learning-lock → curation-lock} +2 -2
  151. package/src/assets/scripts/hooks/curation-move +293 -0
  152. package/src/assets/scripts/hooks/ensure-devflow-init +45 -13
  153. package/src/assets/scripts/hooks/ensure-proxy +4 -4
  154. package/src/assets/scripts/hooks/ensure-root-gitignore +4 -4
  155. package/src/assets/scripts/hooks/git-marker +81 -0
  156. package/src/assets/scripts/hooks/json-helper.cjs +176 -51
  157. package/src/assets/scripts/hooks/json-parse +1 -1
  158. package/src/assets/scripts/hooks/lib/curation-move.cjs +1582 -0
  159. package/src/assets/scripts/hooks/lib/{learning-store.cjs → curation-store.cjs} +308 -122
  160. package/src/assets/scripts/hooks/lib/decisions-format.cjs +3 -3
  161. package/src/assets/scripts/hooks/lib/mkdir-lock.cjs +24 -7
  162. package/src/assets/scripts/hooks/lib/project-paths.cjs +132 -39
  163. package/src/assets/scripts/hooks/lib/render-decisions.cjs +42 -22
  164. package/src/assets/scripts/hooks/lib/tracked-areas.cjs +452 -0
  165. package/src/assets/scripts/hooks/memory-permission +10 -2
  166. package/src/assets/scripts/hooks/memory-worker +12 -1
  167. package/src/assets/scripts/hooks/pre-compact-memory +17 -16
  168. package/src/assets/scripts/hooks/queue-append +444 -102
  169. package/src/assets/scripts/hooks/resolve-project-root +2 -2
  170. package/src/assets/scripts/hooks/session-start-context +198 -72
  171. package/src/assets/scripts/hooks/session-start-memory +42 -43
  172. package/src/assets/scripts/lib/project-config.cjs +12 -5
  173. package/src/assets/scripts/pr-evidence.cjs +5 -2
  174. package/src/assets/scripts/resolve-base.cjs +1043 -0
  175. package/src/assets/scripts/resolve-settings.cjs +283 -45
  176. package/src/assets/scripts/verify-evidence.cjs +307 -75
  177. package/src/assets/skills/agent-references/SKILL.md +11 -2
  178. package/src/assets/skills/agent-references/references/commands/implement-levels.md +29 -0
  179. package/src/assets/skills/agent-references/references/commands/implement-revalidate.md +6 -4
  180. package/src/assets/skills/agent-references/references/commands/resolve-levels.md +25 -0
  181. package/src/assets/skills/agent-references/references/synthesize/review.md +4 -4
  182. package/src/assets/skills/agent-references/references/triage/severity-tiers.md +43 -0
  183. package/src/assets/skills/agent-references/references/validate/passed-alone.md +14 -0
  184. package/src/assets/skills/apply-decisions/SKILL.md +1 -1
  185. package/src/assets/skills/docs-framework/SKILL.md +7 -7
  186. package/src/assets/skills/docs-framework/references/patterns.md +3 -4
  187. package/src/assets/skills/quality-gates/SKILL.md +1 -1
  188. package/src/assets/skills/worktree-support/references/roots.md +2 -2
  189. package/templates/lint-pack/.lint-pack.conf +86 -0
  190. package/templates/lint-pack/README.md +190 -0
  191. package/templates/lint-pack/lint-pack.sh +905 -0
  192. package/dist/cli/commands/learning.js +0 -554
  193. package/dist/core/learning-queue-cleanup.js +0 -27
  194. package/dist/core/learning-store.js +0 -61
  195. /package/dist/{learning-off → curation-off}/agents/debug.md +0 -0
  196. /package/dist/{learning-off → curation-off}/agents/design.md +0 -0
  197. /package/dist/{learning-off → curation-off}/agents/harden.md +0 -0
  198. /package/dist/{learning-off → curation-off}/agents/knowledge.md +0 -0
  199. /package/dist/{learning-off → curation-off}/agents/research.md +0 -0
  200. /package/dist/{learning-off → curation-off}/agents/skim.md +0 -0
  201. /package/dist/{learning-off → curation-off}/commands/dynamic-plan.md +0 -0
  202. /package/dist/{learning-off → curation-off}/commands/dynamic-profile.md +0 -0
  203. /package/dist/{learning-off → curation-off}/commands/dynamic-tickets.md +0 -0
  204. /package/dist/{learning-off → curation-off}/commands/release.md +0 -0
  205. /package/dist/{learning-off → curation-off}/commands/research.md +0 -0
@@ -34,29 +34,29 @@ $ARGUMENTS
34
34
 
35
35
  ## Phases
36
36
 
37
- <!-- learning:on -->
37
+ <!-- curation:on -->
38
38
  ### Phase 1: Load Decisions (Orchestrator-Local)
39
- <!-- learning:off -->
39
+ <!-- curation:off -->
40
40
  ### Phase 1: Load Context (Orchestrator-Local)
41
- <!-- learning:end -->
41
+ <!-- curation:end -->
42
42
 
43
- <!-- learning:on -->
43
+ <!-- curation:on -->
44
44
  **Produces:** DECISIONS_CONTEXT, FEATURE_KNOWLEDGE, FEATURE_KNOWLEDGE_RULES
45
- <!-- learning:off -->
45
+ <!-- curation:off -->
46
46
  **Produces:** FEATURE_KNOWLEDGE, FEATURE_KNOWLEDGE_RULES
47
- <!-- learning:end -->
47
+ <!-- curation:end -->
48
48
 
49
49
  {{docs_root()}}
50
50
 
51
- <!-- learning:on -->
51
+ <!-- curation:on -->
52
52
  {{settings.settings_resolve()}}
53
53
 
54
- <!-- learning:end -->
54
+ <!-- curation:end -->
55
55
  {{decisions_load()}}
56
- <!-- learning:on -->
56
+ <!-- curation:on -->
57
57
  Use `DECISIONS_CONTEXT` locally when framing research — prior decisions and pitfalls suggest areas to investigate. Follow `devflow:apply-decisions` to Read full entry bodies on demand. Pass `DECISIONS_CONTEXT` to each Research agent in Phase 4 so their findings can account for relevant decisions.
58
58
 
59
- <!-- learning:end -->
59
+ <!-- curation:end -->
60
60
  {{knowledge_load()}}
61
61
 
62
62
  Use `FEATURE_KNOWLEDGE` **locally** for research framing. Pass to each Research agent in Phase 4.
@@ -82,11 +82,11 @@ Analyze the research question to infer research types needed (min 2, max 5). For
82
82
 
83
83
  Only if `codebase` type is in RESEARCH_PLAN.
84
84
 
85
- <!-- learning:on -->
86
- Spawn `Agent(subagent_type="Skim")` with `LEARNING` from the settings line, targeting codebase areas relevant to the research question.
87
- <!-- learning:off -->
85
+ <!-- curation:on -->
86
+ Spawn `Agent(subagent_type="Skim")` with `CURATION` from the settings line, targeting codebase areas relevant to the research question.
87
+ <!-- curation:off -->
88
88
  Spawn `Agent(subagent_type="Skim")` targeting codebase areas relevant to the research question.
89
- <!-- learning:end -->
89
+ <!-- curation:end -->
90
90
 
91
91
  Skip and set ORIENT_OUTPUT = "(none)" if `codebase` type is not in RESEARCH_PLAN.
92
92
 
@@ -99,9 +99,9 @@ Spawn 2-5 `Agent(subagent_type="Research")` agents **in a single message** (para
99
99
 
100
100
  Each Research agent receives:
101
101
  - `RESEARCH_TYPE`, `RESEARCH_QUESTION`, `OUTPUT_PATH` from RESEARCH_PLAN
102
- <!-- learning:on -->
102
+ <!-- curation:on -->
103
103
  - `DECISIONS_CONTEXT`: From Phase 1
104
- <!-- learning:end -->
104
+ <!-- curation:end -->
105
105
  - `FEATURE_KNOWLEDGE`: `{feature_knowledge}` from Phase 1
106
106
  - `ORIENT_OUTPUT`: Only for `codebase` type
107
107
  - `WORKTREE_PATH`: If in a worktree context
@@ -164,11 +164,11 @@ Research findings saved to `{worktree}/.devflow/docs/research/{topic-slug}/{YYYY
164
164
  ```
165
165
  /research (orchestrator)
166
166
  │
167
- <!-- learning:on -->
167
+ <!-- curation:on -->
168
168
  ├─ Phase 1: Load Decisions (Orchestrator-Local)
169
- <!-- learning:off -->
169
+ <!-- curation:off -->
170
170
  ├─ Phase 1: Load Context (Orchestrator-Local)
171
- <!-- learning:end -->
171
+ <!-- curation:end -->
172
172
  │
173
173
  ├─ Phase 2: Requirements
174
174
  │ └─ Infer 2-5 research types from question
@@ -2,7 +2,7 @@
2
2
  description: Process review issues - validate with Triage agent, fix with Code agent, verify with Validate agent
3
3
  output-dir: dist/commands
4
4
  ---
5
- @import { knowledge_load, knowledge_writeback } from "./_partials/_knowledge.mds"
5
+ @import { knowledge_load, knowledge_writeback_after_load } from "./_partials/_knowledge.mds"
6
6
  @import { decisions_load } from "./_partials/_decisions.mds"
7
7
  @import { evidence_policy } from "./_partials/_evidence_policy.mds"
8
8
  @import { publication_gate } from "./_partials/_publication.mds"
@@ -79,7 +79,7 @@ For each worktree:
79
79
  2. **If `--review {timestamp}` provided:** use that specific directory (not supported in multi-worktree mode)
80
80
  3. **Otherwise:** sort directories by name descending (timestamps are naturally sortable), scan the 10 most recent directories only. Select the first that contains `review-summary.md` (complete review)
81
81
  4. **If latest directory already has `resolution-summary.md`:** the review is resolved — check bug-analysis fallback (step 5b).
82
- 5. **Legacy fallback:** if no timestamped subdirectories exist but flat `*.md` files do in `{worktree}/.devflow/docs/reviews/{branch-slug}/`, read them directly (backwards compatible).
82
+ 5. **Legacy fallback:** if no timestamped subdirectories exist but flat `*.md` files do in `{worktree}/.devflow/docs/reviews/{branch-slug}/`, read them directly.
83
83
 
84
84
  **5b. Bug analysis fallback** — if no qualifying review directory found (no reviews exist, or all resolved):
85
85
  - List directories in `{worktree}/.devflow/docs/bug-analysis/{branch-slug}/`
@@ -91,25 +91,25 @@ For each worktree:
91
91
 
92
92
  Set `TARGET_DIR` to the selected review or bug-analysis directory path, and `TARGET_DIR_REL` to the same directory relative to the worktree root (`.devflow/docs/reviews/…` or `.devflow/docs/bug-analysis/…`) — the only form of it that may reach a PR comment.
93
93
 
94
- <!-- learning:on -->
94
+ <!-- curation:on -->
95
95
  #### Step 0d: Load Project Decisions
96
- <!-- learning:off -->
96
+ <!-- curation:off -->
97
97
  #### Step 0d: Load Project Context
98
- <!-- learning:end -->
98
+ <!-- curation:end -->
99
99
 
100
- <!-- learning:on -->
101
- **Produces:** DECISIONS_CONTEXT, FEATURE_KNOWLEDGE, FEATURE_KNOWLEDGE_RULES, EVIDENCE_POLICY, ISSUE_REQUIRED, APPLY_CONVENTIONS, REQUIRE_NON_AUTHOR_APPROVAL, REVIEW_PUBLICATION, RESOLUTION_TS
102
- <!-- learning:off -->
103
- **Produces:** FEATURE_KNOWLEDGE, FEATURE_KNOWLEDGE_RULES, EVIDENCE_POLICY, ISSUE_REQUIRED, APPLY_CONVENTIONS, REQUIRE_NON_AUTHOR_APPROVAL, REVIEW_PUBLICATION, RESOLUTION_TS
104
- <!-- learning:end -->
100
+ <!-- curation:on -->
101
+ **Produces:** DECISIONS_CONTEXT, FEATURE_KNOWLEDGE, FEATURE_KNOWLEDGE_RULES, EVIDENCE_POLICY, ISSUE_REQUIRED, APPLY_CONVENTIONS, REQUIRE_NON_AUTHOR_APPROVAL, REVIEW_PUBLICATION, RESOLUTION_TS, GATE_LEVEL
102
+ <!-- curation:off -->
103
+ **Produces:** FEATURE_KNOWLEDGE, FEATURE_KNOWLEDGE_RULES, EVIDENCE_POLICY, ISSUE_REQUIRED, APPLY_CONVENTIONS, REQUIRE_NON_AUTHOR_APPROVAL, REVIEW_PUBLICATION, RESOLUTION_TS, GATE_LEVEL
104
+ <!-- curation:end -->
105
105
 
106
106
  {{settings.settings_resolve()}}
107
107
 
108
108
  {{decisions_load()}}
109
- <!-- learning:on -->
109
+ <!-- curation:on -->
110
110
  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.
111
111
 
112
- <!-- learning:end -->
112
+ <!-- curation:end -->
113
113
  {{knowledge_load()}}
114
114
 
115
115
  Pass `FEATURE_KNOWLEDGE` to the Triage agent in Phase 2.
@@ -124,6 +124,12 @@ Resolve this per worktree — unlike the evidence policy above, the settings lin
124
124
 
125
125
  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.
126
126
 
127
+ **Gate level.** Each worktree keeps its own `GATE_LEVEL`. When any is `standard` or `lean`, once per run, run `d="${CLAUDE_CONFIG_DIR:-}"; case "$d" in /*) ;; *) d="$HOME/.claude" ;; esac; printf '%s\n' "$d"` in Bash and Read `<that directory>/skills/devflow:agent-references/references/commands/resolve-levels.md` with the Read tool, and apply each row to the phase it names, as the reference says.
128
+
129
+ - No row or rule overrides the next two lines.
130
+ - If the Read fails, or the file has no `## Phases` heading with the `| Phase | standard | lean |` header, or a row breaks its grammar, apply no row in any worktree, keep every `GATE_LEVEL` and say `level reference unreadable: no level rows applied`.
131
+ - No level changes the Triage security gate or the ESCALATED route. The Verification Gate, the CI gate and the compliance directive run at every level.
132
+
127
133
  **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.
128
134
 
129
135
  ### Phase 1: Parse Issues
@@ -176,11 +182,11 @@ Parse `THREAD_MAP` from Git agent output. If Git agent returns `TRACEABILITY: DE
176
182
  ### Phase 2: Global Triage
177
183
 
178
184
  **Produces:** TRIAGE_RESULTS
179
- <!-- learning:on -->
185
+ <!-- curation:on -->
180
186
  **Requires:** ISSUES, DIFF_FILES, DECISIONS_CONTEXT, FEATURE_KNOWLEDGE, PR_DESCRIPTION
181
- <!-- learning:off -->
187
+ <!-- curation:off -->
182
188
  **Requires:** ISSUES, DIFF_FILES, FEATURE_KNOWLEDGE, PR_DESCRIPTION
183
- <!-- learning:end -->
189
+ <!-- curation:end -->
184
190
 
185
191
  Spawn a single global Triage agent for ALL issues:
186
192
 
@@ -189,31 +195,33 @@ Agent(subagent_type="Triage"):
189
195
  "ISSUES: {all_issues}
190
196
  DIFF_FILES: {diff_files}
191
197
  WORKTREE_PATH: {worktree_path} (omit if cwd)
192
- <!-- learning:on -->
198
+ <!-- curation:on -->
193
199
  DECISIONS_CONTEXT: {decisions_context}
194
- <!-- learning:end -->
200
+ <!-- curation:end -->
195
201
  FEATURE_KNOWLEDGE: {feature_knowledge}
196
202
  PR_DESCRIPTION: <pr-description>{pr_description}</pr-description>
197
203
  Triage every issue: collapse duplicates first, then apply the blast-radius disposition matrix to each group's primary. Assign exactly one verdict per issue.
198
- <!-- learning:on -->
204
+ <!-- curation:on -->
199
205
  Follow devflow:apply-decisions to Read full ADR/PF bodies on demand.
200
- <!-- learning:end -->
206
+ <!-- curation:end -->
201
207
  Follow devflow:apply-feature-knowledge for FEATURE_KNOWLEDGE."
202
208
  ```
203
209
 
204
210
  Wait for Triage agent to complete before proceeding. Parse verdict ledger from Triage agent output:
205
211
  - **ESCALATED**: Security issues requiring human escalation
206
- - **FIX_NOW**: Valid issues assigned to Code agents (with risk tier: Standard | Careful)
212
+ - **FIX_NOW**: Valid issues assigned to Code agents (with risk tier: Standard | Careful | `Standard, prose only: edit text alone; agent instructions count as logic; if this issue needs a logic change, leave it unedited and name it`; any other value counts as Careful). SCOPE gives one `{id}: {tier}` line per issue.
207
213
  - **FALSE_POSITIVE**: Issues the Review agent got wrong (with cited evidence)
208
214
  - **BY_DESIGN**: Intentional code (with a recorded decision, stated in words, or a code doc citation)
209
215
  - **FIX_SEPARATE**: Valid but out of blast-radius scope (must become manage-debt ticket)
210
216
  - **TECH_DEBT**: Architectural overhaul only — LAST RESORT
211
217
  - **DUPLICATE**: Collapsed duplicate issue — carries `duplicate_of: <primary-id>` referencing the non-DUPLICATE primary; inherits the primary's outcome
212
218
 
213
- <!-- learning:on -->
219
+ A ledger `### Summary` line `- Tiers: not applied (…)` is the level note.
220
+
221
+ <!-- curation:on -->
214
222
  Collect every decision and pitfall the Triage agent's Reasoning columns state, in its words — the resolution summary is posted, so it never carries an ADR/PF ID.
215
223
 
216
- <!-- learning:end -->
224
+ <!-- curation:end -->
217
225
  **Triage agent completeness assertion:** Verify the parsed ledger against ISSUES before proceeding:
218
226
  1. Every issue `id` from ISSUES must appear in exactly one verdict bucket — none may vanish, none may appear in multiple buckets. DUPLICATE is a valid bucket; a valid DUPLICATE entry must name its `duplicate_of` primary (the `Duplicate Of` column of the ledger's DUPLICATE table) and that primary must be a non-DUPLICATE issue id. A missing `duplicate_of` or one that chains to another DUPLICATE is a **Triage agent failure** (retry-then-abort as below).
219
227
  2. If the Triage agent output is empty, contains a skill re-entrancy guard string (e.g., contains `already running`), or is missing any issue IDs from ISSUES: treat as a **Triage agent failure**:
@@ -227,21 +235,21 @@ Collect every decision and pitfall the Triage agent's Reasoning columns state, i
227
235
  **Produces:** BATCHES
228
236
  **Requires:** TRIAGE_RESULTS
229
237
 
230
- If FIX_NOW list is empty: skip to Phase 5 — write full summary (Phase 5), run manage-debt (Phase 9) if FIX_SEPARATE/TECH_DEBT exist, run thread resolution + resolution comment (Phase 9b), run merge readiness (Phase 9c), display results (Phase 10).
238
+ If FIX_NOW list is empty: skip to Phase 5, then run Phases 9, 9b, 9c and 10.
231
239
 
232
240
  Otherwise, batch FIX_NOW issues for Code agent execution. **DUPLICATE issues are never dispatched** — they inherit the primary's outcome:
233
- - **Same-file issues** → one batch (one Code agent per file, sequential for same-file pairs)
241
+ - **Same-file issues** → one batch (one Code agent per file)
234
242
  - **Distinct-file issues** → parallel Code agents
235
243
  - **Max 5 issues per batch** — chunk large sets
236
244
 
237
245
  ### Phase 4: Fix (Code agent × N)
238
246
 
239
247
  **Produces:** CODE_AGENT_RESULTS
240
- <!-- learning:on -->
248
+ <!-- curation:on -->
241
249
  **Requires:** BATCHES, DECISIONS_CONTEXT, FEATURE_KNOWLEDGE
242
- <!-- learning:off -->
250
+ <!-- curation:off -->
243
251
  **Requires:** BATCHES, FEATURE_KNOWLEDGE
244
- <!-- learning:end -->
252
+ <!-- curation:end -->
245
253
 
246
254
  For each batch, spawn Code agent with `OPERATION: issue-fix` and `PUSH: false`:
247
255
 
@@ -253,9 +261,9 @@ ISSUES: {fix_now_issues_in_batch}
253
261
  SCOPE: {risk_tier_per_issue}
254
262
  PUSH: false
255
263
  WORKTREE_PATH: {worktree_path} (omit if cwd)
256
- <!-- learning:on -->
264
+ <!-- curation:on -->
257
265
  DECISIONS_CONTEXT: {decisions_context}
258
- <!-- learning:end -->
266
+ <!-- curation:end -->
259
267
  FEATURE_KNOWLEDGE: {feature_knowledge}
260
268
  {COMPLIANCE_DIRECTIVE}
261
269
  Fix only the listed pre-classified FIX_NOW issues. Do not re-litigate dispositions.
@@ -268,24 +276,27 @@ Spawn distinct-file batch Code agents **in a single message** (parallel). Sequen
268
276
  Collect from each Code agent:
269
277
  - `{status, commitShas, unresolved}` per batch
270
278
  - `## Verification` block (commands run + results)
279
+ - An unresolved prose-only issue that Code names as needing a logic change, and whose type is not `security` → FIX_SEPARATE in TRIAGE_RESULTS, Reason `needs a logic change`; every other unresolved issue stays Blocked
271
280
 
272
281
  ### Phase 5: Write resolution-summary.md
273
282
 
274
283
  **Produces:** RESOLUTION_FILE (early write for compaction safety)
275
- **Requires:** TRIAGE_RESULTS, CODE_AGENT_RESULTS, TARGET_DIR, TARGET_DIR_REL, BRANCH_INFO, RESOLUTION_TS
284
+ **Requires:** TRIAGE_RESULTS, CODE_AGENT_RESULTS, TARGET_DIR, TARGET_DIR_REL, BRANCH_INFO, RESOLUTION_TS, GATE_LEVEL
276
285
 
277
- **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.
286
+ **Immediately write `resolution-summary.md`** to `{TARGET_DIR}` using the Write tool.
278
287
 
279
288
  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).
280
289
 
281
290
  DUPLICATE issues are listed **only** in `## Duplicates` — never in `## Fixed Issues`, `## False Positives`, `## By Design`, `## Fix Separately`, `## Deferred to Tech Debt`, `## Escalations`, or `## Blocked`. A duplicate of a FALSE_POSITIVE primary therefore leaves only the primary in the `False Positive` row and the `## False Positives` section; the same holds for every other outcome the duplicate inherits.
282
291
 
283
- Use the template from the Output Artifact section below.
292
+ Open each Issue cell with its severity in brackets when it has one, as `[HIGH]`.
293
+
294
+ Use the template from the Output Artifact section below. Put text not for public posting in a final `## Private notes` section.
284
295
 
285
296
  ### Phase 6: Polish
286
297
 
287
298
  **Produces:** POLISH_RESULT
288
- **Requires:** CODE_AGENT_RESULTS
299
+ **Requires:** CODE_AGENT_RESULTS, GATE_LEVEL
289
300
 
290
301
  If any fixes were made, spawn Polish agent to refine the changed code:
291
302
 
@@ -329,9 +340,9 @@ Run build, typecheck, lint, test. Report pass/fail with failure details."
329
340
  SCOPE: Fix only the listed failures, no other changes
330
341
  PUSH: false
331
342
  WORKTREE_PATH: {worktree_path} (omit if cwd)
332
- <!-- learning:on -->
343
+ <!-- curation:on -->
333
344
  DECISIONS_CONTEXT: {decisions_context}
334
- <!-- learning:end -->
345
+ <!-- curation:end -->
335
346
  {COMPLIANCE_DIRECTIVE}"
336
347
  ```
337
348
  - Loop back to re-validate
@@ -349,7 +360,7 @@ git -C {worktree} push
349
360
 
350
361
  **If `fork_no_push` is set:** do not push. Record `Push: skipped — cannot push to fork` under `## Verification`, and skip Phase 8 — no pushed commit exists for CI to check.
351
362
 
352
- **Route after push:** VERIFICATION_STATUS = PASS → continue to Phase 8 (CI gate). VERIFICATION_STATUS = FAILED → skip Phase 8; proceed directly to Phase 9 (manage-debt), then Phase 9b (thread resolution + resolution comment), then Phase 9c (merge readiness), then Phase 10 (report). VERIFICATION_STATUS = SKIPPED → skip Phase 8 (no fixes applied); proceed to Phase 9 (manage-debt), then Phase 9b (thread resolution + resolution comment), then Phase 9c (merge readiness, when non-author approval is required), then Phase 10 (report).
363
+ **Route after push:** VERIFICATION_STATUS = PASS → continue to Phase 8 (CI gate). FAILED or SKIPPED → skip Phase 8 and continue with Phase 9 and the later phases in order.
353
364
 
354
365
  ### Phase 8: CI Status Gate (Conditional)
355
366
 
@@ -380,11 +391,11 @@ Phase 7 has pushed already, so this is a no-op unless the head moved since. `exi
380
391
  3. **If NO_PR or NO_CI** → skip: "No PR/CI configured, skipping CI validation." Proceed to next phase.
381
392
  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.
382
393
  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.
383
- <!-- learning:on -->
394
+ <!-- curation:on -->
384
395
  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.
385
- <!-- learning:off -->
396
+ <!-- curation:off -->
386
397
  6. **If FAILING** and fewer than 2 fixes have run → report the failing checks from the line. Spawn `Agent(subagent_type="Fix")` whose prompt opens with `OPERATION: ci-fix`, with `COMPLIANCE_DIRECTIVE` (when it is not empty), `CI_FAILURES` and `PUSH: false`; `CI_FAILURES` holds the failing-check names from the line and nothing else, because the Fix agent fetches the full names and reads the logs itself and this command reads none. After a fix, push with the command above and, if a wait remains, wait again (step 1); a failed push records `TRACEABILITY: DEGRADED (ci push failed)`, reports "CI status unknown — verify manually before merging" and stops waiting. After the second fix still FAILING → report the failing checks and proceed.
387
- <!-- learning:end -->
398
+ <!-- curation:end -->
388
399
  7. **Budget**: at most 3 waits and 2 fixes in all, per worktree. When one is spent, report the current status and proceed.
389
400
  <!-- /PATTERN: ci-status-gate -->
390
401
 
@@ -523,7 +534,7 @@ If the script prints a `TRACEABILITY: DEGRADED` line: warn, proceed to Phase 10.
523
534
 
524
535
  ### Phase 10: Report
525
536
 
526
- **Requires:** BRANCH_INFO, TARGET_DIR, PR_COMMENT, THREAD_RESOLUTION_RESULT
537
+ **Requires:** BRANCH_INFO, TARGET_DIR, PR_COMMENT, THREAD_RESOLUTION_RESULT, GATE_LEVEL
527
538
 
528
539
  The resolution summary was already written to `{TARGET_DIR}/resolution-summary.md` in Phase 5 (updated by Phase 7, Phase 9 and Phase 9b-1). Display results to the user:
529
540
 
@@ -533,6 +544,7 @@ The resolution summary was already written to `{TARGET_DIR}/resolution-summary.m
533
544
  **Branch**: {branch}
534
545
  **Reviews Processed**: {n} reports from {TARGET_DIR}
535
546
  **Total Issues**: {n}
547
+ **Gate level**: {GATE_LEVEL, with any level note}
536
548
 
537
549
  ### Results
538
550
  | Outcome | Count |
@@ -576,7 +588,7 @@ Final gate: {PASS | FAILED after N attempts}
576
588
 
577
589
  In multi-worktree mode, report results per worktree with aggregate summary.
578
590
 
579
- {{knowledge_writeback()}}
591
+ {{knowledge_writeback_after_load()}}
580
592
 
581
593
  ## Architecture
582
594
 
@@ -584,21 +596,18 @@ In multi-worktree mode, report results per worktree with aggregate summary.
584
596
  /resolve (orchestrator - spawns agents only)
585
597
  │
586
598
  ├─ Phase 0: Worktree Discovery & Pre-flight
587
- ├─ Phase 1: Parse issues from TARGET_DIR + extract confidence %
599
+ ├─ Phase 1: Parse issues from TARGET_DIR
588
600
  ├─ Phase 1b: Fetch external threads (evidence policy required)
589
601
  ├─ Phase 2: Global Triage [Triage agent, opus, single agent]
590
- ├─ Phase 3: Batch FIX_NOW issues (skip if empty; DUPLICATE issues never dispatched)
591
- ├─ Phase 4: Fix [Code agent × N, OPERATION: issue-fix, PUSH: false]
602
+ ├─ Phase 3: Batch FIX_NOW issues
603
+ ├─ Phase 4: Fix [Code agent × N]
592
604
  ├─ Phase 5: Write resolution-summary.md (compaction safety; Tracked = "(pending)" or "(pending — TRACEABILITY: DEGRADED)" if manage-debt degrades)
593
- ├─ Phase 6: Polish [Polish agent]
605
+ ├─ Phase 6: Polish
594
606
  ├─ Phase 7: Verification Gate [Validate agent, haiku] + push + Fix agent validation-fix loop ≤2
595
- ├─ Phase 8: CI Status Gate (conditional — skipped if no fixes or verification FAILED)
607
+ ├─ Phase 8: CI Status Gate (conditional)
596
608
  ├─ Phase 9: Git agent (manage-debt) — FIX_SEPARATE + TECH_DEBT → backfill Tracked={ISSUE_REF} (or TRACEABILITY: DEGRADED on failure)
597
609
  │
598
- ├─ Phase 9b: Thread resolution + resolution comment
599
- │ ├─ Step 9b-0: verify-evidence.cjs --stale-out → ≤1 Test agent on the stale TPs (wrapped) — only after this run's push
600
- │ ├─ Step 9b-1: Git agent (resolve-review-threads) — evidence policy required
601
- │ ├─ Step 9b-2: Git agent (post-resolution-summary, REVIEW_PUBLICATION) — always-on
610
+ ├─ Phase 9b: 9b-0 Test agent (stale TPs), 9b-1/9b-2 Git agent (threads, resolution comment)
602
611
  │ └─ Step 9b-3: verify-evidence.cjs publish (inline, no Git spawn) — only when the head moved
603
612
  │
604
613
  ├─ Phase 9c: verify-evidence.cjs readiness (inline, no Git spawn) — non-author approval required, report-only
@@ -611,27 +620,23 @@ In multi-worktree mode, report results per worktree with aggregate summary.
611
620
  | Case | Handling |
612
621
  |------|----------|
613
622
  | No reviews exist | Check bug-analysis fallback (Step 0c-5b); if also absent, error and suggest `/code-review` or `/bug-analysis` |
614
- | All false positives | Normal completion, report shows 0 fixes |
615
623
  | Fix attempt fails | Revert changes, mark BLOCKED, continue others |
616
624
  | Issue dependencies | Sequential chain, skip dependents if predecessor blocked |
617
- | No actionable issues | Report "No issues to resolve" |
618
- | Latest review already resolved | Check bug-analysis fallback (Step 0c-5b); if also absent, skip worktree and suggest `/code-review` or `/bug-analysis` |
625
+ | No issues parsed | Report "No issues to resolve" |
619
626
  | `--review {timestamp}` in multi-worktree mode | Not supported — use `--path` + `--review` to target specific worktree + review |
620
627
  | gh/GitHub absent | manage-debt degrades (`TRACEABILITY: DEGRADED ({reason})`); Tracked stays `(pending — TRACEABILITY: DEGRADED ({reason}))` — recorded, not dropped |
621
628
  | `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 |
622
629
  | `REQUIRE_NON_AUTHOR_APPROVAL` is `false` | Phase 9c is skipped and reported as SKIPPED |
623
- | Public repo (`auto` mode) | Git agent probes visibility, posts counts-only STUB comment; full resolution report stays local |
624
630
  | `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 |
625
- | 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 |
631
+ | Fork PR this run cannot push to | `TRACEABILITY: DEGRADED (cannot push to fork)` → `fork_no_push`: no push in Phase 7, Phase 8 skipped, 9b-1 records FIXED threads as DEGRADED, 9b-2 still posts; the head did not move, so 9b-0 and 9b-3 are skipped |
626
632
  | The PR has no trusted evidence record | 9b-0 finds no vouched-for stale line, so no Test agent runs; 9b-3 still refreshes the block and comment, every TP without a claim reading `UNVERIFIED` |
627
633
  | A CI run behind a claim has expired (~90 days) | The TP reads `INDETERMINATE` — never verified, never failed — until a claim at a newer SHA settles it |
628
634
 
629
635
  ## Principles
630
636
 
631
637
  1. **Orchestration only** - Command spawns agents, doesn't do git/resolve work itself
632
- 2. **No agent grades its own homework** - Triage agent validates, Code agents fix, Validate agent verifies
633
- 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)
634
- 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)
638
+ 2. **Git agent for git work** - All git operations go through Git agent; inline scripts are plumbing
639
+ 3. **Traceability-aware** - Policy-gated ops 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)
635
640
 
636
641
  ## Output Artifact
637
642
 
@@ -644,15 +649,16 @@ Written in Phase 5 (Collect Results) to `{TARGET_DIR}/resolution-summary.md`:
644
649
  **Date**: {RESOLUTION_TS}
645
650
  **Review**: {TARGET_DIR_REL}
646
651
  **Command**: /resolve
652
+ **Gate level**: {GATE_LEVEL, with any level note}
647
653
 
648
- <!-- learning:on -->
654
+ <!-- curation:on -->
649
655
  ## Decisions Citations
650
656
 
651
657
  - {decision applied or pitfall avoided, stated in words — never its ID} — {batch-id}, {issue-id}
652
658
 
653
659
  (Omit section if no citations were made)
654
660
 
655
- <!-- learning:end -->
661
+ <!-- curation:end -->
656
662
  ## Statistics
657
663
  | Metric | Value |
658
664
  |--------|-------|
@@ -2,7 +2,7 @@
2
2
  description: Self-review workflow - Polish agent (code clarity) then Harden agent (9-pillar quality gate)
3
3
  output-dir: dist/commands
4
4
  ---
5
- @import { knowledge_load, knowledge_writeback } from "./_partials/_knowledge.mds"
5
+ @import { knowledge_load, knowledge_writeback_after_load } from "./_partials/_knowledge.mds"
6
6
  @import { decisions_load } from "./_partials/_decisions.mds"
7
7
  @import "./_partials/_settings.mds" as settings
8
8
  # Self-Review Command
@@ -18,11 +18,11 @@ Run Polish agent and Harden agent sequentially on changed files for post-impleme
18
18
 
19
19
  ### Phase 0: Context Gathering
20
20
 
21
- <!-- learning:on -->
21
+ <!-- curation:on -->
22
22
  **Produces:** FILES_CHANGED, TASK_DESCRIPTION, DECISIONS_CONTEXT, FEATURE_KNOWLEDGE, FEATURE_KNOWLEDGE_RULES, HEAD_BEFORE
23
- <!-- learning:off -->
23
+ <!-- curation:off -->
24
24
  **Produces:** FILES_CHANGED, TASK_DESCRIPTION, FEATURE_KNOWLEDGE, FEATURE_KNOWLEDGE_RULES, HEAD_BEFORE
25
- <!-- learning:end -->
25
+ <!-- curation:end -->
26
26
 
27
27
  Detect changed files and build context:
28
28
 
@@ -35,19 +35,19 @@ Detect changed files and build context:
35
35
  {{settings.settings_resolve()}}
36
36
 
37
37
  {{decisions_load()}}
38
- <!-- learning:on -->
38
+ <!-- curation:on -->
39
39
  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.)
40
40
 
41
- <!-- learning:end -->
41
+ <!-- curation:end -->
42
42
  {{knowledge_load()}}
43
43
 
44
44
  Pass `FEATURE_KNOWLEDGE_RULES` to Harden agent.
45
45
 
46
- <!-- learning:on -->
46
+ <!-- curation:on -->
47
47
  **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)
48
- <!-- learning:off -->
48
+ <!-- curation:off -->
49
49
  **Extract:** FILES_CHANGED (list), TASK_DESCRIPTION (string), FEATURE_KNOWLEDGE (string, optional), FEATURE_KNOWLEDGE_RULES (string, optional), HEAD_BEFORE (40-hex SHA)
50
- <!-- learning:end -->
50
+ <!-- curation:end -->
51
51
 
52
52
  ### Phase 1: Polish agent (Code Refinement)
53
53
 
@@ -67,25 +67,25 @@ Commit any improvements with a conventional-commit message."
67
67
  ### Phase 2: Harden agent (9-Pillar Quality Gate)
68
68
 
69
69
  **Produces:** HARDEN_STATUS
70
- <!-- learning:on -->
70
+ <!-- curation:on -->
71
71
  **Requires:** FILES_CHANGED, TASK_DESCRIPTION, DECISIONS_CONTEXT
72
- <!-- learning:off -->
72
+ <!-- curation:off -->
73
73
  **Requires:** FILES_CHANGED, TASK_DESCRIPTION
74
- <!-- learning:end -->
74
+ <!-- curation:end -->
75
75
 
76
76
  Spawn Harden agent for quality evaluation and fixing:
77
77
 
78
78
  Agent(subagent_type="Harden", run_in_background=false):
79
79
  "TASK_DESCRIPTION: {task_description}
80
80
  FILES_CHANGED: {files_changed}
81
- <!-- learning:on -->
81
+ <!-- curation:on -->
82
82
  DECISIONS_CONTEXT: {decisions_context}
83
- <!-- learning:end -->
83
+ <!-- curation:end -->
84
84
  FEATURE_KNOWLEDGE: {feature_knowledge_rules}
85
85
  Evaluate against 9-pillar framework. Fix P0/P1 issues. Return structured report.
86
- <!-- learning:on -->
86
+ <!-- curation:on -->
87
87
  Follow devflow:apply-decisions to scan DECISIONS_CONTEXT and Read full ADR/PF bodies on demand. Skip if (none).
88
- <!-- learning:end -->
88
+ <!-- curation:end -->
89
89
  Follow devflow:apply-feature-knowledge for FEATURE_KNOWLEDGE. Skip if (none)."
90
90
 
91
91
  **Wait for completion.** Extract: STATUS (PASS|FIXED|BLOCKED) from the `### Status` line
@@ -139,7 +139,7 @@ Display summary:
139
139
 
140
140
  {If BLOCKED: ### Blocking Issue\n{description}}
141
141
 
142
- {{knowledge_writeback()}}
142
+ {{knowledge_writeback_after_load()}}
143
143
 
144
144
  ## Architecture
145
145
 
@@ -147,12 +147,12 @@ Display summary:
147
147
  │
148
148
  ├─ Phase 0: Context gathering
149
149
  │ ├─ Git diff for changed files
150
- <!-- learning:on -->
150
+ <!-- curation:on -->
151
151
  │ ├─ Record HEAD_BEFORE
152
152
  │ └─ Read index.md → DECISIONS_CONTEXT
153
- <!-- learning:off -->
153
+ <!-- curation:off -->
154
154
  │ └─ Record HEAD_BEFORE
155
- <!-- learning:end -->
155
+ <!-- curation:end -->
156
156
  │
157
157
  ├─ Phase 1: Polish agent
158
158
  │ └─ Code refinement (commits directly)
@@ -48,7 +48,7 @@ These defines call nothing, so they capture nothing.
48
48
  @define ensure_pr_ready_contract():
49
49
  Pre-flight: make the branch ready for review and open its PR.
50
50
 
51
- **Input:** `WORKTREE_PATH` (optional), `BASE_BRANCH` (optional), `TASK_ID` (optional), `ISSUE_NUMBER` (optional), `ISSUE_PR_LINK` (optional), `PR_EXCEPTIONS` (optional), `COMMIT_UNCOMMITTED` (optional), `PR_DESCRIPTION_GUIDANCE` (optional), `PR_TEST_PLAN_BLOCK` (optional), `PR_WAVE_BLOCK` (optional), `APPLY_CONVENTIONS`
51
+ **Input:** `WORKTREE_PATH` (optional), `BASE_BRANCH` (optional), `BASE_REF` (optional), `TASK_ID` (optional), `ISSUE_NUMBER` (optional), `ISSUE_PR_LINK` (optional), `PR_EXCEPTIONS` (optional), `COMMIT_UNCOMMITTED` (optional), `PR_DESCRIPTION_GUIDANCE` (optional), `PR_TEST_PLAN_BLOCK` (optional), `PR_WAVE_BLOCK` (optional), `APPLY_CONVENTIONS`
52
52
 
53
53
  **Output:**
54
54
  ```markdown
@@ -57,6 +57,7 @@ Pre-flight: make the branch ready for review and open its PR.
57
57
  ### Branch
58
58
  - **Current**: {branch}
59
59
  - **Base**: {base_branch}
60
+ - **Base ref**: {base_ref}
60
61
  - **Branch Slug**: {branch-slug}
61
62
  - **PR**: #{number}
62
63
 
@@ -71,6 +72,7 @@ Pre-flight: make the branch ready for review and open its PR.
71
72
  ### Status: READY | BLOCKED
72
73
  {BLOCKED reason if applicable}
73
74
  {Any `TRACEABILITY: DEGRADED ({reason})` lines from steps 4b/4c — these never change the READY/BLOCKED verdict}
75
+ {`TRACEABILITY: DEGRADED (base {REASON}; fix: {fix})` or `(base name unreadable; fix: re-run)` from step 5; only an invalid base name, or a step-4a base that cannot be written, makes the Status BLOCKED}
74
76
 
75
77
  ### Uncommitted files
76
78
  {only when `COMMIT_UNCOMMITTED` is `false`: one `- {path}` line each, or `none`}
@@ -202,7 +204,12 @@ Each issue in the batch is wrapped individually in its own `<untrusted-issue-bod
202
204
  @end
203
205
 
204
206
  @define manage_debt_contract():
205
- Update tech debt backlog with deferred issues from resolution and pre-existing issues from code review.
207
+ Update tech debt backlog from `{REVIEW_DIR}/resolution-summary.md`:
208
+ - Add only entries of `## Fix Separately` (FIX_SEPARATE) and `## Deferred to Tech Debt` (TECH_DEBT). A section ends at the next heading.
209
+ - An empty section adds none.
210
+ - If `resolution-summary.md` is missing, return `TRACEABILITY: DEGRADED (resolution summary missing)` and do not update the backlog.
211
+ - Never add an item that also has an entry in `## Escalations`, `## Blocked` or `## Fixed Issues`.
212
+ - Read no review report: in `{REVIEW_DIR}`, read only `resolution-summary.md`.
206
213
 
207
214
  **Input:** `REVIEW_DIR`, `TIMESTAMP`, `WORKTREE_PATH` (optional)
208
215