cadre-ai 3.9.1 → 4.0.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 (233) hide show
  1. package/.claude-plugin/plugin.json +1 -1
  2. package/.codex-plugin/plugin.json +1 -1
  3. package/CHANGELOG.md +176 -0
  4. package/README.md +64 -17
  5. package/dist/cadre-cli.mjs +4 -6
  6. package/dist/cadre-mcp.mjs +5217 -4061
  7. package/package.json +2 -2
  8. package/skills/archive/SKILL.md +11 -11
  9. package/skills/create/SKILL.md +9 -9
  10. package/skills/implement/SKILL.md +7 -7
  11. package/skills/implement/references/resume-recovery.md +2 -0
  12. package/skills/refresh/SKILL.md +25 -18
  13. package/skills/revert/SKILL.md +29 -13
  14. package/skills/review/SKILL.md +21 -30
  15. package/skills/revise/SKILL.md +21 -11
  16. package/skills/status/SKILL.md +2 -0
  17. package/skills/track/SKILL.md +10 -6
  18. package/templates/{v5 → v6}/init/workflow.md +1 -1
  19. package/templates/v1/init/gitignore.template +0 -5
  20. package/templates/v1/init/patterns/index.md +0 -6
  21. package/templates/v1/init/project.json +0 -26
  22. package/templates/v1/init/workflow.md +0 -181
  23. package/templates/v1/project/archive-operation.json +0 -15
  24. package/templates/v1/project/refresh-operation.json +0 -14
  25. package/templates/v1/track/execution.json +0 -19
  26. package/templates/v1/track/learning.md +0 -39
  27. package/templates/v1/track/plan.md +0 -39
  28. package/templates/v1/track/revert-operation.json +0 -13
  29. package/templates/v1/track/revise-operation.json +0 -14
  30. package/templates/v1/track/state.json +0 -25
  31. package/templates/v2/init/archive/.gitkeep +0 -1
  32. package/templates/v2/init/gitignore.template +0 -8
  33. package/templates/v2/init/guidelines.md +0 -25
  34. package/templates/v2/init/operations/.gitkeep +0 -1
  35. package/templates/v2/init/patterns/index.md +0 -6
  36. package/templates/v2/init/product.md +0 -30
  37. package/templates/v2/init/project.json +0 -27
  38. package/templates/v2/init/refreshes/.gitkeep +0 -1
  39. package/templates/v2/init/styleguides/general.md +0 -14
  40. package/templates/v2/init/styleguides/language.md +0 -21
  41. package/templates/v2/init/tech-stack.md +0 -21
  42. package/templates/v2/init/tracks/.gitkeep +0 -1
  43. package/templates/v2/init/tracks.md +0 -6
  44. package/templates/v2/init/wisps/.gitkeep +0 -1
  45. package/templates/v2/init/workflow.md +0 -72
  46. package/templates/v2/project/pattern.md +0 -20
  47. package/templates/v2/project/refresh.md +0 -21
  48. package/templates/v2/styleguides/dart.md +0 -27
  49. package/templates/v2/styleguides/flutter.md +0 -27
  50. package/templates/v2/styleguides/go.md +0 -29
  51. package/templates/v2/styleguides/gradle.md +0 -28
  52. package/templates/v2/styleguides/html-css.md +0 -39
  53. package/templates/v2/styleguides/index.md +0 -27
  54. package/templates/v2/styleguides/java.md +0 -27
  55. package/templates/v2/styleguides/javascript.md +0 -27
  56. package/templates/v2/styleguides/kotlin.md +0 -26
  57. package/templates/v2/styleguides/maven.md +0 -28
  58. package/templates/v2/styleguides/python.md +0 -27
  59. package/templates/v2/styleguides/react.md +0 -28
  60. package/templates/v2/styleguides/swift.md +0 -27
  61. package/templates/v2/styleguides/swiftui.md +0 -27
  62. package/templates/v2/styleguides/typescript.md +0 -26
  63. package/templates/v2/track/bug.md +0 -14
  64. package/templates/v2/track/execution.json +0 -19
  65. package/templates/v2/track/learning.md +0 -39
  66. package/templates/v2/track/plan.md +0 -39
  67. package/templates/v2/track/revision.md +0 -36
  68. package/templates/v2/track/spec.md +0 -38
  69. package/templates/v2/track/state.json +0 -31
  70. package/templates/v3/init/archive/.gitkeep +0 -1
  71. package/templates/v3/init/gitignore.template +0 -8
  72. package/templates/v3/init/guidelines.md +0 -25
  73. package/templates/v3/init/operations/.gitkeep +0 -1
  74. package/templates/v3/init/product.md +0 -30
  75. package/templates/v3/init/project.json +0 -27
  76. package/templates/v3/init/refreshes/.gitkeep +0 -1
  77. package/templates/v3/init/styleguides/general.md +0 -14
  78. package/templates/v3/init/styleguides/language.md +0 -21
  79. package/templates/v3/init/tech-stack.md +0 -21
  80. package/templates/v3/init/tracks/.gitkeep +0 -1
  81. package/templates/v3/init/tracks.md +0 -6
  82. package/templates/v3/init/wisps/.gitkeep +0 -1
  83. package/templates/v3/init/workflow.md +0 -82
  84. package/templates/v3/project/archive-operation.json +0 -19
  85. package/templates/v3/project/pattern.md +0 -20
  86. package/templates/v3/project/refresh-operation.json +0 -18
  87. package/templates/v3/project/refresh.md +0 -21
  88. package/templates/v3/styleguides/dart.md +0 -27
  89. package/templates/v3/styleguides/flutter.md +0 -27
  90. package/templates/v3/styleguides/go.md +0 -29
  91. package/templates/v3/styleguides/gradle.md +0 -28
  92. package/templates/v3/styleguides/html-css.md +0 -39
  93. package/templates/v3/styleguides/index.md +0 -27
  94. package/templates/v3/styleguides/java.md +0 -27
  95. package/templates/v3/styleguides/javascript.md +0 -27
  96. package/templates/v3/styleguides/kotlin.md +0 -26
  97. package/templates/v3/styleguides/maven.md +0 -28
  98. package/templates/v3/styleguides/python.md +0 -27
  99. package/templates/v3/styleguides/react.md +0 -28
  100. package/templates/v3/styleguides/swift.md +0 -27
  101. package/templates/v3/styleguides/swiftui.md +0 -27
  102. package/templates/v3/styleguides/typescript.md +0 -26
  103. package/templates/v3/track/bug.md +0 -14
  104. package/templates/v3/track/execution.json +0 -19
  105. package/templates/v3/track/plan.md +0 -39
  106. package/templates/v3/track/revert-operation.json +0 -17
  107. package/templates/v3/track/revise-operation.json +0 -18
  108. package/templates/v3/track/revision.md +0 -36
  109. package/templates/v3/track/spec.md +0 -38
  110. package/templates/v3/track/state.json +0 -31
  111. package/templates/v4/init/archive/.gitkeep +0 -1
  112. package/templates/v4/init/gitignore.template +0 -8
  113. package/templates/v4/init/guidelines.md +0 -25
  114. package/templates/v4/init/operations/.gitkeep +0 -1
  115. package/templates/v4/init/patterns/index.md +0 -8
  116. package/templates/v4/init/product.md +0 -30
  117. package/templates/v4/init/project.json +0 -27
  118. package/templates/v4/init/refreshes/.gitkeep +0 -1
  119. package/templates/v4/init/styleguides/general.md +0 -14
  120. package/templates/v4/init/styleguides/language.md +0 -21
  121. package/templates/v4/init/tech-stack.md +0 -21
  122. package/templates/v4/init/tracks/.gitkeep +0 -1
  123. package/templates/v4/init/tracks.md +0 -6
  124. package/templates/v4/init/wisps/.gitkeep +0 -1
  125. package/templates/v4/init/workflow.md +0 -91
  126. package/templates/v4/project/archive-operation.json +0 -19
  127. package/templates/v4/project/pattern.md +0 -20
  128. package/templates/v4/project/refresh-operation.json +0 -18
  129. package/templates/v4/project/refresh.md +0 -21
  130. package/templates/v4/styleguides/dart.md +0 -27
  131. package/templates/v4/styleguides/flutter.md +0 -27
  132. package/templates/v4/styleguides/go.md +0 -29
  133. package/templates/v4/styleguides/gradle.md +0 -28
  134. package/templates/v4/styleguides/html-css.md +0 -39
  135. package/templates/v4/styleguides/index.md +0 -27
  136. package/templates/v4/styleguides/java.md +0 -27
  137. package/templates/v4/styleguides/javascript.md +0 -27
  138. package/templates/v4/styleguides/kotlin.md +0 -26
  139. package/templates/v4/styleguides/maven.md +0 -28
  140. package/templates/v4/styleguides/python.md +0 -27
  141. package/templates/v4/styleguides/react.md +0 -28
  142. package/templates/v4/styleguides/swift.md +0 -27
  143. package/templates/v4/styleguides/swiftui.md +0 -27
  144. package/templates/v4/styleguides/typescript.md +0 -26
  145. package/templates/v4/track/bug.md +0 -14
  146. package/templates/v4/track/execution.json +0 -20
  147. package/templates/v4/track/learning.md +0 -45
  148. package/templates/v4/track/plan.md +0 -39
  149. package/templates/v4/track/revert-operation.json +0 -17
  150. package/templates/v4/track/revise-operation.json +0 -18
  151. package/templates/v4/track/revision.md +0 -36
  152. package/templates/v4/track/spec.md +0 -38
  153. package/templates/v4/track/state.json +0 -31
  154. package/templates/v5/init/archive/.gitkeep +0 -1
  155. package/templates/v5/init/guidelines.md +0 -25
  156. package/templates/v5/init/operations/.gitkeep +0 -1
  157. package/templates/v5/init/patterns/index.md +0 -8
  158. package/templates/v5/init/product.md +0 -30
  159. package/templates/v5/init/refreshes/.gitkeep +0 -1
  160. package/templates/v5/init/styleguides/general.md +0 -14
  161. package/templates/v5/init/styleguides/language.md +0 -21
  162. package/templates/v5/init/tech-stack.md +0 -21
  163. package/templates/v5/init/tracks/.gitkeep +0 -1
  164. package/templates/v5/init/tracks.md +0 -6
  165. package/templates/v5/init/wisps/.gitkeep +0 -1
  166. package/templates/v5/project/archive-operation.json +0 -19
  167. package/templates/v5/project/pattern.md +0 -20
  168. package/templates/v5/project/refresh-operation.json +0 -18
  169. package/templates/v5/project/refresh.md +0 -21
  170. package/templates/v5/styleguides/dart.md +0 -27
  171. package/templates/v5/styleguides/flutter.md +0 -27
  172. package/templates/v5/styleguides/go.md +0 -29
  173. package/templates/v5/styleguides/gradle.md +0 -28
  174. package/templates/v5/styleguides/html-css.md +0 -39
  175. package/templates/v5/styleguides/index.md +0 -27
  176. package/templates/v5/styleguides/java.md +0 -27
  177. package/templates/v5/styleguides/javascript.md +0 -27
  178. package/templates/v5/styleguides/kotlin.md +0 -26
  179. package/templates/v5/styleguides/maven.md +0 -28
  180. package/templates/v5/styleguides/python.md +0 -27
  181. package/templates/v5/styleguides/react.md +0 -28
  182. package/templates/v5/styleguides/swift.md +0 -27
  183. package/templates/v5/styleguides/swiftui.md +0 -27
  184. package/templates/v5/styleguides/typescript.md +0 -26
  185. package/templates/v5/track/bug.md +0 -14
  186. package/templates/v5/track/learning.md +0 -45
  187. package/templates/v5/track/revert-operation.json +0 -17
  188. package/templates/v5/track/revise-operation.json +0 -18
  189. package/templates/v5/track/revision.md +0 -36
  190. package/templates/v5/track/spec.md +0 -38
  191. /package/templates/{v1 → v6}/init/archive/.gitkeep +0 -0
  192. /package/templates/{v5 → v6}/init/gitignore.template +0 -0
  193. /package/templates/{v1 → v6}/init/guidelines.md +0 -0
  194. /package/templates/{v1 → v6}/init/operations/.gitkeep +0 -0
  195. /package/templates/{v3 → v6}/init/patterns/index.md +0 -0
  196. /package/templates/{v1 → v6}/init/product.md +0 -0
  197. /package/templates/{v5 → v6}/init/project.json +0 -0
  198. /package/templates/{v1 → v6}/init/refreshes/.gitkeep +0 -0
  199. /package/templates/{v1 → v6}/init/styleguides/general.md +0 -0
  200. /package/templates/{v1 → v6}/init/styleguides/language.md +0 -0
  201. /package/templates/{v1 → v6}/init/tech-stack.md +0 -0
  202. /package/templates/{v1 → v6}/init/tracks/.gitkeep +0 -0
  203. /package/templates/{v1 → v6}/init/tracks.md +0 -0
  204. /package/templates/{v1 → v6}/init/wisps/.gitkeep +0 -0
  205. /package/templates/{v2 → v6}/project/archive-operation.json +0 -0
  206. /package/templates/{v1 → v6}/project/pattern.md +0 -0
  207. /package/templates/{v2 → v6}/project/refresh-operation.json +0 -0
  208. /package/templates/{v1 → v6}/project/refresh.md +0 -0
  209. /package/templates/{v1 → v6}/styleguides/dart.md +0 -0
  210. /package/templates/{v1 → v6}/styleguides/flutter.md +0 -0
  211. /package/templates/{v1 → v6}/styleguides/go.md +0 -0
  212. /package/templates/{v1 → v6}/styleguides/gradle.md +0 -0
  213. /package/templates/{v1 → v6}/styleguides/html-css.md +0 -0
  214. /package/templates/{v1 → v6}/styleguides/index.md +0 -0
  215. /package/templates/{v1 → v6}/styleguides/java.md +0 -0
  216. /package/templates/{v1 → v6}/styleguides/javascript.md +0 -0
  217. /package/templates/{v1 → v6}/styleguides/kotlin.md +0 -0
  218. /package/templates/{v1 → v6}/styleguides/maven.md +0 -0
  219. /package/templates/{v1 → v6}/styleguides/python.md +0 -0
  220. /package/templates/{v1 → v6}/styleguides/react.md +0 -0
  221. /package/templates/{v1 → v6}/styleguides/swift.md +0 -0
  222. /package/templates/{v1 → v6}/styleguides/swiftui.md +0 -0
  223. /package/templates/{v1 → v6}/styleguides/typescript.md +0 -0
  224. /package/templates/{v1 → v6}/track/bug.md +0 -0
  225. /package/templates/{v5 → v6}/track/dependency-context.json +0 -0
  226. /package/templates/{v5 → v6}/track/execution.json +0 -0
  227. /package/templates/{v3 → v6}/track/learning.md +0 -0
  228. /package/templates/{v5 → v6}/track/plan.md +0 -0
  229. /package/templates/{v2 → v6}/track/revert-operation.json +0 -0
  230. /package/templates/{v2 → v6}/track/revise-operation.json +0 -0
  231. /package/templates/{v1 → v6}/track/revision.md +0 -0
  232. /package/templates/{v1 → v6}/track/spec.md +0 -0
  233. /package/templates/{v5 → v6}/track/state.json +0 -0
@@ -7,15 +7,15 @@ description: Review a Cadre track that is ready for review, present evidence-bac
7
7
 
8
8
  ## Cohesive commits and retained context
9
9
 
10
- For v5/schema-2 state, each approved operation produces one immutable receipt under `.cadre/receipts/` and a temporary recovery journal under `.cadre/stage/operations/`. Apply returns `receipt` (or the receipt fields directly): `operationId`, `receiptHash`, `trailers`, and `status: commit_pending`. Include the promoted files and receipt in one agent-created Git commit with both exact returned trailers. Commit execution stays with the agent. Use `candidate_apply` with `request: {mode: "reconcile", projectRoot, operationId}` after committing; reconciliation verifies a unique reachable commit and committed artifacts and changes temporary state only. Never add a follow-up record-SHA commit. An operation reference is `op:<operationId>`, not a Git revision to pass directly to shell Git. Resolve it through receipt reconciliation before Git range commands.
10
+ Each approved operation produces one immutable receipt under `.cadre/receipts/` and a temporary recovery journal under `.cadre/stage/operations/`. Apply returns `receipt` (or the receipt fields directly): `operationId`, `receiptHash`, `trailers`, and `status: commit_pending`. Include the promoted files and receipt in one agent-created Git commit with both exact returned trailers. Commit execution stays with the agent. Use `candidate_apply` with `request: {mode: "reconcile", projectRoot, operationId}` after committing; reconciliation verifies a unique reachable commit and committed artifacts and changes temporary state only. Never add a follow-up record-SHA commit. An operation reference is `op:<operationId>`, not a Git revision to pass directly to shell Git. Resolve it through receipt reconciliation before Git range commands.
11
11
 
12
- Before any dependent delivery, resolve `commit_pending`. On interruption, inspect the persisted recovery journal and original approval; use `candidate_apply` with `request: {mode: "resume", projectRoot, operationId, approvalDigest}` to finish the already-approved promotion. Reconcile an existing commit before creating another. Any drift or ambiguous/forged receipt blocks continuation. Never replace an approved recovery journal or fabricate its approval.
12
+ Before any dependent delivery, resolve `commit_pending`. On interruption, inspect the persisted recovery journal and original approval; use `candidate_apply` with `request: {mode: "resume", projectRoot, operationId, approvalDigest}` to finish the already-approved promotion. Reconcile an existing commit before creating another. Any drift or ambiguous/forged receipt blocks continuation. Never replace an approved recovery journal or fabricate its approval. Resume checks the approved unchanged-input fingerprints before further writes. `OPERATION_INPUT_DRIFT` preserves the pending operation; retain changed files and deliberately restore the approved inputs or obtain an exact repair approval. Never alter recovery hashes, delete the journal, or repeat product work to bypass this gate.
13
13
 
14
- Use the scheduler and validation in mutation results. Do not immediately request the same status again. For `context_read`, retain `retainedContextToken` only after a complete successful read. Pass it on later reads only while that text remains in context, with the same token across continuation pages. Clear it after compaction, context loss, expiration, or a fresh task. Keep `knownSources` only for compatibility. Default pages are 48 KiB, maximum 64 KiB. Section identity/content hashes allow reuse despite unrelated file changes; source freshness is checked independently. Required project instructions, full current spec/plan, applicable constraints, and repository instructions remain authoritative. Consume every page and require `contextReady`. An explicit full-source dependency fallback must be read completely and reassessed; do not silently omit guidance.
14
+ Use the scheduler and validation in mutation results. Do not immediately request the same status again. For `context_read`, retain `retainedContextToken` only after a complete successful read. Pass it on later reads only while that text remains in context, with the same scope, token and knowledge arguments across continuation pages. Do not add or change `knownSources` midway through a paginated read; changing those arguments invalidates its cursor. Clear it after compaction, context loss, expiration, or a fresh task. Default pages are 48 KiB, maximum 64 KiB. Section identity/content hashes allow reuse despite unrelated file changes; source freshness is checked independently. Required project instructions, full current spec/plan, applicable constraints, and repository instructions remain authoritative. Consume every page and require `contextReady`. An explicit full-source dependency fallback must be read completely and reassessed; do not silently omit guidance.
15
15
 
16
16
  Serialized errors are bounded to 8 KiB. Use `diagnostic_read` with the returned diagnostic ID only when fuller evidence is needed; paginate it. Do not dump cache path lists into conversation. Build outputs belong in the runtime-returned owned `buildCachePath`, never an arbitrary `.cadre/.build-cache` directory.
17
17
 
18
- Legacy SHA records and immutable v1–v4 templates remain evidence. Migrate through one approved refresh at a quiescent boundary before creating a v5 execution. Retain each existing execution's original contract and preserve approvals, completed nodes, findings, journals, and archived learning. The v5 commit instructions here replace legacy follow-up provenance commits described below.
18
+ Existing 3.9.0/3.9.1/3.9.2 projects using schema-2 state and template v5 continue without a version-only refresh. If status reports `PROJECT_UPGRADE_REQUIRED`, stop mutations: install Cadre 3.9.0, reconcile interrupted operations and perform its approved refresh to schema-2/v5 at a quiescent boundary, then install 4.0.0 and reload the client. Preserve approvals, historical journals, SHA references and archived learning; never edit version labels to bypass this gate.
19
19
 
20
20
  Review a `ready_for_review` track. A persisted policy-v2 Autonomous review operation may also resume interrupted promotion from `in_progress`; finish that operation before implementation starts. Apply the Autonomous rules below under the originating persisted authorization and retain explicit human approval for clean completion. Load `.cadre/workflow.md`, all track artifacts and learning, dependency context, relevant patterns/styleguides, implementation commits, and repository tests. Read every reviewed file before judging or proposing edits.
21
21
 
@@ -27,7 +27,7 @@ Call `project_status` first with `view: "track"` and `trackId`; use its embedded
27
27
 
28
28
  Build one bounded context inventory from `project_status`, the current track paths, and the reviewed Git range. Read each required artifact once. Do not run a line-count pass before reading, repeat `rg --files` discovery, or reread a whole file after truncated output; continue from the first unread line. During consecutive review cycles in the same flow, reuse unchanged product, workflow, pattern, and styleguide context and verify it by Git path/hash; reread the current state, plan, execution, new review range, and affected files/callers. Use batched parallel reads where independent.
29
29
 
30
- The declared review mutation surface is adaptive `review_complete` for clean completion and `candidate_apply` for v5 remediation. Legacy recovery uses its original explicitly journaled direct-write procedure. Do not inspect the installed runtime, global tool catalog, or generated MCP bundle looking for another review-state tool.
30
+ The declared review mutation surface is adaptive `review_complete` for clean completion and `candidate_apply` for remediation. Do not inspect the installed runtime, global tool catalog, or generated MCP bundle looking for another review-state tool.
31
31
 
32
32
  Expected human decision count is one per review cycle outside policy-v2 Autonomous when the human accepts the recommended exact remediation, approves a clean review, or explicitly rejects findings and approves clean completion. Ask again only when the human changes the proposal or new evidence changes its content or consequences.
33
33
 
@@ -42,7 +42,7 @@ Expected human decision count is one per review cycle outside policy-v2 Autonomo
42
42
  - Inspection validates that target status without changing canonical state. Keep the canonical track `ready_for_review` and its completed execution unchanged until human approval or the exact Autonomous remediation authorization is journaled. If a staged state is included, its status must agree with `targetStatus`; an active execution still requires reconciliation at a safe boundary.
43
43
  - If the human changes the finding subset or remediation, rebuild and validate the exact proposal and request approval once for that changed proposal. Do not reuse approval for superseded content.
44
44
  - If no findings exist, prepare the clean completion proposal in step 5 before presenting its exact transition for approval.
45
- 4. For v5 approved changes, include findings, appended plan, reassessed learning and dependency context in `candidate_apply` prepare with `workflow: "review"`. Autonomous also includes `reviews/loop-<next-cycle>.json` and omits `state.json`: the runtime derives the state transition, changes-requested cycle, attempted finding IDs and receipt reference from canonical authority and the exact snapshot. Keep canonical state and operation unchanged while preparing. Other modes include the proposed `in_progress` state and require the human decision. Apply only the unchanged approved token; the receipt binds its digest without a self-referential operation. Commit `cadre(review): request changes for <track-id>` once with receipt trailers and reconcile before the next execution. For legacy recovery, retain the original candidate_inspect planValidations and SHA journal contract.
45
+ 4. For approved changes, include findings, appended plan, reassessed learning and dependency context in `candidate_apply` prepare with `workflow: "review"`. Autonomous also includes `reviews/loop-<next-cycle>.json` and omits `state.json`: the runtime derives the state transition, changes-requested cycle, attempted finding IDs and receipt reference from canonical authority and the exact snapshot. Keep canonical state and operation unchanged while preparing. Other modes include the proposed `in_progress` state and require the human decision. Apply only the unchanged approved token; the receipt binds its digest without a self-referential operation. Commit `cadre(review): request changes for <track-id>` once with receipt trailers and reconcile before the next execution.
46
46
  5. For a clean review, call `review_complete` with `request: { mode: "prepare", projectRoot, trackId, approval, acceptedRisks? }`. The server derives the cumulative range for Autonomous and the completed execution range for other modes. Present its exact proposal and evidence, then ask once for explicit approval. After approval, call only `request: { mode: "apply", proposalToken }`. A retry converges a matching cycle/index without duplicating history. Commit `cadre(review): complete <track-id>` with the receipt trailers and reconcile. If a retry returns `receipt.status: committed` and no changed paths, completion is already committed; do not create another commit or ask for another approval.
47
47
 
48
48
  Repeat review → implement → review until a human approves a clean review. Autonomous continues the loop in this task without asking permission for in-scope remediation. Other approval modes retain their existing gates. Only this command may mark a track completed.
@@ -55,9 +55,9 @@ Satisfy `prerequisite` before handoff: `implementation_bookkeeping_commit` means
55
55
 
56
56
  ## Memory contract
57
57
 
58
- Preserve phase history and existing handoffs. For active v3/v4/v5 tracks, keep the marked `cadre:memory` JSON block inside Pattern Seed synchronized with the proposed spec/plan revisions and exact approved pattern hashes. Every applicable pattern requires its safe `patterns/<slug>.md` path, SHA-256, and human-readable relevance/constraints; never invent or silently omit guidance. When a staged plan changes revisions, include the reassessed learning file in `expectedFiles`. Inspect `candidate_inspect.learning` and `memoryInputs` as well as `plans`; resolve invalid or stale memory before approval. Immediately before direct promotion, re-inspect and compare the complete approved digest, including unchanged memory inputs; changed inputs require reassessment and a corrected approval. Archive apply performs this check in the runtime. Completed and archived learning remains historical evidence, not a claim that old hashes describe current patterns.
58
+ Preserve phase history and existing handoffs. For active tracks, keep the marked `cadre:memory` JSON block inside Pattern Seed synchronized with the proposed spec/plan revisions and exact approved pattern hashes. Every applicable pattern requires its safe `patterns/<slug>.md` path, SHA-256, and human-readable relevance/constraints; never invent or silently omit guidance. When a staged plan changes revisions, include the reassessed learning file in `expectedFiles`. Inspect `candidate_inspect.learning` and `memoryInputs` as well as `plans`; resolve invalid or stale memory before approval. Immediately before direct promotion, re-inspect and compare the complete approved digest, including unchanged memory inputs; changed inputs require reassessment and a corrected approval. Archive apply performs this check in the runtime. Completed and archived learning remains historical evidence, not a claim that old hashes describe current patterns.
59
59
 
60
- The legacy input field `approval` carries prepared review evidence, not a claim of a human decision. State stores it as `reviewEvidence`. Prepare once, obtain approval of the exact digest, and apply its token unchanged. The runtime adds `approvalConfirmation` with the bound digest, confirmation time and `explicit-apply` method, separately from the evidence. Do not re-prepare merely to replace pending-approval prose. This receipt records the approved application, not an authenticated identity or a fabricated quotation from a human.
60
+ The input field `approval` carries prepared review evidence, not a claim of a human decision. State stores it as `reviewEvidence`. Prepare once, obtain approval of the exact digest, and apply its token unchanged. The runtime adds `approvalConfirmation` with the bound digest, confirmation time and `explicit-apply` method, separately from the evidence. Do not re-prepare merely to replace pending-approval prose. This receipt records the approved application, not an authenticated identity or a fabricated quotation from a human.
61
61
 
62
62
  The clean-review prepare state hash excludes the future `approvalConfirmation`. After apply, verify the applied state/index against the returned immutable receipt's artifact hashes, and confirm that the state differs from the prepared proposal only by this exact confirmation. Do not require the prepared and applied state hashes to be identical or treat that documented addition as source drift. Preserve the original approval and finish its pending commit/reconciliation.
63
63
 
@@ -65,24 +65,7 @@ The clean-review prepare state hash excludes the future `approvalConfirmation`.
65
65
 
66
66
  These rules override intermediate human gates only for a valid policy-v2 persisted Autonomous loop. Use the same candidate, journal, promotion, memory, and commit procedure above. Main owns scheduling and state and performs a separate review pass; no additional reviewer agent is required. Never duplicate a review cycle, execution, or commit during recovery.
67
67
 
68
- For legacy executions only, use this exact canonical `state.operation` shape for remediation; a finding disposition such as `request_changes` is not an operation action. V5 uses `candidate_apply` and its ignored recovery journal instead; never create this legacy operation for a new v5 promotion:
69
-
70
- ```json
71
- {
72
- "action": "review",
73
- "checkpoint": "approved",
74
- "baseCommit": "<canonical HEAD before promotion>",
75
- "expectedCommit": "cadre(review): request changes for <track-id>",
76
- "approvedArtifacts": ["<each inspected relative path>"],
77
- "approvedArtifactHashes": [{ "path": "<same relative path>", "sha256": "<inspected hash>" }],
78
- "artifactProgress": [],
79
- "approvedAt": "<ISO timestamp of this mode-authorized operation>",
80
- "approvalDigest": "<complete inspected digest>",
81
- "authorization": { "kind": "persisted-mode", "originExecutionId": "<original execution>", "proposalDigest": "<same digest>" }
82
- }
83
- ```
84
-
85
- For that legacy journal, list every inspected file in both artifact arrays, including the loop snapshot and learning. `approvedArtifacts` contains path strings; `approvedArtifactHashes` contains path/hash objects. `expectedCommit` is the intended commit message, not a SHA. After journaling, call `state_validate` and require valid state before the first canonical promotion; repair journal metadata without changing its inspected manifest or authority if validation fails. Record the findings assigned to the next remediation execution as `attemptedFindingIds` on the changes-requested cycle, even though their completed-attempt counters are initially empty. V5 derives this cycle in the promotion preview and records no new human confirmation for automatic remediation.
68
+ Use `candidate_apply` to derive the remediation transition from the staged loop snapshot and artifacts. The preview binds the exact findings, next remediation execution and persisted-mode authorization to its receipt. Do not author a separate direct-write review operation or add a provenance commit.
86
69
 
87
70
  ## Durable authority and checkpoints
88
71
 
@@ -108,13 +91,21 @@ Checkpoints are `implementing`, `reviewing`, `remediating`, `awaiting_approval`,
108
91
 
109
92
  1. Finish the current implementation journal and commit its bookkeeping before invoking review. At `ready_for_review`, review `initialBaseCommit..lastExecution.headCommit`, all acceptance criteria, affected callers/tests, and prior findings. Verify actual product changes and re-run affected checks. Do not treat the latest remediation diff alone as a clean track review.
110
93
  2. Keep each finding's ID stable across renames, moves, rewritten fixes, and review wording. Use lowercase slug IDs such as `exact-integer-precision` in loop JSON; uppercase bug labels in report headings are not finding IDs. Reopen a recurring finding using the same ID. After reviewing a completed execution that attempted that finding, append that execution ID to `attemptExecutionIds` only if absent; never count the original discovery execution or count an interrupted attempt twice. Mark resolved only from actual verification and review evidence. Preserve resolved finding history.
111
- 3. If an open finding has two recorded remediation execution IDs, stop with checkpoint `blocked` and a precise blocker. Do the same for material scope decisions, unavailable human-only verification, or external blockers. Present the evidence and ask how to continue; never reset IDs/attempt counts to bypass the stop. Persist this evidence in canonical state using a focused bookkeeping commit. On explicit instructions to retry a stalled finding, use a digest-bound refresh to record those instructions and start a new authorized loop while retaining the former loop in track history.
112
- 4. For progressable in-scope findings, stage bug artifacts, appended remediation phases and final verification, learning, reassessed `dependency-context.json`, and `reviews/loop-<cycle>.json` at the review candidate root. Use the next cycle number. The loop snapshot contains the complete updated `autonomousReview` object: retained authority/findings, reviewed execution/HEAD, and checkpoint `remediating`. Include every exact path in `expectedFiles`; validate the proposed plan as `in_progress`. Keep canonical state `ready_for_review` until promotion; omit staged `state.json` in v5. Do not reopen or rename completed verification phases or change the specification revision; increment the plan revision once.
113
- 5. Re-inspect the exact complete staged set immediately before promotion; require valid plan and fresh learning/memory inputs. For v5, prepare `candidate_apply` with that exact manifest and `workflow: "review"`, verify its derived proposal against the persisted authority, then apply its unchanged token. The runtime journals the approved receipt and records attempted finding IDs; do not hand-write canonical state, `state.operation`, or `approvalConfirmation`. The candidate_inspect digest and candidate_apply digest bind different previews: use the apply tool's proposal token for promotion. Legacy recovery retains the journal authorization and digest procedure above.
114
- 6. For v5, commit all promoted files and the immutable receipt once with both returned trailers, then reconcile the operation. On interruption, resume or reconcile that original receipt; never create a second commit to record its SHA or clear an operation in tracked state. The runtime copies the approved snapshot into `state.autonomousReview` and clears the canonical operation in the same promotion. Legacy recovery retains its original promotion/commit/provenance contract. After reconciliation, call focused `project_status` and follow its `nextStep` into implement with a new execution ID and inherited Autonomous mode. No additional user prompt is needed for these bounded changes.
94
+ 3. For each open finding, count remediation execution IDs since its latest explicitly approved `retryAuthorization.attemptBaseline`; count all IDs when no retry authority exists. After two new attempts in that budget, stop with checkpoint `blocked` and a precise blocker. Retain the entire attempt array as history. Do the same for material scope decisions, unavailable human-only verification, or external blockers. Present the evidence and ask how to continue; never reset IDs/attempt counts to bypass the stop. Persist this evidence in canonical state using a focused bookkeeping commit. On explicit instructions to retry a blocked or stalled loop, use the refresh skill’s `reviewRetry` request under a new digest-bound human approval. Stage the unchanged current track state and a human-instruction refresh record. The runtime preserves the original authorization, cumulative baseline, finding identities and all attempts, appends the complete prior loop to refresh history, removes the approved blocker and records a fresh two-attempt budget. Never hand-reset attempts, replace the loop or reuse an earlier approval to renew the budget.
95
+ 4. For progressable in-scope findings, stage bug artifacts, appended remediation phases and final verification, learning, reassessed `dependency-context.json`, and `reviews/loop-<cycle>.json` at the review candidate root. Use the next cycle number. The loop snapshot contains the complete updated `autonomousReview` object: retained authority/findings, reviewed execution/HEAD, and checkpoint `remediating`. Include every exact path in `expectedFiles`; validate the proposed plan as `in_progress`. Keep canonical state `ready_for_review` until promotion; omit staged `state.json` in this receipt-based review operation. Do not reopen or rename completed verification phases or change the specification revision; increment the plan revision once.
96
+
97
+ The runtime checks the persisted loop's blocked/stalled gate before accepting this snapshot. Changing only the proposed checkpoint cannot remove a blocker. Pending remediation also retains and revalidates its original authority on generic resume, including after state promotion or candidate-stage loss. Older partial intent without exact pre-promotion evidence requires an approved evidence repair; never replace its digest or reset the loop to continue.
98
+ 5. Re-inspect the exact complete staged set immediately before promotion; require valid plan and fresh learning/memory inputs. prepare `candidate_apply` with that exact manifest and `workflow: "review"`, verify its derived proposal against the persisted authority, then apply its unchanged token. The runtime journals the approved receipt and records attempted finding IDs; do not hand-write canonical state, `state.operation`, or `approvalConfirmation`. The candidate_inspect digest and candidate_apply digest bind different previews: use the apply tool's proposal token for promotion. Legacy recovery retains the journal authorization and digest procedure above.
99
+ 6. Commit all promoted files and the immutable receipt once with both returned trailers, then reconcile the operation. On interruption, resume or reconcile that original receipt; never create a second commit to record its SHA or clear an operation in tracked state. The runtime copies the approved snapshot into `state.autonomousReview` and clears the canonical operation in the same promotion. Legacy recovery retains its original promotion/commit/provenance contract. After reconciliation, call focused `project_status` and follow its `nextStep` into implement with a new execution ID and inherited Autonomous mode. No additional user prompt is needed for these bounded changes.
115
100
 
116
101
  ## Clean result and approval
117
102
 
118
103
  When no unresolved findings remain, persist checkpoint `awaiting_approval`, findings, and `reviewedExecutionId`/`reviewedHead`, and retain that evidence durably on disk without a clean-evidence-only commit. The track remains `ready_for_review`. Call `review_complete` prepare with review evidence, present verification results, remediation history, and its exact completion proposal, and ask once for explicit human approval. Apply only that unchanged token after approval; only the review runtime marks the loop and track completed. Autonomous does not use `acceptedRisks` to waive findings.
119
104
 
120
105
  Resume `awaiting_approval` by checking the recorded execution/HEAD and product content, preparing a fresh token if needed, and requesting the still-missing final approval. A prior unresolved question is not approval. Changed product or verification inputs require renewed verification/review and a new clean checkpoint; ordinary Cadre bookkeeping alone does not. A request for changes returns to review under the existing scope; cancellation stops with state intact.
106
+
107
+ ## Review freshness on approval and recovery
108
+
109
+ All modes preserve the complete completed plan and append remediation at exactly the next plan revision, with the specification revision unchanged. Ordinary review state retains its prior execution, scope, policy and review history and appends one `changes_requested` cycle naming that execution's ID, plan revision, graph digest and reviewed HEAD. Approval of a review does not authorize reopening completed tasks. Pending promotion retains exact original state/plan evidence for recovery after partial writes or stage loss; missing or inconsistent original evidence requires an approved repair, never recreated hashes or another delivery run.
110
+
111
+ Every approval mode checks product and verification-policy content against the reviewed HEAD before clean completion. Interrupted clean or finding-bearing review promotion performs the same check before any remaining write, using the reviewed evidence retained in its original intent, including older pending receipts. Preserve dirty changes and the pending journal if freshness fails; verify the current product and obtain an exact repair approval, or deliberately restore the approved inputs. A committed approval replays its immutable historical receipt even after later product changes.
@@ -7,24 +7,29 @@ description: Route a requested track change according to lifecycle state, revise
7
7
 
8
8
  ## Cohesive commits and retained context
9
9
 
10
- For v5/schema-2 state, each approved operation produces one immutable receipt under `.cadre/receipts/` and a temporary recovery journal under `.cadre/stage/operations/`. Apply returns `receipt` (or the receipt fields directly): `operationId`, `receiptHash`, `trailers`, and `status: commit_pending`. Include the promoted files and receipt in one agent-created Git commit with both exact returned trailers. Commit execution stays with the agent. Use `candidate_apply` with `request: {mode: "reconcile", projectRoot, operationId}` after committing; reconciliation verifies a unique reachable commit and committed artifacts and changes temporary state only. Never add a follow-up record-SHA commit. An operation reference is `op:<operationId>`, not a Git revision to pass directly to shell Git. Resolve it through receipt reconciliation before Git range commands.
10
+ Each approved operation produces one immutable receipt under `.cadre/receipts/` and a temporary recovery journal under `.cadre/stage/operations/`. Apply returns `receipt` (or the receipt fields directly): `operationId`, `receiptHash`, `trailers`, and `status: commit_pending`. Include the promoted files and receipt in one agent-created Git commit with both exact returned trailers. Commit execution stays with the agent. Use `candidate_apply` with `request: {mode: "reconcile", projectRoot, operationId}` after committing; reconciliation verifies a unique reachable commit and committed artifacts and changes temporary state only. Never add a follow-up record-SHA commit. An operation reference is `op:<operationId>`, not a Git revision to pass directly to shell Git. Resolve it through receipt reconciliation before Git range commands.
11
11
 
12
- Before any dependent delivery, resolve `commit_pending`. On interruption, inspect the persisted recovery journal and original approval; use `candidate_apply` with `request: {mode: "resume", projectRoot, operationId, approvalDigest}` to finish the already-approved promotion. Reconcile an existing commit before creating another. Any drift or ambiguous/forged receipt blocks continuation. Never replace an approved recovery journal or fabricate its approval.
12
+ Before any dependent delivery, resolve `commit_pending`. On interruption, inspect the persisted recovery journal and original approval; use `candidate_apply` with `request: {mode: "resume", projectRoot, operationId, approvalDigest}` to finish the already-approved promotion. Reconcile an existing commit before creating another. Any drift or ambiguous/forged receipt blocks continuation. Never replace an approved recovery journal or fabricate its approval. Resume checks the approved unchanged-input fingerprints before further writes. `OPERATION_INPUT_DRIFT` preserves the pending operation; retain changed files and deliberately restore the approved inputs or obtain an exact repair approval. Never alter recovery hashes, delete the journal, or repeat product work to bypass this gate.
13
13
 
14
- Use the scheduler and validation in mutation results. Do not immediately request the same status again. For `context_read`, retain `retainedContextToken` only after a complete successful read. Pass it on later reads only while that text remains in context, with the same token across continuation pages. Clear it after compaction, context loss, expiration, or a fresh task. Keep `knownSources` only for compatibility. Default pages are 48 KiB, maximum 64 KiB. Section identity/content hashes allow reuse despite unrelated file changes; source freshness is checked independently. Required project instructions, full current spec/plan, applicable constraints, and repository instructions remain authoritative. Consume every page and require `contextReady`. An explicit full-source dependency fallback must be read completely and reassessed; do not silently omit guidance.
14
+ Use the scheduler and validation in mutation results. Do not immediately request the same status again. For `context_read`, retain `retainedContextToken` only after a complete successful read. Pass it on later reads only while that text remains in context, with the same scope, token and knowledge arguments across continuation pages. Do not add or change `knownSources` midway through a paginated read; changing those arguments invalidates its cursor. Clear it after compaction, context loss, expiration, or a fresh task. Default pages are 48 KiB, maximum 64 KiB. Section identity/content hashes allow reuse despite unrelated file changes; source freshness is checked independently. Required project instructions, full current spec/plan, applicable constraints, and repository instructions remain authoritative. Consume every page and require `contextReady`. An explicit full-source dependency fallback must be read completely and reassessed; do not silently omit guidance.
15
15
 
16
16
  Serialized errors are bounded to 8 KiB. Use `diagnostic_read` with the returned diagnostic ID only when fuller evidence is needed; paginate it. Do not dump cache path lists into conversation. Build outputs belong in the runtime-returned owned `buildCachePath`, never an arbitrary `.cadre/.build-cache` directory.
17
17
 
18
- Legacy SHA records and immutable v1–v4 templates remain evidence. Migrate through one approved refresh at a quiescent boundary before creating a v5 execution. Retain each existing execution's original contract and preserve approvals, completed nodes, findings, journals, and archived learning. The v5 commit instructions here replace legacy follow-up provenance commits described below.
18
+ Existing 3.9.0/3.9.1/3.9.2 projects using schema-2 state and template v5 continue without a version-only refresh. If status reports `PROJECT_UPGRADE_REQUIRED`, stop mutations: install Cadre 3.9.0, reconcile interrupted operations and perform its approved refresh to schema-2/v5 at a quiescent boundary, then install 4.0.0 and reload the client. Preserve approvals, historical journals, SHA references and archived learning; never edit version labels to bypass this gate.
19
19
 
20
20
  Read `.cadre/workflow.md`, the full target track, its dependencies, all tracks that depend on it, relevant repository files, and applicable patterns. Read each artifact before editing; never propose a revision from guessed contents.
21
21
 
22
22
  At every required clarification or approval boundary, show a concise impact summary or focused diff. Inspect the active host policy before calling `workflow_elicit`: if the task context reports approval policy `never`, including Codex Full Access, skip the form and ask the same short question once in chat. Otherwise prefer `workflow_elicit`, using `clarification` for at most three questions and `approval` bound to the exact revision proposal checkpoint. Treat only an `approved` result as approval. If it returns `fallback_required`, or immediately returns `declined` while the task explicitly reports policy `never`, ask the same short question once in chat; the latter is policy rejection, not a human decline. Never request secrets or retry the form.
23
23
 
24
- Call `project_status` first with `view: "implementation"` and `trackId` for active canonical work, otherwise `view: "track"`; use its embedded structured validation and do not repeat `state_validate` at command entry. Stop on invalid status. A `staged_track_candidate` has no approved baseline: route its changes through the track proposal without creating a revision artifact or operation.
24
+ Call `project_status` first with `view: "implementation"` and `trackId` for active canonical work, otherwise `view: "track"`; use its embedded structured validation and do not repeat `state_validate` at command entry. Stop on invalid status, except for preparing an explicitly approved revision repair when the only errors are the reported revision's scope/current-graph mismatch and the original execution binding remains intact. Inspect the original receipt, full artifacts, and committed execution plan first; unrelated validation failures remain blockers. A `staged_track_candidate` has no approved baseline: route its changes through the track proposal without creating a revision artifact or operation.
25
+
26
+ Pending recovery enforces the original history, fresh revision record and synchronized counters before further writes. If an older intent lacks that evidence, retain it for an explicitly approved repair; do not repeatedly reconcile it or fabricate missing approval fields. Already-committed receipt replay remains historical and unchanged.
27
+
28
+ For an imported draft, derive the specification counter from its committed approval, not an edited draft plan. Revision and its recovery keep `drafting-plan` with no plan approval or execution; obtain plan approval through track before implementation.
25
29
 
26
30
  ## Route by current status
27
31
 
32
+ - No canonical track: use `track`; revision cannot create its own approved baseline, including when resuming an older pending operation.
28
33
  - `drafting-spec`: follow the `track` specification procedure and resume its journal. The content is not yet an approved baseline, so do not create a revision artifact or increment a revision.
29
34
  - `drafting-plan`: if the approved specification changes, perform the semantic revision procedure below and remain `drafting-plan`; if only the unapproved plan changes, resume the `track` planning procedure without a revision artifact.
30
35
  - `planned`: perform the semantic revision and remain `planned`.
@@ -43,16 +48,21 @@ Expected human decision count is one when the requested change and partial-work
43
48
  3. Apply the workflow clarification gate. Ask when materially different interpretations remain for the desired outcome, scope, acceptance criteria, compatibility, dependency changes, treatment of completed or partial work, or whether dependent tracks should change now. Do not infer permission to invalidate approved work.
44
49
  4. Trace transitive dependent tracks. For each, classify impact as none, reseed-only, plan change, spec change, or invalidated work, with evidence. If evidence cannot resolve a material impact, ask before choosing a classification.
45
50
  5. Call `template_get_many` once for `track/revision` and `track/revise-operation`, then `candidate_stage_prepare` for `revise-<track-id>` with `expectedFiles` equal to the exact revision and affected artifact paths. Render only that set beneath the stage, preserving eventual track-relative paths and completed provenance.
46
- 6. Increment revisions exactly once and restore derived manual-verification barriers. A changed plan uses a new execution ID. Do not pass plan Markdown through MCP, validate the stale canonical plan, or create a temporary project copy.
47
- When appending work after completed track verification, preserve that historical phase's exact title, task IDs, checks, and commit markers and append a new final `Track-level User Manual Verification`. Historical verification depends only on its preceding phases. Candidate inspection uses the intended resulting status for a revision of `ready_for_review`; no pre-approval canonical status change is needed. A staged state must agree with its plan's `targetStatus`, and active execution bindings must still match the reconciled graph.
48
- 7. Call `candidate_inspect` once for every staged revision and cascading artifact. Supply one `planValidations` entry for every staged root or nested `plan.md`, using its exact candidate-relative path and intended resulting track status; omit the list only when the candidate contains no plans. Present every plan result, the target revision, manifest, partial-work disposition, dependent changes, lifecycle transitions, commits, and bookkeeping together, bound to its digest. Partial approval requires a fresh inspection.
49
- 8. Include proposed final states, reassessed dependency-context artifacts, and every cascading change in `candidate_apply` prepare with `workflow: "revise"`. This replaces direct promotion and the separate candidate inspection on the v5 path; `planValidations` remains the legacy inspection interface. Preserve original execution bindings and historical evidence.
51
+ 6. Increment revisions exactly once and restore derived manual-verification barriers. A changed approved plan uses a new execution ID; a specification revision while drafting-plan retains the unapproved plan and has no execution. Do not pass plan Markdown through MCP, validate the stale canonical plan, or create a temporary project copy.
52
+ When appending work after completed track verification, preserve that historical phase's exact title, task IDs, checks, and commit markers and append a new final `Track-level User Manual Verification`. Historical verification depends only on its preceding phases. Proposed state and plan must agree on the resulting lifecycle status; keep canonical state and the original execution binding unchanged until the runtime derives the revision transition.
53
+ 7. Use sequential task ordinals in each phase. Preserve completed task IDs, titles, dependencies and commit groups. Inserting work before pending tasks may renumber those pending tasks and their dependency references; do not renumber completed work. If this cannot preserve completed provenance, append a new phase. A completed task line ends with `<!-- commit: FULL_HEX_SHA -->`, substituting its verified full SHA; a bare `[SHA]` or backticked SHA is not a task commit marker. A completed phase uses `- Phase completion commit: ` followed by its backticked verified SHA.
54
+ Validate the full revision through `candidate_apply` prepare below. Do not first run `candidate_inspect` on revised state that still retains the original execution binding: that inspection compares the new graph with the old journal before revision derivation. Keep every staged file in the manifest, including state.json; fix reported staged syntax or content rather than dropping files or clearing authority.
55
+ 8. Use only `candidate_apply` prepare with `workflow: "revise"`, including `state.json` with the next track revision, exactly one revision record per revised track, reassessed dependency-context artifacts, and every cascading change. A changed specification requires the next spec revision in a reassessed plan; changed graphs require the next plan revision and updated learning/dependency context. The revision record must agree with all previous/new revision numbers. Preserve the authored operation, last execution, review cycles, Autonomous loop, and commit references; the runtime derives their resulting transition in the proposal. Do not rewrite the old execution to fit the new graph or clear its binding before approval. Copy completed-task and phase commit markers from verified journal evidence into the revised plan, retaining their structure and handoffs. Invalidated completed work requires an approved additive revert first.
56
+ For an imported `drafting-plan` baseline with an approved spec and no approved plan or execution, keep the proposed status `drafting-plan`. Stage the changed spec, reassessed draft plan/learning/dependency context, next track revision, and fresh revision record together. Preserve authored commit references; the runtime records the previous spec approval, binds the revised spec, and leaves `commits.plan` null. Increment the spec and draft-plan counters exactly once. An initial draft with no plan uses previous spec revision 1 and previous plan revision 0; do not guess missing counters for a later draft. Resume the track drafting flow afterwards to obtain combined plan approval before delivery. Draft-plan-only edits stay on track drafting without a semantic revision.
57
+ At a quiescent active boundary, the full proposal includes the old journal as `superseded`, its unchanged node evidence, the retained execution binding, and updated Autonomous scope authority. Superseded does not mean completed. Inspect the complete manifest and `stateChanges` before asking for approval. After commit/reconciliation, start a new execution for the revised graph with inherited modes; do not resume the superseded execution. A spec-only promotion or a committed revision record alone cannot complete this transition. Receipt reconciliation verifies the recorded promotion; it cannot manufacture fields omitted from its original approval.
58
+ For an older incomplete promotion, keep its receipt and revision record immutable and use a fresh repair artifact. State/plan/spec revision numbers must describe the actual canonical source and proposed result. When canonical plan and active journal differ, include `## Recovery evidence` with exact `- Previous execution graph: <graphDigest>` and `- Previous execution plan commit: <planCommit>` lines. The runtime verifies the journal against that reachable committed plan before proposing supersession; it never rewrites the original graph or invents completion.
59
+ Assign appended delivery a fresh commit group; adding tasks to an already completed group would require replacing that group's verified product commit and is rejected before approval.
50
60
  9. Obtain one approval for its exact manifest/digest, then apply the proposal token. Commit `cadre(revise): update <track-id>` with the operation receipt trailers and reconcile. The runtime sets changed spec/plan references before commit and updates the index atomically. Do not write a follow-up record commit or fill the operation's SHA into tracked files.
51
61
 
52
62
  ## Memory contract
53
63
 
54
- Preserve phase history and existing handoffs. For active v3/v4/v5 tracks, keep the marked `cadre:memory` JSON block inside Pattern Seed synchronized with the proposed spec/plan revisions and exact approved pattern hashes. Every applicable pattern requires its safe `patterns/<slug>.md` path, SHA-256, and human-readable relevance/constraints; never invent or silently omit guidance. When a staged plan changes revisions, include the reassessed learning file in `expectedFiles`. Inspect `candidate_inspect.learning` and `memoryInputs` as well as `plans`; resolve invalid or stale memory before approval. Immediately before direct promotion, re-inspect and compare the complete approved digest, including unchanged memory inputs; changed inputs require reassessment and a corrected approval. Archive apply performs this check in the runtime. Completed and archived learning remains historical evidence, not a claim that old hashes describe current patterns.
64
+ Preserve phase history and existing handoffs. For active tracks, keep the marked `cadre:memory` JSON block inside Pattern Seed synchronized with the proposed spec/plan revisions and exact approved pattern hashes. Every applicable pattern requires its safe `patterns/<slug>.md` path, SHA-256, and human-readable relevance/constraints; never invent or silently omit guidance. When a staged plan changes revisions, include the reassessed learning file in `expectedFiles`. Use the combined `candidate_apply` preparation to validate the proposed graph, state and memory together; resolve invalid or stale inputs before approval. Bind approval to that complete proposal digest, including unchanged memory inputs. If inputs change, reassess and prepare a corrected proposal for approval; never substitute a separate inspection digest for the apply token. Completed and archived learning remains historical evidence, not a claim that old hashes describe current patterns.
55
65
 
56
66
  ## Revision provenance
57
67
 
58
- Use `revisions/revision-<id>.md` (including the `revision-` prefix), with lowercase letters, digits and hyphens in the artifact ID, such as `revisions/revision-2.md` or `revisions/revision-20261001t064657z.md`. Uppercase ISO timestamp letters and dots are not allowed in that basename. Include the same path in the approved manifest and operation. Before clearing the revision operation, set `state.commits.spec` and `state.commits.plan` to the revision artifact commit for every spec/plan changed by that commit. Confirm the committed plan has the proposed revisions and graph; a reachable SHA alone is insufficient. For v5, candidate_apply includes stable operation references in the original approval envelope; reconcile them without a follow-up commit. Do not start delivery with pointers to an older revision. Retain the previous execution binding and handoffs while an approved repair operation owns state.
68
+ Use `revisions/revision-<id>.md` (including the `revision-` prefix), with lowercase letters, digits and hyphens in the artifact ID, such as `revisions/revision-2.md` or `revisions/revision-20261001t064657z.md`. Uppercase ISO timestamp letters and dots are not allowed in that basename. Include the same path in the approved manifest and operation. The runtime binds changed `state.commits.spec` and `state.commits.plan` to the revision operation receipt within the approved promotion. Confirm the committed plan has the proposed revisions and graph; a reachable SHA alone is insufficient. candidate_apply includes stable operation references in the original approval envelope; reconcile them without a follow-up commit. Do not start delivery with pointers to an older revision. Retain the previous execution binding and handoffs while an approved repair operation owns state.
@@ -26,3 +26,5 @@ Read any file before quoting or interpreting it. Do not mutate files, run commit
26
26
  ## Bounded reporting
27
27
 
28
28
  This workflow creates no commits. Reuse retained context and the latest mutation receipt when available; status itself is read-only. Report `commit_pending` as unresolved provenance, never as completed delivery. Clear retainedContextToken after context loss. Use diagnostic_read only for explicitly needed full diagnostics; ordinary errors are capped at 8 KiB. Never migrate or normalize historical state from this workflow.
29
+
30
+ When status reports `PROJECT_UPGRADE_REQUIRED`, show its upgrade instructions: use Cadre 3.9.0 to reconcile pending operations and perform the approved schema-2/v5 refresh, then install 4.0.0 and reload the client. Compatible 3.9.0/3.9.1/3.9.2 schema-2/v5 projects need no version-only refresh. Do not mutate metadata from status.
@@ -7,18 +7,20 @@ description: Create or resume a Cadre feature or bug track, including a function
7
7
 
8
8
  ## Cohesive commits and retained context
9
9
 
10
- For v5/schema-2 state, each approved operation produces one immutable receipt under `.cadre/receipts/` and a temporary recovery journal under `.cadre/stage/operations/`. Apply returns `receipt` (or the receipt fields directly): `operationId`, `receiptHash`, `trailers`, and `status: commit_pending`. Include the promoted files and receipt in one agent-created Git commit with both exact returned trailers. Commit execution stays with the agent. Use `candidate_apply` with `request: {mode: "reconcile", projectRoot, operationId}` after committing; reconciliation verifies a unique reachable commit and committed artifacts and changes temporary state only. Never add a follow-up record-SHA commit. An operation reference is `op:<operationId>`, not a Git revision to pass directly to shell Git. Resolve it through receipt reconciliation before Git range commands.
10
+ Each approved operation produces one immutable receipt under `.cadre/receipts/` and a temporary recovery journal under `.cadre/stage/operations/`. Apply returns `receipt` (or the receipt fields directly): `operationId`, `receiptHash`, `trailers`, and `status: commit_pending`. Include the promoted files and receipt in one agent-created Git commit with both exact returned trailers. Commit execution stays with the agent. Use `candidate_apply` with `request: {mode: "reconcile", projectRoot, operationId}` after committing; reconciliation verifies a unique reachable commit and committed artifacts and changes temporary state only. Never add a follow-up record-SHA commit. An operation reference is `op:<operationId>`, not a Git revision to pass directly to shell Git. Resolve it through receipt reconciliation before Git range commands.
11
11
 
12
- Before any dependent delivery, resolve `commit_pending`. On interruption, inspect the persisted recovery journal and original approval; use `candidate_apply` with `request: {mode: "resume", projectRoot, operationId, approvalDigest}` to finish the already-approved promotion. Reconcile an existing commit before creating another. Any drift or ambiguous/forged receipt blocks continuation. Never replace an approved recovery journal or fabricate its approval.
12
+ Before any dependent delivery, resolve `commit_pending`. On interruption, inspect the persisted recovery journal and original approval; use `candidate_apply` with `request: {mode: "resume", projectRoot, operationId, approvalDigest}` to finish the already-approved promotion. Reconcile an existing commit before creating another. Any drift or ambiguous/forged receipt blocks continuation. Never replace an approved recovery journal or fabricate its approval. Resume checks the approved unchanged-input fingerprints before further writes. `OPERATION_INPUT_DRIFT` preserves the pending operation; retain changed files and deliberately restore the approved inputs or obtain an exact repair approval. Never alter recovery hashes, delete the journal, or repeat product work to bypass this gate.
13
13
 
14
- Use the scheduler and validation in mutation results. Do not immediately request the same status again. For `context_read`, retain `retainedContextToken` only after a complete successful read. Pass it on later reads only while that text remains in context, with the same token across continuation pages. Clear it after compaction, context loss, expiration, or a fresh task. Keep `knownSources` only for compatibility. Default pages are 48 KiB, maximum 64 KiB. Section identity/content hashes allow reuse despite unrelated file changes; source freshness is checked independently. Required project instructions, full current spec/plan, applicable constraints, and repository instructions remain authoritative. Consume every page and require `contextReady`. An explicit full-source dependency fallback must be read completely and reassessed; do not silently omit guidance.
14
+ Use the scheduler and validation in mutation results. Do not immediately request the same status again. For `context_read`, retain `retainedContextToken` only after a complete successful read. Pass it on later reads only while that text remains in context, with the same scope, token and knowledge arguments across continuation pages. Do not add or change `knownSources` midway through a paginated read; changing those arguments invalidates its cursor. Clear it after compaction, context loss, expiration, or a fresh task. Default pages are 48 KiB, maximum 64 KiB. Section identity/content hashes allow reuse despite unrelated file changes; source freshness is checked independently. Required project instructions, full current spec/plan, applicable constraints, and repository instructions remain authoritative. Consume every page and require `contextReady`. An explicit full-source dependency fallback must be read completely and reassessed; do not silently omit guidance.
15
15
 
16
16
  Serialized errors are bounded to 8 KiB. Use `diagnostic_read` with the returned diagnostic ID only when fuller evidence is needed; paginate it. Do not dump cache path lists into conversation. Build outputs belong in the runtime-returned owned `buildCachePath`, never an arbitrary `.cadre/.build-cache` directory.
17
17
 
18
- Legacy SHA records and immutable v1–v4 templates remain evidence. Migrate through one approved refresh at a quiescent boundary before creating a v5 execution. Retain each existing execution's original contract and preserve approvals, completed nodes, findings, journals, and archived learning. The v5 commit instructions here replace legacy follow-up provenance commits described below.
18
+ Existing 3.9.0/3.9.1/3.9.2 projects using schema-2 state and template v5 continue without a version-only refresh. If status reports `PROJECT_UPGRADE_REQUIRED`, stop mutations: install Cadre 3.9.0, reconcile interrupted operations and perform its approved refresh to schema-2/v5 at a quiescent boundary, then install 4.0.0 and reload the client. Preserve approvals, historical journals, SHA references and archived learning; never edit version labels to bypass this gate.
19
19
 
20
20
  Create only `feature` or `bug` tracks. Resume an existing drafting track instead of replacing it.
21
21
 
22
+ Track IDs remain reserved after archive. Inspect both active and archived ownership before proposing a new track; terminal work needs a distinct successor ID. An interrupted older proposal that would duplicate an archived ID requires an approved repair, preserving the archived evidence and pending intent.
23
+
22
24
  At every required clarification or approval boundary, show a concise summary or focused diff. Inspect the active host policy before calling `workflow_elicit`: if the task context reports approval policy `never`, including Codex Full Access, skip the form and ask the same short question once in chat. Otherwise prefer `workflow_elicit`, using `clarification` for at most three questions and `approval` bound to the current proposal digest. Treat only an `approved` result as approval. If it returns `fallback_required`, or immediately returns `declined` while the task explicitly reports policy `never`, ask the same short question once in chat; the latter is policy rejection, not a human decline. Never request secrets or retry the form.
23
25
 
24
26
  ## Required context
@@ -38,12 +40,14 @@ Call `project_status` first with `view: "project"` for a new track or `view: "tr
38
40
  7. Author `dependency-context.json` from every transitive dependency's spec and learning. Record spec/plan revisions, direct dependency IDs, the dependency-graph fingerprint, exact source SHA-256s, and stable constraint IDs with source-linked text. Source records contain exactly `{path, sha256}`; put applicability assessments in constraints shaped `{id, text, sources: [sourcePath]}`, not extra source fields or a singular `source` field. Every source needs an explicit applicability assessment, including no applicable constraints when justified. This curated context is part of the same human approval; never silently summarize away uncertain requirements. An empty dependency set uses the supplied template.
39
41
  8. Call `candidate_apply` with `request: {mode: "prepare", projectRoot, candidateId: "track-<track-id>", workflow: "track", files: ["spec.md", "plan.md", "learning.md", "state.json", "dependency-context.json"]}`. It validates graphs, state and memory and generates the final state/index. Present the complete proposed content, manifest, commit groups, dependency coverage, and one combined commit. After approval, call `request: {mode: "apply", proposalToken}`. Commit `cadre(track): plan <track-id>` once with receipt trailers, then reconcile. No direct canonical promotion, separate specification commit, index call, or record-plan commit is needed.
40
42
 
41
- For legacy candidates, `candidate_inspect` with exact `planValidations` remains available for diagnostics and the original recovery contract. New tracks use the combined v5 operation.
43
+ For legacy candidates, `candidate_inspect` with exact `planValidations` remains available for diagnostics and the original recovery contract. New tracks use the combined receipt-based operation.
42
44
 
43
45
  Expected human decision count is one for a clear new track; do not create a specification-only approval prompt.
44
46
 
45
47
  The plan is the execution source of truth. Dependency changes or a modified approved spec require the Cadre revise workflow.
46
48
 
49
+ When resuming `drafting-plan`, compare the proposed specification against its reachable approved commit, even if the working copy already contains requested edits. Preserve that approved content, specification revision counter, track revision and dependencies during planning. Unapproved draft-plan counters cannot replace the specification's approval evidence. Route changed approved scope through revise first; an interrupted older planning proposal that replaces it requires an approved repair.
50
+
47
51
  ## Memory contract
48
52
 
49
- Preserve phase history and existing handoffs. For active v3/v4/v5 tracks, keep the marked `cadre:memory` JSON block inside Pattern Seed synchronized with the proposed spec/plan revisions and exact approved pattern hashes. Every applicable pattern requires its safe `patterns/<slug>.md` path, SHA-256, and human-readable relevance/constraints; never invent or silently omit guidance. When a staged plan changes revisions, include the reassessed learning file in `expectedFiles`. Inspect `candidate_inspect.learning` and `memoryInputs` as well as `plans`; resolve invalid or stale memory before approval. Immediately before direct promotion, re-inspect and compare the complete approved digest, including unchanged memory inputs; changed inputs require reassessment and a corrected approval. Archive apply performs this check in the runtime. Completed and archived learning remains historical evidence, not a claim that old hashes describe current patterns.
53
+ Preserve phase history and existing handoffs. For active tracks, keep the marked `cadre:memory` JSON block inside Pattern Seed synchronized with the proposed spec/plan revisions and exact approved pattern hashes. Every applicable pattern requires its safe `patterns/<slug>.md` path, SHA-256, and human-readable relevance/constraints; never invent or silently omit guidance. When a staged plan changes revisions, include the reassessed learning file in `expectedFiles`. Inspect `candidate_inspect.learning` and `memoryInputs` as well as `plans`; resolve invalid or stale memory before approval. Immediately before direct promotion, re-inspect and compare the complete approved digest, including unchanged memory inputs; changed inputs require reassessment and a corrected approval. Archive apply performs this check in the runtime. Completed and archived learning remains historical evidence, not a claim that old hashes describe current patterns.
@@ -96,7 +96,7 @@ drafting-spec -> drafting-plan -> planned -> in_progress -> ready_for_review
96
96
  - Initialization and combined track planning each use one commit. Revise, refresh, clean review and archive each use one approved-operation commit. Implementation uses one product commit per cohesive group plus one completion commit. Revert uses approved reversal commits plus one reconciliation commit. Status and standard Wisp make no commits.
97
97
  - Keep execution journals durable on disk; no automatic execution-start, phase-record, final-verification-phase or clean-evidence-only commits. An explicit handoff/blocker checkpoint is allowed. Reconciliation removes only ignored recovery state and never creates a follow-up provenance commit.
98
98
  - New plans may assign commit groups within a phase. Preserve every task's verification, authorization and handoff, execute internal dependencies in order, and approve all affected siblings before reverting a shared commit. Existing executions retain their original contract.
99
- - Candidate apply validates approved Cadre manifests and promotes state/indexes together. It cannot edit arbitrary product files or execute Git. Migration requires one approved refresh at a quiescent boundary; preserve historical evidence and immutable v1–v4 templates.
99
+ - Candidate apply validates approved Cadre manifests and promotes state/indexes together. It cannot edit arbitrary product files or execute Git. Existing 3.9.x projects with schema-2 state and template v5 continue without migration. Older project formats must be migrated with Cadre 3.9.0 before using 4.0; preserve historical evidence and approvals.
100
100
  - Active dependency-context artifacts carry curated source-linked contracts and inherited constraints under the same approval. Missing/stale coverage triggers explicit reassessment or a identified full-source fallback. Never rewrite archived learning.
101
101
  - Use 48 KiB context pages and retainedContextToken after complete retrieval; clear it after context loss. Source-section hashes permit reuse while source freshness remains independently checked. Mutations return scheduler/validation for reuse.
102
102
  - Use composite record_verification without a separate start. Complete a direct-main phase against verified HEAD in one checkpoint. Integration may fast-forward and may retain only validated owned execution state. Build outputs use the owned ignored `.cadre/.build-cache/cadre/` subtree. Other untracked files remain errors.
@@ -1,5 +0,0 @@
1
- # Cadre-managed temporary execution worktrees
2
- /.worktrees/
3
-
4
- # Disposable Wisp output
5
- /wisps/
@@ -1,6 +0,0 @@
1
- # Pattern Catalog
2
-
3
- Patterns are created only by distilling completed, cleanly reviewed tracks during archival.
4
-
5
- | Pattern | Summary | Provenance | Supersedes |
6
- | --- | --- | --- | --- |
@@ -1,26 +0,0 @@
1
- {
2
- "schemaVersion": 1,
3
- "runtimeVersion": "{{RUNTIME_VERSION}}",
4
- "templateSetVersion": "{{TEMPLATE_SET_VERSION}}",
5
- "project": {
6
- "name": "{{PROJECT_NAME}}",
7
- "context": "{{greenfield|brownfield}}"
8
- },
9
- "setup": {
10
- "status": "in_progress",
11
- "checkpoint": "approved",
12
- "commit": null,
13
- "artifactProgress": [],
14
- "operation": {
15
- "action": "create",
16
- "baseCommit": "{{BASE_COMMIT_OR_NULL}}",
17
- "expectedCommit": "cadre(create): initialize project harness",
18
- "repositoryRoot": "{{PROJECT_ROOT}}",
19
- "gitDisposition": "{{existing|initialize}}",
20
- "approvedArtifacts": [],
21
- "approvedAt": "{{APPROVED_AT}}"
22
- }
23
- },
24
- "lastRefresh": null,
25
- "history": []
26
- }
@@ -1,181 +0,0 @@
1
- # Cadre Workflow
2
-
3
- This file governs every Cadre command except that `wisp` does not mutate Cadre state. If a command-specific instruction conflicts with this file, stop and present the conflict to the human.
4
-
5
- Cadre's plugin-scoped MCP server is the authoritative runtime and immutable template provider. Project-local `.cadre/` contains only approved mutable context, lifecycle artifacts, and history; it must not contain copied Cadre runtime code or template catalogs. Stateful commands fail closed when required Cadre MCP tools are unavailable.
6
-
7
- ## Non-negotiable operating rules
8
-
9
- ### Read before edit
10
-
11
- Before editing an existing file, read the current file and its directly relevant context, including applicable repository instructions, callers, tests, types, and configuration. Before creating a file, inspect the target directory and nearby conventions. Never change a file by guessing its current contents. Record material evidence read in the task or review summary.
12
-
13
- ### Human governance
14
-
15
- Treat semantic content, scope, and consequences as proposals until the human reviews and explicitly approves them. One approval creates an authorization envelope over the complete exact proposal and all unchanged deterministic consequences named in it, including operation journals, generated indexes, validation, commits, lifecycle transitions, and provenance recording. Those mechanics do not become separate human decisions. Persist the authorization and checkpoint before pausing a multi-stage flow so another session can resume it.
16
-
17
- Present exact content or focused diffs, consequences, unknowns, and verification evidence once at the decision boundary. Combine related decisions whenever their complete artifacts and consequences are available together. In particular, do not split create configuration from initialization, a clear track specification from its validated plan, finding disposition from prepared remediation, project refresh from its exact cascading track changes, revert intent from deterministic reconciliation, reject-all risk acceptance from clean-review completion, or a uniquely determined archive selection from its full batch proposal. A response must unambiguously approve every included semantic consequence. Require a corrected proposal and new approval only when content, scope, selection, digest-bound semantics, verification exceptions, or newly discovered consequences materially change.
18
-
19
- An `implement` invocation authorizes execution using its persisted `approvalMode`: `governed`, `phase`, or `autonomous`. This is scoped authorization for work already bounded by the approved specification and plan, not permission to guess through material ambiguity, expand scope, waive required checks, perform destructive or remote actions, or conceal conflicts and exceptions. `phase` is the default unless the human explicitly requests another approval mode; a resumed execution inherits its recorded mode. Starting a `phase` or `autonomous` execution from that invocation does not require a separate approval prompt.
20
-
21
- ### Human interaction forms
22
-
23
- For a required clarification or human decision, first show only the concise context, focused diff, consequences, and evidence needed to decide. Inspect the active host policy before calling the read-only `workflow_elicit` MCP tool. If the task context reports approval policy `never`, including Codex Full Access, skip the form and ask the same short question once in chat. Otherwise prefer `workflow_elicit` so Codex and Claude can render the same client-native form. Use `clarification` with at most three flat questions. Use `approval` only after the exact proposal or verification evidence is ready, and bind it to the current preview digest or an immutable checkpoint containing the relevant track, execution/node, and commit. An `approved` result is explicit human approval of that binding; `changes_requested`, `declined`, and `cancelled` are not approval.
24
-
25
- If the client does not advertise form elicitation or rejects the request with `fallback_required`, ask the same short question once in chat and do not retry the form. If `workflow_elicit` was mistakenly called while the task explicitly reports policy `never` and immediately returns `declined`, treat that response as policy rejection and use the same chat fallback; do not report it as a human decline. Never use form elicitation for passwords, API keys, access tokens, payment credentials, or other secrets. Do not print a complete unchanged workflow or other large default artifact merely to create context for a form; identify it by path/version/hash and summarize it unless the human asks for the full content.
26
-
27
- ### Clarification gate
28
-
29
- Inspect available files, history, state, and approved artifacts before asking. If a material choice remains ambiguous and different answers would change scope, requirements, acceptance criteria, dependencies, compatibility, architecture, plans, or cascading state, ask the human a concise targeted question and pause that branch of work. Do not guess, choose a convenient default, or treat silence as approval. Continue without asking only when evidence resolves the choice or the assumption is immaterial and is explicitly disclosed.
30
-
31
- `create` must explicitly classify the repository as `greenfield` or `brownfield`. Greenfield means no substantive existing product implementation/history; brownfield means existing implementation, behavior, users, data, interfaces, or delivery history must be understood and preserved or intentionally changed. If evidence is mixed or insufficient, ask which classification to use before drafting Cadre artifacts. Persist the approved classification in `project.json` and `product.md`.
32
-
33
- `track`, `revise`, and `refresh` must apply this gate before drafting and again whenever later analysis reveals a new material ambiguity.
34
-
35
- ### Create-time configuration envelope
36
-
37
- During `create`, identify the default workflow by template ID, version, hash, and a concise summary. Include it with product context, Git disposition, styleguides, generated state, and initialization consequences in one final approval envelope. Do not create separate workflow, styleguide-selection, manifest, Git-initialization, validation, or commit approvals. Ask before the final proposal only when a material workflow or convention choice is unresolved; a clarification answer is input to the final proposal, not an additional approval stage.
38
-
39
- Always propose `styleguides/general.md`. Match the proposed tech stack against the bundled default catalog, then propose the applicable language, framework, and build-tool guides as one set. Let the human request an amended default or a user-provided replacement without asking them to accept every guide separately. Framework/tool guides supplement their language guide: HTML/CSS underpins browser UI; TypeScript supplements JavaScript; React for the web supplements HTML/CSS plus JavaScript or TypeScript; Flutter supplements Dart; SwiftUI supplements Swift; Maven or Gradle supplements Java/Kotlin. In brownfield projects, existing enforced conventions take precedence unless the final envelope explicitly replaces them.
40
-
41
- ### Interruption-safe operations
42
-
43
- At command entry, call `project_status` once and use its embedded structured validation. Reserve a separate `state_validate` call for final mutation gates or focused diagnostics; do not perform redundant full-project validation scans. Derived-state warnings such as a stale generated `tracks.md` are resumable drift, not canonical corruption. Report and repair them through the MCP render gate within the owning authorization envelope before a final commit.
44
-
45
- Within one command flow, inventory required context once and reuse content whose Git path/hash is unchanged. Continue truncated reads from the first unread line instead of restarting them. Do not run line-count or repeated path-discovery passes before known reads. Consecutive reviews reread the current lifecycle artifacts and changed implementation range while reusing unchanged project guidance. Archive reads selected evidence and provenance in one bounded pass. Fetch known immutable template IDs directly with `template_get_many`; do not call the catalog merely to rediscover them.
46
-
47
- For every multi-step state mutation—and specifically `create`, both spec/plan stages of `track`, `implement`, finding-bearing `review`, `revise`, `refresh`, `revert`, and archive batches—write an operation journal immediately after approval and before artifact writes or Git mutations. Use `project.json.setup.operation` for create, track `state.json.operation` plus `executions/execution-<ts>.json` for implementation, track `state.json.operation` for other track-local flows including revert, and a versioned operation file under `.cadre/operations/` for refresh and archive batches. Record the action, durable checkpoint, base commit, expected commit message, approved artifact paths, and per-artifact progress.
48
-
49
- On every command entry, reconcile an existing journal before starting new work:
50
-
51
- 1. If the journal exists and matching files are dirty, resume the first incomplete artifact/checkpoint, validate, and create the expected commit.
52
- 2. If the journal exists, the worktree is clean, and HEAD matches its expected message and base relationship, the artifact commit already succeeded; record HEAD instead of repeating work.
53
- 3. If the artifact SHA is recorded and only the approved state bookkeeping is dirty, finish its `cadre(...): record ...` commit.
54
- 4. If files, journal, approval record, Git status, or HEAD disagree, stop and present the mismatch. Never reset, discard, reconstruct from guesses, or restart the flow.
55
-
56
- Advance the checkpoint after each durable artifact write. Once an artifact commit is identified, append it to history and advance the lifecycle checkpoint. Preserve or transition the same operation journal while later stages remain inside one authorization envelope, as with combined track specification and planning; clear it only after every authorized stage and provenance record is complete. This protocol makes interruption before a commit, between commits, after a commit, or before follow-up bookkeeping resumable.
57
-
58
- During `create`, detect an existing worktree with `git rev-parse --show-toplevel` and never initialize a nested repository. If no worktree exists, record the approved project root and `initialize` disposition through the MCP initialization preview/apply gate before running `git init` there. Verify the resulting root and record that checkpoint before the setup commit. Resume a pending initialization from the journal; stop if the observed repository conflicts with the recorded disposition or root.
59
-
60
- For deterministic MCP mutations, call the read-only preview immediately before apply and pass only its opaque proposal token. Do not inspect the global tool catalog or probe previews to rediscover declared contracts. Show the exact proposal whenever the owning workflow and persisted approval mode require a human decision. In `phase` or `autonomous` implementation, execution start plus deterministic worktree, clean integration, cleanup, journal, index, and bookkeeping mutations already covered by the invocation do not create new approval prompts. A stale token is refreshed before presentation rather than forcing duplicate approval. The MCP never grants approval or replaces required repository inspection. Its Git surface is limited to constrained Cadre worktree creation, integration, and safe cleanup; it accepts no arbitrary command, path, force deletion, or automatic conflict resolution.
61
-
62
- Resuming a recorded authorization envelope never requires another human approval when the operation journal has the same approval/content digest and the newly previewed artifacts are identical to the approved proposal, with only checkpoint progress changed. Any content, selection, semantic consequence, or approval-digest mismatch requires a corrected proposal and new approval.
63
-
64
- When a command skill explicitly instructs direct writes for approved Cadre artifacts and no corresponding MCP mutation tool is declared, those direct writes are intentional. Do not search the global tool list for an undeclared operation. Journal the change first, use the available MCP validation and derived-render gates, and stop if the resulting state does not match the approved proposal.
65
-
66
- ### Sources of truth
67
-
68
- - `plan.md` is the execution source of truth for phase/task identities, dependencies, verification barriers, completion, and commit provenance. Display order is only a deterministic scheduling tie-breaker.
69
- - `spec.md` is the scope and acceptance source of truth.
70
- - Each track's `state.json` is the canonical source for its identity, title, type, status, track dependencies, revision, checkpoints, operation pointer, completed execution, and history; it must agree with the approved spec and plan. Active execution nodes are derived from the execution journal, never duplicated as singular active phase/task fields.
71
- - Track location is derived: non-archived state lives at `tracks/<track-id>` and archived state at `archive/<track-id>`. Never persist a track path field.
72
- - `project.json` contains project/setup/refresh history only; it does not duplicate track records.
73
- - `tracks.md` is a generated lifecycle summary discovered from track-local state. It intentionally omits dependencies and paths; never hand-edit it.
74
- - Templates are immutable plugin resources addressed by logical IDs such as `track/spec`; they are rendered into approved artifacts but are never copied into `.cadre/`.
75
- - Git is the implementation history. Do not claim completion without recorded commits.
76
- - `.cadre/.gitignore` keeps `.worktrees/` and `wisps/` out of Git. Worktree and Wisp contents are runtime-only and never Cadre history.
77
-
78
- ## Lifecycle
79
-
80
- ```text
81
- drafting-spec -> drafting-plan -> planned -> in_progress -> ready_for_review
82
- | | | |
83
- +-- revise ---+-------------+ +-- revise --> in_progress/planned
84
- | | +-- approved bugs --> in_progress
85
- +-------------+ +-- clean review --> completed --> archived
86
-
87
- completed/archived -- changed intent --> successor track
88
- ```
89
-
90
- Legal track statuses are `drafting-spec`, `drafting-plan`, `planned`, `in_progress`, `ready_for_review`, `completed`, and `archived`. The `revise` command may be invoked in any status, but it routes according to the approved-baseline rules below; it does not make completed or archived history mutable. Only review can mark `completed`; only archive can mark `archived`.
91
-
92
- ## Track construction
93
-
94
- - Track type is exactly `feature` or `bug`.
95
- - A spec contains functional requirements, non-functional requirements, acceptance criteria, additional information, dependencies, and impact.
96
- - A plan is an acyclic graph. Every regular phase explicitly declares phase dependencies; every regular task explicitly declares same-phase task dependencies. Missing declarations, unknown references, self-dependencies, cross-phase task dependencies, and cycles are invalid.
97
- - Every delivery/remediation phase ends with a task named `User Manual Verification`; its dependencies are derived as every sibling delivery task and must not be repeated in the plan.
98
- - The final phase is named `Track-level User Manual Verification`, contains only `User Manual Verification`, and implicitly depends on every preceding phase. Those dependencies are derived and must not be repeated.
99
- - A track may start implementation only when every declared dependency is completed or archived after completion.
100
- - After spec and plan approval, populate the marked Pattern Seed section at the top of `learning.md` only from relevant, existing patterns and cite the source pattern paths. Do not create a separate seed file.
101
-
102
- ## Implementation scheduling and discipline
103
-
104
- `implement` defaults to parallel mode unless the human explicitly requests sequential execution. Persist the requested and effective mode in the execution journal. Parallel mode is permission to schedule ready work concurrently, not a requirement to create workers: when fewer than two safe executable nodes are ready, execute in the main agent without worker overhead. Bound workers by the minimum of ready nodes, host capacity, and the approved workflow maximum of 3.
105
-
106
- Persist one independent implementation approval mode:
107
-
108
- - `governed`: require human approval for every regular task diff and commit, conflict resolution, manual-verification barrier, and material integration transition.
109
- - `phase` (default): execute regular work autonomously but pause at each phase's final `User Manual Verification` task.
110
- - `autonomous`: execute regular work and phase-level verification autonomously; pause only at `Track-level User Manual Verification`.
111
-
112
- All modes stop for a material ambiguity, scope or compatibility decision, failed required check needing an exception, unsafe or mismatched state, destructive action, remote publication, or other authority not granted by the approved spec, plan, and execution. Such a stop is a clarification or blocker, not a routine approval gate. Track-level manual verification always requires the human.
113
-
114
- The main agent is the only scheduler and operational owner of every phase integration worktree. Workers never spawn workers, mutate `.cadre/**`, merge, resolve integration conflicts, delete worktrees, or record human approval. Treat the track as a hierarchical DAG: phase dependencies determine active phases, task dependencies determine ready tasks inside each running phase, and main allocates the global worker bound across all ready work. Different phases may run different modes concurrently. Inside one phase, use direct main execution for one ready task, a temporary phase-worker lease for a tightly coupled sequential chain when delegation is justified, or task-worker fan-out for two or more independent ready tasks.
115
-
116
- A phase has one mutating execution mode at a time but may switch modes at a clean, journaled checkpoint. Before fan-out, the phase worker finishes and records the current task, verifies the phase worktree is clean, reports its HEAD, releases its lease through a `running`-to-`running` phase update with `workerId: null`, and remains inactive. Main creates each task worktree from that recorded phase HEAD and integrates branches one at a time. Only after every active task worker is completed and its integration/cleanup recorded may main assign a phase worker again. A phase/task worker edits product files only in its assigned absolute worktree, runs focused verification, and returns a structured diff/evidence/learning summary. In `governed` it waits for human task approval before committing; in `phase` or `autonomous` main reviews scope and evidence, then authorizes the commit under the persisted mode.
117
-
118
- Before creating workers, main performs a host-permission preflight from the approved plan, repository scripts, lockfiles, and likely checks. Host security permission and Cadre lifecycle approval are separate: a shell, network, listener, or filesystem prompt does not approve an artifact, commit, merge, verification result, or journal transition. Reuse already-approved commands and prefixes; centralize shared installs, registry access, image pulls, code generation, and other shared preparation; use locked/offline worker commands where supported; and request a new permission only for one exact necessary operation with a narrow reusable prefix. Do not chain unrelated privilege levels, repeat equivalent commands, or use scaffolding modes that create nested repositories requiring destructive cleanup. Run independent read-only inspections and checks in parallel when the host supports it; keep only commands with a real data, mutation, or Git dependency sequential. A worker that encounters an unexpected permission stops and reports the exact command to main.
119
-
120
- Cadre worktrees use sibling namespaces because one worktree cannot safely contain another:
121
-
122
- ```text
123
- .cadre/.worktrees/<track>/<execution>/phases/P1
124
- .cadre/.worktrees/<track>/<execution>/tasks/P1--t1-1
125
- ```
126
-
127
- Git ancestry is derived from the current canonical or registered phase-worktree HEAD. Task branches merge without squashing into the registered phase worktree when one exists, otherwise into canonical main for explicitly main-coordinated work. Phase branches merge without squashing into canonical main. Cadre tool names are direct contracts: semantic execution events use `execution_checkpoint_preview`/`execution_checkpoint_apply`, and every apply receives only the opaque proposal token returned by preview. Worktree tools derive phase and base from the node ID and current Git state.
128
-
129
- 1. Load this workflow and the full current track. Validate the DAG and reconcile the execution journal, Git worktrees, branch tips, dirty files, and recent commits before scheduling.
130
- 2. Root phases read the marked Pattern Seed. Every other phase reads learning from all declared dependency phases; parallel sibling phases do not assume each other's learning.
131
- 3. Derive ready work from the journal and allocate workers by critical path, downstream work unblocked, then plan order. Send semantic checkpoint events only after their commit, verification, integration, or approval evidence exists; the server expands each event into its complete legal transition sequence.
132
- 4. Follow read-before-edit and keep every worker limited to its assigned node and worktree.
133
- 5. Write/update tests and documentation required by the spec and Definition of Done.
134
- 6. Run focused checks per task, combined phase checks after task integration, and the relevant broader suite after conflict resolution, phase integration, and before track verification. Record command, working directory, result, and verified product HEAD/tree; reuse a passing result while product files, test inputs, and policy are unchanged. `.cadre/**`-only bookkeeping does not invalidate product verification.
135
- 7. Main reads every worker diff and evidence. In `governed`, present each regular task for human approval before its Conventional Commit. In `phase` or `autonomous`, main may authorize an in-scope, fully verified task commit without another prompt and records the persisted mode as its approval evidence. A phase worker checkpoints one regular task at a time and waits for main to record the distinct SHA before starting the next task. Manual-verification nodes may reuse phase-head or merge evidence instead of creating empty commits.
136
- 8. Resolve task conflicts in the phase integration worktree and phase conflicts in the canonical worktree. Read both sides and rerun combined verification. In `governed`, present the resolution for approval. In `phase` or `autonomous`, resolve an unambiguous in-scope conflict autonomously and retain it for the next verification evidence; stop for clarification if it requires a material product or scope decision. Never let the leaf worker silently resolve integration conflicts.
137
- 9. Phase-level manual verification becomes ready only after every sibling task is integrated. Run its technical evidence in the phase worktree through the phase worker when present, otherwise through main. `governed` and `phase` require one human approval at this final phase task; `autonomous` records the verified evidence without a prompt. Afterward checkpoint, phase integration, provenance, learning, and cleanup are deterministic consequences and do not create extra approvals outside `governed`. Keep the phase node `integrated` through safe worktree cleanup, then mark it `completed` and start dependents. Cleanup may recover an already-`completed` node without reopening that terminal state. A phase remains `running` until all sibling tasks and this barrier are `completed`; integration and cleanup must not run early.
138
- 10. Track-level manual verification becomes ready only after every phase is integrated, is executed entirely by the main agent in the canonical worktree, and requires explicit human approval in every mode.
139
- 11. Remove a worktree with `git worktree remove` and delete its branch without force only after clean, recorded integration. Never delete dirty, conflicted, unintegrated, or mismatched work.
140
- 12. Append dependency-aware phase learning. Do not overwrite earlier learning.
141
-
142
- Product task commits remain distinct provenance boundaries. Cadre-only learning and journal bookkeeping is committed at meaningful checkpoints, not per internal status. Execution finish derives HEAD/time and atomically applies plan evidence, the completed journal, `ready_for_review` state, and `tracks.md`, so do not run marker or index repair workflows.
143
-
144
- ## Definition of Done
145
-
146
- A task is done when its approved outcome exists, relevant tests cover success/failure/edge cases, checks pass or documented exceptions are approved, formatting and repository conventions are satisfied, docs are updated, no unrelated changes are included, its diff and evidence were reviewed at the barrier required by the persisted approval mode, and commit provenance is recorded.
147
-
148
- A phase is done when all tasks are integrated, phase learning is recorded, combined verification passes, and its final User Manual Verification is approved by the human in `governed` or `phase`, or authorized by verified evidence in `autonomous`. A track is ready for review only after all execution nodes are complete, all worker branches are integrated, all worktrees are removed, the journal is finalized, and track-level manual verification is approved in main. It is completed only after an approved clean review bound to the current execution ID, plan revision, graph digest, and reviewed HEAD.
149
-
150
- ## Review and remediation
151
-
152
- Review acceptance criteria, non-functional requirements, diffs, callers, tests, security, compatibility, error paths, and learning claims. Present findings before recording them. Approved findings go in `bugs/bug-<review-ts>.md`; insert dependency-aware remediation phases before the single final track-level verification phase, ending each with manual verification. Reset the final barrier to pending while preserving its prior evidence in the review cycle and completed execution journal. A replacement execution carries already-completed plan nodes forward from their commit provenance and schedules only pending work. Set the track back to `in_progress`. A clean cycle records the current execution ID, plan revision, graph digest, and reviewed HEAD. Repeat implement/review until a clean review is approved.
153
-
154
- ## Revisions, refreshes, and cascading impact
155
-
156
- `revise` is callable at any point, with these state-specific semantics:
157
-
158
- - In `drafting-spec`, continue the interrupted or active `track` specification flow. There is no approved baseline yet, so do not create a revision entry.
159
- - In `drafting-plan`, a change to the approved specification is a revision; a change only to the unapproved plan continues the `track` planning flow.
160
- - In `planned`, revise the approved baseline and remain `planned`.
161
- - In `in_progress`, first reconcile any operation and active or dirty task work. Preserve completed tasks and commits, supersede rather than erase affected work, and remain `in_progress` when all dependencies are satisfied. Return to `planned` when a newly approved dependency is incomplete.
162
- - In `ready_for_review`, use `review` for defects against the approved specification. Use `revise` for a changed desired outcome, scope, requirement, or acceptance criterion; invalidate review readiness, append the necessary delivery and manual-verification work, and return to `in_progress`, or `planned` when an approved dependency is incomplete.
163
- - In `completed` or `archived`, keep the track immutable and propose a successor feature or bug track that references it. Do not reopen it or rewrite its clean-review history.
164
-
165
- A semantic revision requires an approved specification baseline and no unresolved non-revision operation. Reconcile a matching revision journal before doing new work. If active implementation or dirty work overlaps the revision, include its exact complete, preserve-as-superseded, or additive-revert disposition in the combined revision envelope whenever it can be safely assessed in advance. Ask for a preliminary disposition only when that choice is required to reach a state that can be fully analyzed.
166
-
167
- Every approved semantic revision gets `revisions/revision-<ts>.md` and a track-local `operation.action` of `revise` before artifact mutation. Increment the track revision once per approved revision; increment the specification revision only when the specification changes and the plan revision only when the plan changes. A revision must record its source and target status, base commit, affected phases/tasks, treatment of completed and partial work, review-readiness impact, and transitive dependency impact. Preserve completed-work provenance and append replacement work rather than erasing history.
168
-
169
- Every project refresh gets `refreshes/refresh-<ts>.md`. Assess transitive dependent tracks whenever a spec, acceptance criterion, dependency, workflow, pattern, tech-stack, or styleguide change may affect them. Present project context and every exact cascading track change in one refresh authorization envelope before mutation. Preserve superseded content and completed-work provenance rather than erasing history.
170
-
171
- ## Archival and learning
172
-
173
- Archive one or more selected completed tracks in one approved batch. Require `completed` status and clean centralized state validation; do not recompute the DAG, manual-verification barriers, or review evidence inside archive. Validate the whole selection before mutation, distill the selected learning as one corpus into patterns with source track/task/commit provenance, reconcile it with existing patterns, then propose relevant reseeding for all active tracks. Journal the ordered selection and per-track/artifact progress, move each full track directory to `archive/`, validate once, and commit the batch together. Never discard history or start another archive batch while one is incomplete.
174
-
175
- ## Git safety and commits
176
-
177
- - Use Conventional Commits for product work.
178
- - Cadre-only state commits use `cadre(<command>): <description>`.
179
- - Do not mix unrelated work into a task commit.
180
- - Prefer additive `git revert` commits. Do not rewrite shared history or use destructive reset/checkout as the default revert mechanism.
181
- - Do not overwrite dirty user changes. Stop and explain overlap.