cadre-ai 3.7.1 → 3.9.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 (110) hide show
  1. package/.claude-plugin/plugin.json +1 -1
  2. package/.codex-plugin/plugin.json +1 -1
  3. package/CHANGELOG.md +66 -1
  4. package/README.md +42 -6
  5. package/agents/cadre-phase-worker.md +5 -1
  6. package/agents/cadre-task-worker.md +5 -1
  7. package/dist/cadre-cli.mjs +6 -3
  8. package/dist/cadre-mcp.mjs +3192 -2079
  9. package/package.json +1 -1
  10. package/skills/archive/SKILL.md +18 -4
  11. package/skills/create/SKILL.md +15 -3
  12. package/skills/implement/SKILL.md +39 -13
  13. package/skills/implement/agents/openai.yaml +1 -1
  14. package/skills/implement/references/conflict-handling.md +1 -1
  15. package/skills/implement/references/parallel-workers.md +4 -0
  16. package/skills/implement/references/resume-recovery.md +6 -0
  17. package/skills/refresh/SKILL.md +28 -5
  18. package/skills/revert/SKILL.md +20 -2
  19. package/skills/review/SKILL.md +87 -11
  20. package/skills/revise/SKILL.md +18 -5
  21. package/skills/status/SKILL.md +4 -0
  22. package/skills/track/SKILL.md +19 -9
  23. package/skills/wisp/SKILL.md +4 -0
  24. package/templates/v4/init/archive/.gitkeep +1 -0
  25. package/templates/v4/init/gitignore.template +8 -0
  26. package/templates/v4/init/guidelines.md +25 -0
  27. package/templates/v4/init/operations/.gitkeep +1 -0
  28. package/templates/v4/init/patterns/index.md +8 -0
  29. package/templates/v4/init/product.md +30 -0
  30. package/templates/v4/init/project.json +27 -0
  31. package/templates/v4/init/refreshes/.gitkeep +1 -0
  32. package/templates/v4/init/styleguides/general.md +14 -0
  33. package/templates/v4/init/styleguides/language.md +21 -0
  34. package/templates/v4/init/tech-stack.md +21 -0
  35. package/templates/v4/init/tracks/.gitkeep +1 -0
  36. package/templates/v4/init/tracks.md +6 -0
  37. package/templates/v4/init/wisps/.gitkeep +1 -0
  38. package/templates/v4/init/workflow.md +91 -0
  39. package/templates/v4/project/archive-operation.json +19 -0
  40. package/templates/v4/project/pattern.md +20 -0
  41. package/templates/v4/project/refresh-operation.json +18 -0
  42. package/templates/v4/project/refresh.md +21 -0
  43. package/templates/v4/styleguides/dart.md +27 -0
  44. package/templates/v4/styleguides/flutter.md +27 -0
  45. package/templates/v4/styleguides/go.md +29 -0
  46. package/templates/v4/styleguides/gradle.md +28 -0
  47. package/templates/v4/styleguides/html-css.md +39 -0
  48. package/templates/v4/styleguides/index.md +27 -0
  49. package/templates/v4/styleguides/java.md +27 -0
  50. package/templates/v4/styleguides/javascript.md +27 -0
  51. package/templates/v4/styleguides/kotlin.md +26 -0
  52. package/templates/v4/styleguides/maven.md +28 -0
  53. package/templates/v4/styleguides/python.md +27 -0
  54. package/templates/v4/styleguides/react.md +28 -0
  55. package/templates/v4/styleguides/swift.md +27 -0
  56. package/templates/v4/styleguides/swiftui.md +27 -0
  57. package/templates/v4/styleguides/typescript.md +26 -0
  58. package/templates/v4/track/bug.md +14 -0
  59. package/templates/v4/track/execution.json +20 -0
  60. package/templates/v4/track/learning.md +45 -0
  61. package/templates/v4/track/plan.md +39 -0
  62. package/templates/v4/track/revert-operation.json +17 -0
  63. package/templates/v4/track/revise-operation.json +18 -0
  64. package/templates/v4/track/revision.md +36 -0
  65. package/templates/v4/track/spec.md +38 -0
  66. package/templates/v4/track/state.json +31 -0
  67. package/templates/v5/init/archive/.gitkeep +1 -0
  68. package/templates/v5/init/gitignore.template +9 -0
  69. package/templates/v5/init/guidelines.md +25 -0
  70. package/templates/v5/init/operations/.gitkeep +1 -0
  71. package/templates/v5/init/patterns/index.md +8 -0
  72. package/templates/v5/init/product.md +30 -0
  73. package/templates/v5/init/project.json +27 -0
  74. package/templates/v5/init/refreshes/.gitkeep +1 -0
  75. package/templates/v5/init/styleguides/general.md +14 -0
  76. package/templates/v5/init/styleguides/language.md +21 -0
  77. package/templates/v5/init/tech-stack.md +21 -0
  78. package/templates/v5/init/tracks/.gitkeep +1 -0
  79. package/templates/v5/init/tracks.md +6 -0
  80. package/templates/v5/init/wisps/.gitkeep +1 -0
  81. package/templates/v5/init/workflow.md +103 -0
  82. package/templates/v5/project/archive-operation.json +19 -0
  83. package/templates/v5/project/pattern.md +20 -0
  84. package/templates/v5/project/refresh-operation.json +18 -0
  85. package/templates/v5/project/refresh.md +21 -0
  86. package/templates/v5/styleguides/dart.md +27 -0
  87. package/templates/v5/styleguides/flutter.md +27 -0
  88. package/templates/v5/styleguides/go.md +29 -0
  89. package/templates/v5/styleguides/gradle.md +28 -0
  90. package/templates/v5/styleguides/html-css.md +39 -0
  91. package/templates/v5/styleguides/index.md +27 -0
  92. package/templates/v5/styleguides/java.md +27 -0
  93. package/templates/v5/styleguides/javascript.md +27 -0
  94. package/templates/v5/styleguides/kotlin.md +26 -0
  95. package/templates/v5/styleguides/maven.md +28 -0
  96. package/templates/v5/styleguides/python.md +27 -0
  97. package/templates/v5/styleguides/react.md +28 -0
  98. package/templates/v5/styleguides/swift.md +27 -0
  99. package/templates/v5/styleguides/swiftui.md +27 -0
  100. package/templates/v5/styleguides/typescript.md +26 -0
  101. package/templates/v5/track/bug.md +14 -0
  102. package/templates/v5/track/dependency-context.json +9 -0
  103. package/templates/v5/track/execution.json +21 -0
  104. package/templates/v5/track/learning.md +45 -0
  105. package/templates/v5/track/plan.md +42 -0
  106. package/templates/v5/track/revert-operation.json +17 -0
  107. package/templates/v5/track/revise-operation.json +18 -0
  108. package/templates/v5/track/revision.md +36 -0
  109. package/templates/v5/track/spec.md +38 -0
  110. package/templates/v5/track/state.json +19 -0
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "cadre-ai",
3
- "version": "3.7.1",
3
+ "version": "3.9.0",
4
4
  "description": "Cross-agent, human-governed software delivery harness",
5
5
  "author": {
6
6
  "name": "Vishal Kumar",
@@ -5,13 +5,27 @@ description: Archive one or more completed Cadre tracks in one approved, resumab
5
5
 
6
6
  # Cadre Archive
7
7
 
8
+ ## Cohesive commits and retained context
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.
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.
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.
15
+
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
+
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.
19
+
8
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.
9
21
 
10
22
  At every required selection or approval boundary, show a concise batch 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 archive proposal digest. Treat only an `approved` result as approval. If it returns `fallback_required`, or immediately returns `declined` while the task explicitly reports policy `never`, ask the same short question once in chat; the latter is policy rejection, not a human decline. Never request secrets or retry the form.
11
23
 
12
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.
13
25
 
14
- 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 atomic `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 for v5 (legacy batches retain `archive_batch_record`); do not inspect the installed runtime or tool catalog for alternatives.
27
+
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.
15
29
 
16
30
  Expected human decision count is one for the complete batch. Ask again only when its selection, content, or consequences change.
17
31
 
@@ -22,8 +36,8 @@ Expected human decision count is one for the complete batch. Ask again only when
22
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.
23
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.
24
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.
25
- 8. Call `archive_batch_record` once with the project root and batch ID; it derives the actual current HEAD and atomically records deterministic provenance and the generated index without another approval. Create `cadre(archive): record batch <batch-id>`, then remove only the matching candidate stage.
26
- 9. Use the final apply result instead of redundant `state_validate` or `project_status` calls when it is valid/current. Verify only the clean worktree and the two expected commits.
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.
40
+ 9. Reuse the apply validation. Verify the receipt, one archive commit, and clean worktree; do not reread all completed histories.
27
41
 
28
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.
29
43
 
@@ -31,7 +45,7 @@ Do not delete learning, review cycles, revisions, bug reports, or commit provena
31
45
 
32
46
  ## Memory contract
33
47
 
34
- Preserve phase history and existing handoffs. For active v3 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 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.
35
49
 
36
50
  ## Evidence quality and proposal identity
37
51
 
@@ -5,6 +5,18 @@ description: Initialize or resume Cadre in a greenfield or brownfield repository
5
5
 
6
6
  # Cadre Create
7
7
 
8
+ ## Cohesive commits and retained context
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.
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.
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.
15
+
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
+
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.
19
+
8
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.
9
21
 
10
22
  At every required clarification or approval boundary, show a concise summary or focused diff. Inspect the active host policy before calling `workflow_elicit`: if the task context reports approval policy `never`, including Codex Full Access, skip the form and ask the same short question once in chat. Otherwise prefer `workflow_elicit`, using `clarification` for at most three questions and `approval` bound to the current proposal digest. Treat only an `approved` result as approval. If it returns `fallback_required`, or immediately returns `declined` while the task explicitly reports policy `never`, ask the same short question once in chat; the latter is policy rejection, not a human decline. Never request secrets or retry the form.
@@ -19,9 +31,9 @@ At every required clarification or approval boundary, show a concise summary or
19
31
  6. Identify the proposed `workflow.md` by template ID, template-set version, content hash, and a concise summary of its material rules and consequences. Do not print the complete unchanged bundled workflow unless the human asks. If changes are requested, show a focused diff and summarize the resulting behavior; show the complete revised workflow only on request. Do not create a standalone workflow approval.
20
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.
21
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.
22
- 9. If Git disposition is `initialize`, run `git init` only at the approved root, verify `git rev-parse --show-toplevel` equals that root, then call `setup_record_git_initialized`. If Git is unavailable, initialization fails, or a different repository appears, stop with the setup journal intact. For an existing repository, verify its root again.
23
- 10. Call `state_validate` and report the result. Commit the authorized setup as `cadre(create): initialize project harness` only when validation is clean and checkpoint is `commit-pending`; validation failure is a blocker, not a request to approve an exception implicitly.
24
- 11. Call `setup_record_commit`; it records the actual current HEAD. If the index needs regeneration, call `tracks_render` once. Commit the bookkeeping as `cadre(create): record setup commit`, then remove only `.cadre/stage/create` after its approved hashes and provenance are complete.
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.
25
37
 
26
38
  ## Resume protocol
27
39
 
@@ -5,7 +5,19 @@ description: Execute or resume an approved Cadre plan as a dependency DAG, using
5
5
 
6
6
  # Cadre Implement
7
7
 
8
- Treat approved `plan.md` as the source of truth. Implement only `planned` or `in_progress` tracks. 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.
8
+ ## Cohesive commits and retained context
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.
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.
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.
15
+
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
+
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.
19
+
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.
9
21
 
10
22
  At a clarification or manual-verification boundary, inspect host policy before `workflow_elicit`. Under approval policy `never`, including Codex Full Access, skip the form and ask the same short question once in chat. Otherwise use a concise form bound to execution ID, node ID, and verified commit. Treat only `approved` as approval. On `fallback_required`, or an immediate policy-driven `declined`, ask once in chat; policy rejection is not a human decline. Never request secrets or retry the form.
11
23
 
@@ -20,12 +32,12 @@ Read only the references required by current state:
20
32
 
21
33
  ## Entry and modes
22
34
 
23
- 1. Call `project_status` once with `view: "implementation"`, `trackId`, and the known `executionId` if resuming. 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.
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`.
24
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.
25
- 3. Scheduling defaults to `parallel`; use `sequential` only when requested. Approval mode defaults to `phase`; use `governed` or `autonomous` only when explicitly requested. Resume journaled modes. A mode authorizes only work bounded by the approved spec and plan.
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.
26
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.
27
39
 
28
- `governed` pauses for regular task diffs and integrations. `phase` runs regular phase work autonomously and pauses at each phase's final `User Manual Verification`. `autonomous` also performs phase verification autonomously and pauses only at `Track-level User Manual Verification`.
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.
29
41
 
30
42
  Host security permission is distinct from Cadre approval. Request only a narrow required command permission, centralize shared network/dependency preparation in main, use existing scripts, and run independent read-only checks in parallel. A permission prompt never approves an artifact, commit, merge, or lifecycle transition.
31
43
 
@@ -36,29 +48,43 @@ Use the scheduler returned by the preflight or latest mutation receipt. Plan ord
36
48
  - Execute one ready task directly in main when delegation adds no value. Follow returned `eventGuidance`: `record_commit` requires commit, verification, and authorization; `record_verification` requires those same fields; `record_integration` requires commit and verification; `block` requires a blocker. A running-phase `complete` also requires commit, verification, and authorization.
37
49
  - Delegate only independent or cohesive work. Read `references/parallel-workers.md` before doing so.
38
50
  - Include a `handoff` with task `record_commit` and `block`: `decisions`, `failedApproaches`, `openQuestions`, `nextAction`, and `sources` containing repository-relative `path` and exact `sha256`. Keep its serialized JSON within 8 KiB; reference longer durable evidence instead of truncating it. Main records it with the existing checkpoint, without another call or approval. A handoff records observations and never authorizes work.
39
- - Never checkpoint evidence before it exists. Each regular task has one Conventional Commit and a distinct recorded SHA. `record_commit` includes focused verification and authorization evidence.
51
+ - Never checkpoint evidence before it exists. Each approved commit group has one cohesive product commit; legacy executions retain distinct task commits. `record_commit` includes focused verification and authorization evidence.
40
52
  - A `.cadre/**`-only bookkeeping commit does not invalidate product verification while product files, tests, inputs, and verification policy remain unchanged.
41
53
 
42
54
  For a delegated node, the normal lifecycle is four MCP calls:
43
55
 
44
56
  1. `worktree_create` creates or reconciles the derived worktree and records `start` with its path and branch.
45
57
  2. After main reviews the returned worker diff/checks and the worker creates its clean task commit, `execution_checkpoint` records `record_commit` with SHA, verification, and mode/human authorization.
46
- 3. `integration` with `request: { mode: "prepare", projectRoot, trackId, executionId, nodeId }` validates and merges immediately in `phase`/`autonomous`, recording `record_integration` in its receipt. In `governed` it returns `approval_required`; after human approval call only `request: { mode: "apply", proposalToken }`. Never make the governed calls consecutively without human input.
58
+ 3. `integration` with `request: { mode: "prepare", projectRoot, trackId, executionId, nodeId }` validates and merges immediately in `phase`/`track`/`autonomous`, recording `record_integration` in its receipt. In `governed` it returns `approval_required`; after human approval call only `request: { mode: "apply", proposalToken }`. Never make the governed calls consecutively without human input.
47
59
  4. `worktree_cleanup` verifies integration, removes the worktree/branch, and records `complete` when all invariants hold.
48
60
 
49
61
  Do not add standalone `start`, `record_integration`, or `complete` calls around this composite path. Retried calls reconcile an existing worktree, merge commit, removed worktree, or missing journal transition. Keep standalone checkpoints for direct-main work, manual verification, blockers, conflict recovery, and interruption repair.
50
62
 
51
63
  ## Verification, learning, and finish
52
64
 
53
- - A phase barrier depends on all sibling tasks. Prepare evidence against the phase head. In `governed` and `phase`, present it once and record human approval; in `autonomous`, record persisted-mode authorization.
54
- - After the barrier, integrate the phase, record dependency-aware learning (including persisted task handoffs) and task/merge provenance in canonical plan/learning, and make one `cadre(implement): record <track-id> <phase-id>` bookkeeping commit. Start dependents only after cleanup/completion.
55
- - The final `Track-level User Manual Verification` runs in main against fully integrated canonical HEAD and always requires explicit human approval.
56
- - When every node is complete, learning/provenance is recorded, worktrees are gone, and final verification is approved, run full relevant checks and call `execution_finish`. It converges interrupted final writes using the persisted completion identity. Commit only its completed journal, plan markers, `ready_for_review` state, and `tracks.md` as `cadre(implement): complete <track-id>`; never let review absorb this bookkeeping.
65
+ - A phase barrier depends on all sibling tasks. Prepare evidence against the phase head. In `governed` and `phase`, present it once and record human approval; in `track` and `autonomous`, record persisted-mode authorization.
66
+ - After the barrier, integrate the phase and persist dependency-aware learning and task provenance on disk. Complete a direct-main phase in one `complete` checkpoint with verified product/integration HEAD. Do not create phase-record or final-verification commits. Start dependents only after cleanup/completion.
67
+ - The final `Track-level User Manual Verification` runs in main against fully integrated canonical HEAD and requires explicit human approval in Governed, Phase, and Track. Autonomous records actual verification and persisted-mode authorization, never a fabricated human approval; unavailable human-only checks block the loop.
68
+ - When every node is complete, learning/provenance is recorded, worktrees are gone, and final verification is authorized under the applicable mode, run full relevant checks and call `execution_finish`. It converges interrupted final writes using the persisted completion identity. Commit only its completed journal, plan markers, `ready_for_review` state, and `tracks.md` as `cadre(implement): complete <track-id>`; never let review absorb this bookkeeping.
69
+
70
+ In Autonomous, follow the `execution_finish.nextStep` after the implementation bookkeeping commit; do not end the task at `ready_for_review`. Never mark a track `completed`; only an explicitly approved clean review may do that.
57
71
 
58
- Never mark a track `completed`; only an approved clean review may do that.
72
+ ## Autonomous execution and recovery
73
+
74
+ `execution_start` creates the policy-v2 `state.autonomousReview` authority and `implementing` checkpoint; `execution_finish` advances it to `reviewing`. Preserve its original authorization, initial review baseline, specification commit, finding identities, and attempted execution IDs across every remediation execution. The review skill owns review, remediation proposals, stalled findings, and final approval.
75
+
76
+ On resume, read canonical state, review cycles, the current operation, execution journals, staged manifest, and Git. Resume an active implementation rather than replacing it. A pending review operation belongs to review even when partial promotion has already set `in_progress`. After review promotion and its bookkeeping commit, a `remediating` checkpoint starts a new execution for the appended graph with inherited Autonomous mode and scheduling. Preserve all completed phases and execution history. Unavailable human-only checks, conflicting requirements, material scope decisions, and external blockers pause the loop; persist the precise blocker and actual evidence without fabricating approval. Continue while verifiable progress is possible, without a fixed cycle cap.
77
+
78
+ ## MCP skill continuation
79
+
80
+ Follow `nextStep` from focused `project_status` and `execution_finish` using its exact `projectRoot`, `trackId`, and current `executionId`. `invoke_skill` identifies the installed Cadre skill by `plugin` and `skill`; invoke it through the host's native skill mechanism in the same task. Codex/Claude resolve the Cadre plugin workflow; Zed resolves `cadre-<skill>`. If native invocation is unavailable, load the full skill from its host-advertised installed location and execute its procedure. Reuse an already loaded, unchanged skill; a next step naming the current skill means continue it, not recursive re-entry. Never derive sibling filesystem paths or merely print a slash command. If the installed skill cannot be resolved, stop with that blocker.
81
+
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.
59
83
 
60
84
  ## Direct-main checkpoint order
61
85
 
62
- Start the ready phase with `execution_checkpoint(start)`, then start its ready task before editing. After tests and the distinct task commit, use `record_commit` with verification, mode/approval authorization and handoff, then `complete`. A manual node requires its parent phase running: start the node and record verification only after the applicable approval. After a phase barrier, append learning, make `cadre(implement): record <track-id> <phase-id>`, then record/complete the phase with that SHA. Fill learning's phase-completion SHA in the next authorized bookkeeping commit. Repeat for the final verification phase, with its separate human gate. `execution_finish` renders all plan task/phase commit markers from journal evidence; do not hand-edit those markers or create extra corrective commits. It does not author learning prose.
86
+ 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
+
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.
63
89
 
64
- For `context_read`, supply `knownSources` only for complete source sections actually retained in this session: `{path, sha256, section, contentHash}` from fully consumed excerpts. Keep the same inventory across continuation pages. `reused: true` explicitly refers to those retained bytes; a changed file or section is returned in full. Clear inventory on fresh-session recovery or lost context. Consume pages until `complete`; require `contextReady` before editing. A complete page stream with errors or stale guidance is not permission to execute.
90
+ 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.
@@ -1,4 +1,4 @@
1
1
  interface:
2
2
  display_name: "Cadre: Implement"
3
3
  short_description: "Execute a track DAG with safe workers"
4
- default_prompt: "Use $implement to execute or resume an approved track DAG, in parallel scheduling and phase approval mode by default unless explicitly requested otherwise."
4
+ default_prompt: "Use $implement to execute or resume an approved track DAG, in parallel scheduling and Track approval mode by default unless explicitly requested otherwise. Explicit Autonomous continues verification, review, and in-scope remediation until a clean review and one final human completion approval."
@@ -2,4 +2,4 @@
2
2
 
3
3
  When integration reports a conflict, record `conflicted` and preserve the worktree. Resolve task conflicts in the phase integration worktree and phase conflicts in main. Read every conflicted file and both sides, explain the chosen resolution, and rerun combined verification.
4
4
 
5
- In governed mode, present the exact resolution for approval. In phase/autonomous mode, apply only an unambiguous in-scope resolution; stop for clarification if product intent, scope, compatibility, or authority is material. Use standalone checkpoints to record recovery and the verified resulting integration. Never force-delete, reset, or silently choose a side.
5
+ In governed mode, present the exact resolution for approval. In phase/track/autonomous mode, apply only an unambiguous in-scope resolution; stop for clarification if product intent, scope, compatibility, or authority is material. Use standalone checkpoints to record recovery and the verified resulting integration. Never force-delete, reset, or silently choose a side.
@@ -9,3 +9,7 @@ Every worker prompt includes its absolute worktree, track/execution/node IDs, ap
9
9
  Workers must not merge, rebase, reset, clean up, force Git operations, or switch to other plan work. A phase worker must stop at a clean handoff while task workers for that phase are active.
10
10
 
11
11
  Supply workers a bounded context handoff with required source paths/hashes and exact relevant learning, not the parent's entire conversation. Workers must read required sources if they do not already have their current content. Their result includes the typed task handoff (`decisions`, `failedApproaches`, `openQuestions`, `nextAction`, `sources`) within 8 KiB; main persists it with the existing task checkpoint. Never silently trim required constraints to fit a prompt.
12
+
13
+ ## Cohesive execution contract
14
+
15
+ 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.
@@ -10,3 +10,9 @@ Reconcile the implementation status receipt with worker identities, branches, `g
10
10
  Never reset, discard, reconstruct, force-delete, or silently restart. Use standalone `block`/`resume` checkpoints for interruption repair that cannot be completed by a composite call.
11
11
 
12
12
  Read the persisted handoff for the current node and declared dependencies through `context_read` or focused `execution_status`. Preserve decisions, failed approaches, open questions, and next action. Missing handoffs mean "not recorded"; never infer them as historical facts. Reconcile source fingerprints, plan identity, journal evidence, and Git before using a handoff. Changed sources require reinspection, and observations never replace authorization. Recovery reaches only the last persisted checkpoint; a crash before recording may leave work that still needs investigation.
13
+
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
+
16
+ ## Cohesive execution contract
17
+
18
+ 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.
@@ -5,6 +5,18 @@ description: Refresh Cadre product, guidelines, workflow, styleguides, and tech-
5
5
 
6
6
  # Cadre Refresh
7
7
 
8
+ ## Cohesive commits and retained context
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.
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.
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.
15
+
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
+
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.
19
+
8
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.
9
21
 
10
22
  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.
@@ -15,18 +27,29 @@ Call `project_status` first with `view: "project"` and use its embedded structur
15
27
  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.
16
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.
17
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.
18
- 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. 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.
19
- 6. After approval and before any context or track write, persist the refresh operation journal with the approved manifest digest and path/hash entries. Resume an existing matching journal from its first incomplete artifact; never replace it. Promote only authorized staged changes, verify canonical hashes, and advance its checkpoint and artifact progress after each write. Reseed affected active tracks, retain prior project refresh/history until the artifact commit exists, then call `tracks_render` once and call `state_validate` without another prompt.
20
- 7. Commit `cadre(refresh): update project context` without staging `.cadre/stage/`, then record that SHA in the refresh journal and as `lastRefresh.commit`, mark the journal completed, and create the follow-up `cadre(refresh): record refresh commit` state commit. Remove only the matching candidate stage after provenance is recorded. These unchanged deterministic consequences remain inside the one refresh envelope. If interrupted after the first commit, identify and record the existing expected commit rather than repeating context changes.
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.
21
33
 
22
34
  ## Memory contract
23
35
 
24
- Preserve phase history and existing handoffs. For active v3 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.
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.
25
37
 
26
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.
27
39
 
28
- ## Refresh bookkeeping contract
40
+ ## Legacy SHA refresh bookkeeping contract (not the v5 path)
29
41
 
30
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.
31
43
 
32
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.
45
+
46
+
47
+ ## Approval policy v2 migration
48
+
49
+ 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
+ At a quiescent worker boundary, stage `state.approvalModeMigration` as `{ executionId, approvalMode: "track" | "autonomous", approvedAt, refreshPath: "refreshes/refresh-<id>.md" }`. The existing refresh operation owns the inspected digest and exact path/hash manifest; the migration record points to that refresh without embedding its own digest. For an active execution, include its journal and implement operation in the same envelope: set both `approvalMode` to the selected mode and `approvalPolicyVersion` to `2`, preserving nodes, commits, timestamps, and graph identity. For a completed execution, leave the journal and `lastExecution` byte-for-byte unchanged; the migration record supplies the explicitly chosen effective mode for subsequent review or execution inheritance.
52
+
53
+ 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
+ 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.
@@ -5,6 +5,18 @@ description: Prepare and execute a human-approved Git-aware revert of a Cadre ta
5
5
 
6
6
  # Cadre Revert
7
7
 
8
+ ## Cohesive commits and retained context
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.
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.
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.
15
+
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
+
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.
19
+
8
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.
9
21
 
10
22
  At every required clarification or approval boundary, show a concise impact summary or focused diff. Inspect the active host policy before calling `workflow_elicit`: if the task context reports approval policy `never`, including Codex Full Access, skip the form and ask the same short question once in chat. Otherwise prefer `workflow_elicit`, using `clarification` for at most three questions and `approval` bound to the exact revert 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,9 +35,15 @@ Expected human decision count is one on the clean path. The exact revert proposa
23
35
 
24
36
  If exact commit provenance is missing or commits mix unrelated work, stop with a precise manual recovery plan.
25
37
 
38
+ ## v5 group reversal and reconciliation
39
+
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
+
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.
43
+
26
44
  ## Memory contract
27
45
 
28
- Preserve phase history and existing handoffs. For active v3 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.
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.
29
47
 
30
48
  ## Preparation safety and execution binding
31
49
 
@@ -37,7 +55,7 @@ Candidate paths never include a leading `.cadre/`: use `state.json`, `plan.md`,
37
55
 
38
56
  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.
39
57
 
40
- ## Durable revert receipt
58
+ ## Legacy SHA durable revert receipt
41
59
 
42
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.
43
61
 
@@ -5,11 +5,23 @@ description: Review a Cadre track that is ready for review, present evidence-bac
5
5
 
6
6
  # Cadre Review
7
7
 
8
- Review only a `ready_for_review` track. Load `.cadre/workflow.md`, all track artifacts and learning, dependency context, relevant patterns/styleguides, implementation commits, and repository tests. Read every reviewed file before judging or proposing edits.
8
+ ## Cohesive commits and retained context
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.
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.
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.
15
+
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
+
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.
19
+
20
+ Review a `ready_for_review` track. A persisted policy-v2 Autonomous review operation may also resume interrupted promotion from `in_progress`; finish that operation before implementation starts. Apply the Autonomous rules below under the originating persisted authorization and retain explicit human approval for clean completion. Load `.cadre/workflow.md`, all track artifacts and learning, dependency context, relevant patterns/styleguides, implementation commits, and repository tests. Read every reviewed file before judging or proposing edits.
9
21
 
10
22
  At every required clarification or approval boundary, show a concise finding/evidence summary and focused diff. Inspect the active host policy before calling `workflow_elicit`: if the task context reports approval policy `never`, including Codex Full Access, skip the form and ask the same short question once in chat. Otherwise prefer `workflow_elicit`, using `clarification` for at most three questions and `approval` bound to the current proposal digest or reviewed execution/HEAD. 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.
11
23
 
12
- Call `project_status` first with `view: "track"` and `trackId`; use its embedded structured validation and do not repeat `state_validate` at command entry. Stop when `valid` is false. Continue only for `kind: "canonical_track"` and `ready_for_review`; candidate-only or any other lifecycle state stops with its returned next action.
24
+ Call `project_status` first with `view: "track"` and `trackId`; use its embedded structured validation and do not repeat `state_validate` at command entry. Stop when `valid` is false, `upgradeRequired` is true, relevant memory is stale, or `nextStep.action` is `blocked`. Continue only for `kind: "canonical_track"` and `ready_for_review`, or a journaled Autonomous review operation recovering from `in_progress`. Follow a returned implementation handoff only after review bookkeeping is complete; candidate-only or other lifecycle states stop with their returned next action.
13
25
 
14
26
  ## Read context once
15
27
 
@@ -17,26 +29,90 @@ Build one bounded context inventory from `project_status`, the current track pat
17
29
 
18
30
  The declared review mutation surface is adaptive `review_complete` for clean completion. Finding-bearing review uses the explicitly journaled direct-write procedure below. Do not inspect the installed runtime, global tool catalog, or generated MCP bundle looking for another review-state tool.
19
31
 
20
- Expected human decision count is one per review cycle when the human accepts the recommended exact remediation, approves a clean review, or explicitly rejects findings and approves clean completion. Ask again only when the human changes the proposal or new evidence changes its content or consequences.
32
+ Expected human decision count is one per review cycle outside policy-v2 Autonomous when the human accepts the recommended exact remediation, approves a clean review, or explicitly rejects findings and approves clean completion. Ask again only when the human changes the proposal or new evidence changes its content or consequences.
21
33
 
22
34
  ## Procedure
23
35
 
24
- 1. Read the completed execution journal and review its exact `baseCommit..headCommit` range, which includes the first implementation commit. Inspect diffs and affected callers, tests, security boundaries, error paths, compatibility, acceptance criteria, and non-functional requirements.
36
+ 1. Read the completed execution journal and review its exact `baseCommit..headCommit` range (Autonomous uses persisted `initialBaseCommit..headCommit` across all remediation executions), which includes the first implementation commit. Inspect diffs and affected callers, tests, security boundaries, error paths, compatibility, acceptance criteria, and non-functional requirements.
25
37
  2. Run relevant verification without mutating production behavior. Report findings by severity with file/line evidence, impact, reproduction, and proposed acceptance criteria. Do not write a bug file yet.
26
- 3. Prepare one decision-ready proposal before asking for approval:
38
+ 3. Prepare one decision-ready proposal before asking for approval (Autonomous binds in-scope findings to persisted authorization as described below):
27
39
  - If findings exist, call `template_get_many` for `track/bug`, then `candidate_stage_prepare` for `review-<track-id>` with `expectedFiles` equal to the exact bug artifact paths plus `plan.md`. Draft only those files beneath the stage so removed findings cannot remain. Do not pass plan Markdown through MCP or create a temporary project copy.
28
40
  - Append remediation phases and a new final `Track-level User Manual Verification` phase. Preserve every completed former final verification phase with its exact title, task IDs, checkboxes, and commit markers; its dependencies remain the preceding phases it verified. Do not rename it, insert a fictitious delivery task, or reopen it to satisfy validation.
29
41
  - Call `candidate_inspect` once for the complete staged bug/plan set with `planValidations: [{ path: "plan.md", targetStatus: "in_progress" }]`. Present findings, exact diff, graph summary, manifest, consequences, and choices together, bound to its digest. One response may approve both the finding disposition and the unchanged exact artifacts, or reject all findings while explicitly accepting their risks and approve clean completion.
30
- - Inspection validates that target status without changing canonical state. Keep the canonical track `ready_for_review` and its completed execution unchanged until approval. If a staged state is included, its status must agree with `targetStatus`; an active execution still requires reconciliation at a safe boundary.
42
+ - Inspection validates that target status without changing canonical state. Keep the canonical track `ready_for_review` and its completed execution unchanged until human approval or the exact Autonomous remediation authorization is journaled. If a staged state is included, its status must agree with `targetStatus`; an active execution still requires reconciliation at a safe boundary.
31
43
  - If the human changes the finding subset or remediation, rebuild and validate the exact proposal and request approval once for that changed proposal. Do not reuse approval for superseded content.
32
- - If no findings exist, present clean-review evidence and the exact completion transition once, then ask approval to complete the track.
33
- 4. For approved changes, record a resumable `review` operation containing the approved manifest digest and path/hash entries before changing the bug artifact, plan, or state. Promote only those staged files, verify their canonical hashes, increment the plan revision, set state to `in_progress`, reset review readiness, and record the review cycle. Call `tracks_render` once, validate, and commit `cadre(review): request changes for <track-id>` without staging `.cadre/stage/`. Record that commit SHA as the new approved plan commit, clear the operation, and use `cadre(review): record changes for <track-id>` for follow-up bookkeeping when needed. Remove only the matching candidate stage after its canonical hashes and commits are recorded. The prior completed execution remains historical until `implement` starts a new execution ID for the changed graph.
34
- 5. For an approved clean review, call `review_complete` with `request: { mode: "prepare", projectRoot, trackId, approval, acceptedRisks? }`. The server derives the range from the completed execution base through its reviewed HEAD. After approval, call only `request: { mode: "apply", proposalToken }`. A retry converges a matching cycle/index without duplicating history. Commit `cadre(review): complete <track-id>`.
44
+ - If no findings exist, prepare the clean completion proposal in step 5 before presenting its exact transition for approval.
45
+ 4. For v5 approved changes, include the findings, proposed final state, appended plan, reassessed learning and dependency context in `candidate_apply` prepare with `workflow: "review"`. Preserve completed execution and finding evidence. Under valid Autonomous authority bind the exact candidate to that authority; other modes require the human decision. Apply only the unchanged approved token. Commit `cadre(review): request changes for <track-id>` once with receipt trailers and reconcile before the next execution. For legacy recovery, retain the original candidate_inspect planValidations and SHA journal contract.
46
+ 5. For a clean review, call `review_complete` with `request: { mode: "prepare", projectRoot, trackId, approval, acceptedRisks? }`. The server derives the cumulative range for Autonomous and the completed execution range for other modes. Present its exact proposal and evidence, then ask once for explicit approval. After approval, call only `request: { mode: "apply", proposalToken }`. A retry converges a matching cycle/index without duplicating history. Commit `cadre(review): complete <track-id>`.
35
47
 
36
- Repeat review → implement → review until a human approves a clean review. Only this command may mark a track completed.
48
+ Repeat review → implement → review until a human approves a clean review. Autonomous continues the loop in this task without asking permission for in-scope remediation. Other approval modes retain their existing gates. Only this command may mark a track completed.
49
+
50
+ ## MCP skill continuation
51
+
52
+ Follow `nextStep` from focused `project_status` and `execution_finish` using its exact `projectRoot`, `trackId`, and current `executionId`. `invoke_skill` identifies the installed Cadre skill by `plugin` and `skill`; invoke it through the host's native skill mechanism in the same task. Codex/Claude resolve the Cadre plugin workflow; Zed resolves `cadre-<skill>`. If native invocation is unavailable, load the full skill from its host-advertised installed location and execute its procedure. Reuse an already loaded, unchanged skill; a next step naming the current skill means continue it, not recursive re-entry. Never derive sibling filesystem paths or merely print a slash command. If the installed skill cannot be resolved, stop with that blocker.
53
+
54
+ 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.
37
55
 
38
56
  ## Memory contract
39
57
 
40
- Preserve phase history and existing handoffs. For active v3 tracks, keep the marked `cadre:memory` JSON block inside Pattern Seed synchronized with the proposed spec/plan revisions and exact approved pattern hashes. Every applicable pattern requires its safe `patterns/<slug>.md` path, SHA-256, and human-readable relevance/constraints; never invent or silently omit guidance. When a staged plan changes revisions, include the reassessed learning file in `expectedFiles`. Inspect `candidate_inspect.learning` and `memoryInputs` as well as `plans`; resolve invalid or stale memory before approval. Immediately before direct promotion, re-inspect and compare the complete approved digest, including unchanged memory inputs; changed inputs require reassessment and a corrected approval. Archive apply performs this check in the runtime. Completed and archived learning remains historical evidence, not a claim that old hashes describe current patterns.
58
+ Preserve phase history and existing handoffs. For active 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.
41
59
 
42
60
  The legacy input field `approval` carries prepared review evidence, not a claim of a human decision. State stores it as `reviewEvidence`. Prepare once, obtain approval of the exact digest, and apply its token unchanged. The runtime adds `approvalConfirmation` with the bound digest, confirmation time and `explicit-apply` method, separately from the evidence. Do not re-prepare merely to replace pending-approval prose. This receipt records the approved application, not an authenticated identity or a fabricated quotation from a human.
61
+
62
+ ## Autonomous authorization
63
+
64
+ These rules override intermediate human gates only for a valid policy-v2 persisted Autonomous loop. Use the same candidate, journal, promotion, memory, and commit procedure above. Main owns scheduling and state and performs a separate review pass; no additional reviewer agent is required. Never duplicate a review cycle, execution, or commit during recovery.
65
+
66
+ Use this exact canonical `state.operation` shape for remediation; a finding disposition such as `request_changes` is not an operation action:
67
+
68
+ ```json
69
+ {
70
+ "action": "review",
71
+ "checkpoint": "approved",
72
+ "baseCommit": "<canonical HEAD before promotion>",
73
+ "expectedCommit": "cadre(review): request changes for <track-id>",
74
+ "approvedArtifacts": ["<each inspected relative path>"],
75
+ "approvedArtifactHashes": [{ "path": "<same relative path>", "sha256": "<inspected hash>" }],
76
+ "artifactProgress": [],
77
+ "approvedAt": "<ISO timestamp of this mode-authorized operation>",
78
+ "approvalDigest": "<complete inspected digest>",
79
+ "authorization": { "kind": "persisted-mode", "originExecutionId": "<original execution>", "proposalDigest": "<same digest>" }
80
+ }
81
+ ```
82
+
83
+ List every inspected file in both artifact arrays, including the loop snapshot and learning. `approvedArtifacts` contains path strings; `approvedArtifactHashes` contains path/hash objects. `expectedCommit` is the intended commit message, not a SHA. After journaling, call `state_validate` and require valid state before the first canonical promotion; repair journal metadata without changing its inspected manifest or authority if validation fails. Record the findings assigned to the next remediation execution as `attemptedFindingIds` on the changes-requested cycle, even though their completed-attempt counters are initially empty.
84
+
85
+ ## Durable authority and checkpoints
86
+
87
+ `execution_start` creates `state.autonomousReview` for a new explicit Autonomous selection. It preserves that object across remediation executions; `execution_finish` advances it to `reviewing`. Its schema is:
88
+
89
+ ```json
90
+ {
91
+ "policyVersion": 2,
92
+ "originExecutionId": "<original-execution-id>",
93
+ "authorizedAt": "<ISO timestamp of explicit invocation or migration>",
94
+ "initialBaseCommit": "<original implementation base SHA>",
95
+ "specCommit": "<approved specification SHA>",
96
+ "checkpoint": "implementing",
97
+ "findings": [
98
+ { "id": "stable-bug-id", "summary": "Root cause and violated acceptance criterion", "status": "open", "attemptExecutionIds": [] }
99
+ ]
100
+ }
101
+ ```
102
+
103
+ Checkpoints are `implementing`, `reviewing`, `remediating`, `awaiting_approval`, `blocked`, and `completed`. A reviewed result also records `reviewedExecutionId` and `reviewedHead`. A blocked loop records a nonempty `blocker`. Never change the originating authorization, specification commit, or initial baseline during automatic remediation. Changes to scope require human authority through refresh/revise.
104
+
105
+ ## Review and remediation
106
+
107
+ 1. Finish the current implementation journal and commit its bookkeeping before invoking review. At `ready_for_review`, review `initialBaseCommit..lastExecution.headCommit`, all acceptance criteria, affected callers/tests, and prior findings. Verify actual product changes and re-run affected checks. Do not treat the latest remediation diff alone as a clean track review.
108
+ 2. Keep each finding's ID stable across renames, moves, rewritten fixes, and review wording. Reopen a recurring finding using the same ID. After reviewing a completed execution that attempted that finding, append that execution ID to `attemptExecutionIds` only if absent; never count the original discovery execution or count an interrupted attempt twice. Mark resolved only from actual verification and review evidence. Preserve resolved finding history.
109
+ 3. If an open finding has two recorded remediation execution IDs, stop with checkpoint `blocked` and a precise blocker. Do the same for material scope decisions, unavailable human-only verification, or external blockers. Present the evidence and ask how to continue; never reset IDs/attempt counts to bypass the stop. Persist this evidence in canonical state using a focused bookkeeping commit. On explicit instructions to retry a stalled finding, use a digest-bound refresh to record those instructions and start a new authorized loop while retaining the former loop in track history.
110
+ 4. For progressable in-scope findings, stage bug artifacts, appended remediation phases and final verification, learning, and `reviews/loop-<cycle>.json` at the review candidate root. The loop snapshot contains the complete updated `autonomousReview` object: retained authority/findings, reviewed execution/HEAD, and checkpoint `remediating`. Include that exact snapshot path in `expectedFiles`; validate the proposed plan as `in_progress`. Keep canonical state `ready_for_review` until promotion; do not stage `state.json` with a self-referential operation digest. Record attempted finding IDs on the changes-requested review cycle so the next review can identify which findings this execution attempted. Do not reopen or rename completed verification phases.
111
+ 5. Re-inspect the exact complete staged set immediately before promotion; require valid plan and fresh learning/memory inputs. Bind the current digest to `operation.authorization: { kind: "persisted-mode", originExecutionId, proposalDigest }`, with `proposalDigest` equal to `operation.approvalDigest`. Existing `approvedAt`/`approvedArtifacts` fields record the mode-authorized operation, not a new human decision. Journal the operation before any canonical promotion. Record verification and scope evidence in the review cycle; do not record `approvalConfirmation` for automatic remediation.
112
+ 6. Promote only the inspected files, copy the approved loop snapshot into `state.autonomousReview` as the deterministic state transition while retaining its active review operation, and follow the revision/index/commit/provenance procedure above. Retain the operation in canonical state until the commit is recorded; re-inspect changed candidates and reconcile interrupted promotion before resuming. After the review bookkeeping commit and operation clearance, call focused `project_status` and follow its `nextStep` into implement with a new execution ID and inherited Autonomous mode. No additional user prompt is needed for these bounded changes.
113
+
114
+ ## Clean result and approval
115
+
116
+ When no unresolved findings remain, persist checkpoint `awaiting_approval`, findings, and `reviewedExecutionId`/`reviewedHead`, and retain that evidence durably on disk without a clean-evidence-only commit. The track remains `ready_for_review`. Call `review_complete` prepare with review evidence, present verification results, remediation history, and its exact completion proposal, and ask once for explicit human approval. Apply only that unchanged token after approval; only the review runtime marks the loop and track completed. Autonomous does not use `acceptedRisks` to waive findings.
117
+
118
+ Resume `awaiting_approval` by checking the recorded execution/HEAD and product content, preparing a fresh token if needed, and requesting the still-missing final approval. A prior unresolved question is not approval. Changed product or verification inputs require renewed verification/review and a new clean checkpoint; ordinary Cadre bookkeeping alone does not. A request for changes returns to review under the existing scope; cancellation stops with state intact.