devflow-kit 3.2.0 → 3.4.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 (188) hide show
  1. package/CHANGELOG.md +34 -0
  2. package/README.md +1 -1
  3. package/dist/agents/code.md +330 -0
  4. package/{src/assets → dist}/agents/design.md +11 -1
  5. package/{src/assets → dist}/agents/diagnose.md +17 -13
  6. package/dist/agents/git.md +29 -56
  7. package/{src/assets → dist}/agents/knowledge.md +8 -5
  8. package/{src/assets → dist}/agents/research.md +21 -2
  9. package/{src/assets → dist}/agents/review.md +18 -7
  10. package/{src/assets → dist}/agents/scrutinize.md +35 -11
  11. package/dist/agents/skim.md +148 -0
  12. package/{src/assets → dist}/agents/triage.md +8 -2
  13. package/dist/cli/commands/init.js +62 -0
  14. package/dist/cli/commands/learning.js +63 -8
  15. package/dist/cli/commands/uninstall.js +42 -1
  16. package/dist/commands/bug-analysis.md +30 -8
  17. package/dist/commands/code-review.md +142 -61
  18. package/dist/commands/debug.md +15 -13
  19. package/dist/commands/dynamic-build.md +176 -130
  20. package/dist/commands/dynamic-plan.md +31 -19
  21. package/dist/commands/dynamic-profile.md +27 -13
  22. package/dist/commands/dynamic-tickets.md +28 -14
  23. package/dist/commands/explore.md +16 -14
  24. package/dist/commands/implement.md +163 -158
  25. package/dist/commands/plan.md +37 -24
  26. package/dist/commands/release.md +69 -4
  27. package/dist/commands/research.md +33 -11
  28. package/dist/commands/resolve.md +61 -47
  29. package/dist/commands/self-review.md +50 -32
  30. package/dist/core/agent-models.js +53 -7
  31. package/dist/core/assets.js +55 -10
  32. package/dist/core/claude-md-audit.js +190 -0
  33. package/dist/core/feature-switch.js +20 -1
  34. package/dist/core/flags.js +28 -0
  35. package/dist/core/fs-atomic.js +8 -3
  36. package/dist/core/learning-tuning-config.js +8 -0
  37. package/dist/core/learning-variants.js +213 -0
  38. package/dist/core/manifest.js +62 -0
  39. package/dist/core/mds-variants.js +38 -1
  40. package/dist/core/plugins.js +78 -11
  41. package/{src/assets → dist/learning-off}/agents/code.md +77 -28
  42. package/dist/learning-off/agents/design.md +119 -0
  43. package/dist/learning-off/agents/diagnose.md +210 -0
  44. package/dist/learning-off/agents/knowledge.md +90 -0
  45. package/dist/learning-off/agents/research.md +149 -0
  46. package/dist/learning-off/agents/review.md +228 -0
  47. package/dist/learning-off/agents/scrutinize.md +117 -0
  48. package/{src/assets → dist/learning-off}/agents/skim.md +5 -10
  49. package/dist/learning-off/agents/triage.md +163 -0
  50. package/dist/learning-off/commands/bug-analysis.md +420 -0
  51. package/dist/learning-off/commands/code-review.md +525 -0
  52. package/dist/learning-off/commands/debug.md +294 -0
  53. package/dist/learning-off/commands/dynamic-build.md +1255 -0
  54. package/dist/learning-off/commands/dynamic-plan.md +424 -0
  55. package/dist/learning-off/commands/dynamic-profile.md +214 -0
  56. package/dist/learning-off/commands/dynamic-tickets.md +632 -0
  57. package/dist/learning-off/commands/explore.md +210 -0
  58. package/dist/learning-off/commands/implement.md +808 -0
  59. package/dist/learning-off/commands/plan.md +664 -0
  60. package/dist/learning-off/commands/release.md +310 -0
  61. package/dist/learning-off/commands/research.md +222 -0
  62. package/dist/learning-off/commands/resolve.md +837 -0
  63. package/dist/learning-off/commands/self-review.md +266 -0
  64. package/dist/skills/git/references/tracker/_contract.md +33 -0
  65. package/dist/skills/git/references/tracker/github/fetch-issue.md +2 -0
  66. package/dist/skills/git/references/tracker/github/fetch-issues-batch.md +2 -0
  67. package/dist/skills/git/references/tracker/github/gather-release-evidence.md +5 -1
  68. package/dist/skills/git/references/tracker/github/post-wave-report.md +2 -0
  69. package/dist/skills/git/references/tracker/github/setup-task.md +12 -0
  70. package/dist/skills/git/references/tracker/jira/associate-release.md +1 -1
  71. package/dist/skills/git/references/tracker/jira/fetch-issue.md +2 -0
  72. package/dist/skills/git/references/tracker/jira/fetch-issues-batch.md +2 -0
  73. package/dist/skills/git/references/tracker/jira/gather-release-evidence.md +5 -1
  74. package/dist/skills/git/references/tracker/jira/post-wave-report.md +2 -0
  75. package/dist/skills/git/references/tracker/jira/setup-task.md +14 -2
  76. package/dist/skills/git/references/tracker/linear/associate-release.md +1 -1
  77. package/dist/skills/git/references/tracker/linear/fetch-issue.md +2 -0
  78. package/dist/skills/git/references/tracker/linear/fetch-issues-batch.md +2 -0
  79. package/dist/skills/git/references/tracker/linear/gather-release-evidence.md +5 -1
  80. package/dist/skills/git/references/tracker/linear/post-wave-report.md +2 -0
  81. package/dist/skills/git/references/tracker/linear/setup-task.md +14 -2
  82. package/dist/targets/claude-code/installer.js +72 -36
  83. package/dist/targets/claude-code/language-stamp.js +185 -0
  84. package/dist/targets/claude-code/learning-install.js +489 -0
  85. package/package.json +1 -1
  86. package/src/assets/agents/code.mds +339 -0
  87. package/src/assets/agents/design.mds +149 -0
  88. package/src/assets/agents/diagnose.mds +225 -0
  89. package/src/assets/agents/evaluate.md +12 -25
  90. package/src/assets/agents/git.mds +29 -56
  91. package/src/assets/agents/knowledge.mds +125 -0
  92. package/src/assets/agents/learning.md +4 -6
  93. package/src/assets/agents/research.mds +176 -0
  94. package/src/assets/agents/review.mds +286 -0
  95. package/src/assets/agents/scrutinize.mds +132 -0
  96. package/src/assets/agents/simplify.md +20 -0
  97. package/src/assets/agents/skim.mds +161 -0
  98. package/src/assets/agents/synthesize.md +12 -0
  99. package/src/assets/agents/test.md +2 -2
  100. package/src/assets/agents/triage.mds +194 -0
  101. package/src/assets/agents/validate.md +15 -8
  102. package/src/assets/commands/_partials/_compliance.mds +5 -4
  103. package/src/assets/commands/_partials/_decisions.mds +31 -0
  104. package/src/assets/commands/_partials/_engine.mds +29 -24
  105. package/src/assets/commands/_partials/_knowledge.mds +26 -13
  106. package/src/assets/commands/_partials/_plan_contract.mds +1 -1
  107. package/src/assets/commands/_partials/_preamble.mds +33 -9
  108. package/src/assets/commands/_partials/_publication.mds +5 -4
  109. package/src/assets/commands/_partials/_settings.mds +13 -5
  110. package/src/assets/commands/_partials/_wave.mds +16 -6
  111. package/src/assets/commands/bug-analysis.mds +24 -2
  112. package/src/assets/commands/code-review.mds +148 -45
  113. package/src/assets/commands/debug.mds +17 -1
  114. package/src/assets/commands/dynamic-build.mds +144 -65
  115. package/src/assets/commands/dynamic-plan.mds +36 -6
  116. package/src/assets/commands/dynamic-profile.mds +9 -1
  117. package/src/assets/commands/dynamic-tickets.mds +16 -2
  118. package/src/assets/commands/explore.mds +27 -1
  119. package/src/assets/commands/implement.mds +171 -138
  120. package/src/assets/commands/plan.mds +47 -8
  121. package/src/assets/commands/{release.md → release.mds} +27 -24
  122. package/src/assets/commands/research.mds +28 -4
  123. package/src/assets/commands/resolve.mds +69 -17
  124. package/src/assets/commands/self-review.mds +43 -13
  125. package/src/assets/mds/tracker/_common.mds +1 -1
  126. package/src/assets/mds/tracker/_contract.mds +72 -0
  127. package/src/assets/mds/tracker/_github.mds +13 -2
  128. package/src/assets/mds/tracker/_jira.mds +17 -5
  129. package/src/assets/mds/tracker/_linear.mds +17 -5
  130. package/src/assets/mds/tracker/_mcp.mds +2 -2
  131. package/src/assets/mds/tracker/_steps.mds +97 -0
  132. package/src/assets/rules/context-economy.md +10 -0
  133. package/src/assets/rules/go.md +1 -0
  134. package/src/assets/rules/java.md +1 -0
  135. package/src/assets/rules/python.md +1 -0
  136. package/src/assets/rules/rust.md +1 -0
  137. package/src/assets/rules/typescript.md +1 -0
  138. package/src/assets/scripts/ci-wait.cjs +636 -0
  139. package/src/assets/scripts/claude-md-audit.cjs +611 -0
  140. package/src/assets/scripts/hooks/assets/orchestrator-charter.md +2 -3
  141. package/src/assets/scripts/hooks/background-memory-update +290 -9
  142. package/src/assets/scripts/hooks/json-helper.cjs +13 -5
  143. package/src/assets/scripts/hooks/json-parse +34 -10
  144. package/src/assets/scripts/hooks/session-start-context +315 -7
  145. package/src/assets/scripts/release-trace.cjs +27 -10
  146. package/src/assets/skills/accessibility/SKILL.md +1 -1
  147. package/src/assets/skills/apply-decisions/SKILL.md +12 -82
  148. package/src/assets/skills/apply-feature-knowledge/SKILL.md +9 -43
  149. package/src/assets/skills/architecture/SKILL.md +1 -1
  150. package/src/assets/skills/boundary-validation/SKILL.md +1 -1
  151. package/src/assets/skills/complexity/SKILL.md +1 -1
  152. package/src/assets/skills/compliance/SKILL.md +1 -1
  153. package/src/assets/skills/consistency/SKILL.md +1 -1
  154. package/src/assets/skills/database/SKILL.md +1 -1
  155. package/src/assets/skills/dependencies/SKILL.md +1 -1
  156. package/src/assets/skills/dependency-research/SKILL.md +3 -6
  157. package/src/assets/skills/design-review/SKILL.md +1 -1
  158. package/src/assets/skills/docs-framework/SKILL.md +1 -1
  159. package/src/assets/skills/documentation/SKILL.md +1 -1
  160. package/src/assets/skills/feature-knowledge/SKILL.md +43 -12
  161. package/src/assets/skills/gap-analysis/SKILL.md +1 -1
  162. package/src/assets/skills/git/SKILL.md +1 -1
  163. package/src/assets/skills/go/SKILL.md +1 -1
  164. package/src/assets/skills/java/SKILL.md +1 -1
  165. package/src/assets/skills/patterns/SKILL.md +1 -1
  166. package/src/assets/skills/performance/SKILL.md +1 -1
  167. package/src/assets/skills/python/SKILL.md +1 -1
  168. package/src/assets/skills/qa/SKILL.md +1 -3
  169. package/src/assets/skills/quality-gates/SKILL.md +10 -13
  170. package/src/assets/skills/quality-gates/references/report-template.md +20 -20
  171. package/src/assets/skills/react/SKILL.md +1 -1
  172. package/src/assets/skills/regression/SKILL.md +1 -1
  173. package/src/assets/skills/reliability/SKILL.md +1 -1
  174. package/src/assets/skills/research-codebase/SKILL.md +1 -1
  175. package/src/assets/skills/research-competitor/SKILL.md +1 -1
  176. package/src/assets/skills/research-external/SKILL.md +1 -1
  177. package/src/assets/skills/research-technology/SKILL.md +1 -1
  178. package/src/assets/skills/review-methodology/SKILL.md +1 -1
  179. package/src/assets/skills/rust/SKILL.md +1 -1
  180. package/src/assets/skills/security/SKILL.md +1 -1
  181. package/src/assets/skills/software-design/SKILL.md +1 -1
  182. package/src/assets/skills/test-driven-development/SKILL.md +9 -29
  183. package/src/assets/skills/testing/SKILL.md +1 -1
  184. package/src/assets/skills/typescript/SKILL.md +1 -1
  185. package/src/assets/skills/ui-design/SKILL.md +1 -1
  186. package/src/assets/skills/worktree-support/SKILL.md +3 -55
  187. package/src/assets/skills/worktree-support/references/discovery.md +48 -0
  188. package/src/assets/skills/worktree-support/references/roots.md +2 -2
@@ -1,4 +1,7 @@
1
- @import "./_settings.mds" as settings
1
+ A partial: the feature-knowledge load and write-back steps. D-SETTINGS-LINE: it
2
+ imports nothing from `_settings.mds`. Write-back Step 1 takes `KNOWLEDGE` from the
3
+ settings line the host's settings block resolved above, and keeps the
4
+ `KNOWLEDGE=off` skip inside its own step.
2
5
 
3
6
  @define knowledge_load():
4
7
  ### Load Feature Knowledge
@@ -29,22 +32,32 @@ Glob `{worktree}/.devflow/features/*/KNOWLEDGE.md`. For each file found, read on
29
32
 
30
33
  Match the current task area and description against each index line (or frontmatter `description` + `directories` on fallback). Select entries whose documented area overlaps the current task. This is a relevance judgment — prefer specificity over breadth.
31
34
 
32
- **Step 4 — Read selected KBs:**
35
+ **Step 4 — Read each selected KB's Rules:**
33
36
 
34
- For each selected entry, read `{worktree}/.devflow/features/{slug}/KNOWLEDGE.md` in full. When the KB content contradicts the current code you observe, **trust the code** — the code is the freshness mechanism; the KB may lag behind.
37
+ For each selected entry, `{kb}` is `{worktree}/.devflow/features/{slug}/KNOWLEDGE.md`:
35
38
 
36
- **Step 5 — Set FEATURE_KNOWLEDGE:**
39
+ 1. List its `##` headings with line numbers through Bash: `command grep -n '^## ' "{kb}"`. This only locates sections; the text of a KB comes from the Read view alone.
40
+ 2. Read the `## Rules` range (its line to the next heading) with the Read tool, using `offset` and `limit`, and choose the one to three bullets most relevant to the current task. The choice is yours, made per KB.
41
+ 3. If the KB has no `## Rules` section, choose one to three entries from its `## Anti-Patterns` or `## Gotchas` range the same way, and label them by that section's name instead of an ID.
37
42
 
38
- Concatenate the selected KNOWLEDGE.md files under slug headers:
43
+ When a KB contradicts the code you observe, **trust the code** — the code is the freshness mechanism; the KB may lag behind. A missing Rules section, a missing heading list and `(none)` are legitimate states, not errors.
44
+
45
+ **Step 5 — Set FEATURE_KNOWLEDGE and FEATURE_KNOWLEDGE_RULES:**
46
+
47
+ Write one block per selected KB. Paste each bullet verbatim from the Read view, never from a shell view. The path is relative to the checkout root; an agent resolves it under `WORKTREE_PATH` when one is provided.
39
48
 
40
49
  ```
41
50
  --- Feature knowledge: {slug} ---
42
- {full KNOWLEDGE.md content}
51
+ KB: .devflow/features/{slug}/KNOWLEDGE.md
52
+ Rules:
53
+ - **KB-AP-2** {bullet text, verbatim}
54
+ - **KB-INV-1** {bullet text, verbatim}
55
+ Headings: L5 Rules · L40 Overview · L62 Anti-Patterns · L118 Key Files
43
56
  ```
44
57
 
45
- If no KBs exist, no KBs are relevant, or `.devflow/features/` is absent, set `FEATURE_KNOWLEDGE` to `(none)`.
58
+ 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)`.
46
59
 
47
- **One git call, then direct file reads — no `.cjs` script.** After resolving `{worktree}`, this step is 1 index read (or N frontmatter reads on fallback), bounded by KB count.
60
+ **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.
48
61
  @end
49
62
 
50
63
  @export knowledge_load
@@ -60,16 +73,14 @@ git -C "{start}" rev-parse --show-toplevel
60
73
 
61
74
  and use its one-line output. If the command fails (outside a git repository), `{worktree}` is the start directory itself. All paths below are relative to `{worktree}`.
62
75
 
63
- **Step 1 — Check the opt-out gate, with `{root}` = `{worktree}`:**
64
-
65
- {{settings.settings_resolve()}}
76
+ **Step 1 — Check the opt-out gate, with `{root}` = `{worktree}`:** take the settings line resolved above for that root, resolving it with the settings block when this run has not yet.
66
77
 
67
78
  If the settings line says `KNOWLEDGE=off`, skip write-back entirely. The machine switch (`devflow knowledge --disable`), the repository and the personal settings can each turn knowledge off, and none can turn it back on (D-FEATURES-NARROW-ONLY). The fail-closed line says `KNOWLEDGE=off` too, so an unresolvable line skips write-back.
68
79
 
69
80
  **Step 2 — Evaluate whether write-back is warranted:**
70
81
 
71
82
  Only proceed if **at least one** of these is true:
72
- - This workflow changed files in a directory that is documented by an existing feature knowledge base (a documented area changed).
83
+ - This workflow changed files in a directory that is documented by an existing feature knowledge base (a documented area changed). Knowledge bases are written through at that point, never on a background schedule.
73
84
  - This workflow surfaced durable, cross-cutting knowledge about a codebase area that would help future agents working in the same area — patterns, anti-patterns, integration points, gotchas not visible from a single file read.
74
85
 
75
86
  **Never spawn unconditionally.** If neither condition is met, skip write-back silently.
@@ -84,7 +95,9 @@ FEATURE_SLUG: {slug derived from primary changed directory, kebab-case}
84
95
  FEATURE_NAME: {human-readable name}
85
96
  DIRECTORIES: {list of primary directories touched by this workflow}
86
97
  FILES_CHANGED: {list of files changed}
98
+ <!-- learning:on -->
87
99
  DECISIONS_CONTEXT: {DECISIONS_CONTEXT if available, else (none)}
100
+ <!-- learning:end -->
88
101
 
89
102
  Write the knowledge base to:
90
103
  {worktree}/.devflow/features/{slug}/KNOWLEDGE.md
@@ -92,7 +105,7 @@ Write the knowledge base to:
92
105
  Then update the index cache by performing a read-modify-write on:
93
106
  {worktree}/.devflow/features/index.md
94
107
 
95
- Index line format: `- **{slug}** — {areas} — {Use-when description}`
108
+ Index line format: `- **{slug}** — {areas} — {Use-when description}` — at most 300 characters, the description at most 220; reword a longer one, never cut it.
96
109
 
97
110
  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.
98
111
 
@@ -46,7 +46,7 @@ Every line of a `## Test Plan` section, or of a PR's test-plan block, follows th
46
46
 
47
47
  #### Consumption by Gate 2
48
48
 
49
- The Evaluate agent panel receives: the per-ticket plan + the numbered acceptance criteria (positive and negative).
49
+ The Evaluate agent receives: the per-ticket plan + the numbered acceptance criteria (positive and negative).
50
50
 
51
51
  The Test agent receives: the test plan's TP lines, once `check tp` has admitted them.
52
52
 
@@ -1,5 +1,21 @@
1
1
  @import "./_decisions.mds" as decisions
2
2
 
3
+ A partial: the Workflow-authoring preamble the dynamic commands share, and the
4
+ decisions step that precedes authoring.
5
+
6
+ D-DECISIONS-AUTHORING-STEP: the "DECISIONS_CONTEXT — obtain BEFORE authoring" step
7
+ is its own define, `authoring_decisions()`, expanded by the hosts that load
8
+ decisions (dynamic-build, dynamic-plan, dynamic-tickets and dynamic-profile) right
9
+ after their settings block, so the gate in it reads a line already resolved.
10
+ `authoring_preamble()` carries no decisions text. D-LEARNING-VARIANTS: the whole of
11
+ `authoring_decisions()` is a learning-on arm, so a learning-off build carries no decisions
12
+ step.
13
+
14
+ D-DECISIONS-DECLARED-ONLY: the step names, as the receivers of the index, only the
15
+ agent types whose contract declares `DECISIONS_CONTEXT` among the valid
16
+ `agentType`s. `tests/decisions/decisions-seam.test.ts` computes the declared set
17
+ from the agent sources and holds every pass sentence to it.
18
+
3
19
  @define authoring_preamble():
4
20
  ## Your task: author a Claude Code dynamic Workflow and run it
5
21
 
@@ -62,17 +78,9 @@ Then run a cheap syntax gate: write the authored script to a fresh, run-unique s
62
78
 
63
79
  The `budget` global governs depth. Scale Review agent roster and verification votes to `budget`. A low-budget run uses a leaner roster and fewer verification votes; a high-budget run expands both. Never hardcode a roster size — let budget guide it.
64
80
 
65
- ### DECISIONS_CONTEXT — obtain BEFORE authoring
66
-
67
- {{decisions.decisions_locate()}}
68
-
69
- Before you author the workflow script, read `{ledger}/.devflow/learning/index.md`. If the file is absent or empty, set `DECISIONS_CONTEXT` to `(none)`; otherwise use the file content as `DECISIONS_CONTEXT`.
70
-
71
- The script body cannot perform this read — you (the main model) do it before authoring. Then inject the relevant DECISIONS_CONTEXT into agent prompts using the `devflow:apply-decisions` consumption algorithm (scan index → Read relevant entries → cite verbatim IDs in agent prompts). Only agents that need architectural context (Code agent, Evaluate agent, Review agent, Scrutinize agent) need DECISIONS_CONTEXT injected; lightweight agents (Validate agent, Simplify agent) do not.
72
-
73
81
  ### Handoff convention for sequential Code agents within a ticket
74
82
 
75
- When a ticket requires multiple sequential Code agent phases, each Code agent writes `{toplevel}/.devflow/docs/handoff-{branch_slug}.md` (branch-scoped to prevent concurrent session clobber), `{toplevel}` being `git rev-parse --show-toplevel` in the checkout the ticket's branch is in — never a subdirectory. The next Code agent reads it via HANDOFF_FILE input. PRIOR_PHASE_SUMMARY is the compact in-context form; the handoff file is the durable form that survives context compaction. Always read the handoff file directly — code is authoritative, summaries are supplementary.
83
+ When a ticket requires multiple sequential Code agent phases, each Code agent appends its own `## Phase {N} Implementation Summary` section, at most 8,192 bytes, to `{toplevel}/.devflow/docs/handoff-{branch_slug}.md` (branch-scoped to prevent concurrent session clobber), `{toplevel}` being `git rev-parse --show-toplevel` in the checkout the ticket's branch is in — never a subdirectory. It never rewrites an earlier section. The next Code agent reads, via HANDOFF_FILE input, only the section of the phase immediately before its own, not the whole file. PRIOR_PHASE_SUMMARY is the compact in-context form; the handoff file is the durable form that survives context compaction. Code is authoritative, summaries are supplementary.
76
84
 
77
85
  ### IRON RULE (LLM-vs-plumbing)
78
86
 
@@ -83,4 +91,20 @@ When a ticket requires multiple sequential Code agent phases, each Code agent wr
83
91
  **NEVER merge to main or master** — the workflow merges to an integration branch only. The user merges to main themselves after reviewing. This rule is absolute and must appear as an `engine_invariants()` note in every workflow that touches git.
84
92
  @end
85
93
 
94
+ @define authoring_decisions():
95
+ <!-- learning:on -->
96
+ ### DECISIONS_CONTEXT — obtain BEFORE authoring
97
+
98
+ {{decisions.decisions_gate()}}
99
+
100
+ {{decisions.decisions_locate()}}
101
+
102
+ Before you author the workflow script, read `{ledger}/.devflow/learning/index.md`. If the file is absent or empty, set `DECISIONS_CONTEXT` to `(none)`; otherwise use the file content as `DECISIONS_CONTEXT`.
103
+
104
+ The script body cannot perform this read — you (the main model) do it before authoring. Then inject the relevant DECISIONS_CONTEXT into the prompts of the Code, Design, Knowledge, Review and Scrutinize agents, using the `devflow:apply-decisions` consumption algorithm (scan index → Read relevant entries → cite verbatim IDs in agent prompts). Those are the agent types above whose contract declares it; every other agent type gets no decisions context.
105
+
106
+ <!-- learning:end -->
107
+ @end
108
+
86
109
  @export authoring_preamble
110
+ @export authoring_decisions
@@ -1,9 +1,10 @@
1
- @import "./_settings.mds" as settings
1
+ A partial: the publication-value gate. D-SETTINGS-LINE: it imports nothing from
2
+ `_settings.mds`. Its host expands the settings block once, before the earliest of
3
+ its consumers, and this text takes `REVIEW_PUBLICATION` from the line resolved
4
+ there for the worktree's root.
2
5
 
3
6
  @define publication_gate():
4
- {{settings.settings_resolve()}}
5
-
6
- **Resolve `REVIEW_PUBLICATION` per worktree:** take `REVIEW_PUBLICATION` from that worktree's settings line, with `{root}` the worktree's root — multi-worktree repos may resolve different values per worktree. The line already caps the personal choice at the team's (D-PUBLICATION-CEILING), so it is `off`, `auto` or `full`, and `off` when the line was unresolvable.
7
+ **Resolve `REVIEW_PUBLICATION` per worktree:** take `REVIEW_PUBLICATION` from that worktree's settings line — the line resolved above for `{root}`, the worktree's root, by the settings block when this run has not yet resolved that root; multi-worktree repos may resolve different values per worktree. The line already caps the personal choice at the team's (D-PUBLICATION-CEILING), so it is `off`, `auto` or `full`, and `off` when the line was unresolvable.
7
8
 
8
9
  **Evidence stub:** only when `EVIDENCE_POLICY` is `required`, a resolved `off` becomes `stub`, so a counts-only record still reaches the PR. `stub` is never a config value: the settings line never carries it.
9
10
 
@@ -3,11 +3,19 @@ A partial: the one way a prompt learns the repository's settings (D-SETTINGS-LIN
3
3
  machine manifest for a value this line carries — `resolve-settings.cjs` folds all
4
4
  three, and `tests/guards/no-config-read.test.ts` holds every compiled prompt to it.
5
5
 
6
- Imported by `_publication.mds`, `_compliance.mds` and `_knowledge.mds` themselves,
7
- as ALIAS imports (a selective import deep-clones this module's scope into every
8
- define of the importer). A command that runs two of those gates carries the
9
- block twice; the text says "reuse a line this run already resolved for the same
10
- root", so the second copy costs bytes and never a second resolution.
6
+ Each command host that has a consumer imports this file itself, as an ALIAS import
7
+ (a selective import deep-clones this module's scope into every define of the
8
+ importer), and expands `settings_resolve()` exactly once, immediately before the
9
+ earliest of its consumers: its decisions load or gate, its compliance lens, its
10
+ publication gate, its knowledge write-back Step 1, or a Skim spawn that takes
11
+ `LEARNING`. The gate partials import nothing from here: their text refers to the
12
+ settings line resolved above and keeps each gate's own condition inside its own step.
13
+
14
+ The block stays a per-root procedure: "reusing a line this run already resolved for
15
+ the same root". A consumer whose `{root}` may differ from the first-resolved root
16
+ names that root and says its line is the one for that root, resolved by the block
17
+ above when this run has not yet resolved it. The guard counts textual invocations,
18
+ not runtime calls.
11
19
 
12
20
  The accepted shape below is `SETTINGS_LINE_RE` written out, and the fallback is
13
21
  `SETTINGS_FAIL_CLOSED_LINE`, both exported by `resolve-settings.cjs`;
@@ -40,8 +40,8 @@ For each ready ticket (sequentially by default; parallel only past the §7.1 bar
40
40
  - Branch setup: the engine's setup-task creates the ticket's branch off integration HEAD at ready-time (so it already contains merged deps); every later phase, and the merge, uses the branch setup-task created, and a setup-task that reports none stops the ticket before implementing
41
41
  - Run the single-ticket engine inside a try/catch — one ticket's crash/stall never kills the wave; catch the exception, quarantine that ticket, and continue with the remaining ready set
42
42
  - The engine gets the ticket's own reference, the one the pre-fetch printed, as its setup-task input — never the wave's tracking issue
43
- - On engine PASS or UNVERIFIED: merge to integration branch, run Validate agent (build + test)
44
- - Merge FAIL (build red after merge): quarantine ticket, mark as escalated, continue
43
+ - On engine PASS or UNVERIFIED: merge to the integration branch locally through Git (no push, no build or test), then the workflow spawns the Validate agent (build + test) over the merge. The merge counts as kept only when that Validate returns PASS
44
+ - Validate FAIL or no PASS (build red after merge): the workflow spawns Git to undo the merge, quarantines the ticket, marks it as escalated, and continues. If the undo is refused, the wave stops taking merges and rounds
45
45
  - On any other verdict (PARTIAL, FAIL, ESCALATED) or none: quarantine ticket, do not block independent siblings
46
46
 
47
47
  **Cascade quarantine:** when a ticket is quarantined for any reason (Gate-1 exhausted, engine crash/stall, build-red after merge, review coverage incomplete after retry), the quarantine cascades to its direct and transitive dependents — each is marked blocked with the named reason, naming the blocker by its `{ISSUE_REF}` (e.g. "blocked: depends on {ISSUE_REF} which failed Gate-1"). Independent siblings are never affected. The quarantined list is injected into every subsequent Design agent reader prompt so the reader never schedules dependents of failed tickets.
@@ -70,7 +70,9 @@ MAX_ROUNDS = LLM judgment based on ticket count (heuristic: ticket_count * 2 + 5
70
70
 
71
71
  **Parallel independent tickets:** each gets its own `git worktree add` + durable branch managed by the Git agent. Use explicit `git worktree add` — NOT the Workflow tool's ephemeral `isolation:'worktree'`. The branch must persist across implement → review → resolve → merge stages; ephemeral worktrees are gone when the agent call ends.
72
72
 
73
- **Post-merge validation:** after EVERY merge into the integration branch, run Validate agent (build + test). A red build immediately after merge is the cheapest possible conflict detector. Red → quarantine the merged result + escalate.
73
+ **Post-merge validation:** after EVERY merge into the integration branch, the workflow itself spawns the Validate agent (build + test) over the integration branch; Git runs no build or test. A red build immediately after merge is the cheapest possible conflict detector. It always runs — the merge reports `treeEqual` (whether the merge commit's tree equals the ticket branch head's tree) and the wave row records it, but a true value never skips the Validate.
74
+
75
+ **Undo of a red merge:** on FAIL or no PASS verdict the workflow spawns Git to undo the merge. The undo runs only when no remote branch contains the merge commit and the integration HEAD still equals it, as `git reset --keep {mergeSha}^1` on the integration branch — never `--hard`, never a push. It returns `{"undone": true}` or `{"undone": false, "reason": "..."}`. Undone → the row reads `merged: false` and the ticket is quarantined ("post-merge build red; merge undone"). Not undone → the wave stops taking merges and rounds, and its report names the red integration HEAD.
74
76
 
75
77
  **Commit discipline:** Git agent creates atomic commits per logical change, conventional-commit format, on the ticket branch before merge.
76
78
  @end
@@ -83,17 +85,25 @@ Two parallel sibling tickets can produce real git conflicts. The resolution is *
83
85
  **Resolution procedure:**
84
86
 
85
87
  1. Git agent detects the conflict and reports the conflicting files + sections
86
- 2. Spawn a Code agent with FULL intent context:
88
+ <!-- learning:on -->
89
+ 2. Spawn a Code agent whose prompt opens with `OPERATION: implement` and carries `COMPLIANCE_FRAMEWORKS` and `DECISIONS_CONTEXT`, with FULL intent context:
90
+ <!-- learning:off -->
91
+ 2. Spawn a Code agent whose prompt opens with `OPERATION: implement` and carries `COMPLIANCE_FRAMEWORKS`, with FULL intent context:
92
+ <!-- learning:end -->
87
93
  - Both ticket descriptions and plans
88
94
  - The conflicting diff sections (both sides)
95
+ <!-- learning:on -->
89
96
  - Relevant ADRs from DECISIONS_CONTEXT (loaded by main model before authoring)
97
+ <!-- learning:end -->
90
98
  3. Code agent resolves to PRESERVE BOTH INTENTS — the resolution must honor what both tickets were trying to achieve
91
99
  4. If the correct resolution is NOT UNAMBIGUOUS from the intent context: **do NOT guess** → quarantine + escalate
92
- 5. After any resolution: Validate agent (build + test) immediately
100
+ 5. After any resolution: the post-merge Validate covers it — the workflow spawns it after the merge, and no Validate is requested from Git
93
101
 
94
102
  **Conservative-or-escalate is absolute.** An LLM silently guessing a wrong merge is the highest-danger failure mode in the whole design. When in doubt: quarantine + surface in report. The user re-runs (resume) with the escalated context.
103
+ <!-- learning:on -->
95
104
 
96
105
  **New decisions surfaced during resolution** (a conflict that reveals an undocumented architectural choice) are noted in the run report for the user to write back as ADRs.
106
+ <!-- learning:end -->
97
107
  @end
98
108
 
99
109
  @define escalation_model():
@@ -106,7 +116,7 @@ A workflow cannot pause mid-run (F4). "Escalate" means: quarantine-and-continue
106
116
  - Ticket engine FAIL after max retries (Gate 1 exhausted)
107
117
  - Gate 2 FAIL after max retries (Evaluate agent/Test agent not satisfied)
108
118
  - Circular dependency detected (all remaining tickets blocked on each other)
109
- - Build red after merge (Validate agent fails post-merge)
119
+ - Build red after merge (the post-merge Validate agent fails: the merge is undone and the ticket quarantined; a refused undo halts the wave)
110
120
  - Review coverage incomplete after retry (a focus area failed to produce a live Review agent result after the retry)
111
121
  - Ticket engine crash/stall (unrecoverable exception or watchdog kill — quarantine cascades to dependents)
112
122
  - No ticket link while issues are required (the engine stops before implementing)
@@ -6,6 +6,7 @@ output-dir: dist/commands
6
6
  @import { decisions_load } from "./_partials/_decisions.mds"
7
7
  @import { docs_root } from "./_partials/_docs_root.mds"
8
8
  @import { evidence_policy } from "./_partials/_evidence_policy.mds"
9
+ @import "./_partials/_settings.mds" as settings
9
10
  # Bug Analysis Command
10
11
 
11
12
  Run a proactive bug analysis on the current branch by combining static analysis tools with parallel semantic analyzers, then synthesizing results into an actionable bug report. Supports incremental analysis, timestamped report directories, and `/resolve` compatibility.
@@ -168,12 +169,19 @@ If no tool produced findings: set `STATIC_FINDINGS` to `(none)`.
168
169
 
169
170
  ### Phase 3: Context Loading
170
171
 
171
- **Produces:** DECISIONS_CONTEXT, FEATURE_KNOWLEDGE, PLAN_CONTEXT, ACCEPTANCE_RULES
172
+ <!-- learning:on -->
173
+ **Produces:** DECISIONS_CONTEXT, FEATURE_KNOWLEDGE, FEATURE_KNOWLEDGE_RULES, PLAN_CONTEXT, ACCEPTANCE_RULES
174
+ <!-- learning:off -->
175
+ **Produces:** FEATURE_KNOWLEDGE, FEATURE_KNOWLEDGE_RULES, PLAN_CONTEXT, ACCEPTANCE_RULES
176
+ <!-- learning:end -->
172
177
 
178
+ <!-- learning:on -->
173
179
  #### Decisions Index
174
180
 
175
- {{decisions_load()}}
181
+ {{settings.settings_resolve()}}
176
182
 
183
+ <!-- learning:end -->
184
+ {{decisions_load()}}
177
185
  #### Feature Knowledge
178
186
 
179
187
  {{knowledge_load()}}
@@ -203,7 +211,11 @@ Determine which focus analyzers to run using `CHANGED_FILES` (already computed i
203
211
  ### Phase 5: Parallel Bug Analysis
204
212
 
205
213
  **Produces:** ANALYZER_OUTPUTS
214
+ <!-- learning:on -->
206
215
  **Requires:** DIFF_RANGE, ANALYSIS_DIR, ACTIVE_FOCUSES, STATIC_FINDINGS, ACCEPTANCE_RULES, PLAN_CONTEXT, DECISIONS_CONTEXT, FEATURE_KNOWLEDGE
216
+ <!-- learning:off -->
217
+ **Requires:** DIFF_RANGE, ANALYSIS_DIR, ACTIVE_FOCUSES, STATIC_FINDINGS, ACCEPTANCE_RULES, PLAN_CONTEXT, FEATURE_KNOWLEDGE
218
+ <!-- learning:end -->
207
219
 
208
220
  Spawn ALL active Diagnose agents **in a single message** (parallel, NOT background):
209
221
 
@@ -216,11 +228,15 @@ DIFF_COMMAND: git diff {DIFF_RANGE}
216
228
  ACCEPTANCE_RULES: {ACCEPTANCE_RULES filtered to this focus type, or (none)}
217
229
  PLAN_CONTEXT: {PLAN_CONTEXT}
218
230
  STATIC_FINDINGS: {STATIC_FINDINGS if focus == security, else (none)}
231
+ <!-- learning:on -->
219
232
  DECISIONS_CONTEXT: {DECISIONS_CONTEXT}
233
+ <!-- learning:end -->
220
234
  FEATURE_KNOWLEDGE: {FEATURE_KNOWLEDGE}
221
235
  PR_DESCRIPTION: <pr-description>{PR_DESCRIPTION}</pr-description>
222
236
  OUTPUT_PATH: {ANALYSIS_DIR}/{focus}.md
237
+ <!-- learning:on -->
223
238
  Follow devflow:apply-decisions to Read full ADR/PF bodies on demand.
239
+ <!-- learning:end -->
224
240
  Follow devflow:apply-feature-knowledge for FEATURE_KNOWLEDGE.
225
241
  IMPORTANT: Write report to {ANALYSIS_DIR}/{focus}.md using Write tool"
226
242
  ```
@@ -299,7 +315,9 @@ Run `/resolve` to process and fix these findings.
299
315
  │ Write static-findings.md
300
316
  │
301
317
  ├─ Phase 3: Context Loading
318
+ <!-- learning:on -->
302
319
  │ ├─ index.md (pre-rendered) → DECISIONS_CONTEXT
320
+ <!-- learning:end -->
303
321
  │ ├─ Feature knowledge load → FEATURE_KNOWLEDGE
304
322
  │ └─ {worktree}/.devflow/docs/design/*.md → PLAN_CONTEXT + ACCEPTANCE_RULES
305
323
  │
@@ -356,7 +374,11 @@ Before reporting results, verify every phase was executed:
356
374
 
357
375
  - [ ] Phase 1: Pre-flight → BRANCH_INFO captured, PR_DESCRIPTION fetched (or `(none)`)
358
376
  - [ ] Phase 2: Static Analysis → STATIC_FINDINGS captured (or `(none)` if skipped/no tools/no findings); ANALYSIS_DIR created; CHANGED_FILES populated
377
+ <!-- learning:on -->
359
378
  - [ ] Phase 3: Context Loading → DECISIONS_CONTEXT captured, FEATURE_KNOWLEDGE loaded (or `(none)`), PLAN_CONTEXT and ACCEPTANCE_RULES captured (or `(none)`)
379
+ <!-- learning:off -->
380
+ - [ ] Phase 3: Context Loading → FEATURE_KNOWLEDGE loaded (or `(none)`), PLAN_CONTEXT and ACCEPTANCE_RULES captured (or `(none)`)
381
+ <!-- learning:end -->
360
382
  - [ ] Phase 4: File Analysis → ACTIVE_FOCUSES determined (security + functional always present)
361
383
  - [ ] Phase 5: Parallel Bug Analysis → ANALYZER_OUTPUTS captured per active focus; all reports written to ANALYSIS_DIR
362
384
  - [ ] Phase 6: Synthesis → BUG_ANALYSIS_SUMMARY written to `{ANALYSIS_DIR}/bug-analysis-summary.md`