cclaw-cli 7.7.1 → 8.1.1

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 (284) hide show
  1. package/README.md +211 -134
  2. package/dist/artifact-frontmatter.d.ts +51 -0
  3. package/dist/artifact-frontmatter.js +131 -0
  4. package/dist/artifact-paths.d.ts +7 -27
  5. package/dist/artifact-paths.js +20 -249
  6. package/dist/cancel.d.ts +16 -0
  7. package/dist/cancel.js +66 -0
  8. package/dist/cli.d.ts +2 -27
  9. package/dist/cli.js +107 -511
  10. package/dist/compound.d.ts +26 -0
  11. package/dist/compound.js +96 -0
  12. package/dist/config.d.ts +14 -51
  13. package/dist/config.js +23 -359
  14. package/dist/constants.d.ts +11 -18
  15. package/dist/constants.js +19 -106
  16. package/dist/content/antipatterns.d.ts +1 -0
  17. package/dist/content/antipatterns.js +109 -0
  18. package/dist/content/artifact-templates.d.ts +10 -0
  19. package/dist/content/artifact-templates.js +550 -0
  20. package/dist/content/cancel-command.d.ts +2 -2
  21. package/dist/content/cancel-command.js +25 -17
  22. package/dist/content/core-agents.d.ts +9 -233
  23. package/dist/content/core-agents.js +39 -768
  24. package/dist/content/decision-protocol.d.ts +1 -12
  25. package/dist/content/decision-protocol.js +27 -20
  26. package/dist/content/examples.d.ts +8 -42
  27. package/dist/content/examples.js +293 -425
  28. package/dist/content/idea-command.d.ts +2 -0
  29. package/dist/content/idea-command.js +38 -0
  30. package/dist/content/iron-laws.d.ts +4 -138
  31. package/dist/content/iron-laws.js +18 -197
  32. package/dist/content/meta-skill.d.ts +1 -3
  33. package/dist/content/meta-skill.js +57 -134
  34. package/dist/content/node-hooks.d.ts +12 -8
  35. package/dist/content/node-hooks.js +188 -838
  36. package/dist/content/recovery.d.ts +8 -0
  37. package/dist/content/recovery.js +179 -0
  38. package/dist/content/reference-patterns.d.ts +4 -13
  39. package/dist/content/reference-patterns.js +260 -389
  40. package/dist/content/research-playbooks.d.ts +8 -8
  41. package/dist/content/research-playbooks.js +108 -121
  42. package/dist/content/review-loop.d.ts +6 -192
  43. package/dist/content/review-loop.js +29 -731
  44. package/dist/content/skills.d.ts +8 -38
  45. package/dist/content/skills.js +681 -732
  46. package/dist/content/specialist-prompts/architect.d.ts +1 -0
  47. package/dist/content/specialist-prompts/architect.js +225 -0
  48. package/dist/content/specialist-prompts/brainstormer.d.ts +1 -0
  49. package/dist/content/specialist-prompts/brainstormer.js +168 -0
  50. package/dist/content/specialist-prompts/index.d.ts +2 -0
  51. package/dist/content/specialist-prompts/index.js +14 -0
  52. package/dist/content/specialist-prompts/planner.d.ts +1 -0
  53. package/dist/content/specialist-prompts/planner.js +182 -0
  54. package/dist/content/specialist-prompts/reviewer.d.ts +1 -0
  55. package/dist/content/specialist-prompts/reviewer.js +193 -0
  56. package/dist/content/specialist-prompts/security-reviewer.d.ts +1 -0
  57. package/dist/content/specialist-prompts/security-reviewer.js +133 -0
  58. package/dist/content/specialist-prompts/slice-builder.d.ts +1 -0
  59. package/dist/content/specialist-prompts/slice-builder.js +232 -0
  60. package/dist/content/stage-playbooks.d.ts +8 -0
  61. package/dist/content/stage-playbooks.js +404 -0
  62. package/dist/content/start-command.d.ts +2 -12
  63. package/dist/content/start-command.js +221 -207
  64. package/dist/flow-state.d.ts +21 -178
  65. package/dist/flow-state.js +67 -170
  66. package/dist/fs-utils.d.ts +6 -26
  67. package/dist/fs-utils.js +29 -162
  68. package/dist/gitignore.d.ts +2 -1
  69. package/dist/gitignore.js +51 -34
  70. package/dist/harness-detect.d.ts +10 -0
  71. package/dist/harness-detect.js +29 -0
  72. package/dist/harness-prompt.d.ts +26 -0
  73. package/dist/harness-prompt.js +142 -0
  74. package/dist/install.d.ts +35 -15
  75. package/dist/install.js +238 -1347
  76. package/dist/knowledge-store.d.ts +19 -163
  77. package/dist/knowledge-store.js +56 -590
  78. package/dist/logger.d.ts +8 -3
  79. package/dist/logger.js +13 -4
  80. package/dist/orchestrator-routing.d.ts +29 -0
  81. package/dist/orchestrator-routing.js +156 -0
  82. package/dist/run-persistence.d.ts +7 -118
  83. package/dist/run-persistence.js +29 -845
  84. package/dist/runtime/run-hook.entry.d.ts +1 -3
  85. package/dist/runtime/run-hook.entry.js +19 -4
  86. package/dist/runtime/run-hook.mjs +13 -1024
  87. package/dist/types.d.ts +25 -261
  88. package/dist/types.js +8 -36
  89. package/package.json +6 -3
  90. package/dist/artifact-linter/brainstorm.d.ts +0 -2
  91. package/dist/artifact-linter/brainstorm.js +0 -353
  92. package/dist/artifact-linter/design.d.ts +0 -18
  93. package/dist/artifact-linter/design.js +0 -444
  94. package/dist/artifact-linter/findings-dedup.d.ts +0 -56
  95. package/dist/artifact-linter/findings-dedup.js +0 -232
  96. package/dist/artifact-linter/plan.d.ts +0 -2
  97. package/dist/artifact-linter/plan.js +0 -826
  98. package/dist/artifact-linter/review-army.d.ts +0 -49
  99. package/dist/artifact-linter/review-army.js +0 -520
  100. package/dist/artifact-linter/review.d.ts +0 -2
  101. package/dist/artifact-linter/review.js +0 -113
  102. package/dist/artifact-linter/scope.d.ts +0 -2
  103. package/dist/artifact-linter/scope.js +0 -158
  104. package/dist/artifact-linter/shared.d.ts +0 -637
  105. package/dist/artifact-linter/shared.js +0 -2163
  106. package/dist/artifact-linter/ship.d.ts +0 -2
  107. package/dist/artifact-linter/ship.js +0 -250
  108. package/dist/artifact-linter/spec.d.ts +0 -2
  109. package/dist/artifact-linter/spec.js +0 -176
  110. package/dist/artifact-linter/tdd.d.ts +0 -118
  111. package/dist/artifact-linter/tdd.js +0 -1404
  112. package/dist/artifact-linter.d.ts +0 -15
  113. package/dist/artifact-linter.js +0 -517
  114. package/dist/codex-feature-flag.d.ts +0 -58
  115. package/dist/codex-feature-flag.js +0 -193
  116. package/dist/content/closeout-guidance.d.ts +0 -14
  117. package/dist/content/closeout-guidance.js +0 -44
  118. package/dist/content/diff-command.d.ts +0 -1
  119. package/dist/content/diff-command.js +0 -43
  120. package/dist/content/harness-doc.d.ts +0 -1
  121. package/dist/content/harness-doc.js +0 -65
  122. package/dist/content/hook-events.d.ts +0 -9
  123. package/dist/content/hook-events.js +0 -23
  124. package/dist/content/hook-manifest.d.ts +0 -81
  125. package/dist/content/hook-manifest.js +0 -156
  126. package/dist/content/hooks.d.ts +0 -11
  127. package/dist/content/hooks.js +0 -1972
  128. package/dist/content/idea.d.ts +0 -60
  129. package/dist/content/idea.js +0 -416
  130. package/dist/content/language-policy.d.ts +0 -2
  131. package/dist/content/language-policy.js +0 -13
  132. package/dist/content/learnings.d.ts +0 -6
  133. package/dist/content/learnings.js +0 -141
  134. package/dist/content/observe.d.ts +0 -19
  135. package/dist/content/observe.js +0 -86
  136. package/dist/content/opencode-plugin.d.ts +0 -1
  137. package/dist/content/opencode-plugin.js +0 -635
  138. package/dist/content/review-prompts.d.ts +0 -1
  139. package/dist/content/review-prompts.js +0 -104
  140. package/dist/content/runtime-shared-snippets.d.ts +0 -8
  141. package/dist/content/runtime-shared-snippets.js +0 -80
  142. package/dist/content/session-hooks.d.ts +0 -7
  143. package/dist/content/session-hooks.js +0 -107
  144. package/dist/content/skills-elicitation.d.ts +0 -1
  145. package/dist/content/skills-elicitation.js +0 -167
  146. package/dist/content/stage-command.d.ts +0 -2
  147. package/dist/content/stage-command.js +0 -17
  148. package/dist/content/stage-schema.d.ts +0 -117
  149. package/dist/content/stage-schema.js +0 -955
  150. package/dist/content/stages/_lint-metadata/index.d.ts +0 -2
  151. package/dist/content/stages/_lint-metadata/index.js +0 -97
  152. package/dist/content/stages/brainstorm.d.ts +0 -2
  153. package/dist/content/stages/brainstorm.js +0 -184
  154. package/dist/content/stages/design.d.ts +0 -2
  155. package/dist/content/stages/design.js +0 -288
  156. package/dist/content/stages/index.d.ts +0 -8
  157. package/dist/content/stages/index.js +0 -11
  158. package/dist/content/stages/plan.d.ts +0 -2
  159. package/dist/content/stages/plan.js +0 -191
  160. package/dist/content/stages/review.d.ts +0 -2
  161. package/dist/content/stages/review.js +0 -240
  162. package/dist/content/stages/schema-types.d.ts +0 -203
  163. package/dist/content/stages/schema-types.js +0 -1
  164. package/dist/content/stages/scope.d.ts +0 -2
  165. package/dist/content/stages/scope.js +0 -254
  166. package/dist/content/stages/ship.d.ts +0 -2
  167. package/dist/content/stages/ship.js +0 -159
  168. package/dist/content/stages/spec.d.ts +0 -2
  169. package/dist/content/stages/spec.js +0 -170
  170. package/dist/content/stages/tdd.d.ts +0 -4
  171. package/dist/content/stages/tdd.js +0 -273
  172. package/dist/content/state-contracts.d.ts +0 -1
  173. package/dist/content/state-contracts.js +0 -63
  174. package/dist/content/status-command.d.ts +0 -4
  175. package/dist/content/status-command.js +0 -109
  176. package/dist/content/subagent-context-skills.d.ts +0 -4
  177. package/dist/content/subagent-context-skills.js +0 -279
  178. package/dist/content/subagents.d.ts +0 -3
  179. package/dist/content/subagents.js +0 -997
  180. package/dist/content/templates.d.ts +0 -26
  181. package/dist/content/templates.js +0 -1692
  182. package/dist/content/track-render-context.d.ts +0 -18
  183. package/dist/content/track-render-context.js +0 -53
  184. package/dist/content/tree-command.d.ts +0 -1
  185. package/dist/content/tree-command.js +0 -64
  186. package/dist/content/utility-skills.d.ts +0 -30
  187. package/dist/content/utility-skills.js +0 -160
  188. package/dist/content/view-command.d.ts +0 -2
  189. package/dist/content/view-command.js +0 -92
  190. package/dist/delegation.d.ts +0 -649
  191. package/dist/delegation.js +0 -1539
  192. package/dist/early-loop.d.ts +0 -70
  193. package/dist/early-loop.js +0 -302
  194. package/dist/execution-topology.d.ts +0 -44
  195. package/dist/execution-topology.js +0 -95
  196. package/dist/gate-evidence.d.ts +0 -85
  197. package/dist/gate-evidence.js +0 -631
  198. package/dist/harness-adapters.d.ts +0 -151
  199. package/dist/harness-adapters.js +0 -756
  200. package/dist/harness-selection.d.ts +0 -31
  201. package/dist/harness-selection.js +0 -214
  202. package/dist/hook-schema.d.ts +0 -6
  203. package/dist/hook-schema.js +0 -114
  204. package/dist/hook-schemas/claude-hooks.v1.json +0 -10
  205. package/dist/hook-schemas/codex-hooks.v1.json +0 -10
  206. package/dist/hook-schemas/cursor-hooks.v1.json +0 -13
  207. package/dist/init-detect.d.ts +0 -2
  208. package/dist/init-detect.js +0 -50
  209. package/dist/internal/advance-stage/advance.d.ts +0 -89
  210. package/dist/internal/advance-stage/advance.js +0 -655
  211. package/dist/internal/advance-stage/cancel-run.d.ts +0 -8
  212. package/dist/internal/advance-stage/cancel-run.js +0 -19
  213. package/dist/internal/advance-stage/flow-state-coercion.d.ts +0 -3
  214. package/dist/internal/advance-stage/flow-state-coercion.js +0 -81
  215. package/dist/internal/advance-stage/helpers.d.ts +0 -14
  216. package/dist/internal/advance-stage/helpers.js +0 -145
  217. package/dist/internal/advance-stage/hook.d.ts +0 -8
  218. package/dist/internal/advance-stage/hook.js +0 -40
  219. package/dist/internal/advance-stage/parsers.d.ts +0 -72
  220. package/dist/internal/advance-stage/parsers.js +0 -357
  221. package/dist/internal/advance-stage/proactive-delegation-trace.d.ts +0 -24
  222. package/dist/internal/advance-stage/proactive-delegation-trace.js +0 -56
  223. package/dist/internal/advance-stage/review-loop.d.ts +0 -16
  224. package/dist/internal/advance-stage/review-loop.js +0 -199
  225. package/dist/internal/advance-stage/rewind.d.ts +0 -14
  226. package/dist/internal/advance-stage/rewind.js +0 -108
  227. package/dist/internal/advance-stage/start-flow.d.ts +0 -13
  228. package/dist/internal/advance-stage/start-flow.js +0 -241
  229. package/dist/internal/advance-stage/verify.d.ts +0 -21
  230. package/dist/internal/advance-stage/verify.js +0 -185
  231. package/dist/internal/advance-stage.d.ts +0 -7
  232. package/dist/internal/advance-stage.js +0 -138
  233. package/dist/internal/cohesion-contract-stub.d.ts +0 -24
  234. package/dist/internal/cohesion-contract-stub.js +0 -148
  235. package/dist/internal/compound-readiness.d.ts +0 -23
  236. package/dist/internal/compound-readiness.js +0 -102
  237. package/dist/internal/detect-public-api-changes.d.ts +0 -5
  238. package/dist/internal/detect-public-api-changes.js +0 -45
  239. package/dist/internal/detect-supply-chain-changes.d.ts +0 -6
  240. package/dist/internal/detect-supply-chain-changes.js +0 -138
  241. package/dist/internal/early-loop-status.d.ts +0 -7
  242. package/dist/internal/early-loop-status.js +0 -93
  243. package/dist/internal/envelope-validate.d.ts +0 -7
  244. package/dist/internal/envelope-validate.js +0 -66
  245. package/dist/internal/flow-state-repair.d.ts +0 -20
  246. package/dist/internal/flow-state-repair.js +0 -104
  247. package/dist/internal/plan-split-waves.d.ts +0 -190
  248. package/dist/internal/plan-split-waves.js +0 -764
  249. package/dist/internal/runtime-integrity.d.ts +0 -7
  250. package/dist/internal/runtime-integrity.js +0 -268
  251. package/dist/internal/slice-commit.d.ts +0 -7
  252. package/dist/internal/slice-commit.js +0 -619
  253. package/dist/internal/tdd-loop-status.d.ts +0 -14
  254. package/dist/internal/tdd-loop-status.js +0 -68
  255. package/dist/internal/tdd-red-evidence.d.ts +0 -7
  256. package/dist/internal/tdd-red-evidence.js +0 -153
  257. package/dist/internal/waiver-grant.d.ts +0 -62
  258. package/dist/internal/waiver-grant.js +0 -294
  259. package/dist/internal/wave-status.d.ts +0 -74
  260. package/dist/internal/wave-status.js +0 -506
  261. package/dist/managed-resources.d.ts +0 -53
  262. package/dist/managed-resources.js +0 -313
  263. package/dist/policy.d.ts +0 -10
  264. package/dist/policy.js +0 -167
  265. package/dist/retro-gate.d.ts +0 -9
  266. package/dist/retro-gate.js +0 -47
  267. package/dist/run-archive.d.ts +0 -61
  268. package/dist/run-archive.js +0 -391
  269. package/dist/runs.d.ts +0 -2
  270. package/dist/runs.js +0 -2
  271. package/dist/stack-detection.d.ts +0 -116
  272. package/dist/stack-detection.js +0 -489
  273. package/dist/streaming/event-stream.d.ts +0 -31
  274. package/dist/streaming/event-stream.js +0 -114
  275. package/dist/tdd-cycle.d.ts +0 -107
  276. package/dist/tdd-cycle.js +0 -289
  277. package/dist/tdd-verification-evidence.d.ts +0 -17
  278. package/dist/tdd-verification-evidence.js +0 -122
  279. package/dist/track-heuristics.d.ts +0 -27
  280. package/dist/track-heuristics.js +0 -154
  281. package/dist/util/slice-id.d.ts +0 -58
  282. package/dist/util/slice-id.js +0 -89
  283. package/dist/worktree-manager.d.ts +0 -20
  284. package/dist/worktree-manager.js +0 -108
@@ -1,1692 +0,0 @@
1
- import { CCLAW_VERSION, SHIP_FINALIZATION_MODES } from "../constants.js";
2
- import { renderBehaviorAnchorTemplateLine } from "./examples.js";
3
- import { orderedStageSchemas } from "./stage-schema.js";
4
- import { FLOW_STAGES } from "../types.js";
5
- const SHIP_FINALIZATION_ENUM_LINES = SHIP_FINALIZATION_MODES.map((mode) => ` - ${mode}`).join("\n");
6
- const MARKDOWN_CODE_FENCE = "```";
7
- function artifactFrontmatter(stage) {
8
- return `---
9
- stage: ${stage}
10
- schema_version: 1
11
- version: ${CCLAW_VERSION}
12
- run: <run-id>
13
- locked_decisions: []
14
- inputs_hash: sha256:pending
15
- ---`;
16
- }
17
- const SEED_SHELF_SECTION = `## Seed Shelf Candidates (optional)
18
- | Seed file | Trigger when | Suggested action | Status (planted/deferred/ignored) |
19
- |---|---|---|---|
20
- | .cclaw/seeds/SEED-YYYY-MM-DD-<slug>.md | | | |`;
21
- /**
22
- * Shared investigation discipline block. Rendered once per
23
- * elicitation/spec stage skill (brainstorm, scope, design, spec, plan, tdd,
24
- * review). The block enforces a four-step ladder before drafting and a
25
- * path-passing rule for delegations so token cost and "jumped into code"
26
- * regressions stay bounded. Stop-trigger count and ladder-step count are
27
- * verified by `tests/unit/investigation-discipline-block.test.ts`.
28
- */
29
- export const INVESTIGATION_DISCIPLINE_BLOCK = `## Investigation Discipline
30
-
31
- Use this ladder before drafting or delegating; do not jump straight to the editor.
32
-
33
- 1. **Search** — locate the surface (file path, symbol, ref) before reading. Use \`rg\` / glob / graph; record the query, not the chunk.
34
- 2. **Graph / impact** — name what the change touches (callers, callees, tests, configs) and its blast radius before opening a file.
35
- 3. **Narrow read** — read at most 1-3 files, only the sections needed; cite paths with \`:line\` ranges instead of pasting bodies.
36
- 4. **Draft** — only after the trace exists; the trace is the authority, not chat history or memory.
37
-
38
- **Path-passing in delegations.** When delegating, pass repo-relative paths and refs (e.g. \`src/foo/bar.ts:42\`, \`D-12\`, \`AC-3\`) — never the file body. The subagent re-reads from path; pasting content fragments breaks freshness and inflates tokens.
39
-
40
- **Stop triggers** (any one means halt and re-enter the ladder):
41
-
42
- - You are about to read more than 3 files in one pass.
43
- - You are about to load file content into a delegation prompt instead of paths or refs.
44
- - You are about to start a draft before any trace (search log, graph note, narrow-read citation) exists.
45
- `;
46
- export const ARTIFACT_TEMPLATES = {
47
- "01-brainstorm.md": `${artifactFrontmatter("brainstorm")}
48
-
49
- # Brainstorm Artifact
50
-
51
- ${renderBehaviorAnchorTemplateLine("brainstorm")}
52
-
53
- ## Mode Block
54
- - **Mode:** STARTUP | BUILDER | ENGINEERING | OPS | RESEARCH (pick exactly one)
55
- - **Why this mode:** (one line; cite a concrete signal — repo state, user prompt, ownership, risk window)
56
-
57
- ## Context
58
- - **Project state:**
59
- - **Relevant existing code/patterns:**
60
-
61
- ### Discovered context
62
- - (paths, prior artifacts, seeds, prompt fragments — referenced by downstream stages, or \`- None.\`)
63
-
64
- ## Reference Pattern Candidates
65
- | Pattern / source | Reusable invariant | Disposition (accept/reject/defer) | Why |
66
- |---|---|---|---|
67
- | | | | |
68
-
69
- ## Idea Evidence Carry-forward
70
- > Required only when this brainstorm started from \`/cc-ideate\` (\`flow-state.interactionHints.brainstorm.fromIdeaArtifact\` is set). Skip the section entirely otherwise.
71
- - Source: \`<.cclaw/ideas/idea-YYYY-MM-DD-slug.md>\`
72
- - Candidate: \`I-#\`
73
- - Reused fields: Title, Why-now, Expected impact, Risk, Counter-argument
74
- - Newly generated: challenger row(s) only — the idea candidate becomes the \`baseline\` row of \`## Approaches\` and the seed of \`## Selected Direction\`; do NOT regenerate divergent + critique + rank work that \`/cc-ideate\` already produced.
75
-
76
- ## Problem Decision Record
77
- - **Depth:** lite | standard | deep
78
- - **Frame type:** \`<free-form-label>\` (one short token that names how this work is framed; pick whatever fits — examples in commentary only: \`product\`, \`technical-maintenance\`, \`research-spike\`, \`ops-incident\`, \`infrastructure\`, \`library-extraction\`. Do NOT treat the examples as an enum.)
79
-
80
- ### Framing fields (universal — keep field names; fill in whatever is meaningful for this work)
81
- - **Affected user / role / operator:** (who experiences the problem or carries the consequence)
82
- - **Current state / failure mode / opportunity:** (what is happening today)
83
- - **Desired outcome (observable):** (what changes when this work lands; phrase so a test or operator could verify)
84
- - **Evidence / signal supporting this framing:** (citation, metric, ticket, prior artifact, repo path, or \`- None.\`)
85
- - **Why now (urgency / cost of waiting):**
86
- - **Do-nothing consequence:** (concrete — not "nothing happens")
87
- - **Non-goals:**
88
-
89
- ## Premise Check
90
- - **Right problem?** (yes/no + one-line justification — take a position)
91
- - **Direct path?** (yes/no + one-line justification)
92
-
93
- ## How Might We
94
- - *How might we …?* — one line naming the user, the desired outcome, and the binding constraint.
95
-
96
- ## Clarity Gate
97
- - Ambiguity score (0.00-1.00):
98
- - Decision boundaries (what this stage will decide):
99
- - Reaffirmed non-goals:
100
- - Residual-risk handoff to scope:
101
-
102
- ## Sharpening Questions
103
- > Ask one decision-changing question at a time. For concrete early exits, record \`None - early exit\` with rationale.
104
- | # | Question | Answer / Assumption | Decision impact |
105
- |---|---|---|---|
106
- | 1 | | | |
107
-
108
- ## Clarifying Questions
109
- | # | Question | Answer | Decision impact |
110
- |---|---|---|---|
111
- | 1 | | | |
112
-
113
- ## Q&A Log
114
- | Turn | Question | User answer (1-line) | Decision impact |
115
- |---|---|---|---|
116
- | 1 | | | scope-shaping [topic:pain] |
117
-
118
- > Append-only by turn. Add one row after each user answer; do not rewrite prior rows.
119
- > **Topic tag is MANDATORY for forcing-question rows.** Stamp \`[topic:<id>]\` in the \`Decision impact\` cell so the linter can verify coverage in any natural language (RU/EN/UA/etc.). Brainstorm IDs: \`pain\`, \`direct-path\`, \`operator\`, \`no-go\`. Multiple tags allowed when one answer covers several topics. Stop-signal rows do NOT need a tag. The counterfactual \`do-nothing\` topic is intentionally absent — Do-nothing consequence lives in the Problem Decision Record.
120
-
121
- ## Approach Tier
122
- - Tier: lite | standard | deep
123
- - Why this tier:
124
-
125
- ## Short-Circuit Decision
126
- - Status: bypassed
127
- - Why:
128
- - Scope handoff:
129
-
130
- ## Approaches
131
- | Approach | Role | Upside | Architecture | Trade-offs | Reuses / reference pattern | Recommendation |
132
- |---|---|---|---|---|---|---|
133
- | A | baseline | modest | | | | |
134
- | B | challenger | high | | | | |
135
-
136
- > Role values: \`baseline\` | \`challenger\` | \`wild-card\`. Upside values: \`low\` | \`modest\` | \`high\` | \`higher\`. Exactly one row must be a \`challenger\` with \`high\` or \`higher\` upside.
137
-
138
- ### Approach Detail Cards
139
- > Required structural form per approach (≥2). One block per row above:
140
-
141
- #### APPROACH A
142
- - Summary:
143
- - Effort:
144
- - Risk:
145
- - Pros:
146
- - Cons:
147
- - Reuses:
148
-
149
- #### APPROACH B
150
- - Summary:
151
- - Effort:
152
- - Risk:
153
- - Pros:
154
- - Cons:
155
- - Reuses:
156
-
157
- RECOMMENDATION: <approach letter — one-line rationale, traced to forcing-question answers and premise list>
158
-
159
- ## Outside Voice (optional)
160
- - source: <model id | critic agent | human reviewer> | (or \`- not used.\`)
161
- - prompt:
162
- - tension:
163
- - resolution:
164
-
165
- ## Approach Reaction
166
- - Closest option:
167
- - Concerns:
168
- - What changed after reaction:
169
-
170
- ## Selected Direction
171
- - **Approach:**
172
- - **Rationale:** Trace this to the prior Approach Reaction.
173
- - **Approval:** pending
174
- - **Next-stage handoff:** On standard track, hand this to \`scope\`; on medium track, hand this directly to \`spec\`. Include upstream decisions used, drift, confidence, unresolved questions, risk hints, and non-goals.
175
-
176
- ## Embedded Grill
177
- | Question | Recommended answer | Disposition (accept/refine/reject) |
178
- |---|---|---|
179
- | | | |
180
-
181
- ## Not Doing
182
- - (3-5 things this brainstorm is *not* committing to — distinct from \`Deferred\`. These will not appear in scope unless the user explicitly opts in.)
183
-
184
- ${SEED_SHELF_SECTION}
185
-
186
- ## Design
187
- - **Architecture:**
188
- - **Key components:**
189
- - **Data flow:**
190
-
191
- ## Visual Companion
192
- - (compact ASCII/Mermaid diagram for medium+ complexity, or one-line justification for omission.)
193
-
194
- ## Self-Review Notes
195
- - Status: Approved
196
- - Patches applied:
197
- - None
198
- - Remaining concerns:
199
- - None
200
-
201
- ## Assumptions and Open Questions
202
- - **Assumptions:**
203
- - **Open questions (or "None"):**
204
-
205
- ## Victory Detector
206
- - Loop status file: \`.cclaw/state/early-loop.json\`
207
- - Iteration: <n>/<maxIterations>
208
- - Open concerns: <count>
209
- - Convergence guard: clear | tripped
210
- - Decision: iterate | ready_for_advance | escalate_for_human_override
211
-
212
- ## Critic Pass
213
- After each producer iteration append one JSON line to \`.cclaw/state/early-loop-log.jsonl\`:
214
-
215
- ${MARKDOWN_CODE_FENCE}json
216
- {"ts":"<ISO-8601>","runId":"<run-id>","stage":"brainstorm","iteration":1,"concerns":[{"id":"C-1","severity":"important","locator":"Approaches > Row 2","summary":"<specific concern>"}],"resolvedConcernIds":[]}
217
- ${MARKDOWN_CODE_FENCE}
218
-
219
- - \`concerns\` lists unresolved concerns after this pass.
220
- - Keep concern IDs stable across iterations so convergence checks stay meaningful.
221
- - Include \`resolvedConcernIds\` when a previously open concern is explicitly closed.
222
-
223
- ## Learnings
224
- - None this stage.
225
- `,
226
- "02-scope.md": `${artifactFrontmatter("scope")}
227
-
228
- # Scope Artifact
229
-
230
- ${renderBehaviorAnchorTemplateLine("scope")}
231
-
232
- ## Upstream Handoff
233
- - Source artifacts: \`00-idea.md\`, \`01-brainstorm-<slug>.md\`
234
- - Decisions carried forward:
235
- - Constraints carried forward:
236
- - Open questions:
237
- - Drift from upstream (or \`None\`):
238
-
239
- ## Q&A Log
240
- | Turn | Question | User answer (1-line) | Decision impact |
241
- |---|---|---|---|
242
- | 1 | | | scope-shaping [topic:in-out] |
243
-
244
- > Append-only by turn. Add one row after each user answer; do not rewrite prior rows.
245
- > **Topic tag is MANDATORY for forcing-question rows.** Stamp \`[topic:<id>]\` in the \`Decision impact\` cell so the linter can verify coverage in any natural language (RU/EN/UA/etc.). Scope IDs: \`in-out\`, \`locked-upstream\`, \`rollback\`, \`failure-modes\`. Multiple tags allowed when one answer covers several topics. Stop-signal rows do NOT need a tag.
246
-
247
- ## Pre-Scope System Audit
248
- | Check | Command | Findings |
249
- |---|---|---|
250
- | Recent commits | \`git log -30 --oneline\` | |
251
- | Current diff | \`git diff --stat\` | |
252
- | Stash state | \`git stash list\` | |
253
- | Debt markers | \`rg -n "TODO|FIXME|XXX|HACK"\` | |
254
-
255
- ## Prime Directives
256
- - Zero silent failures:
257
- - Every error has a name:
258
- - Four paths per data flow:
259
-
260
- ## Premise Drift
261
- > Optional. Brainstorm OWNS the premise check. Record \`None\` unless scope-stage Q&A surfaced new evidence (constraint, user signal, regulatory change) that materially changes brainstorm's \`## Premise Check\` answer.
262
-
263
- | Brainstorm question | New evidence (scope-stage) | Drift verdict (no-change / shift / reverse) | Action |
264
- |---|---|---|---|
265
- | (cite brainstorm Q) | | | |
266
-
267
- - Default: \`Drift: None — brainstorm Premise Check stands.\`
268
-
269
- ## Scope Contract
270
- - **Selected mode:** HOLD SCOPE | SELECTIVE EXPANSION | SCOPE EXPANSION | SCOPE REDUCTION
271
- - **In scope:**
272
- - **Out of scope:**
273
- - **Requirements:**
274
- - **Locked decisions:**
275
- - **Discretion areas:**
276
- - **Deferred ideas:**
277
- - **Accepted reference ideas:**
278
- - **Rejected reference ideas:**
279
- - **Constraints (external/regulatory/system/integration):** (spec carries these forward — do NOT restate as assumptions)
280
- - **Success definition:**
281
- - **Design handoff:** (name what design must decide: architecture-tier, framework, data-model, etc. — design OWNS the architecture choice)
282
-
283
- ## Decision Drivers
284
- | Driver | Weight (1-5) | Option A | Option B | Option C | Notes |
285
- |---|---|---|---|---|---|
286
- | Value impact | | | | | |
287
- | Risk reduction | | | | | |
288
- | Reversibility | | | | | |
289
- | Delivery effort | | | | | |
290
- | Timeline fit | | | | | |
291
-
292
- ## Scope Completeness Score
293
- - Score (0.00-1.00):
294
- - What is still uncertain:
295
- - Blockers requiring escalation:
296
-
297
- ## Scope Mode
298
- - [ ] SCOPE EXPANSION — explore ambitious alternatives; user explicitly opts into the larger product slice.
299
- - [ ] SELECTIVE EXPANSION — hold baseline scope and cherry-pick one high-leverage addition.
300
- - [ ] HOLD SCOPE — preserve the approved brainstorm direction with maximum rigor.
301
- - [ ] SCOPE REDUCTION — strip to the smallest useful wedge when risk/blast radius is too high.
302
-
303
- ## Mode-Specific Analysis
304
- | Selected mode | Rationale | Depth |
305
- |---|---|---|
306
- | | | lite / standard / deep |
307
-
308
- > Default path: one selected-mode row plus rationale. Deep/high-risk scope may expand with optional evidence headings below.
309
-
310
- ## Landscape Check
311
- - Optional for EXPAND/SELECTIVE/deep; omit for compact HOLD SCOPE.
312
-
313
- ## Taste Calibration
314
- - Optional quality-bar references from in-repo modules/files.
315
-
316
- ## Reference Pattern Registry
317
- | Pattern / source | Invariant to preserve | Disposition (accepted/rejected/deferred) | Scope boundary impact |
318
- |---|---|---|---|
319
- | | | | |
320
-
321
- ## Reference Pull
322
- - Optional evidence from \`<repo-relative references dir>\`; list accepted/rejected ideas or \`Not needed - compact scope\`.
323
-
324
- ## Ambitious Alternatives
325
- - Optional for SCOPE EXPANSION/SELECTIVE; list larger alternatives and disposition.
326
-
327
- ## Ruthless Minimum Slice
328
- - Optional for SCOPE REDUCTION/high-risk scope; define the smallest useful wedge.
329
-
330
- ## Requirements (stable IDs)
331
- | ID | Requirement (observable outcome) | Priority | Source (origin doc / prompt line) |
332
- |---|---|---|---|
333
- | R1 | | P0 | |
334
-
335
- > Assign \`R1\`, \`R2\`, \`R3\`… once and never renumber. Downstream artifacts
336
- > (design, spec, plan, review) reference these IDs verbatim. If a requirement
337
- > is later dropped, keep the row and mark Priority \`DROPPED\`; if a new one is
338
- > added mid-flow, append with the next free R-number — do NOT reuse numbers.
339
-
340
- ## Locked Decisions
341
- | ID | Decision | Why locked now | Downstream impact |
342
- |---|---|---|---|
343
- | D-1 | | | |
344
-
345
- > Decision IDs are stable \`D-XX\` numbers. Assign once and never renumber across
346
- > scope/design/spec/plan/review/ship; downstream artifacts reference these IDs
347
- > verbatim. If a decision is later dropped, keep the row and mark it
348
- > \`(superseded by D-Y)\`; if a new one is added mid-flow, append with the next
349
- > free D-number. The earlier LD#<sha8> hash anchor is gone —
350
- > existing artifacts with LD# anchors remain valid markdown but the linter only
351
- > tracks D-XX IDs.
352
-
353
- ## In Scope / Out of Scope
354
-
355
- ### In Scope
356
- -
357
-
358
- ### Out of Scope
359
- -
360
-
361
- ## Discretion Areas
362
- - (or \`None\`)
363
-
364
- ## Deferred Items
365
- | Item | Rationale |
366
- |---|---|
367
- | | |
368
-
369
- ${SEED_SHELF_SECTION}
370
-
371
- ## Error & Rescue Registry
372
- | Capability | Failure mode | Detection | Fallback |
373
- |---|---|---|---|
374
- | | | | |
375
-
376
- ## Outside Voice Findings
377
- | ID | Dimension | Finding | Disposition | Rationale |
378
- |---|---|---|---|---|
379
- | F-1 | premise_fit | | accept/reject/defer | |
380
-
381
- ## Scope Outside Voice Loop
382
- | Iteration | Quality Score | Findings | Stop decision |
383
- |---|---|---|---|
384
- | 1 | 0.00 | 0 | continue/stop |
385
- - Stop reason:
386
- - Target score: 0.800
387
- - Max iterations: 3
388
- - Unresolved concerns:
389
-
390
- ## Completion Dashboard
391
- - Checklist findings:
392
- - Resolved decisions count:
393
- - Unresolved decisions (or \`None\`):
394
-
395
- ## Scope Summary
396
- - Selected mode: (one of \`SCOPE EXPANSION\` | \`SELECTIVE EXPANSION\` | \`HOLD SCOPE\` | \`SCOPE REDUCTION\`)
397
- - Confidence: high | medium | low
398
- - Drift from brainstorm: None / <specific drift>
399
- - Unresolved questions: None / <questions>
400
- - Strongest challenges resolved:
401
- - Recommended path:
402
- - Accepted scope:
403
- - Deferred:
404
- - Explicitly excluded:
405
- - Next-stage handoff: identify whether the next stage is \`design\` (standard track) or \`spec\` (medium track), and list the exact artifacts/decisions it must carry forward.
406
-
407
- ## Victory Detector
408
- - Loop status file: \`.cclaw/state/early-loop.json\`
409
- - Iteration: <n>/<maxIterations>
410
- - Open concerns: <count>
411
- - Convergence guard: clear | tripped
412
- - Decision: iterate | ready_for_advance | escalate_for_human_override
413
-
414
- ## Critic Pass
415
- After each producer iteration append one JSON line to \`.cclaw/state/early-loop-log.jsonl\`:
416
-
417
- ${MARKDOWN_CODE_FENCE}json
418
- {"ts":"<ISO-8601>","runId":"<run-id>","stage":"scope","iteration":1,"concerns":[{"id":"C-1","severity":"important","locator":"Scope Contract > In Scope","summary":"<specific concern>"}],"resolvedConcernIds":[]}
419
- ${MARKDOWN_CODE_FENCE}
420
-
421
- - \`concerns\` lists unresolved concerns after this pass.
422
- - Keep concern IDs stable across iterations so convergence checks stay meaningful.
423
- - Include \`resolvedConcernIds\` when a previously open concern is explicitly closed.
424
-
425
- ## Learnings
426
- - None this stage.
427
- `,
428
- "02a-research.md": `${artifactFrontmatter("design")}
429
-
430
- # Research Report
431
-
432
- ## Stack Analysis
433
- | Topic | Finding | Evidence |
434
- |---|---|---|
435
- | Dependency compatibility | | |
436
- | Alternatives/deprecations | | |
437
-
438
- ## Features & Patterns
439
- | Topic | Finding | Evidence |
440
- |---|---|---|
441
- | Domain conventions | | |
442
- | User-facing or operator-facing patterns | | |
443
-
444
- ## Architecture Options
445
- | Option | Trade-offs | Recommendation | Evidence |
446
- |---|---|---|---|
447
- | A | | | |
448
- | B | | | |
449
-
450
- ## Pitfalls & Risks
451
- | Risk | Impact | Mitigation | Evidence |
452
- |---|---|---|---|
453
- | | | | |
454
-
455
- ## Synthesis
456
- - Key decisions informed by research:
457
- - Open questions:
458
-
459
- ## Learnings
460
- - None this stage.
461
- `,
462
- "03-design.md": `${artifactFrontmatter("design")}
463
-
464
- # Design Artifact
465
-
466
- ${renderBehaviorAnchorTemplateLine("design")}
467
-
468
- ## Compact-First Scaffold
469
- - Default to the compact design spine unless risk requires Standard/Deep add-ons.
470
- - Compact required spine: Upstream Handoff, Codebase Investigation, Engineering Lock, Architecture Boundaries, Architecture Diagram, Data Flow, Failure Mode Table, Test Strategy, Spec Handoff, and Completion Dashboard.
471
- - Mark optional Standard/Deep sections as \`Omitted - compact design\` when they do not apply; do not expand the scaffold just to fill empty tables.
472
-
473
- ## Upstream Handoff
474
- - Source artifacts: \`02-scope-<slug>.md\`, \`02a-research.md\` only when present for deep/high-risk research
475
- - Decisions carried forward:
476
- - Constraints carried forward:
477
- - Open questions:
478
- - Drift from upstream (or \`None\`):
479
-
480
- ## Q&A Log
481
- | Turn | Question | User answer (1-line) | Decision impact |
482
- |---|---|---|---|
483
- | 1 | | | architecture-shaping [topic:data-flow] |
484
-
485
- > Append-only by turn. Add one row after each user answer; do not rewrite prior rows.
486
- > **Topic tag is MANDATORY for forcing-question rows.** Stamp \`[topic:<id>]\` in the \`Decision impact\` cell so the linter can verify coverage in any natural language (RU/EN/UA/etc.). Design IDs: \`data-flow\`, \`seams\`, \`invariants\`, \`not-refactor\`. Multiple tags allowed when one answer covers several topics. Stop-signal rows do NOT need a tag.
487
-
488
- ## Codebase Investigation
489
- | File | Current responsibility | Patterns discovered | Existing fit / reuse candidate |
490
- |---|---|---|---|
491
- | | | | |
492
-
493
- ## Engineering Lock
494
- | Decision area | Chosen path | Shadow alternative | Switch trigger | Failure/rescue/degraded behavior | Verification evidence | Confidence |
495
- |---|---|---|---|---|---|---|
496
- | | | | | | | |
497
-
498
- ## Architecture Decision Record (ADR)
499
- | ADR ID | Context | Decision | Alternatives considered | Consequences | Reversal trigger |
500
- |---|---|---|---|---|---|
501
- | ADR-1 | | | | | |
502
-
503
- ## Search Before Building
504
- | Layer | Label | What to reuse first |
505
- |---|---|---|
506
- | Layer 1 | | |
507
- | Layer 2 | | |
508
- | Layer 3 | | |
509
-
510
- ## Research Fleet Synthesis
511
- | Lens actually run | Key findings | Design impact | Evidence |
512
- |---|---|---|---|
513
- | compact inline synthesis | | | |
514
-
515
- > Default path: compact inline synthesis here. Deep/high-risk work may also write \`.cclaw/artifacts/02a-research.md\`.
516
-
517
- ## Architecture Boundaries
518
- | Component | Responsibility | Requirement Refs (R#) | Decision Refs (D-XX) | Owner |
519
- |---|---|---|---|---|
520
- | | | | | |
521
-
522
- ## Architecture Diagram
523
-
524
- <!-- diagram: architecture -->
525
-
526
- ${MARKDOWN_CODE_FENCE}
527
- (ASCII, Mermaid, or tool-generated diagram showing component boundaries and data flow direction)
528
- ${MARKDOWN_CODE_FENCE}
529
-
530
- ## Data-Flow Shadow Paths
531
- - Standard/Deep add-on; omit when compact design does not need a shadow path.
532
- <!-- diagram: data-flow-shadow-paths -->
533
- | Chosen path | Shadow alternative | Switch trigger | Failure/rescue/degraded behavior | Verification evidence |
534
- |---|---|---|---|---|
535
- | | | | | |
536
-
537
- ## Error Flow Diagram
538
- - Standard/Deep add-on; omit when the Failure Mode Table is sufficient.
539
-
540
- <!-- diagram: error-flow -->
541
-
542
- ${MARKDOWN_CODE_FENCE}
543
- (failure detection -> rescue action -> user-visible outcome)
544
- ${MARKDOWN_CODE_FENCE}
545
-
546
- ## Deep Diagram Add-on
547
- - Deep add-on only.
548
- - type: state-machine | rollback | deployment-sequence | none
549
- - Choose exactly one marker below when type is not \`none\`.
550
-
551
- <!-- diagram: state-machine -->
552
- <!-- diagram: rollback-flowchart -->
553
- <!-- diagram: deployment-sequence -->
554
-
555
- ${MARKDOWN_CODE_FENCE}
556
- (deep add-on diagram: state lifecycle OR rollback flow OR deployment sequence)
557
- ${MARKDOWN_CODE_FENCE}
558
-
559
- ## Stale Diagram Audit
560
- | File | Last modified | Diagram marker baseline | Status | Notes |
561
- |---|---|---|---|---|
562
- | | | | clear/stale | |
563
-
564
- ## Blast-radius Diff
565
- > Diff since scope artifact baseline. Scope OWNS the full repo audit (\`## Pre-Scope System Audit\`); design only diffs touched paths.
566
- >
567
- > Suggested command: \`git diff <scope-artifact-head-sha>..HEAD -- <touched-paths>\`
568
-
569
- | File | Change since scope (\`git diff\` summary) | Current responsibility | Reuse candidate / existing pattern |
570
- |---|---|---|---|
571
- | | | | |
572
-
573
- ## Data Flow
574
- - Data/state flow:
575
- - Critical path:
576
- - Happy path:
577
- - Nil/empty input path:
578
- - Upstream error path:
579
- - Timeout/downstream path:
580
-
581
- ### Interaction Edge Case Matrix
582
- | Edge case | Handled? | Design response | Deferred item (if not handled) |
583
- |---|---|---|---|
584
- | double-click | yes/no | | None / D-XX |
585
- | nav-away-mid-request | yes/no | | None / D-XX |
586
- | 10K-result dataset | yes/no | | None / D-XX |
587
- | background-job abandonment | yes/no | | None / D-XX |
588
- | zombie connection | yes/no | | None / D-XX |
589
-
590
- ## Security & Threat Model
591
- | Boundary | Threat | Mitigation | Owner |
592
- |---|---|---|---|
593
- | | | | |
594
-
595
- ## Failure Mode Table
596
- | Method | Exception | Rescue | UserSees |
597
- |---|---|---|---|
598
- | | | | |
599
-
600
- ## Pre-mortem
601
- | Scenario | Earliest warning signal | Mitigation owner | Containment action |
602
- |---|---|---|---|
603
- | | | | |
604
-
605
- ## Test Strategy
606
- - Unit:
607
- - Integration:
608
- - E2E:
609
-
610
- ## Test-Diagram Mapping
611
- | Critical flow | Test coverage (ID/command) | Diagram anchor | Gap status |
612
- |---|---|---|---|
613
- | | | | covered/gap |
614
-
615
- ## Performance Budget
616
- | Critical path | Metric | Target | Measurement method |
617
- |---|---|---|---|
618
- | | | | |
619
-
620
- ## Observability & Debuggability
621
- | Signal | Source | Alert/Debug path |
622
- |---|---|---|
623
- | | | |
624
-
625
- ## Deployment & Rollout
626
- | Step | Strategy | Rollback plan |
627
- |---|---|---|
628
- | | | |
629
-
630
- ## Rejected Alternatives
631
- | Alternative | Why rejected | Revival signal |
632
- |---|---|---|
633
- | | | |
634
-
635
- ## Design Decisions
636
- | Decision Ref | Requirement / LD refs | Decision | Spec impact |
637
- |---|---|---|---|
638
- | DD-1 | | | |
639
-
640
- ## Spec Handoff
641
- - Requirements to carry forward:
642
- - Design decisions to encode:
643
- - Risks and rescue paths:
644
- - Test/performance expectations:
645
- - Unresolved questions (or \`None\`):
646
-
647
- ## Long-Term Trajectory
648
- - (1-3 lines: what comes after this ships, and whether this architecture can absorb that path without major rework. For tactical changes use \`None - tactical change only\`.)
649
-
650
- ## Outside Voice Findings
651
- | ID | Dimension | Finding | Disposition | Rationale |
652
- |---|---|---|---|---|
653
- | F-1 | architecture_fit | | accept/reject/defer | |
654
-
655
- ## Design Outside Voice Loop
656
- | Iteration | Quality Score | Findings | Stop decision |
657
- |---|---|---|---|
658
- | 1 | 0.00 | 0 | continue/stop |
659
- - Stop reason:
660
- - Target score: 0.800
661
- - Max iterations: 3
662
- - Unresolved concerns:
663
-
664
- ## Parallelization Strategy
665
- - Standard/Deep add-on when multi-module; omit for compact sequential work.
666
- - Parallel lanes:
667
- - Conflict risks:
668
-
669
- ## Patterns to Mirror
670
- | Pattern | Source file | Rationale |
671
- |---|---|---|
672
- | | | |
673
-
674
- ## Reference-Grade Contracts
675
- | Pattern / source | Reusable invariant | Local adaptation | Rejection boundary | Verification signal |
676
- |---|---|---|---|---|
677
- | | | | | |
678
-
679
- ## Interface Contracts
680
- - Standard/Deep add-on when module boundaries or APIs change; omit for compact local changes.
681
- | Module | Produces | Consumes |
682
- |---|---|---|
683
- | | | |
684
-
685
- ## Unresolved Decisions
686
- - Standard/Deep add-on; use \`None\` for compact design with no unresolved decisions.
687
- | Decision | Missing info | Owner | Default |
688
- |---|---|---|---|
689
- | | | | |
690
-
691
- ${SEED_SHELF_SECTION}
692
-
693
- ## Completion Dashboard
694
- | Review Section | Status | Issues |
695
- |---|---|---|
696
- | Architecture Review | | |
697
- | Security & Threat Model | | |
698
- | Code Quality Review | | |
699
- | Data Flow & Interaction Edge Cases | | |
700
- | Test Review | | |
701
- | Performance Review | | |
702
- | Observability & Debuggability | | |
703
- | Deployment & Rollout Review | | |
704
-
705
- **Decisions made:** 0 | **Unresolved:** 0
706
-
707
- ## Victory Detector
708
- - Loop status file: \`.cclaw/state/early-loop.json\`
709
- - Iteration: <n>/<maxIterations>
710
- - Open concerns: <count>
711
- - Convergence guard: clear | tripped
712
- - Decision: iterate | ready_for_advance | escalate_for_human_override
713
-
714
- ## Critic Pass
715
- After each producer iteration append one JSON line to \`.cclaw/state/early-loop-log.jsonl\`:
716
-
717
- ${MARKDOWN_CODE_FENCE}json
718
- {"ts":"<ISO-8601>","runId":"<run-id>","stage":"design","iteration":1,"concerns":[{"id":"C-1","severity":"important","locator":"Engineering Lock > Row 1","summary":"<specific concern>"}],"resolvedConcernIds":[]}
719
- ${MARKDOWN_CODE_FENCE}
720
-
721
- - \`concerns\` lists unresolved concerns after this pass.
722
- - Keep concern IDs stable across iterations so convergence checks stay meaningful.
723
- - Include \`resolvedConcernIds\` when a previously open concern is explicitly closed.
724
-
725
- ## Learnings
726
- - None this stage.
727
- `,
728
- "04-spec.md": `${artifactFrontmatter("spec")}
729
-
730
- # Specification Artifact
731
-
732
- ${renderBehaviorAnchorTemplateLine("spec")}
733
-
734
- ## Upstream Handoff
735
- - Source artifacts: standard uses \`02-scope-<slug>.md\` + \`03-design-<slug>.md\`; medium uses \`01-brainstorm-<slug>.md\` when present; quick uses \`00-idea.md\` plus reproduction context.
736
- - Decisions carried forward:
737
- - Constraints carried forward:
738
- - Open questions:
739
- - Drift from upstream (or \`None\`):
740
-
741
- ## Acceptance Criteria
742
- | ID | Requirement Ref (R#) | Criterion (observable/measurable/falsifiable) | Design Decision Ref (D-XX) | parallelSafe (true/false) | touchSurface (paths/modules) |
743
- |---|---|---|---|---|---|
744
- | AC-1 | R1 | | | false | |
745
-
746
- > Standard ACs reference at least one \`R#\` from \`02-scope.md\`. Quick-track ACs may instead put \`Quick Reproduction Contract\` / bug-slice refs in the Requirement Ref column and \`N/A\` for Design Decision Ref. ACs are stable (never renumber): dropped ACs stay with Priority \`DROPPED\`; new ones append with the next free \`AC-#\`. \`parallelSafe\` states whether this AC can be proven in parallel with others; \`touchSurface\` lists repo-relative globs or modules this AC is expected to touch (scheduler + slice planning).
747
-
748
- ## Quick Reproduction Contract
749
- > Required for quick bug-fix specs; use \`N/A\` for non-bugfix or standard/medium tracks. TDD turns this contract into the RED reproduction test.
750
-
751
- | Bug slice | Symptom | Repro steps | Expected RED test behavior | Linked acceptance criterion |
752
- |---|---|---|---|---|
753
- | QS-1 | | | | AC-1 |
754
-
755
- ## Edge Cases
756
- | Criterion ID | Boundary case | Error case |
757
- |---|---|---|
758
- | AC-1 | | |
759
-
760
- ## Constraints and Assumptions
761
- > Constraints are CARRIED FORWARD from scope's \`## Scope Contract > Constraints\`. Cite or copy with attribution; do NOT re-author. Spec OWNS testable assumptions in \`## Assumptions Before Finalization\` below.
762
-
763
- - **Constraints (carry-forward):** See scope: \`02-scope-<slug>.md#scope-contract\` (or list new spec-stage constraints with citation to the Q&A row that surfaced them).
764
- - **Assumptions:** See \`## Assumptions Before Finalization\` (spec-only owner).
765
-
766
- ## Assumptions Before Finalization
767
- | Assumption | Source / confidence | Validation path | Disposition |
768
- |---|---|---|---|
769
- | | | | accepted/rejected/open |
770
-
771
- ## Acceptance Mapping
772
- | Criterion ID | Verification approach | Command/manual steps |
773
- |---|---|---|
774
- | AC-1 | | |
775
-
776
- ## Vague to Fixed
777
- | Original (vague) | Rewritten (observable/testable) |
778
- |---|---|
779
- | | |
780
-
781
- ## Non-Functional Requirements
782
- | Category | Requirement | Threshold | Measurement |
783
- |---|---|---|---|
784
- | | | | |
785
-
786
- ## Interface Contracts
787
- | Module | Produces | Consumes |
788
- |---|---|---|
789
- | | | |
790
-
791
- ## Synthesis Sources
792
- > Spec is synthesized from existing context (CLAUDE.md / AGENTS.md / TODOS.md / git history / brainstorm + scope + design artifacts) — interview only when something genuinely cannot be derived. List the artifacts/files actually read and what each supplied.
793
-
794
- | Source | What it supplied | Confidence (1-10) |
795
- |---|---|---|
796
- | | | |
797
-
798
- ## Behavior Contract
799
- > List behaviors universally (works for CLI, library, infra, web, batch). Use either \`As a <role>, I can <action> so that <outcome>.\` or \`Given <state>, When <event>, Then <outcome>.\`. ≥3 behaviors required. The shape — not the topic — is what the linter checks.
800
-
801
- - (or write \`- None.\` if a single-step spec)
802
-
803
- ## Architecture Modules
804
- > One line of responsibility per module — no file paths, no signatures, no method names. Modules must be derivable from the design artifact.
805
-
806
- | Module | Responsibility (one sentence) | Maps to design ref (DD-#) |
807
- |---|---|---|
808
- | | | |
809
-
810
- ## Spec Self-Review
811
- > Inline pass; fix in place. If a check fails, do not move on without recording the fix.
812
-
813
- - [ ] Placeholders scan (no \`TBD\`, \`TODO\`, \`FIXME\`, \`<placeholder>\`)
814
- - [ ] Internal consistency (sections do not contradict each other)
815
- - [ ] Scope check (focused enough for a single plan)
816
- - [ ] Ambiguity check (no requirement readable two ways)
817
- - Patches applied:
818
- - None
819
- - Remaining concerns:
820
- - None
821
-
822
- ## Approval
823
- - Approved by:
824
- - Date:
825
-
826
- ## Learnings
827
- - None this stage.
828
- `,
829
- "05-plan.md": `${artifactFrontmatter("plan")}
830
-
831
- # Plan Artifact
832
-
833
- ${renderBehaviorAnchorTemplateLine("plan")}
834
-
835
- ## Plan Header
836
- - **Goal:** (one sentence — what this plan delivers)
837
- - **Architecture:** (2-3 sentences — approach + key boundaries)
838
- - **Tech Stack:** (key languages/runtimes/frameworks/libraries that the executor must know)
839
-
840
- ## Upstream Handoff
841
- - Source artifacts: \`03-design-<slug>.md\`, \`04-spec.md\`
842
- - Decisions carried forward:
843
- - Constraints carried forward:
844
- - Open questions:
845
- - Drift from upstream (or \`None\`):
846
-
847
- ## Dependency Graph
848
- -
849
-
850
- ## Dependency Batches
851
-
852
- ### Batch 1 (foundation)
853
- - Task IDs:
854
- - Verification gate:
855
-
856
- ### Batch 2 (dependent)
857
- - Task IDs:
858
- - Depends on:
859
- - Verification gate:
860
-
861
- ### Batch 3 (integration)
862
- - Task IDs:
863
- - Depends on:
864
- - Verification gate:
865
-
866
- Execution rule: complete and verify each batch before starting the next batch.
867
-
868
- ## Task List
869
-
870
- **Rules (apply before writing rows):**
871
- - Task rows are internal TDD steps unless \`Execution Topology\` is \`strict-micro\`. Keep each step in the **2-5 minute budget**; group related steps into feature-atomic \`U-*\` Implementation Units.
872
- - **No placeholders.** Forbidden tokens anywhere in this table: \`TODO\`, \`TBD\`, \`FIXME\`, \`<fill-in>\`, \`<your-*-here>\`, \`xxx\`, bare ellipsis. Every file path, test, and verification command must be copy-pasteable as written.
873
- - **No silent scope reduction.** Forbidden phrasing when locked decisions exist: \`v1\`, \`for now\`, \`later\`, \`temporary\`, \`placeholder\`, \`mock for now\`, \`hardcoded for now\`, \`will improve later\`.
874
- - If an estimate is genuinely uncertain (new library, unfamiliar subsystem), add a **spike task in batch 0** to de-risk — do NOT hide the uncertainty inside a large estimate.
875
-
876
- | Task ID | Description | Acceptance criterion | Verification command | Effort (S/M/L) | Minutes |
877
- |---|---|---|---|---|---|
878
- | T-1 | | | | | [~3m] |
879
-
880
- ## Acceptance Mapping
881
- | Criterion ID | Task IDs |
882
- |---|---|
883
- | AC-1 | T-1 |
884
-
885
- ## Execution Posture
886
- - execution.topology: auto | inline | single-builder | parallel-builders | strict-micro
887
- - execution.strictness: fast | balanced | strict
888
- - execution.maxBuilders: 5
889
- - plan.sliceGranularity: feature-atomic | strict-micro
890
- - plan.microTaskPolicy: advisory | strict
891
- - Posture rationale: (why this is the cheapest safe topology)
892
- - Stop conditions:
893
- - Risk triggers:
894
- - TDD checkpoint plan: RED commit/checkpoint -> GREEN commit/checkpoint -> REFACTOR commit/checkpoint (or deferred because: )
895
-
896
- ## Locked Decision Coverage
897
- | Decision Ref (D-XX) | Source section | Plan tasks implementing decision | Status |
898
- |---|---|---|---|
899
- | D-1 | 02-scope.md > Locked Decisions | T-1 | covered |
900
-
901
- ## Risk Assessment
902
- | Task/Batch | Risk | Likelihood | Impact | Mitigation |
903
- |---|---|---|---|---|
904
- | | | | | |
905
-
906
- ## Boundary Map
907
- | Task/Batch | Produces (exports) | Consumes (imports from) |
908
- |---|---|---|
909
- | | | |
910
-
911
- ## Implementation Units
912
- > Required structural form per implementation unit. Default is feature-atomic units with bite-sized 2-5 minute TDD steps inside each. Use strict micro-slices only for high-risk work or when explicitly configured.
913
-
914
- ### Implementation Unit U-1
915
- - **id:** U-1
916
- - **dependsOn:** none
917
- - **claimedPaths:** (repo-relative, comma-separated globs or files this unit expects to own)
918
- - **parallelizable:** true
919
- - **riskTier:** standard
920
- - **lane:** (optional advisory lane tag for human-readable batching)
921
- - **Goal:**
922
- - **Requirements (from Spec):**
923
- - **Dependencies (other units):**
924
- - **Files (repo-relative; never absolute):**
925
- - Create:
926
- - Modify:
927
- - Test:
928
- - **Approach:** (1-3 sentences; cite design decision DD-# or scope D-XX)
929
- - **Patterns to follow:** (link existing files/modules to mirror, or \`- None applicable.\`)
930
- - **Test scenarios:**
931
- - Happy:
932
- - Edge:
933
- - Error:
934
- - Integration:
935
- - **Verification:** (outcome to observe — not a shell script; e.g., "command exits 0 and prints \`<artifact-anchor>\`").
936
- - **Steps (each 2-5 min, checkbox):**
937
- - [ ] Step 1: write failing test for <behavior>
938
- - [ ] Step 2: run test, observe RED with reason
939
- - [ ] Step 3: minimal implementation
940
- - [ ] Step 4: run test, observe GREEN
941
- - [ ] Step 5: refactor + commit
942
-
943
- ## Calibrated Findings
944
- > Recommended for high-risk or multi-batch plans. Use one line per finding, or \`None this stage\`.
945
- >
946
- > Canonical format:
947
- > \`- [P1|P2|P3] (confidence: <n>/10) <path>[:<line>] — <description>\`
948
-
949
- ## Regression Iron Rule
950
- - Iron rule acknowledged: yes
951
- - Critical regression guardrail:
952
- - Required pre-merge proof:
953
-
954
- ## Execution Handoff
955
- - **Topology chosen:** execution.topology = auto | inline | single-builder | parallel-builders | strict-micro
956
- - **Why this topology:** (one line tying choice to unit count, path independence, risk, and maxBuilders)
957
- - **Subagent recipe (if single/parallel builder):** \`<harness>\` -> \`<dispatch surface>\` -> \`<agent-definition path>\` (substitute neutral placeholders; full recipes in \`docs/harnesses.md\`)
958
- - **Inline recipe (if inline):** TDD loop unit-by-unit with the same RED-before-GREEN, AC traceability, path containment, verification, and managed commit/worktree gates
959
-
960
- ## Plan Quality Scan
961
- <!-- linter-meta -->
962
- - Placeholder scan:
963
- - Scanned tokens: \`TODO\`, \`TBD\`, \`FIXME\`, \`<fill-in>\`, \`<your-*-here>\`, \`xxx\`, bare ellipsis in task rows.
964
- - Hits: 0 (required for WAIT_FOR_CONFIRM to resolve).
965
- - Scope reduction language scan:
966
- - Scanned phrases: \`v1\`, \`for now\`, \`later\`, \`temporary\`, \`placeholder\`, \`mock for now\`, \`hardcoded for now\`, \`will improve later\`.
967
- - Hits: 0 (required when Locked Decisions section is non-empty; reference D-XX IDs from scope).
968
- <!-- /linter-meta -->
969
-
970
- ## WAIT_FOR_CONFIRM
971
- - Status: pending
972
- - Confirmed by:
973
-
974
- ## Learnings
975
- - None this stage.
976
- `,
977
- "06-tdd.md": `${artifactFrontmatter("tdd")}
978
-
979
- # TDD Artifact
980
-
981
- ${renderBehaviorAnchorTemplateLine("tdd")}
982
-
983
- ## Upstream Handoff
984
- - Source artifacts: \`04-spec.md\` plus the active track's upstream source item (plan slice on standard/medium, spec acceptance item or bug reproduction slice on quick).
985
- - Decisions carried forward:
986
- - Constraints carried forward:
987
- - Open questions:
988
- - Drift from upstream (or \`None\`):
989
-
990
- <!-- auto-start: slices-index -->
991
- ## Slices Index
992
-
993
- _Auto-rendered from \`tdd-slices/S-*.md\` once \`slice-builder\` or the controller writes per-slice files. Do not edit by hand._
994
- <!-- auto-end: slices-index -->
995
-
996
- ## Test Discovery
997
- > Overall narrative for how this stage discovered the existing test surface. Per-slice details live in \`tdd-slices/S-<id>.md\`.
998
-
999
- ## System-Wide Impact Check
1000
- | Slice | Callbacks/state/interfaces/contracts affected | Coverage decision |
1001
- |---|---|---|
1002
- | S-1 | | covered/out-of-scope because |
1003
-
1004
- ## RED Evidence
1005
- > Per-slice RED rows are auto-satisfied by \`phase=red\` events in \`delegation-events.jsonl\` (controller dispatches \`slice-builder --slice S-<id> --phase red\`). Use \`Evidence: <path>\` or \`Evidence: spanId:<id>\` pointers if you prefer a manual reference.
1006
-
1007
- ## Acceptance & Failure Map
1008
- | Slice | Source ID | AC ID | Expected behavior | RED-link |
1009
- |---|---|---|---|---|
1010
- | S-1 | SRC-1 | AC-1 | | |
1011
-
1012
- > Each slice maps to the active track's source item (plan slice on standard/medium, or the \`Quick Reproduction Contract\` bug slice / spec acceptance item on quick) and to a spec criterion. The RED-link column is satisfied by either a \`spanId:<id>\` from the delegation ledger or an \`<artifacts-dir>/<file>\` evidence pointer. The column is also auto-derivable: a \`phase=red\` event in \`delegation-events.jsonl\` with non-empty evidenceRefs auto-satisfies the row.
1013
-
1014
- ## GREEN Evidence
1015
- > GREEN rows are auto-satisfied by \`phase=green\` events in \`delegation-events.jsonl\` (controller dispatches \`slice-builder --slice S-<id> --phase green\`). Use \`Evidence: <path>\` or \`Evidence: spanId:<id>\` pointers if you prefer a manual reference.
1016
-
1017
- ## REFACTOR Notes
1018
- - What changed:
1019
- - Why:
1020
- - Behavior preserved:
1021
-
1022
- ## Traceability
1023
- - Source item IDs:
1024
- - Spec criterion IDs:
1025
-
1026
-
1027
- ## Iron Law Acknowledgement
1028
- - Iron Law: NO PRODUCTION CODE WITHOUT A FAILING TEST FIRST.
1029
- - Acknowledged: yes — code that landed before its test will be deleted and rewritten from the test.
1030
- - Exceptions invoked (or \`- None.\`):
1031
-
1032
- <!-- auto-start: tdd-slice-summary -->
1033
- ## Vertical Slice Cycle
1034
-
1035
- _Auto-rendered from \`delegation-events.jsonl\` once \`slice-builder\` is dispatched per slice with \`--slice <id> --phase red|green|refactor|refactor-deferred\`. Do not edit by hand._
1036
- <!-- auto-end: tdd-slice-summary -->
1037
-
1038
- ## Assertion Correctness Notes
1039
- > For each new test assertion, name a *plausible subtle bug* that would still pass it (mental mutation test). If you cannot, the assertion is too coarse — strengthen it.
1040
-
1041
- | Slice | Assertion (one line) | Bug that would still pass | Strengthening action (or \`- Sufficient.\`) |
1042
- |---|---|---|---|
1043
- | S-1 | | | |
1044
-
1045
- ## Verification Ladder
1046
- | Slice | Tier reached | Evidence |
1047
- |---|---|---|
1048
- | S-1 | | |
1049
-
1050
- ## TDD Blocker Taxonomy
1051
- > Fill only when blocked. Choose one canonical class and capture the resume contract.
1052
- >
1053
- > Allowed classes: \`NO_SOURCE_CONTEXT\`, \`NO_TEST_SURFACE\`, \`NO_IMPLEMENTABLE_SLICE\`, \`RED_NOT_EXPRESSIBLE\`, \`NO_VCS_MODE\`.
1054
-
1055
- | Slice | Class | blockedBecause | missingInputs | recommendedRoute | nextCommand | resumeCriteria |
1056
- |---|---|---|---|---|---|---|
1057
- | S-1 | | | | | | |
1058
-
1059
- ## Per-Slice Review
1060
- > Only required when \`.cclaw/config.yaml::sliceReview.enabled\` triggers this slice; otherwise record \`not triggered\`.
1061
-
1062
- | Slice | Trigger fired | Spec-Compliance pass | Quality pass | Fulfillment mode (isolated/role-switch/not triggered) |
1063
- |---|---|---|---|---|
1064
- | S-1 | | | | |
1065
-
1066
- ## Coverage Targets
1067
- | Code type | Target | Current | Command |
1068
- |---|---|---|---|
1069
- | | | | |
1070
-
1071
- ## Test Pyramid Shape
1072
- > Fill in per slice. Size classes: **Small** = pure logic, no I/O, <50ms; **Medium** = single process boundary (fs, in-memory DB, in-process service); **Large** = multi-process / network / real external service. Default to Small; escalate only when a real boundary must be exercised.
1073
-
1074
- | Slice | # Small | # Medium | # Large | Justification for any Medium/Large |
1075
- |---|---|---|---|---|
1076
- | S-1 | | | | |
1077
-
1078
- ## Prove-It Reproduction (bug-fix slices only)
1079
- > Required whenever the slice is classified as a **bug fix** (task class = \`software-bugfix\`). Must demonstrate the test fails without the fix, passes with the fix, and would fail again if the fix were reverted. Skip this table entirely for non-bugfix slices.
1080
-
1081
- | Slice | Reproduction test | RED-without-fix evidence | GREEN-with-fix evidence | Revert-guard note |
1082
- |---|---|---|---|---|
1083
- | S-1 | | | | |
1084
-
1085
- ## Learnings
1086
- - None this stage.
1087
- `,
1088
- "cohesion-contract.md": `${artifactFrontmatter("tdd")}
1089
-
1090
- # Cohesion Contract — <wave / stage / topic>
1091
-
1092
- ## Shared Types & Interfaces
1093
- | Symbol | Path | Signature | Owner slice |
1094
- |---|---|---|---|
1095
- | | | | |
1096
-
1097
- ## Naming Conventions
1098
- -
1099
-
1100
- ## Invariants
1101
- -
1102
-
1103
- ## Integration Touchpoints
1104
- | From slice | To slice | Surface | Integration test name |
1105
- |---|---|---|---|
1106
- | | | | |
1107
-
1108
- ## Behavior Specifications per Slice
1109
- ### Slice <n>: <description>
1110
- - test: <name>
1111
- assert: <one-line assertion>
1112
- surface: <public interface>
1113
-
1114
- ## Status
1115
- | Slice | Implemented | Tests pass | Cohesion verified |
1116
- |---|---|---|---|
1117
- | S-1 | no | no | no |
1118
-
1119
- ## Learnings
1120
- - None this stage.
1121
- `,
1122
- "cohesion-contract.json": `{
1123
- "version": 1,
1124
- "sharedTypes": [
1125
- {
1126
- "symbol": "",
1127
- "path": "",
1128
- "signature": "",
1129
- "ownerSlice": ""
1130
- }
1131
- ],
1132
- "touchpoints": [
1133
- {
1134
- "fromSlice": "",
1135
- "toSlice": "",
1136
- "surface": "",
1137
- "integrationTestName": ""
1138
- }
1139
- ],
1140
- "slices": [
1141
- {
1142
- "sliceId": "S-1",
1143
- "description": "",
1144
- "test": "",
1145
- "assert": "",
1146
- "surface": "",
1147
- "implemented": false,
1148
- "testsPass": false,
1149
- "cohesionVerified": false
1150
- }
1151
- ],
1152
- "status": {
1153
- "overall": "pending",
1154
- "notes": ""
1155
- }
1156
- }
1157
- `,
1158
- "07-review.md": `${artifactFrontmatter("review")}
1159
-
1160
- # Review Artifact
1161
-
1162
- ${renderBehaviorAnchorTemplateLine("review")}
1163
-
1164
- ## Upstream Handoff
1165
- - Source artifacts: \`04-spec.md\`, \`06-tdd.md\`, plus the active track's upstream source item when available.
1166
- - Decisions carried forward:
1167
- - Constraints carried forward:
1168
- - Open questions:
1169
- - Drift from upstream (or \`None\`):
1170
-
1171
- ## Pre-Critic Self-Review
1172
- - [ ] Build/lint/type-check/tests passed locally
1173
- - [ ] Diff matches spec/plan (no scope creep)
1174
- - [ ] Leftover prints / commented code / unused imports removed
1175
- - [ ] Deletion test: each new module justifies its existence
1176
- - Evidence (commands + result):
1177
- - Patches applied (or \`- None.\`):
1178
- - **Goal:**
1179
- - **Approach:**
1180
- - **Risk areas:**
1181
- - **Verification done:**
1182
- - **Open questions for the reviewer:**
1183
-
1184
- ## Critic Subagent Dispatch
1185
- > Dispatch a fresh-context critic (not the session history). Required even for self-driven review — the critic delegates back via \`delegation-record.mjs\` so the proof chain is preserved.
1186
-
1187
- | Field | Value |
1188
- |---|---|
1189
- | Critic agent definition path | \`<repo-relative path under harness directory>\` |
1190
- | Dispatch surface | One of the \`--dispatch-surface\` enum values listed in \`docs/harnesses.md\` (\`claude-task\`, \`cursor-task\`, \`opencode-agent\`, \`codex-agent\`, \`generic-task\`, \`role-switch\`, \`manual\`) |
1191
- | Frame sent | WHAT_WAS_IMPLEMENTED + PLAN_OR_REQUIREMENTS + BASE_SHA + HEAD_SHA |
1192
- | Critic returned | Strengths / Critical / Important / Minor |
1193
- | Span id | \`<span-id>\` |
1194
- | Acknowledgement ts | \`<iso ts>\` |
1195
-
1196
- ## Receiving Posture
1197
- - [ ] No performative agreement (forbidden openers acknowledged)
1198
- - [ ] READ -> UNDERSTAND -> VERIFY -> EVALUATE -> RESPOND -> IMPLEMENT one-at-a-time discipline followed
1199
- - [ ] Push-back recorded with reasoning when the critic was wrong
1200
- - Notes (or \`- None.\`):
1201
-
1202
- ## Critic Convergence
1203
- - Iterations run: <n>/3
1204
- - Convergence reached: yes / no — \`Reviewer Concerns\` populated when no
1205
- - Stop reason:
1206
-
1207
- ## Review Evidence Scope
1208
- - Base/head:
1209
- - Files inspected:
1210
- - Changed-file coverage summary:
1211
- - Diagnostics run:
1212
- - Omitted files with explicit reason:
1213
- - Reviewer delegation evidence:
1214
- - Security-reviewer delegation evidence:
1215
-
1216
- ## Changed-File Coverage
1217
- | File | Coverage status | Evidence / no-impact reason |
1218
- |---|---|---|
1219
- | | inspected / broader-module / omitted-no-impact | |
1220
-
1221
- ## Layer 1 Verdict
1222
- | Criterion | Verdict | Evidence |
1223
- |---|---|---|
1224
- | AC-1 | PASS/FAIL | |
1225
-
1226
- ## Layer 2 Findings
1227
- > Layer 2 categories OWNED by review = cross-slice correctness, security, dependency/version, observability, external-safety. Performance + architecture findings are CARRY-FORWARD from \`03-design-<slug>.md\` (Performance Budget, ADR) — cite, do NOT re-derive. Single-slice findings stay in \`06-tdd.md > Per-Slice Review\`; review may cite their IDs (severity/disposition must match — cross-artifact-duplication linter blocks otherwise).
1228
-
1229
- | ID | Severity | Category | File:line / no-line reason | Description | Status |
1230
- |---|---|---|---|---|---|
1231
- | R-1 | Critical/Important/Suggestion | cross-slice-correctness/security/dependency-version/observability/external-safety | path:line | | open/resolved |
1232
- | R-2 | from-design | performance | cite \`03-design-<slug>.md > Performance Budget\` | | carry-forward |
1233
- | R-3 | from-design | architecture | cite \`03-design-<slug>.md > ADR\` | | carry-forward |
1234
- | R-4 | from-tdd | from-tdd | cite \`06-tdd.md > Per-Slice Review > F-<n>\` | | carry-forward |
1235
- - NO_FINDINGS_ATTESTATION: <required when no findings are reported; cite inspected coverage>
1236
-
1237
- ## Lens Coverage
1238
- - Performance: NO_IMPACT | FOUND_<n>
1239
- - Compatibility: NO_IMPACT | FOUND_<n>
1240
- - Observability: NO_IMPACT | FOUND_<n>
1241
- - Security: routed to security-reviewer (always separate)
1242
-
1243
- ## Security Sweep Attestation
1244
- - Result: findings | NO_CHANGE_ATTESTATION | NO_SECURITY_IMPACT
1245
- - Inspected surfaces:
1246
- - Rationale:
1247
-
1248
- ## Dependency & Version Audit
1249
- - Relevant: yes/no
1250
- - Manifests/lockfiles/generated clients/CI/runtime config/external APIs inspected:
1251
- - Result / no-impact rationale:
1252
-
1253
- ## Incoming Feedback Queue
1254
- | ID | Source | Severity | File:line | Request | Status | Evidence |
1255
- |---|---|---|---|---|---|---|
1256
- | CR-1 | reviewer / bot / ci | Critical/Important/Suggestion | path:line or n/a | | open/in-progress/resolved/accepted-risk/rejected-with-evidence | |
1257
-
1258
- ## Review Findings Contract
1259
- - See \`07-review-army.json\`
1260
- - Reconciliation summary:
1261
-
1262
- ## Review Readiness Snapshot
1263
-
1264
- - Victory Detector: pass | fail (Layer 1, Layer 2, security sweep, structured findings, acceptance/reproduction coverage evidence, unresolved-critical status)
1265
- - Completed checks: Layer 1, Layer 2 tags, security sweep, schema validation
1266
- - Delegation log: \`.cclaw/state/delegation-log.json\` required/completed/waived/pending
1267
- - Staleness signal: commit at last review pass vs current commit
1268
- - Open critical blockers:
1269
- - Ship recommendation: APPROVED | APPROVED_WITH_CONCERNS | BLOCKED
1270
-
1271
-
1272
- ## Completeness Snapshot
1273
- - AC coverage: <N>/<M> (<percent>%)
1274
- - Source item coverage (source items backed by ≥1 test slice): <N>/<M> or \`N/A - direct spec/reproduction coverage\`
1275
- - Slice coverage (slices linked to ≥1 AC or bug reproduction slice): <N>/<M>
1276
- - Adversarial review: not triggered | pass | fail
1277
- - Overall: complete | concerns | blocked
1278
-
1279
- ## Coverage Check
1280
- - AC/source-item/slice coverage rationale:
1281
- - Orphaned source items: none | explain gap
1282
- - Orphaned tests: none | explain gap
1283
- - Evidence ref:
1284
-
1285
- ## Verification Command Discovery
1286
- | Source | Discovered command | Result | Evidence ref |
1287
- |---|---|---|---|
1288
- | package.json / pytest / go.mod / Cargo.toml / pom.xml / gradle | | PASS/FAIL | |
1289
-
1290
- ## Blocked Route
1291
- - ROUTE_BACK_TO_TDD: only when Final Verdict = BLOCKED
1292
- - Target stage: tdd
1293
- - Blocking finding IDs:
1294
- - Rewind command payload:
1295
-
1296
- ## Severity Summary
1297
- - Critical:
1298
- - Important:
1299
- - Suggestion:
1300
-
1301
- ## Final Verdict
1302
- - APPROVED | APPROVED_WITH_CONCERNS | BLOCKED
1303
-
1304
- ## Learnings
1305
- - None this stage.
1306
- `,
1307
- "07-review-army.json": `{
1308
- "version": 1,
1309
- "generatedAt": "<ISO 8601 timestamp, e.g. 2026-04-14T12:00:00Z>",
1310
- "scope": {
1311
- "base": "<base branch or ref>",
1312
- "head": "<head branch or ref>",
1313
- "files": []
1314
- },
1315
- "findings": [],
1316
- "reconciliation": {
1317
- "duplicatesCollapsed": 0,
1318
- "conflicts": [],
1319
- "multiSpecialistConfirmed": [],
1320
- "layerCoverage": {
1321
- "spec": false,
1322
- "correctness": false,
1323
- "security": false,
1324
- "performance": false,
1325
- "architecture": false,
1326
- "external-safety": false
1327
- },
1328
- "shipBlockers": []
1329
- }
1330
- }
1331
- `,
1332
- "08-ship.md": `${artifactFrontmatter("ship")}
1333
-
1334
- # Ship Artifact
1335
-
1336
- ${renderBehaviorAnchorTemplateLine("ship")}
1337
-
1338
- ## Upstream Handoff
1339
- - Source artifacts: \`06-tdd.md\`, \`07-review.md\`
1340
- - Decisions carried forward:
1341
- - Constraints carried forward:
1342
- - Open questions:
1343
- - Drift from upstream (or \`None\`):
1344
-
1345
- ## Verify Tests Gate
1346
- - Discovered test command (cite repo config — package scripts / pyproject / go.mod / Cargo.toml / pom.xml / gradle):
1347
- - Result: PASS | FAIL
1348
- - Evidence (full output snippet or path):
1349
- - Stop on FAIL: confirmed (no options surface unless PASS)
1350
-
1351
- ## Preflight Results
1352
- - Review verdict:
1353
- - Build:
1354
- - Tests:
1355
- - Lint:
1356
- - Type-check:
1357
- - Working tree clean:
1358
-
1359
- ## Architect Cross-Stage Verification
1360
- - Skill: architect-cross-stage-verification
1361
- - Result: CROSS_STAGE_VERIFIED | DRIFT_DETECTED | BLOCKED
1362
- - Evidence refs:
1363
- - Drift summary:
1364
-
1365
- ## Base Branch Determination
1366
- - Command run: \`git merge-base HEAD main || git merge-base HEAD master\`
1367
- - Base branch:
1368
- - User confirmation (if ambiguous):
1369
-
1370
- ## Finalization Options
1371
- > Exactly four options must be surfaced when tests pass. Selecting any option requires a recorded user decision.
1372
-
1373
- 1. **Merge back to base locally** — \`MERGE_LOCAL\`
1374
- 2. **Push and create PR** — \`OPEN_PR\`
1375
- 3. **Keep branch as-is** — \`KEEP_BRANCH\`
1376
- 4. **Discard this work** — \`DISCARD\` (typed-confirmation required)
1377
-
1378
- - Selected option:
1379
- - Typed confirmation (DISCARD only):
1380
- - User decision recorded at:
1381
-
1382
- ## Release Notes
1383
- -
1384
-
1385
- ## Traceability Matrix
1386
- | AC ID | Slice ID(s) | Managed commit evidence | Coverage status |
1387
- |---|---|---|---|
1388
- | AC-1 | S-1 | \`abc1234 S-1/green: ...\` | covered |
1389
-
1390
- ## Structured PR Body
1391
- > Required when selected option is \`OPEN_PR\`. The structure is universal — replace placeholder bullets with concrete content, do not introduce domain-specific subsections.
1392
-
1393
- ### ## Summary
1394
- - (2-3 bullets describing what changed and why)
1395
-
1396
- ### ## Test Plan
1397
- - [ ] (verification step — repo-relative command + expected outcome)
1398
- - [ ] (additional verification step or \`Manual: <action>\`)
1399
-
1400
- ### ## Commits Included
1401
- - (auto-generated commit list; one bullet per commit hash + subject)
1402
-
1403
- ## Worktree Cleanup
1404
- - Cleanup applies to options \`MERGE_LOCAL\` and \`DISCARD\`; preserved for \`OPEN_PR\` and \`KEEP_BRANCH\`.
1405
- - Worktree path:
1406
- - Cleanup result:
1407
-
1408
- ## Rollback Plan
1409
- - Trigger conditions:
1410
- - Rollback steps:
1411
- - Verification steps:
1412
-
1413
- ## Monitoring
1414
- - Metrics/logs to watch:
1415
- - Risk note (if no monitoring):
1416
-
1417
- ## Finalization
1418
- - Selected enum (exactly one):
1419
- ${SHIP_FINALIZATION_ENUM_LINES}
1420
- - Selected label (A/B/C/D/E):
1421
- - Execution result:
1422
- - PR URL / merge commit / kept branch / discard confirmation:
1423
- - NO_VCS handoff target + artifact path (if FINALIZE_NO_VCS):
1424
-
1425
- ## Completion Status
1426
- - Victory Detector: pass | fail (review verdict valid, preflight fresh, rollback ready, one finalization enum selected, execution result present)
1427
- - SHIPPED | SHIPPED_WITH_EXCEPTIONS | BLOCKED
1428
- - Exceptions (if any):
1429
-
1430
- ## Retro Gate Handoff
1431
- - Complete the retro gate before archive.
1432
- - Retro artifact path: \`.cclaw/artifacts/09-retro.md\`
1433
- - Archive remains blocked until retro gate is complete.
1434
-
1435
- ## Learnings
1436
- - None this stage.
1437
- `,
1438
- "09-retro.md": `${artifactFrontmatter("retro")}
1439
-
1440
- # Retro Artifact
1441
-
1442
- ## Run Summary
1443
- - Flow track:
1444
- - Scope delivered:
1445
- - Main outcome:
1446
-
1447
- ## Friction Log
1448
- | Category | What slowed us down | Evidence | Prevention rule |
1449
- |---|---|---|---|
1450
- | | | | |
1451
-
1452
- ## Acceleration Log
1453
- | Category | What helped | Evidence | Reuse trigger |
1454
- |---|---|---|---|
1455
- | | | | |
1456
-
1457
- ## Compound Decisions
1458
- | Insight | Trigger pattern | Action rule for next run |
1459
- |---|---|---|
1460
- | | | |
1461
-
1462
- ## Knowledge Writes
1463
- - Compound entries appended to \`.cclaw/knowledge.jsonl\`: <N>
1464
- - Entry ids / timestamps:
1465
-
1466
- ## Retro Completion
1467
- - RETRO_COMPLETE: yes
1468
- - Completed at (UTC):
1469
- - Notes:
1470
-
1471
- ## Learnings
1472
- - None this stage.
1473
- `
1474
- };
1475
- export const RULEBOOK_MARKDOWN = `# Cclaw Rulebook
1476
-
1477
- ## MUST_ALWAYS
1478
- - Follow flow order: brainstorm -> scope -> design -> spec -> plan -> tdd -> review -> ship
1479
- - Require explicit user confirmation after plan before TDD
1480
- - Keep evidence artifacts in \`.cclaw/artifacts/\`
1481
- - Enforce RED before GREEN in TDD
1482
- - Run two-layer review (spec_compliance and code_quality) before ship
1483
- - Validate all inputs before processing — never trust external data without sanitization
1484
- - Prefer immutable data patterns and pure functions where the language supports them
1485
- - Follow existing repo conventions, patterns, and directory structure — match the codebase
1486
- - Verify claims with fresh evidence: "tests pass" requires running tests in this message
1487
- - Use conventional commits: \`type(scope): description\` (feat, fix, refactor, test, docs, chore)
1488
-
1489
- ## MUST_NEVER
1490
- - Skip RED phase and jump directly to GREEN in TDD
1491
- - Ship with critical review findings
1492
- - Start implementation during /brainstorm
1493
- - Modify generated cclaw files manually when CLI can regenerate them
1494
- - Commit \`.cclaw/\` or generated shim files
1495
- - Expose secrets, tokens, API keys, or absolute system paths in agent output
1496
- - Duplicate existing functionality without explicit justification — search before building
1497
- - Bypass security checks, linting hooks, or type checking to "move faster"
1498
- - Claim success ("Done," "All good," "Tests pass") without running verification in this message
1499
- - Make changes outside the blast radius of the current task without user consent
1500
-
1501
- ## DELEGATION
1502
- When a task requires specialist knowledge (security audit, performance profiling, database review),
1503
- delegate to a specialized agent or skill if the harness supports it. The primary agent should:
1504
- 1. Identify the specialist domain
1505
- 2. Provide focused context (relevant files, the specific concern)
1506
- 3. Evaluate the specialist output before acting on it — do not blindly apply recommendations
1507
- `;
1508
- /**
1509
- * Always-on baseline rule materialized at `.cursor/rules/cclaw-guidelines.mdc`.
1510
- * Independent of skill activation — kicks in even when the agent skips
1511
- * loading skills. Three hard rules cover the most common regressions
1512
- * (premature draft, premature subagent dispatch, command-line echo to chat).
1513
- */
1514
- export const CURSOR_GUIDELINES_RULE_MDC = `---
1515
- description: cclaw zero-install behavior baseline (always-on)
1516
- globs:
1517
- - "**/*"
1518
- alwaysApply: true
1519
- ---
1520
-
1521
- <!-- cclaw-managed-cursor-guidelines-rule -->
1522
-
1523
- # Cclaw Baseline Guidelines
1524
-
1525
- These three rules apply to every Cursor agent session in this project,
1526
- regardless of whether stage skills loaded.
1527
-
1528
- ## 1. Q&A floor before drafting (brainstorm/scope/design)
1529
-
1530
- Before drafting any \`.cclaw/artifacts/01-brainstorm-*.md\`,
1531
- \`02-scope-*.md\`, or \`03-design-*.md\`, verify that the artifact's
1532
- \`## Q&A Log\` table demonstrates Ralph-Loop convergence: every
1533
- forcing-question topic id is tagged \`[topic:<id>]\` on at least one row
1534
- (see the stage's forcing-questions checklist for the id list), the last
1535
- 2 turns produce no new decision-changing impact, OR an explicit user
1536
- stop-signal row is recorded. Walk the stage forcing questions one at a
1537
- time via the \`AskQuestion\` tool. If you find yourself proposing a
1538
- draft after 1-2 questions while forcing topic ids remain untagged, STOP
1539
- and continue the loop.
1540
-
1541
- The \`qa_log_unconverged\` linter rule will block \`stage-complete\` when
1542
- convergence has not been reached. \`[topic:<id>]\` tagging is mandatory:
1543
- English keyword detection is intentionally absent because it mis-reports
1544
- convergence on RU/UA Q&A logs.
1545
-
1546
- ## 2. Mandatory subagents run after Q&A approval
1547
-
1548
- For brainstorm / scope / design, mandatory subagents (
1549
- \`product-discovery\`, \`critic\`, \`planner\`, \`architect\`) run **only
1550
- AFTER the user approves the elicitation outcome**, never before the Q&A
1551
- loop converges. Dispatching them early preempts the user dialogue and
1552
- violates the elicitation contract — the linter will block stage-complete.
1553
-
1554
- See each stage's "Run Phase: post-elicitation" rows in the materialized
1555
- Automatic Subagent Dispatch table.
1556
-
1557
- ## 3. Never echo cclaw command lines to chat
1558
-
1559
- The user does not run cclaw helpers (\`node .cclaw/hooks/...\`) manually.
1560
- NEVER paste full command lines, \`--evidence-json '{...}'\` payloads,
1561
- \`--waive-delegation=...\`, or shell hash commands (\`shasum\`,
1562
- \`sha256sum\`, \`Get-FileHash\`, \`certutil\`, etc.) into chat. Run the
1563
- helper via the tool layer and report only the resulting summary. On
1564
- failure, report a compact human-readable summary plus the helper JSON in
1565
- a single fenced \`json\` block.
1566
- `;
1567
- export const CURSOR_WORKFLOW_RULE_MDC = `---
1568
- description: cclaw workflow guardrails for Cursor agent sessions
1569
- globs:
1570
- - "**/*"
1571
- alwaysApply: true
1572
- ---
1573
-
1574
- <!-- cclaw-managed-cursor-workflow-rule -->
1575
-
1576
- # Cclaw Workflow Guardrails
1577
-
1578
- ## Activation Rule
1579
-
1580
- Before responding to coding work:
1581
- 1. Read \`.cclaw/state/flow-state.json\`.
1582
- 2. Start with \`/cc\` or continue with \`/cc\`.
1583
- 3. If no software-stage flow applies, respond normally.
1584
-
1585
- ## Stage Order
1586
-
1587
- \`brainstorm -> scope -> design -> spec -> plan -> tdd -> review -> ship\`
1588
-
1589
- Track-specific skips are allowed only when \`flow-state.track\` + \`skippedStages\` explicitly say so.
1590
-
1591
- ## Task Classification
1592
-
1593
- | Class | Route |
1594
- |---|---|
1595
- | non-trivial software work | \`/cc <idea>\` |
1596
- | trivial software fix | \`/cc <idea>\` (quick track) |
1597
- | bugfix with repro | \`/cc <idea>\` and enforce RED-first in tdd |
1598
- | pure question / non-software | direct answer (no stage flow) |
1599
-
1600
- ## Command Surface
1601
-
1602
- - \`/cc\` = entry and resume.
1603
- - \`/cc\` = only progression path.
1604
- - Knowledge capture and recall use the \`learnings\` skill when requested.
1605
-
1606
- ## Verification Discipline
1607
-
1608
- - No completion claim without fresh command evidence in this turn.
1609
- - Stage completion claim requires \`stage-complete\` exit 0 in the current turn. Quote the single-line success JSON printed to stdout (e.g. \`{"ok":true,"command":"stage-complete",...}\`); do not paraphrase, do not infer success from empty stdout or from skipped retries.
1610
-
1611
- ## Protocol label hygiene
1612
-
1613
- \`skip\` wording means different things depending on phase: brainstorm/scope/design Q&A stop-signals may still literal **skip**/enough/move-on wording; structured ship closeout retros and compound clustering prompts should expose **no changes** (or accept-as-is language) rather than labeling the passive path as skip. Keep the verbs aligned with the harness question copy you present to the human.
1614
- - Do not mark gates passed from memory.
1615
- - Keep evidence in \`.cclaw/artifacts/\`; archive through closeout via \`/cc\` or cancel early via \`node .cclaw/hooks/cancel-run.mjs\`.
1616
-
1617
- ## Delegation And Approvals
1618
-
1619
- - Machine-only checks in design/plan/tdd/review/ship should auto-dispatch when tooling supports it.
1620
- - **For brainstorm / scope / design stages**: ask user input continuously via adaptive elicitation (one question per turn through the harness-native question tool — \`AskQuestion\` in Cursor). Walk the stage forcing-questions list one-by-one. **Tag each Q&A Log row's \`Decision impact\` cell with \`[topic:<id>]\`** (the id is given in the stage's forcing-questions checklist) so the linter can verify coverage in any natural language. Do NOT batch and do NOT defer to a single approval gate at the end. The \`qa_log_unconverged\` linter rule will block \`stage-complete\` when convergence is not reached (forcing topic ids untagged AND last 2 turns still produce decision-changing rows AND no stop-signal).
1621
- - **For other stages** (spec/plan/tdd/build/review/ship): ask user input only at explicit approval gates (scope mode, plan approval, challenge resolution, ship finalization), not for routine progress updates.
1622
- - If you find yourself proposing a draft after 1-2 questions in brainstorm/scope/design, STOP — go back to the forcing-questions list and continue.
1623
- - Mandatory subagents in brainstorm/scope/design run only AFTER the user approves the elicitation outcome (see each stage's "Run Phase: post-elicitation" rows). Dispatching them before the Q&A loop converges violates the contract.
1624
- - Never echo cclaw command lines (\`node .cclaw/hooks/...\`, \`--evidence-json '{...}'\`) to chat — the user does not run cclaw manually. Run helpers via the tool layer; report only the resulting summary.
1625
- - If harness capabilities are partial, record waiver reasons in delegation logs.
1626
-
1627
- ## Routing Source Of Truth
1628
-
1629
- - Primary router: \`.cclaw/skills/using-cclaw/SKILL.md\`.
1630
- - Stage behavior: current stage skill plus \`.cclaw/state/flow-state.json\`.
1631
- - Preamble budget: keep role/status announcements brief and avoid repeating
1632
- them unless the stage or role changes.
1633
- `;
1634
- /**
1635
- * Per-slice prose file written by `slice-builder` (or the controller)
1636
- * to `<artifacts-dir>/tdd-slices/S-<id>.md`. The main `06-tdd.md` is
1637
- * auto-indexed via `## Slices Index`.
1638
- */
1639
- export function tddSliceFileTemplate(sliceId) {
1640
- return `# Slice ${sliceId}
1641
-
1642
- ## Plan unit
1643
- T-...
1644
-
1645
- ## Acceptance criteria
1646
- AC-...
1647
-
1648
- ## Why this slice
1649
-
1650
- ## What was tested
1651
-
1652
- ## What was implemented
1653
-
1654
- ## REFACTOR notes
1655
-
1656
- ## Learnings
1657
- `;
1658
- }
1659
- export function buildRulesJson() {
1660
- return {
1661
- version: 1,
1662
- stage_order: FLOW_STAGES,
1663
- stage_gates: Object.fromEntries(orderedStageSchemas().map((schema) => [
1664
- schema.stage,
1665
- schema.requiredGates.map((gate) => gate.id)
1666
- ])),
1667
- MUST_ALWAYS: [
1668
- "flow_order",
1669
- "plan_confirm_gate",
1670
- "artifact_evidence",
1671
- "tdd_red_before_green",
1672
- "two_layer_review_before_ship",
1673
- "validate_inputs",
1674
- "prefer_immutable",
1675
- "follow_repo_conventions",
1676
- "verify_claims_with_evidence",
1677
- "conventional_commits"
1678
- ],
1679
- MUST_NEVER: [
1680
- "skip_tdd_stage",
1681
- "ship_with_critical_findings",
1682
- "implement_in_brainstorm",
1683
- "manual_edit_generated",
1684
- "commit_cclaw_runtime",
1685
- "expose_secrets_or_paths",
1686
- "duplicate_without_justification",
1687
- "bypass_security_hooks",
1688
- "claim_success_without_verification",
1689
- "changes_outside_blast_radius"
1690
- ]
1691
- };
1692
- }