cadre-ai 3.9.0 → 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 (234) hide show
  1. package/.claude-plugin/plugin.json +1 -1
  2. package/.codex-plugin/plugin.json +1 -1
  3. package/CHANGELOG.md +213 -0
  4. package/README.md +68 -21
  5. package/dist/cadre-cli.mjs +4 -6
  6. package/dist/cadre-mcp.mjs +5397 -3973
  7. package/package.json +2 -2
  8. package/skills/archive/SKILL.md +12 -10
  9. package/skills/create/SKILL.md +9 -9
  10. package/skills/implement/SKILL.md +10 -8
  11. package/skills/implement/references/governed-mode.md +1 -1
  12. package/skills/implement/references/resume-recovery.md +2 -0
  13. package/skills/refresh/SKILL.md +25 -18
  14. package/skills/revert/SKILL.md +33 -13
  15. package/skills/review/SKILL.md +27 -34
  16. package/skills/revise/SKILL.md +21 -11
  17. package/skills/status/SKILL.md +2 -0
  18. package/skills/track/SKILL.md +11 -7
  19. package/templates/{v5 → v6}/init/workflow.md +1 -1
  20. package/templates/v1/init/gitignore.template +0 -5
  21. package/templates/v1/init/patterns/index.md +0 -6
  22. package/templates/v1/init/project.json +0 -26
  23. package/templates/v1/init/workflow.md +0 -181
  24. package/templates/v1/project/archive-operation.json +0 -15
  25. package/templates/v1/project/refresh-operation.json +0 -14
  26. package/templates/v1/track/execution.json +0 -19
  27. package/templates/v1/track/learning.md +0 -39
  28. package/templates/v1/track/plan.md +0 -39
  29. package/templates/v1/track/revert-operation.json +0 -13
  30. package/templates/v1/track/revise-operation.json +0 -14
  31. package/templates/v1/track/state.json +0 -25
  32. package/templates/v2/init/archive/.gitkeep +0 -1
  33. package/templates/v2/init/gitignore.template +0 -8
  34. package/templates/v2/init/guidelines.md +0 -25
  35. package/templates/v2/init/operations/.gitkeep +0 -1
  36. package/templates/v2/init/patterns/index.md +0 -6
  37. package/templates/v2/init/product.md +0 -30
  38. package/templates/v2/init/project.json +0 -27
  39. package/templates/v2/init/refreshes/.gitkeep +0 -1
  40. package/templates/v2/init/styleguides/general.md +0 -14
  41. package/templates/v2/init/styleguides/language.md +0 -21
  42. package/templates/v2/init/tech-stack.md +0 -21
  43. package/templates/v2/init/tracks/.gitkeep +0 -1
  44. package/templates/v2/init/tracks.md +0 -6
  45. package/templates/v2/init/wisps/.gitkeep +0 -1
  46. package/templates/v2/init/workflow.md +0 -72
  47. package/templates/v2/project/pattern.md +0 -20
  48. package/templates/v2/project/refresh.md +0 -21
  49. package/templates/v2/styleguides/dart.md +0 -27
  50. package/templates/v2/styleguides/flutter.md +0 -27
  51. package/templates/v2/styleguides/go.md +0 -29
  52. package/templates/v2/styleguides/gradle.md +0 -28
  53. package/templates/v2/styleguides/html-css.md +0 -39
  54. package/templates/v2/styleguides/index.md +0 -27
  55. package/templates/v2/styleguides/java.md +0 -27
  56. package/templates/v2/styleguides/javascript.md +0 -27
  57. package/templates/v2/styleguides/kotlin.md +0 -26
  58. package/templates/v2/styleguides/maven.md +0 -28
  59. package/templates/v2/styleguides/python.md +0 -27
  60. package/templates/v2/styleguides/react.md +0 -28
  61. package/templates/v2/styleguides/swift.md +0 -27
  62. package/templates/v2/styleguides/swiftui.md +0 -27
  63. package/templates/v2/styleguides/typescript.md +0 -26
  64. package/templates/v2/track/bug.md +0 -14
  65. package/templates/v2/track/execution.json +0 -19
  66. package/templates/v2/track/learning.md +0 -39
  67. package/templates/v2/track/plan.md +0 -39
  68. package/templates/v2/track/revision.md +0 -36
  69. package/templates/v2/track/spec.md +0 -38
  70. package/templates/v2/track/state.json +0 -31
  71. package/templates/v3/init/archive/.gitkeep +0 -1
  72. package/templates/v3/init/gitignore.template +0 -8
  73. package/templates/v3/init/guidelines.md +0 -25
  74. package/templates/v3/init/operations/.gitkeep +0 -1
  75. package/templates/v3/init/product.md +0 -30
  76. package/templates/v3/init/project.json +0 -27
  77. package/templates/v3/init/refreshes/.gitkeep +0 -1
  78. package/templates/v3/init/styleguides/general.md +0 -14
  79. package/templates/v3/init/styleguides/language.md +0 -21
  80. package/templates/v3/init/tech-stack.md +0 -21
  81. package/templates/v3/init/tracks/.gitkeep +0 -1
  82. package/templates/v3/init/tracks.md +0 -6
  83. package/templates/v3/init/wisps/.gitkeep +0 -1
  84. package/templates/v3/init/workflow.md +0 -82
  85. package/templates/v3/project/archive-operation.json +0 -19
  86. package/templates/v3/project/pattern.md +0 -20
  87. package/templates/v3/project/refresh-operation.json +0 -18
  88. package/templates/v3/project/refresh.md +0 -21
  89. package/templates/v3/styleguides/dart.md +0 -27
  90. package/templates/v3/styleguides/flutter.md +0 -27
  91. package/templates/v3/styleguides/go.md +0 -29
  92. package/templates/v3/styleguides/gradle.md +0 -28
  93. package/templates/v3/styleguides/html-css.md +0 -39
  94. package/templates/v3/styleguides/index.md +0 -27
  95. package/templates/v3/styleguides/java.md +0 -27
  96. package/templates/v3/styleguides/javascript.md +0 -27
  97. package/templates/v3/styleguides/kotlin.md +0 -26
  98. package/templates/v3/styleguides/maven.md +0 -28
  99. package/templates/v3/styleguides/python.md +0 -27
  100. package/templates/v3/styleguides/react.md +0 -28
  101. package/templates/v3/styleguides/swift.md +0 -27
  102. package/templates/v3/styleguides/swiftui.md +0 -27
  103. package/templates/v3/styleguides/typescript.md +0 -26
  104. package/templates/v3/track/bug.md +0 -14
  105. package/templates/v3/track/execution.json +0 -19
  106. package/templates/v3/track/plan.md +0 -39
  107. package/templates/v3/track/revert-operation.json +0 -17
  108. package/templates/v3/track/revise-operation.json +0 -18
  109. package/templates/v3/track/revision.md +0 -36
  110. package/templates/v3/track/spec.md +0 -38
  111. package/templates/v3/track/state.json +0 -31
  112. package/templates/v4/init/archive/.gitkeep +0 -1
  113. package/templates/v4/init/gitignore.template +0 -8
  114. package/templates/v4/init/guidelines.md +0 -25
  115. package/templates/v4/init/operations/.gitkeep +0 -1
  116. package/templates/v4/init/patterns/index.md +0 -8
  117. package/templates/v4/init/product.md +0 -30
  118. package/templates/v4/init/project.json +0 -27
  119. package/templates/v4/init/refreshes/.gitkeep +0 -1
  120. package/templates/v4/init/styleguides/general.md +0 -14
  121. package/templates/v4/init/styleguides/language.md +0 -21
  122. package/templates/v4/init/tech-stack.md +0 -21
  123. package/templates/v4/init/tracks/.gitkeep +0 -1
  124. package/templates/v4/init/tracks.md +0 -6
  125. package/templates/v4/init/wisps/.gitkeep +0 -1
  126. package/templates/v4/init/workflow.md +0 -91
  127. package/templates/v4/project/archive-operation.json +0 -19
  128. package/templates/v4/project/pattern.md +0 -20
  129. package/templates/v4/project/refresh-operation.json +0 -18
  130. package/templates/v4/project/refresh.md +0 -21
  131. package/templates/v4/styleguides/dart.md +0 -27
  132. package/templates/v4/styleguides/flutter.md +0 -27
  133. package/templates/v4/styleguides/go.md +0 -29
  134. package/templates/v4/styleguides/gradle.md +0 -28
  135. package/templates/v4/styleguides/html-css.md +0 -39
  136. package/templates/v4/styleguides/index.md +0 -27
  137. package/templates/v4/styleguides/java.md +0 -27
  138. package/templates/v4/styleguides/javascript.md +0 -27
  139. package/templates/v4/styleguides/kotlin.md +0 -26
  140. package/templates/v4/styleguides/maven.md +0 -28
  141. package/templates/v4/styleguides/python.md +0 -27
  142. package/templates/v4/styleguides/react.md +0 -28
  143. package/templates/v4/styleguides/swift.md +0 -27
  144. package/templates/v4/styleguides/swiftui.md +0 -27
  145. package/templates/v4/styleguides/typescript.md +0 -26
  146. package/templates/v4/track/bug.md +0 -14
  147. package/templates/v4/track/execution.json +0 -20
  148. package/templates/v4/track/learning.md +0 -45
  149. package/templates/v4/track/plan.md +0 -39
  150. package/templates/v4/track/revert-operation.json +0 -17
  151. package/templates/v4/track/revise-operation.json +0 -18
  152. package/templates/v4/track/revision.md +0 -36
  153. package/templates/v4/track/spec.md +0 -38
  154. package/templates/v4/track/state.json +0 -31
  155. package/templates/v5/init/archive/.gitkeep +0 -1
  156. package/templates/v5/init/guidelines.md +0 -25
  157. package/templates/v5/init/operations/.gitkeep +0 -1
  158. package/templates/v5/init/patterns/index.md +0 -8
  159. package/templates/v5/init/product.md +0 -30
  160. package/templates/v5/init/refreshes/.gitkeep +0 -1
  161. package/templates/v5/init/styleguides/general.md +0 -14
  162. package/templates/v5/init/styleguides/language.md +0 -21
  163. package/templates/v5/init/tech-stack.md +0 -21
  164. package/templates/v5/init/tracks/.gitkeep +0 -1
  165. package/templates/v5/init/tracks.md +0 -6
  166. package/templates/v5/init/wisps/.gitkeep +0 -1
  167. package/templates/v5/project/archive-operation.json +0 -19
  168. package/templates/v5/project/pattern.md +0 -20
  169. package/templates/v5/project/refresh-operation.json +0 -18
  170. package/templates/v5/project/refresh.md +0 -21
  171. package/templates/v5/styleguides/dart.md +0 -27
  172. package/templates/v5/styleguides/flutter.md +0 -27
  173. package/templates/v5/styleguides/go.md +0 -29
  174. package/templates/v5/styleguides/gradle.md +0 -28
  175. package/templates/v5/styleguides/html-css.md +0 -39
  176. package/templates/v5/styleguides/index.md +0 -27
  177. package/templates/v5/styleguides/java.md +0 -27
  178. package/templates/v5/styleguides/javascript.md +0 -27
  179. package/templates/v5/styleguides/kotlin.md +0 -26
  180. package/templates/v5/styleguides/maven.md +0 -28
  181. package/templates/v5/styleguides/python.md +0 -27
  182. package/templates/v5/styleguides/react.md +0 -28
  183. package/templates/v5/styleguides/swift.md +0 -27
  184. package/templates/v5/styleguides/swiftui.md +0 -27
  185. package/templates/v5/styleguides/typescript.md +0 -26
  186. package/templates/v5/track/bug.md +0 -14
  187. package/templates/v5/track/learning.md +0 -45
  188. package/templates/v5/track/revert-operation.json +0 -17
  189. package/templates/v5/track/revise-operation.json +0 -18
  190. package/templates/v5/track/revision.md +0 -36
  191. package/templates/v5/track/spec.md +0 -38
  192. /package/templates/{v1 → v6}/init/archive/.gitkeep +0 -0
  193. /package/templates/{v5 → v6}/init/gitignore.template +0 -0
  194. /package/templates/{v1 → v6}/init/guidelines.md +0 -0
  195. /package/templates/{v1 → v6}/init/operations/.gitkeep +0 -0
  196. /package/templates/{v3 → v6}/init/patterns/index.md +0 -0
  197. /package/templates/{v1 → v6}/init/product.md +0 -0
  198. /package/templates/{v5 → v6}/init/project.json +0 -0
  199. /package/templates/{v1 → v6}/init/refreshes/.gitkeep +0 -0
  200. /package/templates/{v1 → v6}/init/styleguides/general.md +0 -0
  201. /package/templates/{v1 → v6}/init/styleguides/language.md +0 -0
  202. /package/templates/{v1 → v6}/init/tech-stack.md +0 -0
  203. /package/templates/{v1 → v6}/init/tracks/.gitkeep +0 -0
  204. /package/templates/{v1 → v6}/init/tracks.md +0 -0
  205. /package/templates/{v1 → v6}/init/wisps/.gitkeep +0 -0
  206. /package/templates/{v2 → v6}/project/archive-operation.json +0 -0
  207. /package/templates/{v1 → v6}/project/pattern.md +0 -0
  208. /package/templates/{v2 → v6}/project/refresh-operation.json +0 -0
  209. /package/templates/{v1 → v6}/project/refresh.md +0 -0
  210. /package/templates/{v1 → v6}/styleguides/dart.md +0 -0
  211. /package/templates/{v1 → v6}/styleguides/flutter.md +0 -0
  212. /package/templates/{v1 → v6}/styleguides/go.md +0 -0
  213. /package/templates/{v1 → v6}/styleguides/gradle.md +0 -0
  214. /package/templates/{v1 → v6}/styleguides/html-css.md +0 -0
  215. /package/templates/{v1 → v6}/styleguides/index.md +0 -0
  216. /package/templates/{v1 → v6}/styleguides/java.md +0 -0
  217. /package/templates/{v1 → v6}/styleguides/javascript.md +0 -0
  218. /package/templates/{v1 → v6}/styleguides/kotlin.md +0 -0
  219. /package/templates/{v1 → v6}/styleguides/maven.md +0 -0
  220. /package/templates/{v1 → v6}/styleguides/python.md +0 -0
  221. /package/templates/{v1 → v6}/styleguides/react.md +0 -0
  222. /package/templates/{v1 → v6}/styleguides/swift.md +0 -0
  223. /package/templates/{v1 → v6}/styleguides/swiftui.md +0 -0
  224. /package/templates/{v1 → v6}/styleguides/typescript.md +0 -0
  225. /package/templates/{v1 → v6}/track/bug.md +0 -0
  226. /package/templates/{v5 → v6}/track/dependency-context.json +0 -0
  227. /package/templates/{v5 → v6}/track/execution.json +0 -0
  228. /package/templates/{v3 → v6}/track/learning.md +0 -0
  229. /package/templates/{v5 → v6}/track/plan.md +0 -0
  230. /package/templates/{v2 → v6}/track/revert-operation.json +0 -0
  231. /package/templates/{v2 → v6}/track/revise-operation.json +0 -0
  232. /package/templates/{v1 → v6}/track/revision.md +0 -0
  233. /package/templates/{v1 → v6}/track/spec.md +0 -0
  234. /package/templates/{v5 → v6}/track/state.json +0 -0
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "cadre-ai",
3
- "version": "3.9.0",
3
+ "version": "4.0.0",
4
4
  "description": "Cross-agent, human-governed software delivery harness",
5
5
  "author": {
6
6
  "name": "Vishal Kumar",
@@ -39,7 +39,7 @@
39
39
  "marketplace/",
40
40
  "README.md",
41
41
  "skills/",
42
- "templates/"
42
+ "templates/v6/"
43
43
  ],
44
44
  "scripts": {
45
45
  "build": "node --import tsx scripts/build.ts",
@@ -7,15 +7,15 @@ description: Archive one or more completed Cadre tracks in one approved, resumab
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
  Archive one or more `completed` tracks in a single batch. Read `.cadre/workflow.md`, every artifact and recorded commit for every selected track, the complete pattern catalog, active-track status summaries, and relevant implementation files. Use catalog applicability, provenance, and supersession summaries to identify affected patterns and active tracks, then read their full pattern/spec/plan/seed artifacts before proposing changes. If metadata is missing, incomplete, or ambiguous, read the full catalog bodies and active specs/plans/seeds. Never exclude guidance by keyword alone.
21
21
 
@@ -23,7 +23,7 @@ At every required selection or approval boundary, show a concise batch summary o
23
23
 
24
24
  Call `project_status` first with `view: "project"` and use its embedded structured validation; do not repeat `state_validate` at command entry. Stop when `valid` is false or the Cadre MCP is unavailable; do not start or advance an archive batch.
25
25
 
26
- Build one bounded archive inventory after selection. Read every selected artifact exactly once, summarize execution journals structurally in one pass, and verify recorded commit reachability in one Git pass. Do not precede reads with line counts, rediscover the same paths, or restart full reads after truncation; continue from the first unread line. Reuse unchanged workflow/product/styleguide context already loaded in the same flow. Fetch known pattern templates directly with one `template_get_many` call and use descriptor tools when an ID must be resolved; do not discover MCP resources. The declared mutation surface is adaptive `archive_batch_candidate` followed by receipt reconciliation for v5 (legacy batches retain `archive_batch_record`); do not inspect the installed runtime or tool catalog for alternatives.
26
+ Build one bounded archive inventory after selection. Read every selected artifact exactly once, summarize execution journals structurally in one pass, and verify recorded commit reachability in one Git pass. Do not precede reads with line counts, rediscover the same paths, or restart full reads after truncation; continue from the first unread line. Reuse unchanged workflow/product/styleguide context already loaded in the same flow. Fetch known pattern templates directly with one `template_get_many` call and use descriptor tools when an ID must be resolved; do not discover MCP resources. The declared mutation surface is adaptive `archive_batch_candidate` followed by receipt reconciliation; do not inspect the installed runtime or tool catalog for alternatives.
27
27
 
28
28
  The approved batch includes the generated index. With no pattern or seed updates, use `expectedFiles: []` and `updates: []`. Active dependency-context source paths are rebased under this same approval; changed inherited guidance requires a staged `active_dependency_context` descriptor and reassessment.
29
29
 
@@ -31,24 +31,26 @@ Expected human decision count is one for the complete batch. Ask again only when
31
31
 
32
32
  1. Accept an explicit list of track IDs. When selection is omitted or the human says `all completed`, omit `selectedTracks`; the server selects every eligible completed track in dependency order. Preserve an explicit order and remove duplicates.
33
33
  2. Verify the entire selection before changing anything. Every selected track must be `completed`, have clean centralized `state_validate`, and have no pending state mutation. Do not recompute its DAG, manual-verification barriers, or review evidence inside archive; those are completed-state invariants. Reject the batch without partial mutation if any selected track is ineligible. Ignore completed tracks that were not selected.
34
- 3. If an in-progress `.cadre/operations/archive-<timestamp>.json` exists, reconcile it before accepting a new batch. Resume from its first incomplete checkpoint. If its journal, files, Git state, or expected commit disagree, stop and present the mismatch.
34
+ 3. If an ignored receipt recovery journal exists, reconcile or resume it before accepting a new batch. An older `.cadre/operations/archive-<timestamp>.json` batch must be completed using Cadre 3.9.0 before returning to 4.0. Never reinterpret or discard its approval.
35
35
  4. Distill durable, evidenced learning across the selected tracks as one corpus; discard track-specific trivia. Merge, replace, split, or retire existing patterns when justified, preserving provenance to every contributing track/phase/task commit. Reconcile overlapping or conflicting learning once so batch order cannot silently change the result.
36
36
  5. Keep catalog summaries and applicability/provenance/supersession information complete. Compute relevant Pattern Seed section changes in `learning.md` for every non-completed, non-archived track using the final proposed pattern set. Never seed by keyword alone; explain semantic relevance.
37
37
  6. Call `candidate_stage_prepare` for `archive-<proposal-id>` with `expectedFiles` equal to every proposed pattern, pattern-index, and active-track seed path, then write exactly that set. Call `archive_batch_candidate` with `request: { mode: "prepare", projectRoot, candidateId, selectedTracks?, updates }`; `updates` contains the required body-free descriptors. Present the resulting proposal once.
38
38
  7. After approval, call only `request: { mode: "apply", proposalToken }` on `archive_batch_candidate`; it re-reads staged files and rejects drift. Never make the two calls consecutively without the human decision between them. Commit all approved moves and derived changes together, keep the matching candidate stage through that checkpoint, and never stage it.
39
- 8. For v5, include the returned receipt and exact trailers in that one archive commit, then reconcile using `candidate_apply`. Do not call archive_batch_record or create a second archive commit. Legacy SHA batches finish their original archive_batch_record contract.
39
+ 8. Include the returned receipt and exact trailers in that one archive commit, then reconcile using `candidate_apply`. Do not create a second archive commit.
40
40
  9. Reuse the apply validation. Verify the receipt, one archive commit, and clean worktree; do not reread all completed histories.
41
41
 
42
- If interrupted, reuse the same approved apply token; the journal and approved hashes converge remaining moves/writes without another approval. Provenance recording is idempotent and never duplicates track/project history. Never redistill or start a second batch while one is active.
42
+ If interrupted, inspect the matching `.cadre/stage/operations/<operationId>.json` and Git evidence. If its receipt is already committed, use `candidate_apply` reconcile. Otherwise use `candidate_apply` with `request: {mode: "resume", projectRoot, operationId, approvalDigest}` from that original approved intent to converge remaining moves/writes, then commit the receipt once and reconcile. Repeating `archive_batch_candidate` apply before reconciliation encounters `COMMIT_PENDING`; it is not the pending-promotion recovery route. The original archive apply token supports zero-change replay after commit/reconciliation. Recovery and replay converge without another approval for unchanged consequences. Provenance recording is idempotent and never duplicates track/project history. Never redistill or start a second batch while one is active.
43
43
 
44
44
  Do not delete learning, review cycles, revisions, bug reports, or commit provenance.
45
45
 
46
46
  ## Memory contract
47
47
 
48
- 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.
48
+ 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.
49
49
 
50
50
  ## Evidence quality and proposal identity
51
51
 
52
+ Archive prepare returns `stateChanges` for each moved track state and project history. Read its `sourcePath`, apply the exact `set`/array `append` changes, and serialize with two-space indentation and a trailing newline; verify the returned SHA-256 for the final `path`. Include these automatic status, checkpoint, history and operation-reference changes in the same archive approval envelope. Preserve all other source fields and historical artifacts.
53
+
52
54
  Before promoting an observation into a pattern, verify it against actual imports, source and relevant tests; distinguish observed facts, hypotheses and scope decisions. Hashes establish freshness, not truth. Do not infer that an assertion is loose from its method name without checking the imported module, or that no I/O implies no trust boundary. Correct mistaken historical claims explicitly in new guidance with evidence, preserving completed history.
53
55
 
54
- Prepare results describe prospective operation paths; check disk before claiming that a journal exists or is duplicated. Apply alone persists the archive journal. The public proposal digest binds the complete preview; the persisted approvalDigest binds the batch inputs/updates. They serve different purposes. Resume using the persisted batch identity, approved file hashes and actual artifact commit; do not interpret the differing digests alone as source drift.
56
+ Prepare results describe prospective paths; they do not prove a journal exists. Apply persists the receipt recovery intent under `.cadre/stage/operations/<operationId>.json`. Use the returned receipt operationId and the original approvalDigest for resume/reconcile. Never create a legacy `.cadre/operations/` journal from preview metadata or compare that prospective path to the actual recovery intent.
@@ -7,15 +7,15 @@ description: Initialize or resume Cadre in a greenfield or brownfield repository
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
  Use the Cadre MCP as the authoritative runtime and template provider. Do not copy runtime code or templates into the project. Treat every rendered artifact and state mutation as a proposal until the human approves it. If required Cadre MCP tools are unavailable, stop and report that the plugin runtime is unavailable; never reconstruct templates from memory.
21
21
 
@@ -32,16 +32,16 @@ At every required clarification or approval boundary, show a concise summary or
32
32
  7. Call `styleguide_resolve` with the proposed technologies. Always include the general guide and resolve the applicable language, framework, markup, and build-tool guides as one set. Preserve evidenced brownfield conventions. Ask only when a material convention choice cannot be resolved from the request and repository; do not ask the human to accept each default guide or the final set separately.
33
33
  8. Expected human decision count is one. Call `candidate_stage_prepare` for candidate `create` with `expectedFiles` equal to `product.md`, `guidelines.md`, `tech-stack.md`, and only requested `workflow.md` or `styleguides/*.md` overrides; this prunes removed files and enforces `/stage/`. Write them beneath `.cadre/stage/create` (for example `.cadre/stage/create/product.md`). Never write `.cadre/init/*` or canonical artifacts before apply, and do not pass artifact bodies through MCP. Call `project_init_candidate` with `request: { mode: "prepare", projectRoot, projectName, context, gitDisposition, baseCommit, approvedAt, stagedFiles, styleguideIds }`. After explicit confirmation, call only `request: { mode: "apply", proposalToken }`. Never make those two calls consecutively without the human decision, and do not add later approval prompts.
34
34
  9. If Git disposition is `initialize`, run `git init` only at the approved root and verify its top level. The approved recovery journal remains durable if initialization fails. Existing Git roots are never reinitialized.
35
- 10. For v5, apply has already written completed state using its stable operation reference. A pre-commit status may report only `commit_pending`; any other structural or artifact error blocks the commit. Commit `cadre(create): initialize project harness` once with the returned receipt trailers. Reconcile it and remove only the matching candidate stage. Do not call a separate Git-initialization checkpoint or make a provenance commit.
36
- 11. Legacy interrupted setup follows its original contract through `setup_record_git_initialized` and `setup_record_commit`; migrate with refresh afterward.
35
+ 10. Apply has already written completed state using its stable operation reference. A pre-commit status may report only `commit_pending`; any other structural or artifact error blocks the commit. Commit `cadre(create): initialize project harness` once with the returned receipt trailers. Reconcile it and remove only the matching candidate stage. Do not call a separate Git-initialization checkpoint or make a provenance commit.
37
36
 
38
37
  ## Resume protocol
39
38
 
40
- - `git-pending`: initialize Git only when the journal says `initialize`; verify the exact approved root and record the checkpoint.
39
+ Create approval binds the inspected repository HEAD, index and tracked/untracked product inputs as well as the staged artifacts. Preserve that baseline through apply and interruption recovery. If source content or canonical project state changes after preview, inspect the new reality and prepare a fresh proposal; never reuse the old token to overwrite a newer setup. Committed replay resolves the original immutable receipt before checking later repository content. An older pending setup without repository evidence needs an explicitly approved repair, retaining its original intent and receipts.
40
+
41
+ - Before the first commit: initialize Git only when the receipt recovery intent authorizes it; verify the exact approved root.
41
42
  - `.cadre/stage/create` with only bootstrap state: re-read the candidate manifest and resume approval or apply. Matching partially promoted canonical files are resumable; any differing or unrelated canonical byte is a hard stop.
42
43
  - `commit-pending` plus matching dirty artifacts: validate and create the expected artifact commit.
43
- - Clean worktree plus matching expected HEAD/base relationship: treat the artifact commit as successful and record that SHA; never repeat it.
44
- - Recorded setup SHA plus dirty bookkeeping: finish only the follow-up state commit.
44
+ - Clean worktree plus matching receipt trailers and artifacts: reconcile that commit; never repeat it.
45
45
  - Journal, files, digest, worktree, or HEAD mismatch: stop and show the mismatch. Never guess, discard, or restart.
46
46
 
47
47
  All later commands must read `.cadre/workflow.md`. Every file is rendered from a versioned MCP template, every multi-step mutation is resumable, and human approval gates artifacts and state changes.
@@ -7,15 +7,15 @@ description: Execute or resume an approved Cadre plan as a dependency DAG, using
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
  Treat approved `plan.md` as the source of truth. Implement `planned` or `in_progress` tracks; a persisted policy-v2 Autonomous loop may resume `ready_for_review` by continuing review without starting another execution. Main is the sole scheduler and `.cadre/**` owner; workers never spawn workers, edit Cadre state, integrate branches, resolve conflicts, clean worktrees, or record human approval.
21
21
 
@@ -32,9 +32,9 @@ Read only the references required by current state:
32
32
 
33
33
  ## Entry and modes
34
34
 
35
- 1. Call `project_status` once with `view: "implementation"`, `trackId`, and the known persisted `executionId` if resuming. Omit `executionId` (or use null) when unknown; never infer it from the track ID. This is the complete preflight: validation, graph, scheduler, dependency, and worktree state; do not repeat `state_validate` at command entry. Stop if `valid` or `graph.valid` is false, `upgradeRequired` is true, the track is candidate-only, or the MCP is unavailable. Follow `nextStep` before choosing an implementation node. A review handoff or pending final approval does not require a ready node or another `execution_start`.
36
- 2. Use `context_read` for the selected ready or resumed node (`projectRoot`, `trackId`, optional `executionId`, `nodeId`). Consume every `nextCursor` page until `complete: true`; stop on returned errors or relevant `staleMemory`. This supplies `.cadre/workflow.md`, full spec/plan, relevant learning, and pattern/styleguide sources. Read repository instructions and relevant code/callers/tests separately. Read full state or other artifacts before editing them. Reuse unchanged sources already loaded in this session by path/hash; a source hash is not a substitute for reading it after context loss.
37
- 3. Scheduling defaults to `parallel`; use `sequential` only when requested. Approval mode defaults to `track`; use `governed`, `phase`, or `autonomous` only when explicitly requested. Resume journaled modes. Stop on `APPROVAL_MODE_MIGRATION_REQUIRED` and use the approved refresh migration; never reinterpret legacy Autonomous authority. A mode authorizes only work bounded by the approved spec and plan.
35
+ 1. Call `project_status` once with `view: "implementation"`, `trackId`, and the known persisted `executionId` if resuming. Omit `executionId` (or use null) when unknown; never infer it from the track ID. This is the complete preflight: validation, graph, scheduler, dependency, and worktree state; do not repeat `state_validate` at command entry. Stop if `valid` or `graph.valid` is false, `upgradeRequired` is true, the track is candidate-only, or the MCP is unavailable. Follow `nextStep` before choosing an implementation node. A review handoff or pending final approval does not require a ready node or another `execution_start`. When a committed revision/remediation has no active operation and `nextStep` directs a new execution, start it even if the retained historical scheduler has no ready nodes; never resume a superseded execution or treat its empty scheduler as a delivery blocker.
36
+ 2. Use `context_read` for the selected ready or resumed node (`projectRoot`, `trackId`, optional `executionId`, `nodeId`). Copy the exact node ID from the returned graph or scheduler, such as `P1` or `T1.1`; a track ID, phase title/slug, or commit-group name is not a node ID. For a commit group, read its phase or a member task. Consume every `nextCursor` page until `complete: true`; stop on returned errors or relevant `staleMemory`. This supplies `.cadre/workflow.md`, full spec/plan, relevant learning, and pattern/styleguide sources. Read repository instructions and relevant code/callers/tests separately. Read full state or other artifacts before editing them. Reuse unchanged sources already loaded in this session by path/hash; a source hash is not a substitute for reading it after context loss.
37
+ 3. Scheduling defaults to `parallel`; use `sequential` only when requested. Approval mode defaults to `track`; use `governed`, `phase`, or `autonomous` only when explicitly requested. Treat `auto` as an alias for the `autonomous` approval mode; it does not change scheduling defaults. Resume journaled modes. Stop on `APPROVAL_MODE_MIGRATION_REQUIRED` and use the approved refresh migration; never reinterpret legacy Autonomous authority. A mode authorizes only work bounded by the approved spec and plan.
38
38
  4. For a new execution, the implement invocation authorizes `execution_start`; call it once with the modes. Do not add a start approval outside `governed`. Resume an existing operation instead of creating another.
39
39
 
40
40
  `governed` pauses for regular task diffs and integrations. `phase` runs regular phase work autonomously and pauses at each phase's final `User Manual Verification`. `track` also performs phase verification autonomously and pauses at `Track-level User Manual Verification`, then hands off to ordinary review. `autonomous` performs all available verification, invokes review, and implements in-scope remediation until clean; it pauses for one explicit final completion approval.
@@ -81,10 +81,12 @@ Follow `nextStep` from focused `project_status` and `execution_finish` using its
81
81
 
82
82
  Satisfy `prerequisite` before handoff: `implementation_bookkeeping_commit` means finish and commit the implementation journal/plan/state/index; `review_bookkeeping_commit` means finish review promotion, provenance, commits, and operation clearance. Check Git and journal evidence on resume so an already satisfied prerequisite does not create another commit. `await_approval` routes to review to revalidate evidence, prepare the exact completion proposal, and obtain the missing human decision. `blocked` stops automatic work with its reason. `null` supplies no Autonomous continuation and leaves ordinary mode gates in effect. MCP returns routing data; the agent performs the skill invocation. Routing never grants new authority or replaces validation.
83
83
 
84
+ a reachable verified receipt satisfies its bookkeeping prerequisite; status then returns a null prerequisite. A retried `execution_finish` may return `receipt.status: committed` and no changed paths: continue to review without another commit. The completed execution HEAD remains the verified product commit; never replace it with a bookkeeping HEAD just to make the two SHAs equal.
85
+
84
86
  ## Direct-main checkpoint order
85
87
 
86
88
  Start the ready phase once. For a commit group, follow `readyGroups` and execute internal dependencies in order, retaining verification, authorization and handoff for every task. Make one product commit for the cohesive change; then call `execution_checkpoint` with `event: "complete_group"`, the shared `commit`, and `tasks: [{nodeId, verification, authorization, handoff}, ...]` containing every member exactly once. The transition is atomic. Independent groups may use isolated worker worktrees; integrate their product commit before atomic completion.
87
89
 
88
- For an ungrouped/legacy task, use start, record_commit, complete. For manual verification, call `record_verification` directly from pending after actual verification and applicable approval: never send a separate verification start. Complete the running direct-main phase with `complete`, verified HEAD, verification and authorization. Repeat for the final phase, without a phase-record commit. `execution_finish` renders all plan markers and returns the receipt for the single `cadre(implement): complete <track-id>` commit. Include learning and durable journals. No execution-start commit is needed. An explicit checkpoint commit is allowed when handing off or stopping at a blocker; explain that boundary.
90
+ For an ungrouped task, use start, record_commit, complete. For manual verification, call `record_verification` directly from pending after actual verification and applicable approval: never send a separate verification start. Complete the running direct-main phase with `complete`, verified HEAD, verification and authorization. Repeat for the final phase, without a phase-record commit. `execution_finish` renders all plan markers and returns the receipt for the single `cadre(implement): complete <track-id>` commit. Include learning and durable journals. No execution-start commit is needed. An explicit checkpoint commit is allowed when handing off or stopping at a blocker; explain that boundary.
89
91
 
90
92
  Integration prefers fast-forward when valid and records provenance independently of merge objects. The coordinator's exactly bound journal/state may remain dirty; unrelated files and worker edits to protected Cadre state still block integration. Reuse returned scheduler state.
@@ -2,6 +2,6 @@
2
2
 
3
3
  Governed mode requires human review of each regular task diff before its commit, every conflict resolution, each manual-verification barrier, and each integration or other material mutation required by the approved workflow.
4
4
 
5
- Record a ready diff as `awaiting_approval` with verification evidence, present it once, and proceed only after explicit approval. Bind integration approval to the `integration` prepare digest. After approval call the same tool with only `request: { mode: "apply", proposalToken }`; changed content or Git/state drift requires a fresh prepare and decision.
5
+ Present a ready diff once and proceed only after explicit approval. The checkpoint API has no standalone `awaiting_approval` event: preserve a paused, uncommitted task with `event: "block"`, its verification and handoff, and a blocker explaining the pending task-diff approval. After approval use the returned `resume` guidance before recording the approved commit or completing its group. Never invent an event or record authorization before the decision. Bind integration approval to the `integration` prepare digest. After approval call the same tool with only `request: { mode: "apply", proposalToken }`; changed content or Git/state drift requires a fresh prepare and decision.
6
6
 
7
7
  Do not convert deterministic bookkeeping or cleanup following the approved unchanged operation into another decision.
@@ -13,6 +13,8 @@ Read the persisted handoff for the current node and declared dependencies throug
13
13
 
14
14
  For policy-v2 Autonomous, follow focused `project_status.nextStep` to the installed implement or review skill and resume its durable checkpoint. Legacy Autonomous requires an explicit Track-or-Autonomous migration through refresh before new work; preserve verification, findings, and execution history.
15
15
 
16
+ After an approved receipt-based revision changes the graph, reconcile its receipt, then start the new execution rather than resuming the retained `superseded` journal. The revision proposal must bind the new track/spec/plan revisions, preserved completed work, and Autonomous scope reference together. If an older revision record is committed while canonical state or authority still points to the prior revision, stop and inspect the original approved manifest, receipt, journals, and Git. Reconcile that receipt once; repeating reconciliation cannot add missing approved state. Prepare an explicit repair through revise/refresh from verified evidence instead of editing authority or journal bindings by hand.
17
+
16
18
  ## Cohesive execution contract
17
19
 
18
20
  For a new cohesive-v1 execution, main may assign a whole approved commit group. Execute its internal dependencies in order, verify every task, and return individual authorization, verification and handoff evidence with one shared product commit. Never split a group across workers or independently schedule a member before the group's external dependencies. Legacy executions keep their original task boundaries. Main owns atomic complete_group, Git integration, receipts and all Cadre state. Use only the owned build-cache path main supplies. Fast-forward integration is valid provenance; do not require a merge object.
@@ -7,44 +7,45 @@ description: Refresh Cadre product, guidelines, workflow, styleguides, and tech-
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`, `project.json`, all project context files, the last refresh record, Git history since the recorded setup/refresh commit, completed-track outcomes, and current repository manifests/code. Read every target context file before editing it.
21
21
 
22
+ Include a nonempty fresh `refreshes/refresh-<id>.md` record in every refresh, including migration and explicit review retry. Never reuse or overwrite an earlier record. The runtime binds `lastRefresh.refreshPath` and the new history entry to a proposed record; when supplying several fresh records, select the primary one with `lastRefresh.refreshPath` or review the deterministic selected path in `stateChanges`. Pending recovery retains the original record ownership; committed replay remains unchanged.
23
+
24
+ A scope refresh of an imported `drafting-plan` track follows the draft revision contract: use its committed specification approval for the old spec counter, preserve the unapproved plan and remain `drafting-plan`. Recovery cannot turn that specification revision into plan approval; complete planning through track before implementation.
25
+
22
26
  At every required clarification or approval boundary, show a concise context/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 refresh 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
27
 
24
- Call `project_status` first with `view: "project"` and use its embedded structured validation and complete errors; do not repeat `state_validate` at command entry. Stop when `valid` is false unless every error is explicitly and safely repaired by this refresh proposal. If it reports `upgradeRequired`, use only its exact runtime/template targets.
28
+ Call `project_status` first with `view: "project"` and use its embedded structured validation and complete errors; do not repeat `state_validate` at command entry. Stop when `valid` is false unless every error is explicitly and safely repaired by this refresh proposal. If it reports `upgradeRequired`, follow the 3.9.0 bridge instructions above; do not attempt that migration in 4.0.
25
29
 
26
30
  1. Determine evidence sources: user input, committed repository changes, completed tracks, or a combination.
27
31
  2. Apply the workflow clarification gate before drafting. Ask when the refresh request or evidence does not clearly establish the commit/time range, which context artifacts are in scope, whether files should describe current reality or a desired future state, how to resolve conflicts between user input and repository evidence, or whether cascading active-track updates are intended now.
28
- 3. Before changing execution-governing context, inspect all active implementation journals and workers. Include any required stop, preservation, or reconciliation at a safe quiescent boundary in the final refresh proposal; do not ask for a separate quiescence approval when the exact disposition can be assessed with the refresh. Draft focused diffs for product, guidelines, workflow, tech stack, general styleguide, and language/framework styleguides. Add/remove language guides only when the proposed tech stack requires it.
29
- 4. Assess impact on all active track specs, plans, and marked Pattern Seed sections using the same rules as the Cadre revise workflow, but include every cascading change in this refresh envelope.
30
- 5. Expected human decision count is one. Call `template_get_many` once for `project/refresh` and `project/refresh-operation`, then `candidate_stage_prepare` for `refresh-<ts>` with `expectedFiles` equal to the complete refresh record and project/track update set. Render exactly those files. Use `targetRuntimeVersion` and `targetTemplateSetVersion` from status for legacy projects. For legacy recovery only, call `candidate_inspect` with `planValidations` containing one entry for every staged root or nested `plan.md`, using its exact candidate-relative path and intended target status, or omit it for a plan-free refresh. Keep cascading changes inside this envelope instead of starting separate approval cycles.
31
- 6. For v5 or migration to v5, stage proposed project state and reassessed `dependency-context.json` for every active track along with changed context and the refresh record. Keep existing setup, approvals, findings, historical journals, completed nodes and history intact. Reach a quiescent boundary and preserve existing execution contracts; grouping applies only to new executions.
32
- 7. Use `candidate_apply` prepare with `workflow: "refresh"` and the full exact manifest instead of a separate inspection/promotion sequence. Present the targetRuntimeVersion and targetTemplateSetVersion, semantic diffs and migration consequences together. Apply its token only after approval. Commit `cadre(refresh): update project context` with receipt trailers, then reconcile. This one commit includes final version metadata and stable provenance; no record-refresh commit is needed.
32
+ 3. Before changing execution-governing context, inspect all active implementation journals and workers. Retained worker paths and branch names are provenance after verified cleanup; confirm that registered worktrees, orphaned directories, worker paths, and worker branches are gone rather than deleting historical journal evidence. Include any required stop, preservation, or reconciliation at a safe quiescent boundary in the final refresh proposal; do not ask for a separate quiescence approval when the exact disposition can be assessed with the refresh. Draft focused diffs for product, guidelines, workflow, tech stack, general styleguide, and language/framework styleguides. Add/remove language guides only when the proposed tech stack requires it.
33
+ 4. Assess impact on all active track specs, plans, and marked Pattern Seed sections using the same rules as the Cadre revise workflow, but include every cascading change in this refresh envelope. For each changed active scope/graph, include proposed `tracks/<id>/state.json` with the next track revision and exactly one fresh `tracks/<id>/revisions/revision-<id>.md` recording previous/new track, spec, and plan counters. Reassess learning and dependency context together. Preserve authored operation, last execution, review cycles, Autonomous authority, history, and commit references; the runtime derives supersession and renewed scope authority inside this same approved proposal. Do not stage a manually rewritten journal or clear its binding. After reconciliation, start a new execution with inherited modes. Context-only refresh preserves the complete existing Autonomous loop, including original authorization, cumulative review baseline, findings, attempt history and blockers; do not author checkpoint, finding or approval-mode changes in a context refresh. An explicit legacy policy migration may create a previously absent loop only from its verified execution and recorded migration approval. Context-only refresh preserves the current journal and counters; identical copied spec/plan files do not renew scope authority.
34
+ 5. Expected human decision count is one. Call `template_get_many` once for `project/refresh` and `project/refresh-operation`, then `candidate_stage_prepare` for `refresh-<ts>` with `expectedFiles` equal to the complete refresh record and project/track update set. Render exactly those files. Use `targetRuntimeVersion` and `targetTemplateSetVersion` from status for an ordinary approved context refresh. When separately inspecting a staged proposal, call `candidate_inspect` with `planValidations` containing one entry for every staged root or nested `plan.md`, using its exact candidate-relative path and intended target status, or omit it for a plan-free refresh. Keep cascading changes inside this envelope instead of starting separate approval cycles.
35
+ 6. Stage proposed project state and reassessed `dependency-context.json` for every active track along with changed context and the refresh record. Keep existing setup, approvals, findings, historical journals, completed nodes and history intact. Reach a quiescent boundary and preserve existing execution contracts; grouping applies only to new executions.
36
+ 7. Use `candidate_apply` prepare with `workflow: "refresh"` and the full exact manifest instead of a separate inspection/promotion sequence. Present the targetRuntimeVersion and targetTemplateSetVersion, semantic diffs and their consequences together. Apply its token only after approval. Commit `cadre(refresh): update project context` with receipt trailers, then reconcile. This one commit includes final version metadata and stable provenance; no record-refresh commit is needed.
33
37
 
34
38
  ## Memory contract
35
39
 
36
- 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.
37
-
38
- When `upgradeRequired` is true, delivery mutations remain blocked until the approved refresh records the status-provided runtime/template targets. Upgrade active seed metadata and workflow instructions in the same staged, digest-bound envelope; keep legacy terminal history unchanged and do not fabricate old handoffs. Reach a quiescent worker boundary first. Blocking a node, verifying cleanup of already integrated work, inspecting/staging candidates, and rendering the validated derived index remain available for recovery. Do not perform new implementation or integrations to bypass the upgrade. Publish target versions only after the approved context files have been promoted, then run full validation. On interruption, continue the existing refresh journal rather than requesting a second approval for unchanged consequences.
40
+ 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.
39
41
 
40
- ## Legacy SHA refresh bookkeeping contract (not the v5 path)
42
+ For unsupported project formats, use the 3.9.0 bridge before resuming this workflow. Keep old refresh journals as evidence and recover them with that runtime; 4.0 does not perform legacy SHA bookkeeping or permit recovery mutations on unsupported formats.
41
43
 
42
- Stage `project.json` with the target versions but preserve its existing `lastRefresh` and history until the artifact commit exists. Do not stage a new `lastRefresh` with a null commit. The pending operation belongs in `operations/refresh-<id>.json`; `project_status` with full detail and the operations directory identify it during recovery. Promote version metadata last, record every promoted file including `project.json` in artifactProgress, and verify all approved hashes before committing.
44
+ ## Approval policy v2 migration
43
45
 
44
- After the artifact commit, atomically write the completed journal with `refreshCommit` and `status/checkpoint: completed`. Set `project.lastRefresh` to `{refreshPath, commit}`; append `{action: "refresh", commit, refreshPath}` to project history and affected track history exactly once. These are deterministic consequences of the original approval. Completed operation hashes are checked against the artifact commit, so subsequent provenance bookkeeping or later approved context changes do not invalidate historical evidence. Keep the completed journal; remove only the matching stage after the record commit. No generated-runtime inspection is needed to discover these shapes.
46
+ Context-only refresh preserves track lifecycle status, checkpoint and dependencies. Completion belongs to clean review; lifecycle changes belong to their approved workflow. A dependency change is a scope revision even when the plan text is unchanged: include the next track revision, its fresh revision record and reassessed dependency context. An active track cannot gain an unfinished dependency. These rules and cross-track identity/dependency validation also apply when resuming partial promotion; preserve an invalid older intent for explicit repair.
45
47
 
46
-
47
- ## Approval policy v2 migration
48
+ Refresh preserves completed and superseded execution journals byte-for-byte, including verification, approvals, commits and handoffs. Do not include edited historical journals in a context proposal. Active journals may change only through the supported explicit legacy policy migration or runtime-derived supersession in an approved scope revision. The same checks apply on interrupted recovery; preserve the original intent and evidence when an older pending proposal violates them.
48
49
 
49
50
  Before delivery, resolve each `APPROVAL_MODE_MIGRATION_REQUIRED` warning by including an explicit Track-or-Autonomous choice and its consequences in this refresh proposal. Never infer the choice from the old spelling. Preserve legacy Governed and Phase choices and the Governed fallback for an absent mode.
50
51
 
@@ -53,3 +54,9 @@ At a quiescent worker boundary, stage `state.approvalModeMigration` as `{ execut
53
54
  When Autonomous is selected, also create `state.autonomousReview` using the durable authority schema in the installed review skill: bind the original execution ID, approved specification commit, original `baseCommit`, migration approval time, empty findings, and `implementing` or `reviewing` according to lifecycle. Assess any existing review findings and carry their identities/attempt evidence forward instead of erasing them. Track selection does not authorize an automatic review loop. Preserve completed/archived track history; migrate only when a nonterminal track will continue or inherit legacy authority.
54
55
 
55
56
  Include all changed context, active seed metadata, policy records, journals, and state in one staged refresh envelope. Promote target project versions last and verify the selected authority before resuming delivery. Recovery, blocking, and cleanup of proven integrated work remain available before the migration is complete. Never fabricate historical human verification or broaden an unchanged journal by merely changing the default.
57
+
58
+ ## Explicit blocked-review retry
59
+
60
+ Use this dedicated retry procedure instead of the general context/scope cascade steps above. Do not include the target’s plan, learning, dependency-context or execution files: the scope and consumed inputs remain unchanged. For a policy-v2/schema-2 Autonomous loop that is blocked or stalled, prepare a dedicated refresh with the current `project.json`, the unchanged `tracks/<id>/state.json`, and `refreshes/refresh-<id>.md` recording the human’s retry instructions. Include `reviewRetry: {trackId, refreshPath, reason}` in `candidate_apply` prepare. Do not alter `autonomousReview`, its checkpoint, origin, authorization time, initial baseline, findings or attempts in authored state. Approve scope/plan/execution changes separately.
61
+
62
+ Present the runtime’s derived `stateChanges` and full digest before explicit approval. It appends the complete prior loop and instructions to refresh history and records `retryAuthorization` bound to this receipt, with each finding’s current attempt prefix as the baseline for two additional attempts. All old attempts remain intact; automatic remediation cannot replace this retry authority. The runtime derives `implementing`, `reviewing` or `remediating` from the retained lifecycle and removes the explicitly approved blocker. A healthy loop cannot renew its budget, stale state is rejected, and committed retries make zero changes. Commit/reconcile this refresh before following `nextStep`. Ordinary context refresh retains its existing strict authority-preservation rule.
@@ -7,15 +7,15 @@ description: Prepare and execute a human-approved Git-aware revert of a Cadre ta
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
  Load `.cadre/workflow.md`, project/track state, spec, plan, learning, review/revision history, recorded task commits, Git history, working tree, and dependent tracks. Read every affected file and relevant later diff before proposing a revert.
21
21
 
@@ -26,24 +26,26 @@ Call `project_status` first with `view: "implementation"` and `trackId` for acti
26
26
  Expected human decision count is one on the clean path. The exact revert proposal authorizes additive Git reversals, tests, plan/state/learning reconciliation, generated indexes, commits, and provenance bookkeeping when their content and consequences remain unchanged.
27
27
 
28
28
  1. Resolve the exact task, phase, or track and its worker commits, task-to-phase merge commits, phase-to-canonical merge commits, and execution journal. Detect shared commits, later overlapping edits, active workers/worktrees, dirty changes, and dependent work.
29
- 2. For an eligible active track, build the exact additive revert proposal, call `candidate_stage_prepare` for `revert-<track-id>` with `expectedFiles` equal to every reconciliation artifact, and render exactly those files beneath the stage.
29
+ 2. For an eligible active track, build the exact additive revert proposal, call `candidate_stage_prepare` for `revert-<track-id>` with `expectedFiles` equal to every reconciliation artifact, and render exactly those files beneath the stage. Include `reverts/revert-<id>-baseline.json` in that manifest and write the returned `revertBaseline` JSON there before inspection. It fingerprints pre-existing product/policy edits and the index at the approved base. Retain those exact bytes through reversal and recovery; later stage preparation must not replace the original baseline.
30
30
  3. Call `candidate_inspect` once for the staged reconciliation set. Supply one `planValidations` entry for every staged root or nested `plan.md`, using its exact candidate-relative path and post-revert track status; omit the list only when the candidate contains no plans. Present every plan result, the manifest, Git operations, expected diff, downstream reconciliation, verification, index, and commits as one authorization envelope bound to its digest. Never rewrite public history by default.
31
31
  4. Call `template_get_many` for `track/revert-operation`, render the approved operation into `state.json.operation`, and persist it before any Git mutation. Record the target kind/ID, safe reverse commit order, base commit, expected reconciliation commit, approved manifest digest and path/hash entries, approval time, checkpoint, and applied revert commits. Resume a matching operation; never replace it.
32
32
  5. Reach the authorized quiescent execution boundary before reverting. Use `git revert` to create additive reversal commits, using the correct mainline parent for an approved merge-commit revert. After each successful revert commit, record its SHA and advance the operation checkpoint. If a conflict has one unambiguous in-scope resolution that preserves the approved resulting semantics, resolve and verify it inside the envelope. If it introduces a material choice or changes the proposed result, stop and present one corrected proposal rather than accumulating per-file approval prompts.
33
33
  6. Before promoting any staged file that replaces the temporary revert operation, atomically persist `reverts/revert-<id>.json` from that actual approved operation, with the recorded reversal SHAs and `reconciliationCommit: null`. Read the receipt back and verify its digest, approval time, original snapshot path, and reversal SHAs against the still-persisted operation. Stop if the receipt is missing or differs. Only then promote the approved staged Cadre files, verify their canonical hashes, reconcile plan checkboxes without erasing provenance, set the earliest affected task/phase back to pending or blocked, and mark dependent tracks for approved revision/reseed as needed. The final staged state restores implement ownership; the receipt now preserves the revert authorization through that transition.
34
- 7. Run relevant tests, report the resulting diffs, call `tracks_render` once, then validate. Include the already-persisted receipt in `cadre(revert): reconcile <track-id>` without staging `.cadre/stage/`. After that commit exists, fill its SHA into the receipt, append exactly one matching history entry, and create `cadre(revert): record <track-id> revert commit`. Do not wait for a reconciliation SHA before first writing the receipt. Remove only the matching candidate stage after provenance is recorded. Do not turn these deterministic consequences into a second approval. On resume, never repeat a revert SHA already recorded by the operation or receipt.
34
+ 7. Run relevant tests and verify the final candidate proposal. Apply using candidate_apply, commit `cadre(revert): reconcile <track-id>` with its operation receipt and exact trailers, then reconcile. Remove only the matching candidate stage. Do not turn these deterministic consequences into a second approval. Never fill a self-referential reconciliation SHA or create a follow-up record commit. On resume, never repeat reversal SHAs already recorded by the approved operation.
35
35
 
36
36
  If exact commit provenance is missing or commits mix unrelated work, stop with a precise manual recovery plan.
37
37
 
38
- ## v5 group reversal and reconciliation
38
+ ## Group reversal and reconciliation
39
39
 
40
40
  A task sharing a product commit cannot be reverted alone. Enumerate every task using that SHA, present the whole group and downstream effects, and obtain explicit approval for all of it. Include a staged reversal record with `sharedCommit` and exact `affectedTaskIds`, reset every affected task as approved, and retain the exact original journal snapshot. Candidate validation rejects silent sibling reversal.
41
41
 
42
- After the authorized additive Git reversal commits, use `candidate_apply` prepare/apply with `workflow: "revert"` for the approved reconciliation manifest. Include the actual reversal receipt, original journal snapshot, restored execution bindings, plan, learning and dependency context. This replaces direct promotion and steps 6–7's two-commit bookkeeping on v5. Make one reconciliation commit with the immutable operation receipt and exact trailers; reconcile it without filling a self-referential SHA or making a record-revert commit. Never repeat recorded reversal commits on recovery.
42
+ After the authorized additive Git reversal commits, use `candidate_apply` prepare/apply with `workflow: "revert"` for the approved reconciliation manifest. Include the actual reversal receipt, original journal snapshot, restored execution bindings, plan, learning and dependency context. Make one reconciliation commit with the immutable operation receipt and exact trailers; reconcile it without filling a self-referential SHA or making a record-revert commit. Never repeat recorded reversal commits on recovery.
43
+
44
+ The pre-reversal authorization binds the `candidate_inspect` digest, exact authored reconciliation files, Git targets and resulting semantics. A pre-reversal `candidate_apply` preview is a structural check, not a token to apply after Git changes: its digest also binds HEAD and canonical state. After the approved reversal, prepare the final promotion from the same approved files plus the explicitly authorized reversal record with actual SHAs and approval fields. Verify that every authored file still matches the approved inspection, except those named bookkeeping consequences, and that runtime `stateChanges` preserve the approved execution ownership. Apply that post-reversal token under the original combined approval only when all consequences remain within that envelope. Changed product semantics, targets, artifacts or dependencies require a corrected proposal and approval. Do not apply a stale pre-reversal token or ask again solely because the authorized reversal advanced HEAD.
43
45
 
44
46
  ## Memory contract
45
47
 
46
- 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.
48
+ 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.
47
49
 
48
50
  ## Preparation safety and execution binding
49
51
 
@@ -51,12 +53,30 @@ Preparation is read-only outside the declared candidate stage. Never run `git re
51
53
 
52
54
  When temporarily replacing an implement operation with the approved revert operation, preserve `lastExecution: {executionId, journal, planRevision, graphDigest, headCommit, completedAt, approvalMode}` throughout the repair, copying those values from the persisted journal (including null head/completion values on an active run); include that exact proposed state in staging. After reconciliation restore the original implement operation, with the selected task pending as approved, before clearing the temporary revert. Preserve every handoff and original task SHA as evidence; workerHistory contains worker IDs, never commit SHAs. Never clear both execution references while a journal is in progress. Include state, execution journal, plan and reassessed learning in the single proposal. Do not change plan revisions or task descriptions merely to reset completion markers.
53
55
 
54
- Candidate paths never include a leading `.cadre/`: use `state.json`, `plan.md`, `learning.md`, `executions/execution-<id>.json`, and `reverts/revert-<id>.md` for the owned track, or `tracks/<id>/...` for nested updates. The stage already supplies the root. Use `candidate_inspect` to validate the full proposed overlay before asking for approval.
56
+ Candidate paths never include a leading `.cadre/`: use `state.json`, `plan.md`, `learning.md`, `executions/execution-<id>.json`, and `reverts/revert-<id>.md` for the owned track, or `tracks/<id>/...` for nested updates. Revert artifact IDs use lowercase letters, digits and hyphens: for target `T1.1`, use `reverts/revert-t1-1.md` and `reverts/revert-t1-1-execution-before.json`, while retaining `targetId: "T1.1"` in the evidence. Do not put uppercase node IDs or dots in artifact basenames. The stage already supplies the root. Use `candidate_inspect` to validate the full proposed overlay before asking for approval.
55
57
 
56
58
  Stage the final post-reconciliation state, retaining the original implement operation, rather than a temporary revert operation containing unknown approval fields. After approval, materialize the temporary revert journal from the template with the actual digest/time before Git mutation, retaining the execution binding in lastExecution. The final staged state restores implement ownership. Do not put unresolved approval placeholders or a self-referential digest into approved candidate bytes.
57
59
 
58
- ## Legacy SHA durable revert receipt
60
+ `candidate_apply` prepare returns `stateChanges` for runtime-derived fields: apply each `set` or array `append` to the staged state (or canonical state when none was staged), then verify the reconstructed final state against its returned manifest hash. A changed state hash alone does not mean execution ownership was removed. Include these exact derived changes in the reviewable proposal; never inspect the installed runtime to reconstruct them.
61
+
62
+ ## Durable reversal evidence
63
+
64
+ Before resetting node evidence, include the exact original execution journal as `reverts/revert-<id>-execution-before.json` in the inspected manifest. Preserve original verification, authorization, commit pointers, handoffs and all other nodes. Set the proposed journal checkpoint to `reverted:<target-id>`.
65
+
66
+ After Git reversal, persist the actual approved operation as `reverts/revert-<id>.json` before restoring implement ownership. Include its digest, approved artifact hashes, reversal SHAs and original snapshot path. Keep `reconciliationCommit` null; the immutable operation receipt supplies provenance without rewriting this evidence. A pending receipt uses resume/reconcile; never repeat a reversal or request another approval for unchanged consequences.
67
+
68
+ ## Revert authority preservation
69
+
70
+ A phase completion or fast-forward HEAD reverses only its own commit delta; its `mergeCommit` field does not imply a Git merge object. Include every distinct task boundary in direct-main and fast-forward phase/track reversals. Collapse tasks into an actual phase merge only when they were introduced relative to its explicitly selected mainline parent. Tasks already in that parent still need their own reversal; never reverse a task again when the chosen merge reversal already covers it.
71
+
72
+ Receipt promotion requires the actual persisted approved revert operation, reachable additive reversal commits, its exact durable reversal record and original execution snapshot, and restored implement ownership matching the retained execution. Preserve authored commits, dependency/revision counters, review cycles and approval-policy metadata. Keep the complete original `autonomousReview` in authored state; the runtime derives the execution checkpoint while retaining any existing blocker. Never shorten `initialBaseCommit`, replace the originating authorization, reset findings/attempts, or substitute retry authority as a reversal consequence. State-only authority rewrites are rejected before promotion. A blocked loop still requires the separately approved refresh retry to continue.
73
+
74
+ Copy `candidate_inspect.files` into the persisted operation's complete `approvedArtifactHashes`, with exactly the paths in `approvedArtifacts`; there is no `manifest` field in that result. Every authored final artifact must retain its approved hash, including state and unrelated journal nodes. The only added artifact is the exact reversal record whose basename matches `originalExecutionPath` without `-execution-before`. Runtime-derived history/checkpoint fields are applied after these checks. Missing hashes, extra files or changed authored bytes require exact corrected approval; never mint replacement hashes from changed files under the old approval.
75
+
76
+ Set `repositoryBaselinePath` to the originally inspected baseline artifact in the temporary approved operation and its exact reversal record. Reconciliation permits those unchanged pre-existing edits while rejecting new product/policy changes; it never cleans, stashes or commits user files. A pending older reversal without this evidence retains its original clean-input contract; changed inputs require an exact repair approval. Clean review still verifies the final delivered product separately.
77
+
78
+ Git targets must belong to the named task, phase or track, including the explicitly approved whole shared group. Include every delivery boundary needed to reverse that scope, without reversing task commits a second time when an approved phase integration already covers them. Reset the affected nodes and dependency/phase consequences while retaining unrelated nodes, worker history, handoffs and the execution contract. Clear selected quiescent worker ownership (`workerId`, `branch`, `worktreePath`) for the new run, retaining the original worker ID in `workerHistory` and the exact before-snapshot. A commit from another task/phase cannot satisfy the target merely because it occurs in the same journal.
59
79
 
60
- When resetting node evidence, stage the exact original execution journal as `reverts/revert-<id>-execution-before.json` before changing the proposed journal. Include it in the same inspected manifest and approval. This preserves original verification, authorization, commit pointers and handoffs; keeping only the old commit SHA is insufficient. Preserve all other nodes and derived dependencies. Set the proposed journal checkpoint to `reverted:<target-id>` so status does not claim the reset task remains completed.
80
+ Record exactly one actual reversal SHA per approved target in the approved reverse order. Each target must have retained execution provenance. The runtime computes Git's rename-aware reversal result using an isolated temporary index, object directory, worktree and refs, preserving the delivery index, objects and history; ancestry or a commit message alone is insufficient. For merge targets, include `mainlineParents: {"<target SHA>": <parent number>}` in the pre-reversal operation and approval envelope. If preparation in a disposable clone discovers a conflict, include its exact approved result tree as `conflictResolutionTrees: {"<target SHA>": "<40-character tree SHA>"}`. The result may change only that target's paths and Git-verified later renames of those paths. An unforeseen resolution requires corrected exact approval before reconciliation. Empty, unrelated, missing, reordered or wrong-result reversals are rejected. Product or verification-policy drift after the last reversal also stops reconciliation; preserve those changes and the original evidence.
61
81
 
62
- After Git reversal, retain the actual digest-bound operation as `reverts/revert-<id>.json` before restoring final implement ownership. This receipt is a named bookkeeping consequence of the same approval, not a new proposal. It records `{action: "revert", targetKind, targetId, approvalDigest, approvedAt, baseCommit, commits, revertCommits, originalExecutionPath, approvedArtifacts, approvedArtifactHashes, reconciliationCommit}`. Initially `reconciliationCommit` is null; persist and reread this receipt before replacing the temporary operation. Include it in the reconciliation commit, then set its real SHA after that commit exists. Append exactly one state history entry `{action: "revert", targetId, approvalDigest, revertCommits, commit: reconciliationCommit, receiptPath}` and commit the receipt/history as `cadre(revert): record <track-id> revert commit`. Verify the receipt, history, original snapshot, both commit types, restored execution binding, and dirty-file preservation before removing the stage or reporting completion. Runtime state validity alone does not prove these workflow consequences were completed. On fresh recovery, a receipt with null reconciliationCommit means bookkeeping is unfinished: inspect Git for the matching reconciliation commit, reuse it if present, or create it if absent. Never repeat a reversal or request another approval for unchanged bookkeeping.
82
+ New pending reversals retain the original temporary operation and authored state in the ignored recovery journal, so resume revalidates approval hashes, Git proof and deterministic state even after candidate-stage loss. A valid older intent can retain that proof before further writes when its exact original state/stage remains available. Older partial intents missing original authority or approval hashes need an explicitly approved evidence repair; preserve the intent and receipt, never alter their hashes, erase history or repeat Git reversals to bypass this failure. Already committed replay stays zero-change after later delivery or archive.