devflow-kit 3.6.0 → 3.8.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 (197) hide show
  1. package/CHANGELOG.md +438 -1
  2. package/README.md +15 -11
  3. package/dist/agents/code.md +9 -15
  4. package/dist/agents/design.md +1 -1
  5. package/dist/agents/fix.md +11 -13
  6. package/dist/agents/git.md +1 -1
  7. package/dist/agents/harden.md +1 -1
  8. package/dist/agents/refactor.md +7 -10
  9. package/dist/agents/review.md +6 -4
  10. package/dist/agents/skim.md +2 -2
  11. package/dist/agents/triage.md +2 -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/{learning.js → curation.js} +302 -99
  16. package/dist/cli/commands/gate-level-prompts.js +426 -0
  17. package/dist/cli/commands/gates.js +299 -0
  18. package/dist/cli/commands/init-seed.js +16 -5
  19. package/dist/cli/commands/init.js +263 -54
  20. package/dist/cli/commands/memory.js +20 -2
  21. package/dist/cli/commands/prompt-io.js +37 -0
  22. package/dist/cli/commands/uninstall.js +81 -9
  23. package/dist/cli.js +4 -2
  24. package/dist/commands/bug-analysis.md +25 -36
  25. package/dist/commands/code-review.md +77 -73
  26. package/dist/commands/debug.md +5 -5
  27. package/dist/commands/dynamic-build.md +76 -83
  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 +68 -102
  33. package/dist/commands/plan.md +19 -29
  34. package/dist/commands/release.md +5 -5
  35. package/dist/commands/research.md +6 -6
  36. package/dist/commands/resolve.md +29 -31
  37. package/dist/commands/self-review.md +5 -13
  38. package/dist/core/assets.js +20 -20
  39. package/dist/core/curate-tuning-config.js +5 -6
  40. package/dist/core/curation-move-notice.js +84 -0
  41. package/dist/core/curation-move-skip.js +36 -0
  42. package/dist/core/curation-move.js +35 -0
  43. package/dist/core/curation-queue-cleanup.js +134 -0
  44. package/dist/core/curation-store.js +98 -0
  45. package/dist/core/{learning-variants.js → curation-variants.js} +65 -41
  46. package/dist/core/echo-value.js +48 -0
  47. package/dist/core/evidence-policy.js +18 -6
  48. package/dist/core/feature-switch.js +95 -19
  49. package/dist/core/fs-atomic.js +1 -1
  50. package/dist/core/gate-level.js +221 -0
  51. package/dist/core/git.js +16 -14
  52. package/dist/core/ledger-root.js +82 -22
  53. package/dist/core/linked-path.js +4 -4
  54. package/dist/core/manifest-lock.js +238 -0
  55. package/dist/core/manifest.js +84 -24
  56. package/dist/core/migrations.js +1 -13
  57. package/dist/core/model-discovery.js +7 -1
  58. package/dist/core/observations.js +2 -2
  59. package/dist/core/plugins.js +15 -15
  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 +35 -0
  64. package/dist/core/tracker.js +6 -34
  65. package/dist/{learning-off → curation-off}/agents/code.md +9 -15
  66. package/dist/{learning-off → curation-off}/agents/fix.md +11 -13
  67. package/dist/{learning-off → curation-off}/agents/refactor.md +7 -10
  68. package/dist/{learning-off → curation-off}/agents/review.md +5 -3
  69. package/dist/{learning-off → curation-off}/agents/triage.md +1 -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 +74 -70
  72. package/dist/{learning-off → curation-off}/commands/debug.md +2 -2
  73. package/dist/{learning-off → curation-off}/commands/dynamic-build.md +73 -80
  74. package/dist/{learning-off → curation-off}/commands/explore.md +2 -2
  75. package/dist/{learning-off → curation-off}/commands/implement.md +65 -99
  76. package/dist/{learning-off → curation-off}/commands/plan.md +15 -25
  77. package/dist/{learning-off → curation-off}/commands/resolve.md +26 -28
  78. package/dist/{learning-off → curation-off}/commands/self-review.md +2 -10
  79. package/dist/hud/components/{learning-counts.js → curation-counts.js} +36 -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/validate-branch.md +8 -5
  84. package/dist/skills/git/references/tracker/github/ensure-pr-ready.md +20 -14
  85. package/dist/skills/git/references/tracker/jira/ensure-pr-ready.md +20 -20
  86. package/dist/skills/git/references/tracker/linear/ensure-pr-ready.md +20 -20
  87. package/dist/targets/claude-code/{learning-install.js → curation-install.js} +99 -67
  88. package/dist/targets/claude-code/installer.js +15 -15
  89. package/dist/targets/claude-code/language-stamp.js +5 -5
  90. package/dist/targets/claude-code/post-install.js +2 -2
  91. package/dist/targets/claude-code/tracker-servers.js +1 -1
  92. package/package.json +3 -2
  93. package/src/assets/agents/_partials/_code.mds +16 -17
  94. package/src/assets/agents/code.mds +4 -7
  95. package/src/assets/agents/curate.md +12 -14
  96. package/src/assets/agents/debug.mds +6 -6
  97. package/src/assets/agents/design.mds +18 -18
  98. package/src/assets/agents/fix.mds +6 -5
  99. package/src/assets/agents/git.mds +1 -1
  100. package/src/assets/agents/harden.mds +7 -7
  101. package/src/assets/agents/knowledge.mds +23 -23
  102. package/src/assets/agents/refactor.mds +2 -2
  103. package/src/assets/agents/research.mds +15 -15
  104. package/src/assets/agents/review.mds +45 -43
  105. package/src/assets/agents/skim.mds +11 -11
  106. package/src/assets/agents/synthesize.md +2 -2
  107. package/src/assets/agents/triage.mds +22 -22
  108. package/src/assets/agents/validate.md +13 -26
  109. package/src/assets/commands/_partials/_decisions.mds +13 -13
  110. package/src/assets/commands/_partials/_engine.mds +8 -8
  111. package/src/assets/commands/_partials/_knowledge.mds +29 -15
  112. package/src/assets/commands/_partials/_preamble.mds +4 -4
  113. package/src/assets/commands/_partials/_settings.mds +3 -3
  114. package/src/assets/commands/_partials/_wave.mds +17 -24
  115. package/src/assets/commands/bug-analysis.mds +37 -48
  116. package/src/assets/commands/code-review.mds +90 -86
  117. package/src/assets/commands/debug.mds +14 -14
  118. package/src/assets/commands/dynamic-build.mds +78 -78
  119. package/src/assets/commands/dynamic-plan.mds +22 -22
  120. package/src/assets/commands/dynamic-profile.mds +2 -2
  121. package/src/assets/commands/dynamic-tickets.mds +8 -8
  122. package/src/assets/commands/explore.mds +20 -20
  123. package/src/assets/commands/implement.mds +92 -118
  124. package/src/assets/commands/plan.mds +41 -51
  125. package/src/assets/commands/release.mds +12 -12
  126. package/src/assets/commands/research.mds +19 -19
  127. package/src/assets/commands/resolve.mds +56 -50
  128. package/src/assets/commands/self-review.mds +20 -20
  129. package/src/assets/mds/git/_ops.mds +3 -1
  130. package/src/assets/mds/git/_ops_pr.mds +1 -1
  131. package/src/assets/mds/git/_ops_steps.mds +13 -7
  132. package/src/assets/mds/git/_pr.mds +7 -4
  133. package/src/assets/mds/tracker/_common.mds +23 -12
  134. package/src/assets/mds/tracker/_github.mds +2 -9
  135. package/src/assets/mds/tracker/_jira.mds +2 -15
  136. package/src/assets/mds/tracker/_linear.mds +2 -15
  137. package/src/assets/rules/quality.md +1 -0
  138. package/src/assets/scripts/ci-wait.cjs +22 -4
  139. package/src/assets/scripts/claude-md-audit.cjs +66 -51
  140. package/src/assets/scripts/hooks/background-memory-update +406 -97
  141. package/src/assets/scripts/hooks/capture-prompt +12 -12
  142. package/src/assets/scripts/hooks/capture-question +11 -11
  143. package/src/assets/scripts/hooks/capture-turn +12 -12
  144. package/src/assets/scripts/hooks/{learning-lock → curation-lock} +2 -2
  145. package/src/assets/scripts/hooks/curation-move +293 -0
  146. package/src/assets/scripts/hooks/ensure-devflow-init +45 -13
  147. package/src/assets/scripts/hooks/ensure-proxy +4 -4
  148. package/src/assets/scripts/hooks/ensure-root-gitignore +4 -4
  149. package/src/assets/scripts/hooks/git-marker +81 -0
  150. package/src/assets/scripts/hooks/json-helper.cjs +145 -51
  151. package/src/assets/scripts/hooks/json-parse +19 -4
  152. package/src/assets/scripts/hooks/lib/curation-move.cjs +1582 -0
  153. package/src/assets/scripts/hooks/lib/{learning-store.cjs → curation-store.cjs} +242 -118
  154. package/src/assets/scripts/hooks/lib/decisions-format.cjs +3 -3
  155. package/src/assets/scripts/hooks/lib/mkdir-lock.cjs +24 -7
  156. package/src/assets/scripts/hooks/lib/project-paths.cjs +132 -39
  157. package/src/assets/scripts/hooks/lib/render-decisions.cjs +34 -22
  158. package/src/assets/scripts/hooks/lib/tracked-areas.cjs +259 -0
  159. package/src/assets/scripts/hooks/memory-permission +358 -0
  160. package/src/assets/scripts/hooks/memory-worker +1 -1
  161. package/src/assets/scripts/hooks/pre-compact-memory +6 -16
  162. package/src/assets/scripts/hooks/queue-append +228 -103
  163. package/src/assets/scripts/hooks/resolve-project-root +2 -2
  164. package/src/assets/scripts/hooks/session-start-context +145 -71
  165. package/src/assets/scripts/hooks/session-start-memory +27 -46
  166. package/src/assets/scripts/lib/project-config.cjs +31 -9
  167. package/src/assets/scripts/resolve-base.cjs +1043 -0
  168. package/src/assets/scripts/resolve-settings.cjs +238 -46
  169. package/src/assets/skills/agent-references/SKILL.md +9 -2
  170. package/src/assets/skills/agent-references/references/commands/code-review-levels.md +19 -0
  171. package/src/assets/skills/agent-references/references/commands/implement-levels.md +27 -0
  172. package/src/assets/skills/agent-references/references/commands/implement-revalidate.md +6 -4
  173. package/src/assets/skills/agent-references/references/commands/plan-levels.md +40 -0
  174. package/src/assets/skills/agent-references/references/commands/resolve-levels.md +24 -0
  175. package/src/assets/skills/agent-references/references/synthesize/planning.md +9 -22
  176. package/src/assets/skills/agent-references/references/synthesize/review.md +11 -11
  177. package/src/assets/skills/apply-decisions/SKILL.md +1 -1
  178. package/src/assets/skills/docs-framework/SKILL.md +7 -7
  179. package/src/assets/skills/docs-framework/references/patterns.md +3 -4
  180. package/src/assets/skills/quality-gates/SKILL.md +1 -1
  181. package/src/assets/skills/worktree-support/references/roots.md +2 -2
  182. package/templates/lint-pack/.lint-pack.conf +86 -0
  183. package/templates/lint-pack/README.md +190 -0
  184. package/templates/lint-pack/lint-pack.sh +905 -0
  185. package/dist/core/learning-queue-cleanup.js +0 -27
  186. package/dist/core/learning-store.js +0 -61
  187. /package/dist/{learning-off → curation-off}/agents/debug.md +0 -0
  188. /package/dist/{learning-off → curation-off}/agents/design.md +0 -0
  189. /package/dist/{learning-off → curation-off}/agents/harden.md +0 -0
  190. /package/dist/{learning-off → curation-off}/agents/knowledge.md +0 -0
  191. /package/dist/{learning-off → curation-off}/agents/research.md +0 -0
  192. /package/dist/{learning-off → curation-off}/agents/skim.md +0 -0
  193. /package/dist/{learning-off → curation-off}/commands/dynamic-plan.md +0 -0
  194. /package/dist/{learning-off → curation-off}/commands/dynamic-profile.md +0 -0
  195. /package/dist/{learning-off → curation-off}/commands/dynamic-tickets.md +0 -0
  196. /package/dist/{learning-off → curation-off}/commands/release.md +0 -0
  197. /package/dist/{learning-off → curation-off}/commands/research.md +0 -0
@@ -2,7 +2,7 @@
2
2
  description: Execute a single task through implementation, quality gates, and PR creation - accepts plan documents, issues, or task descriptions
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 { docs_root } from "./_partials/_docs_root.mds"
8
8
  @import { evidence_policy } from "./_partials/_evidence_policy.mds"
@@ -13,7 +13,7 @@ output-dir: dist/commands
13
13
  @import "./_partials/_settings.mds" as settings
14
14
  # Implement Command
15
15
 
16
- Orchestrate a single task through implementation by spawning specialized agents. The orchestrator only spawns agents and passes context - all work is done by agents.
16
+ Orchestrate a single task through implementation by spawning specialized agents.
17
17
 
18
18
  ## Usage
19
19
 
@@ -40,23 +40,21 @@ $ARGUMENTS
40
40
 
41
41
  {{issue_ref_grammar()}}
42
42
 
43
- > **Tip**: For best results, run `/plan` first to produce a design artifact, then pass it to `/implement`.
44
-
45
43
  ## Phases
46
44
 
47
45
  ### Re-validation Continuation Path
48
46
 
49
- When the user explicitly asks to re-validate, re-check, or re-run quality gates after making their own changes, resolve `${CLAUDE_CONFIG_DIR:-$HOME/.claude}` in Bash, Read `<that directory>/skills/devflow:agent-references/references/commands/implement-revalidate.md` with the Read tool and follow it. Otherwise proceed with the full pipeline below.
47
+ When the user explicitly asks to re-validate, re-check, or re-run quality gates after making their own changes, run `d="${CLAUDE_CONFIG_DIR:-}"; case "$d" in /*) ;; *) d="$HOME/.claude" ;; esac; printf '%s\n' "$d"` in Bash, Read `<that directory>/skills/devflow:agent-references/references/commands/implement-revalidate.md` with the Read tool and follow it. Otherwise proceed with the full pipeline below.
50
48
 
51
49
  ### Phase 1: Setup
52
50
 
53
- <!-- learning:on -->
54
- **Produces:** TASK_ID, BASE_BRANCH, EXECUTION_PLAN, DECISIONS_CONTEXT, FEATURE_KNOWLEDGE, FEATURE_KNOWLEDGE_RULES, PR_DESCRIPTION_GUIDANCE, ISSUE_NUMBER, ISSUE_PR_LINK, EVIDENCE_POLICY, ISSUE_REQUIRED, APPLY_CONVENTIONS, REQUIRE_NON_AUTHOR_APPROVAL, PR_EXCEPTIONS, TEST_PLAN, EVIDENCE_FILE, PR_TEST_PLAN_BLOCK, REVIEW_PUBLICATION
55
- <!-- learning:off -->
56
- **Produces:** TASK_ID, BASE_BRANCH, EXECUTION_PLAN, FEATURE_KNOWLEDGE, FEATURE_KNOWLEDGE_RULES, PR_DESCRIPTION_GUIDANCE, ISSUE_NUMBER, ISSUE_PR_LINK, EVIDENCE_POLICY, ISSUE_REQUIRED, APPLY_CONVENTIONS, REQUIRE_NON_AUTHOR_APPROVAL, PR_EXCEPTIONS, TEST_PLAN, EVIDENCE_FILE, PR_TEST_PLAN_BLOCK, REVIEW_PUBLICATION
57
- <!-- learning:end -->
51
+ <!-- curation:on -->
52
+ **Produces:** TASK_ID, BASE_BRANCH, BASE_REF, EXECUTION_PLAN, DECISIONS_CONTEXT, FEATURE_KNOWLEDGE, FEATURE_KNOWLEDGE_RULES, PR_DESCRIPTION_GUIDANCE, ISSUE_NUMBER, ISSUE_PR_LINK, EVIDENCE_POLICY, ISSUE_REQUIRED, APPLY_CONVENTIONS, REQUIRE_NON_AUTHOR_APPROVAL, PR_EXCEPTIONS, TEST_PLAN, EVIDENCE_FILE, PR_TEST_PLAN_BLOCK, REVIEW_PUBLICATION, GATE_LEVEL
53
+ <!-- curation:off -->
54
+ **Produces:** TASK_ID, BASE_BRANCH, BASE_REF, EXECUTION_PLAN, FEATURE_KNOWLEDGE, FEATURE_KNOWLEDGE_RULES, PR_DESCRIPTION_GUIDANCE, ISSUE_NUMBER, ISSUE_PR_LINK, EVIDENCE_POLICY, ISSUE_REQUIRED, APPLY_CONVENTIONS, REQUIRE_NON_AUTHOR_APPROVAL, PR_EXCEPTIONS, TEST_PLAN, EVIDENCE_FILE, PR_TEST_PLAN_BLOCK, REVIEW_PUBLICATION, GATE_LEVEL
55
+ <!-- curation:end -->
58
56
 
59
- Record the current branch name as `BASE_BRANCH` - this will be the PR target.
57
+ Record the current branch name as `BASE_BRANCH`. Stop the run unless it matches `^(?![-#]|origin\/|(?:@|(?:FETCH_|ORIG_|MERGE_)?HEAD)$)(?!.*\.\.)[A-Za-z0-9._\/+@,#-]{1,200}$` (judge the match by reading; never pass the value to a command), telling the user it allows only ASCII letters, digits and `._/+@,#-`, at most 200; no leading `-` or `#`, no `origin/` prefix, no `..`, not `@` or a HEAD name.
60
58
 
61
59
  {{docs_root()}}
62
60
 
@@ -75,7 +73,7 @@ If `PR_DESCRIPTION_GUIDANCE` was not set above (non-plan paths: issue input or t
75
73
 
76
74
  **Empty input.** When `COMMAND_INPUT` is empty — a plan handoff arrives this way, with the plan already in the conversation — there is no argument to name the branch from, and the Git agent sees none of this conversation. Write the description yourself: one line, taken from the plan's title or, with no plan, from the conversation. Send it as the setup-task `TASK_DESCRIPTION` below.
77
75
 
78
- Spawn Git agent to set up task environment. The Git agent derives the branch name automatically from the issue or task description:
76
+ Spawn Git agent to set up the task:
79
77
 
80
78
  ```
81
79
  Agent(subagent_type="Git"):
@@ -90,44 +88,20 @@ Derive branch name from issue or description, create feature branch, and fetch i
90
88
  Return the branch setup summary."
91
89
  ```
92
90
 
93
- The issue token is forwarded **unclassified**, and the routing is decided by
94
- SHAPE alone — how many tokens `COMMAND_INPUT` has, and whether it ends in `.md`.
95
-
96
- `setup-task` is the one step that has resolved a provider, and therefore the only
97
- one that knows what an issue reference looks like on this machine: `#123`,
98
- `PROJ-12` and `ENG-12` are three providers' spellings of the same thing. A
99
- `starts with #` test here would be a github test wearing a neutral name — it
100
- reclassifies every other provider's reference as a task description, so the
101
- branch is derived from prose and no issue is ever fetched, with nothing reporting
102
- a problem. Token COUNT is the gate that stays provider-neutral: every one of
103
- those spellings is a single token, and no free-text task description is.
104
-
105
- The two tests this command does make are its own under every provider:
106
-
107
- - **Extension.** A path ending in `.md` is a plan document, never an issue
108
- reference — it goes to `PLAN_ARTIFACT_PATH` and neither of the other two keys.
109
- `ISSUE_INPUT` then carries the plan's frontmatter `issue` instead, never the
110
- path (Plan Document Handling step 4).
111
- - **Token count.** A single token is an issue reference. Two or more is prose:
112
- forwarding only its FIRST token would send `/implement fix the login bug` to
113
- the Git agent as `ISSUE_INPUT: fix` with no description at all, and
114
- `setup-task` fetches whatever it is handed — so the command would derive a
115
- branch from a failed lookup and drop the request on the floor.
91
+ The issue token is forwarded **unclassified**; routing is by SHAPE alone (the token count of `COMMAND_INPUT` and a `.md` ending). Only `setup-task` has resolved a provider, so a `starts with #` test would be a github test that reclassifies `PROJ-12` and `ENG-12` as task descriptions: the branch comes from prose, no issue is fetched and nothing reports it. Token COUNT is provider-neutral: every issue spelling is one token and no free-text description is.
116
92
 
117
- The cost of the count gate is a one-word task description (`/implement refactor`)
118
- reaching `setup-task` as an issue reference, where it fails the lookup and is
119
- reported. That is the direction the failure has to fall: an unfetched issue is
120
- visible, a silently discarded request is not.
93
+ - **Extension.** A path ending in `.md` is a plan document, never an issue reference: it goes to `PLAN_ARTIFACT_PATH` only, and `ISSUE_INPUT` carries the plan's frontmatter `issue`, never the path (Plan Document Handling step 4).
94
+ - **Token count.** One token is an issue reference; two or more is prose. Forwarding the FIRST token alone would send `/implement fix the login bug` as `ISSUE_INPUT: fix` with no description, so the request is dropped.
121
95
 
122
96
  **Capture from Git agent output** (used throughout flow):
123
97
  - `TASK_ID`: The branch name created by Git agent (use as TASK_ID for rest of flow)
124
- - `BASE_BRANCH`: Branch this feature was created from (for PR target)
98
+ - `BASE_BRANCH`: Branch this feature was created from (for PR target); stop unless it passes the setup check
125
99
  - `ISSUE_NUMBER`: the provider-canonical issue identifier for this task — the same value the Git agent emits as `ISSUE_ID` (if provided, or created by the Git agent's issue-first step in setup-task)
126
100
  - `branch_slug`: `TASK_ID` with every `/` replaced by `-`. It names `handoff-{branch_slug}.md` and `evidence-{branch_slug}.md` only when it matches `^[A-Za-z0-9._-]{1,200}$`; any other branch name stops the run here, telling the user it cannot name those files.
127
101
 
128
102
  {{issue_capture_contract()}}
129
103
 
130
- **Ticket link, only when `ISSUE_REQUIRED` is `true`:** when the capture above holds no `ISSUE_PR_LINK` (absent, or `(none)`), resolve `${CLAUDE_CONFIG_DIR:-$HOME/.claude}` in Bash, Read `<that directory>/skills/devflow:agent-references/references/commands/implement-evidence-asks.md` with the Read tool (once per run), then run its ticket link ask and **Record the exception at once** as it directs, before any Code spawn. `PR_EXCEPTIONS` is `(none)` until an exception is recorded.
104
+ **Ticket link, only when `ISSUE_REQUIRED` is `true`:** when the capture above holds no `ISSUE_PR_LINK` (absent, or `(none)`), run `d="${CLAUDE_CONFIG_DIR:-}"; case "$d" in /*) ;; *) d="$HOME/.claude" ;; esac; printf '%s\n' "$d"` in Bash, Read `<that directory>/skills/devflow:agent-references/references/commands/implement-evidence-asks.md` with the Read tool (once per run), then run its ticket link ask and **Record the exception at once** as it directs, before any Code spawn. `PR_EXCEPTIONS` is `(none)` until an exception is recorded.
131
105
 
132
106
  **Test plan.** Before any Code spawn, give the task a test plan in the evidence file `{worktree}/.devflow/docs/evidence-{branch_slug}.md` (`EVIDENCE_FILE`) — unlike the handoff file, it stays after the PR exists. It holds up to three sections, in this order and nothing else: `## Test Plan`; `## Evidence Exceptions`, a byte copy of `PR_EXCEPTIONS` present only while that is not `(none)`; and `## Claims`, always last, so every claim is appended at the end of the file. Create the file if absent; if it exists, replace its `## Test Plan` and `## Evidence Exceptions` sections and keep `## Claims` byte-identical.
133
107
 
@@ -167,32 +141,34 @@ Phase 11 passes the resolved value to the evidence script (`publish`), which dec
167
141
  Pass `COMPLIANCE_DIRECTIVE` to every Code and Fix spawn, on a line of its own.
168
142
 
169
143
  {{decisions_load()}}
170
- <!-- learning:on -->
144
+ <!-- curation:on -->
171
145
  Pass `DECISIONS_CONTEXT` to Code agent (Phase 2) and Harden agent (Phase 4).
172
146
 
173
- <!-- learning:end -->
147
+ <!-- curation:end -->
174
148
  {{knowledge_load()}}
175
149
 
150
+ **Fresh base.** Before Phase 2, write `BASE_BRANCH` with the Write tool to the file that `F="$(mktemp)" && echo "F=$F"` prints, after one Read of it. If the Write tool fails, treat the value as missing; never write it with a shell command. Then run `F="{name file}"; trap 'rm -- "$F"' EXIT; cd "{worktree}" && node "$HOME/.devflow/scripts/resolve-base.cjs" local --name-stdin < "$F"; echo "exit=$?"`. Output other than one `BASE_REF=` line (40 or 64 hex, or `none`) with `exit=0` counts as `NOTE=stop`, `REASON=resolver-unavailable`. Record `BASE_REF`. By `NOTE`: `none` continues; `info` prints one plain line; `degraded` records `TRACEABILITY: DEGRADED (base {REASON}; fix: {fix})`; `stop` (`BASE_REF=none`) stops the run, naming REASON and its fix. Fix by REASON: no-merge-base `git fetch --unshallow`; no-ref or timeout `git fetch origin <base>` (`<base>` stays as written); resolver-unavailable `re-run; if it repeats, run devflow init`; invalid-name the allowed set, never the name; any other REASON none, and `; fix: {fix}` is left out.
151
+
176
152
  ### Phase 2: Implement
177
153
 
178
154
  **Produces:** CODE_AGENT_OUTPUT, FILES_CHANGED
179
155
  **Requires:** TASK_ID, BASE_BRANCH, EXECUTION_PLAN
180
156
 
181
- Based on Setup context (plan document, issue body, or conversation context), use the three-strategy framework:
157
+ Setup context is the plan document, issue body or conversation.
182
158
 
183
159
  **Strategy Selection**:
184
- - If plan document provided: use `execution-strategy` from frontmatter (default: SINGLE_CODE_AGENT if absent)
185
- - Otherwise: default to SINGLE_CODE_AGENT unless task description signals high complexity
160
+ - If plan document provided: use `execution-strategy` from frontmatter (if absent, use the table below)
161
+ - Otherwise: SINGLE_CODE_AGENT, because there is no Subtask Breakdown to split
186
162
 
187
- | Strategy | When | Frequency |
188
- |----------|------|-----------|
189
- | **SINGLE_CODE_AGENT** | Default. Coherent A→Z implementation | ~80% |
190
- | **SEQUENTIAL_CODE_AGENTS** | Context overflow risk, layered dependencies | ~15% |
191
- | **PARALLEL_CODE_AGENTS** | True artifact independence (rare) | ~5% |
163
+ | Strategy | When |
164
+ |----------|------|
165
+ | **SINGLE_CODE_AGENT** | Default. Coherent A→Z implementation |
166
+ | **SEQUENTIAL_CODE_AGENTS** | The plan writes >= 10 files or has >= 7 steps |
167
+ | **PARALLEL_CODE_AGENTS** | True artifact independence (rare) |
192
168
 
193
169
  ---
194
170
 
195
- **SINGLE_CODE_AGENT** (default):
171
+ **SINGLE_CODE_AGENT**:
196
172
 
197
173
  ```
198
174
  Agent(subagent_type="Code"):
@@ -203,15 +179,15 @@ BASE_BRANCH: {base branch}
203
179
  EXECUTION_PLAN: {full plan from setup context}
204
180
  PATTERNS: {patterns from plan document or empty}
205
181
  FEATURE_KNOWLEDGE: {feature_knowledge}
206
- <!-- learning:on -->
182
+ <!-- curation:on -->
207
183
  DECISIONS_CONTEXT: {decisions_context}
208
- <!-- learning:end -->
184
+ <!-- curation:end -->
209
185
  {COMPLIANCE_DIRECTIVE}"
210
186
  ```
211
187
 
212
188
  ---
213
189
 
214
- **SEQUENTIAL_CODE_AGENTS** (for HIGH/CRITICAL context risk):
190
+ **SEQUENTIAL_CODE_AGENTS**:
215
191
 
216
192
  Spawn Code agents one at a time. Each appends its own phase section to the handoff file, and the next reads only the section before it:
217
193
 
@@ -225,9 +201,9 @@ BASE_BRANCH: {base branch}
225
201
  EXECUTION_PLAN: {phase 1 steps}
226
202
  PATTERNS: {patterns from plan document or empty}
227
203
  FEATURE_KNOWLEDGE: {feature_knowledge}
228
- <!-- learning:on -->
204
+ <!-- curation:on -->
229
205
  DECISIONS_CONTEXT: {decisions_context}
230
- <!-- learning:end -->
206
+ <!-- curation:end -->
231
207
  {COMPLIANCE_DIRECTIVE}
232
208
  HANDOFF_REQUIRED: true
233
209
  HANDOFF_FILE: {worktree}/.devflow/docs/handoff-{branch_slug}.md"
@@ -245,19 +221,19 @@ PATTERNS: {patterns from plan document or empty}
245
221
  PRIOR_PHASE_SUMMARY: {summary from previous Code agent}
246
222
  FILES_FROM_PRIOR_PHASE: {list of files created}
247
223
  FEATURE_KNOWLEDGE: {feature_knowledge}
248
- <!-- learning:on -->
224
+ <!-- curation:on -->
249
225
  DECISIONS_CONTEXT: {decisions_context}
250
- <!-- learning:end -->
226
+ <!-- curation:end -->
251
227
  {COMPLIANCE_DIRECTIVE}
252
228
  HANDOFF_REQUIRED: {true if not last phase}
253
229
  HANDOFF_FILE: {worktree}/.devflow/docs/handoff-{branch_slug}.md"
254
230
  ```
255
231
 
256
- **Handoff Protocol**: Each sequential Code agent receives the prior Code agent's implementation summary via PRIOR_PHASE_SUMMARY and FILES_FROM_PRIOR_PHASE. The Code agent's built-in branch orientation step handles git log scanning, file reading, and pattern discovery automatically. Each Code agent with HANDOFF_REQUIRED=true appends its own `## Phase {N} Implementation Summary` section, at most 8,192 bytes, to `{worktree}/.devflow/docs/handoff-{branch_slug}.md` (survives context compaction), never rewriting an earlier section and keeping any `## Evidence Exceptions` section byte-identical; the next Code agent reads only the section of the phase immediately before its own through HANDOFF_FILE. The orchestrator writes no phase section. Delete `{worktree}/.devflow/docs/handoff-{branch_slug}.md` once the PR exists — after Phase 9 (cleanup).
232
+ **Handoff Protocol**: Each Code agent with HANDOFF_REQUIRED=true appends its own `## Phase {N} Implementation Summary` section, at most 8,192 bytes, to `{worktree}/.devflow/docs/handoff-{branch_slug}.md`, never rewriting an earlier section and keeping any `## Evidence Exceptions` section byte-identical; the next Code agent reads only the section of the phase immediately before its own through HANDOFF_FILE. The orchestrator writes no phase section. Delete `{worktree}/.devflow/docs/handoff-{branch_slug}.md` once the PR exists — after Phase 9 (cleanup).
257
233
 
258
234
  ---
259
235
 
260
- **PARALLEL_CODE_AGENTS** (rare - truly independent artifacts):
236
+ **PARALLEL_CODE_AGENTS**:
261
237
 
262
238
  Spawn multiple Code agents **in a single message**, each with independent subtask:
263
239
 
@@ -270,9 +246,9 @@ BASE_BRANCH: {base branch}
270
246
  EXECUTION_PLAN: {subtask 1 steps}
271
247
  PATTERNS: {patterns}
272
248
  FEATURE_KNOWLEDGE: {feature_knowledge}
273
- <!-- learning:on -->
249
+ <!-- curation:on -->
274
250
  DECISIONS_CONTEXT: {decisions_context}
275
- <!-- learning:end -->
251
+ <!-- curation:end -->
276
252
  {COMPLIANCE_DIRECTIVE}"
277
253
 
278
254
  Agent(subagent_type="Code"): # Code agent 2 (same message)
@@ -283,30 +259,32 @@ BASE_BRANCH: {base branch}
283
259
  EXECUTION_PLAN: {subtask 2 steps}
284
260
  PATTERNS: {patterns}
285
261
  FEATURE_KNOWLEDGE: {feature_knowledge}
286
- <!-- learning:on -->
262
+ <!-- curation:on -->
287
263
  DECISIONS_CONTEXT: {decisions_context}
288
- <!-- learning:end -->
264
+ <!-- curation:end -->
289
265
  {COMPLIANCE_DIRECTIVE}"
290
266
  ```
291
267
 
292
- **Independence criteria** (all must be true for PARALLEL_CODE_AGENTS):
293
- - No shared contracts or interfaces
294
- - No integration points between subtasks
295
- - Different files/modules with no imports between them
296
- - Each subtask is self-contained
268
+ **Independence criteria** (all must be true for PARALLEL_CODE_AGENTS): no shared contracts, interfaces or integration points between subtasks; different files/modules with no imports between them.
297
269
 
298
270
  ### Phase 3: Polish
299
271
 
300
272
  **Produces:** POLISH_OUTPUT
301
- **Requires:** FILES_CHANGED
273
+ **Requires:** BASE_REF, GATE_LEVEL
274
+
275
+ **Gate level.** At `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/implement-levels.md` with the Read tool, and apply each row to the phase it names.
302
276
 
303
- After the Code agent completes, spawn Polish agent to polish the code. The Phase 6 Validate covers its commits.
277
+ - No row or rule overrides the next two lines.
278
+ - 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, keep `GATE_LEVEL` and say `level reference unreadable: no level rows applied`.
279
+ - Validate, the CI gate, the evidence claims and the compliance directive run at every level. An enabled compliance lens keeps Harden.
280
+
281
+ After the Code agent completes, spawn Polish agent to polish the code. The Phase 6 Validate covers its commits. `{branch_diff}` is the output of `git diff --name-only --diff-filter=d {BASE_REF}...HEAD`, run again at each spawn; a non-zero exit stops, and an empty list counts only on exit 0.
304
282
 
305
283
  ```
306
284
  Agent(subagent_type="Polish"):
307
285
  "Polish recently implemented code
308
286
  Task: {task description}
309
- FILES_CHANGED: {list of files from Code agent output}
287
+ FILES_CHANGED: {branch_diff}
310
288
  Focus on code modified by Code agent, apply project standards, enhance clarity
311
289
  Commit any improvements with a conventional-commit message."
312
290
  ```
@@ -314,17 +292,17 @@ Commit any improvements with a conventional-commit message."
314
292
  ### Phase 4: Self-Review
315
293
 
316
294
  **Produces:** HARDEN_OUTPUT
317
- **Requires:** FILES_CHANGED
295
+ **Requires:** BASE_REF
318
296
 
319
- After Polish agent completes, spawn Harden agent as the quality gate:
297
+ After Phase 3, spawn Harden agent as the quality gate:
320
298
 
321
299
  ```
322
300
  Agent(subagent_type="Harden"):
323
301
  "TASK_DESCRIPTION: {task description}
324
- FILES_CHANGED: {list of files from Code agent output}
325
- <!-- learning:on -->
302
+ FILES_CHANGED: {branch_diff}
303
+ <!-- curation:on -->
326
304
  DECISIONS_CONTEXT: {decisions_context}
327
- <!-- learning:end -->
305
+ <!-- curation:end -->
328
306
  FEATURE_KNOWLEDGE: {feature_knowledge_rules}
329
307
  Evaluate 9 pillars, fix P0/P1 issues, report status"
330
308
  ```
@@ -334,7 +312,7 @@ Harden agent reports `### Status: PASS | FIXED | BLOCKED`. **If BLOCKED:** repor
334
312
  ### Phase 5: Alignment Check
335
313
 
336
314
  **Produces:** ALIGNMENT_RESULT
337
- **Requires:** FILES_CHANGED, EXECUTION_PLAN
315
+ **Requires:** BASE_REF, EXECUTION_PLAN
338
316
 
339
317
  After Harden agent passes, spawn Evaluate agent to validate alignment. Evaluate agent receives `FEATURE_KNOWLEDGE_RULES` as acceptance context only; pattern and anti-pattern judgments belong to Harden agent:
340
318
 
@@ -342,7 +320,7 @@ After Harden agent passes, spawn Evaluate agent to validate alignment. Evaluate
342
320
  Agent(subagent_type="Evaluate"):
343
321
  "ORIGINAL_REQUEST: {task description or issue content}
344
322
  EXECUTION_PLAN: {execution plan from Phase 1}
345
- FILES_CHANGED: {list of files from Code agent output}
323
+ FILES_CHANGED: {branch_diff}
346
324
  ACCEPTANCE_CRITERIA: {extracted criteria if available}
347
325
  FEATURE_KNOWLEDGE: {feature_knowledge_rules}
348
326
  Validate alignment with request and plan. Report ALIGNED or MISALIGNED with details."
@@ -362,9 +340,9 @@ Validate alignment with request and plan. Report ALIGNED or MISALIGNED with deta
362
340
  TASK_DESCRIPTION: Fix alignment issues
363
341
  MISALIGNMENTS: {structured misalignments from Evaluate agent}
364
342
  SCOPE: Fix only the listed misalignments, no other changes
365
- <!-- learning:on -->
343
+ <!-- curation:on -->
366
344
  DECISIONS_CONTEXT: {decisions_context}
367
- <!-- learning:end -->
345
+ <!-- curation:end -->
368
346
  {COMPLIANCE_DIRECTIVE}"
369
347
  ```
370
348
  - Loop back to Phase 5 (re-check alignment). The fix is not validated here: the Phase 6 run covers it.
@@ -373,13 +351,15 @@ Validate alignment with request and plan. Report ALIGNED or MISALIGNED with deta
373
351
  ### Phase 6: Validate
374
352
 
375
353
  **Produces:** VALIDATION_RESULT, VALIDATED_HEAD
376
- **Requires:** BASE_BRANCH
354
+ **Requires:** BASE_REF, GATE_LEVEL
377
355
 
378
- Validate takes the one full-suite slot, after every commit it must cover: Code, Polish, Harden and the alignment fixes. After Evaluate agent passes, spawn Validate agent. `FILES_CHANGED` is the branch diff, because the Code agent's own list misses the Polish, Harden and fix commits (`{base}` is `BASE_BRANCH`):
356
+ Validate takes the one full-suite slot, after every commit it must cover: Code, Polish, Harden and the alignment fixes. After Evaluate agent passes, spawn Validate agent. `FILES_CHANGED` is the branch diff:
379
357
 
380
358
  ```
381
359
  Agent(subagent_type="Validate"):
382
- "FILES_CHANGED: {output of `git diff --name-only {base}...HEAD`}
360
+ "GATE_LEVEL: {GATE_LEVEL}
361
+ BASE_SHA: {BASE_REF}
362
+ FILES_CHANGED: {branch_diff}
383
363
  VALIDATION_SCOPE: full
384
364
  Run build, typecheck, lint, test. Report pass/fail with failure details."
385
365
  ```
@@ -396,9 +376,9 @@ Run build, typecheck, lint, test. Report pass/fail with failure details."
396
376
  TASK_DESCRIPTION: Fix validation failures
397
377
  VALIDATION_FAILURES: {parsed failures from Validate agent}
398
378
  SCOPE: Fix only the listed failures, no other changes
399
- <!-- learning:on -->
379
+ <!-- curation:on -->
400
380
  DECISIONS_CONTEXT: {decisions_context}
401
- <!-- learning:end -->
381
+ <!-- curation:end -->
402
382
  {COMPLIANCE_DIRECTIVE}"
403
383
  ```
404
384
  - Loop back to Phase 6 (re-validate at the new HEAD, full scope)
@@ -420,7 +400,7 @@ Run build, typecheck, lint, test. Report pass/fail with failure details."
420
400
  ### Phase 7: QA Testing
421
401
 
422
402
  **Produces:** QA_RESULT
423
- **Requires:** FILES_CHANGED, EXECUTION_PLAN, TEST_PLAN, VALIDATED_HEAD
403
+ **Requires:** BASE_REF, EXECUTION_PLAN, TEST_PLAN, VALIDATED_HEAD
424
404
 
425
405
  After Phase 6 passes, spawn Test agent for scenario-based acceptance testing:
426
406
 
@@ -428,7 +408,7 @@ After Phase 6 passes, spawn Test agent for scenario-based acceptance testing:
428
408
  Agent(subagent_type="Test"):
429
409
  "ORIGINAL_REQUEST: {task description or issue content}
430
410
  EXECUTION_PLAN: {execution plan from Phase 1}
431
- FILES_CHANGED: {list of files from Code agent output}
411
+ FILES_CHANGED: {branch_diff}
432
412
  ACCEPTANCE_CRITERIA: {extracted criteria if available}
433
413
  TEST_PLAN: {the TP lines of the evidence file's ## Test Plan section, or (none)}
434
414
  Design and execute scenario-based acceptance tests. Report PASS or FAIL with evidence."
@@ -450,9 +430,9 @@ After every Test agent run — PASS or FAIL, first run or retry — append its T
450
430
  TASK_DESCRIPTION: Fix QA test failures
451
431
  QA_FAILURES: {structured failures from Test agent}
452
432
  SCOPE: Fix only the listed failures, no other changes
453
- <!-- learning:on -->
433
+ <!-- curation:on -->
454
434
  DECISIONS_CONTEXT: {decisions_context}
455
- <!-- learning:end -->
435
+ <!-- curation:end -->
456
436
  {COMPLIANCE_DIRECTIVE}"
457
437
  ```
458
438
  - Loop back to Phase 7 (re-run Test agent). The fix is not validated here: Phase 8 covers it.
@@ -467,7 +447,7 @@ Run this phase only if a qa-fix committed (`git rev-parse HEAD` differs from `VA
467
447
 
468
448
  ```
469
449
  Agent(subagent_type="Validate"):
470
- "FILES_CHANGED: {output of `git diff --name-only VALIDATED_HEAD..HEAD`}
450
+ "FILES_CHANGED: {output of `git diff --name-only --diff-filter=d VALIDATED_HEAD..HEAD`}
471
451
  VALIDATION_SCOPE: changed-only
472
452
  Verify the qa-fix commits did not break anything."
473
453
  ```
@@ -479,21 +459,22 @@ Verify the qa-fix commits did not break anything."
479
459
  ### Phase 9: Open PR
480
460
 
481
461
  **Produces:** PR_NUMBER
482
- **Requires:** BASE_BRANCH, TASK_ID, ISSUE_NUMBER, ISSUE_PR_LINK, PR_EXCEPTIONS, PR_TEST_PLAN_BLOCK, PR_DESCRIPTION_GUIDANCE, APPLY_CONVENTIONS, CODE_AGENT_OUTPUT
462
+ **Requires:** BASE_BRANCH, BASE_REF, TASK_ID, ISSUE_NUMBER, ISSUE_PR_LINK, PR_EXCEPTIONS, PR_TEST_PLAN_BLOCK, PR_DESCRIPTION_GUIDANCE, APPLY_CONVENTIONS, CODE_AGENT_OUTPUT
483
463
 
484
- Run once, after the gates, under every strategy. This phase sits outside the strategy branches, so no run reaches the end with commits and no PR. No Code agent opens a PR: the Git agent does, and it pastes `ISSUE_PR_LINK`, `PR_EXCEPTIONS` and `PR_TEST_PLAN_BLOCK` through their paste gates and scrubs the body (D11) before `gh pr create`. This command renders no link line and creates no PR itself: the Git agent's Phase-1 rendering is the only one, forwarded verbatim.
464
+ Run once, after the gates, under every strategy. No Code agent opens a PR: the Git agent does, and it pastes `ISSUE_PR_LINK`, `PR_EXCEPTIONS` and `PR_TEST_PLAN_BLOCK` through their paste gates and scrubs the body (D11) before `gh pr create`. This command renders no link line and creates no PR itself: the Git agent's Phase-1 rendering is the only one, forwarded verbatim.
485
465
 
486
466
  ```
487
467
  Agent(subagent_type="Git"):
488
468
  "OPERATION: ensure-pr-ready
489
469
  WORKTREE_PATH: {worktree}
490
470
  BASE_BRANCH: {base branch}
471
+ BASE_REF: {BASE_REF}
491
472
  TASK_ID: {task-id}
492
473
  ISSUE_NUMBER: {ISSUE_ID captured in Phase 1, or (none)}
493
474
  ISSUE_PR_LINK: {ISSUE_PR_LINK captured in Phase 1, or (none)}
494
475
  PR_EXCEPTIONS: {the ## Evidence Exceptions section of {worktree}/.devflow/docs/handoff-{branch_slug}.md verbatim, or (none)}
495
476
  PR_TEST_PLAN_BLOCK: {PR_TEST_PLAN_BLOCK verbatim, or (none)}
496
- PR_DESCRIPTION_GUIDANCE: {pr_description_guidance from Phase 1 unless it is (none), then the Code agents' reports from CODE_AGENT_OUTPUT in spawn order — Implementation, Commits and Key Decisions, and a sequential agent's ## Phase {N} Implementation Summary}
477
+ PR_DESCRIPTION_GUIDANCE: {pr_description_guidance from Phase 1 unless it is (none), then the Code agents' reports from CODE_AGENT_OUTPUT in spawn order — Implementation, Commits and Key Decisions, and a sequential agent's ## Phase {N} Implementation Summary, then Validate's `Lint pack:` line if UNVERIFIED, for Testing}
497
478
  APPLY_CONVENTIONS: {APPLY_CONVENTIONS}
498
479
  COMMIT_UNCOMMITTED: false
499
480
  Open the pull request for this branch and return the pre-flight summary."
@@ -522,11 +503,11 @@ git push origin HEAD; echo "exit=$?"
522
503
  3. **If NO_PR or NO_CI** → skip: "No PR/CI configured, skipping CI validation." Proceed to Phase 11.
523
504
  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.
524
505
  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.
525
- <!-- learning:on -->
506
+ <!-- curation:on -->
526
507
  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.
527
- <!-- learning:off -->
508
+ <!-- curation:off -->
528
509
  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.
529
- <!-- learning:end -->
510
+ <!-- curation:end -->
530
511
  7. **Budget**: at most 3 waits and 2 fixes in all. When one is spent, report the current status and proceed.
531
512
  <!-- /PATTERN: ci-status-gate -->
532
513
 
@@ -535,7 +516,7 @@ git push origin HEAD; echo "exit=$?"
535
516
  **Produces:** EVIDENCE_RESULT
536
517
  **Requires:** PR_NUMBER, EVIDENCE_FILE, REVIEW_PUBLICATION
537
518
 
538
- Run once, after Phase 10, under every strategy: the PR exists by now, opened in Phase 9. The re-validation path has no CI gate and runs this phase straight after Phase 9. Skip it only when Phase 9 stopped the run. A `ci` TP reads `INDETERMINATE` only when the CI gate could not tell or did not run.
519
+ Run once, after Phase 10, under every strategy. Skip it only when Phase 9 stopped the run. A `ci` TP reads `INDETERMINATE` only when the CI gate could not tell or did not run.
539
520
 
540
521
  **Push first.** Every claim is keyed to the HEAD an agent reported, and a Harden or Fix agent may have committed without pushing; a claim whose SHA is not in the PR reads `UNVERIFIED`. So push the branch once before the script — never force, and no retry:
541
522
 
@@ -555,30 +536,27 @@ Drop the `--evidence` pair when that file does not exist or its path does not ma
555
536
 
556
537
  ### Phase 12: Report
557
538
 
558
- **Requires:** VALIDATION_RESULT, ALIGNMENT_RESULT, QA_RESULT, PR_NUMBER, EVIDENCE_RESULT
539
+ **Requires:** VALIDATION_RESULT, ALIGNMENT_RESULT, QA_RESULT, PR_NUMBER, EVIDENCE_RESULT, GATE_LEVEL
559
540
 
560
- Display completion summary with phase status, PR info, and next steps.
541
+ Display completion summary with phase status, `Gate level: {GATE_LEVEL}` with any level note, Validate's `Lint pack:` line if any, PR info, and next steps.
561
542
 
562
543
  Show the test plan's evidence from Phase 11: `Test plan: {VERIFIED-CI + ATTESTED-LOCAL}/{total} verified (VERIFIED-CI {n}, ATTESTED-LOCAL {n})`, read from the `EVIDENCE` line and never inferred, then its `**Body**:` / `**Comment**:` line verbatim. Without an `EVIDENCE` line, show `Test plan: evidence unavailable`; with no test plan, `Test plan: missing`.
563
544
 
564
- If any Git agent output emitted `TRACEABILITY: DEGRADED ({reason})` lines during the run, or Phase 10's push, Phase 11's push or Phase 11's script output carried one, surface them verbatim in the report under a `### Traceability` subsection so the user can act on them.
545
+ If any Git agent output emitted `TRACEABILITY: DEGRADED ({reason})` lines during the run, or the fresh base step, Phase 10's push, Phase 11's push or Phase 11's script output carried one, surface them verbatim in the report under a `### Traceability` subsection so the user can act on them.
565
546
 
566
547
  If Phase 9 listed uncommitted files, show them as a `### Uncommitted files` subsection: the user commits them or discards them.
567
548
 
568
549
  If Phase 1 recorded an evidence exception, show its `## Evidence Exceptions` lines in the report.
569
550
 
570
- {{knowledge_writeback()}}
551
+ {{knowledge_writeback_after_load()}}
571
552
 
572
553
  ## Architecture
573
554
 
574
555
  ```
575
- /implement (orchestrator - spawns agents only)
576
- │
577
- ├─ Re-validation Path (when user says "re-validate"/"re-check"/"re-run gates")
578
- │ └─ Branch safety → skip Phase 2 → detect FILES_CHANGED → Phases 3-8 → Phase 9, 11, 12
556
+ /implement
579
557
  │
580
558
  ├─ Phase 1: Setup
581
- ├─ Phase 2: Implement (3-strategy framework)
559
+ ├─ Phase 2: Implement
582
560
  ├─ Phase 3: Polish
583
561
  ├─ Phase 4: Self-Review
584
562
  ├─ Phase 5: Alignment Check
@@ -587,7 +565,7 @@ If Phase 1 recorded an evidence exception, show its `## Evidence Exceptions` lin
587
565
  ├─ Phase 8: Re-Validate (only if a qa-fix committed)
588
566
  ├─ Phase 9: Open PR (every strategy, outside the strategy branches)
589
567
  ├─ Phase 10: CI Status Gate (every strategy)
590
- ├─ Phase 11: Evidence (every strategy, once the PR exists)
568
+ ├─ Phase 11: Evidence (every strategy)
591
569
  ├─ Phase 12: Report
592
570
  │
593
571
  └─ Feature Knowledge Write-Back (Conditional)
@@ -595,15 +573,11 @@ If Phase 1 recorded an evidence exception, show its `## Evidence Exceptions` lin
595
573
 
596
574
  ## Principles
597
575
 
598
- 1. **Orchestration only** - Command spawns agents, never does work itself; the inline calls are the bounded plumbing the charter allows: the Phase 10 and Phase 11 pushes, the Phase 10 ci-wait call, the Phase 11 evidence publish call and the evidence script checks
599
- 2. **Agent ownership** - Each agent owns its output completely
600
- 3. **Honest reporting** - Display agent outputs directly
601
- 4. **Strict delegation** - Never perform agent work in main session. "Spawn X" means call Agent tool with X, not do X's work yourself
602
- 5. **Validate agent owns validation** - Never run `npm test`, `npm run build`, or similar in main session; always delegate to Validate agent
603
- 6. **Fix agent owns fixes** - Never implement fixes in main session; spawn Fix agent for validation failures and alignment fixes
604
- 7. **Loop limits** - Max 2 validation retries, max 2 alignment fix iterations, max 2 QA retries before escalating to user; the CI gate allows at most 3 waits and 2 fixes
605
- 8. **CI awareness** - CI status is checked before merge under every strategy, once Phase 9 has opened the PR; test-plan evidence (Phase 11) is recorded under every strategy once the PR exists
576
+ 1. **Orchestration only** - Command spawns agents, never does work itself (no tests, builds or fixes); "Spawn X" means call the Agent tool; the inline calls are the bounded plumbing the charter allows: the fresh base step's resolver calls (Phase 1, re-validation), the Phase 10 and 11 pushes, the Phase 10 ci-wait call, the Phase 11 evidence publish call and the evidence script checks
577
+ 2. **Honest reporting** - Display agent outputs directly
578
+ 3. **Loop limits** - Max 2 validation retries, max 2 alignment fix iterations, max 2 QA retries before escalating to user; the CI gate allows at most 3 waits and 2 fixes
579
+ 4. **CI awareness** - CI status is checked before merge; test-plan evidence (Phase 11) is recorded under every strategy
606
580
 
607
581
  ## Error Handling
608
582
 
609
- If any agent fails, report the phase, agent type, and error. Offer options: retry phase, investigate systematically, or escalate to user.
583
+ If any agent fails, report the phase, agent type and error. Offer: retry the phase, investigate, or escalate to user.