cadre-ai 3.3.0 → 3.5.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 (63) hide show
  1. package/.claude-plugin/plugin.json +2 -2
  2. package/.codex-plugin/plugin.json +2 -2
  3. package/CHANGELOG.md +83 -2
  4. package/README.md +52 -31
  5. package/dist/cadre-cli.mjs +395 -92
  6. package/dist/cadre-mcp.mjs +1191 -717
  7. package/package.json +3 -2
  8. package/skills/archive/SKILL.md +6 -6
  9. package/skills/create/SKILL.md +5 -4
  10. package/skills/implement/SKILL.md +34 -83
  11. package/skills/implement/references/conflict-handling.md +5 -0
  12. package/skills/implement/references/governed-mode.md +7 -0
  13. package/skills/implement/references/parallel-workers.md +9 -0
  14. package/skills/implement/references/resume-recovery.md +10 -0
  15. package/skills/refresh/SKILL.md +4 -4
  16. package/skills/revert/SKILL.md +6 -6
  17. package/skills/review/SKILL.md +7 -7
  18. package/skills/revise/SKILL.md +6 -6
  19. package/skills/status/SKILL.md +1 -1
  20. package/skills/track/SKILL.md +5 -5
  21. package/templates/v2/init/archive/.gitkeep +1 -0
  22. package/templates/v2/init/gitignore.template +8 -0
  23. package/templates/v2/init/guidelines.md +25 -0
  24. package/templates/v2/init/operations/.gitkeep +1 -0
  25. package/templates/v2/init/patterns/index.md +6 -0
  26. package/templates/v2/init/product.md +30 -0
  27. package/templates/v2/init/project.json +27 -0
  28. package/templates/v2/init/refreshes/.gitkeep +1 -0
  29. package/templates/v2/init/styleguides/general.md +14 -0
  30. package/templates/v2/init/styleguides/language.md +21 -0
  31. package/templates/v2/init/tech-stack.md +21 -0
  32. package/templates/v2/init/tracks/.gitkeep +1 -0
  33. package/templates/v2/init/tracks.md +6 -0
  34. package/templates/v2/init/wisps/.gitkeep +1 -0
  35. package/templates/v2/init/workflow.md +72 -0
  36. package/templates/v2/project/archive-operation.json +19 -0
  37. package/templates/v2/project/pattern.md +20 -0
  38. package/templates/v2/project/refresh-operation.json +18 -0
  39. package/templates/v2/project/refresh.md +21 -0
  40. package/templates/v2/styleguides/dart.md +27 -0
  41. package/templates/v2/styleguides/flutter.md +27 -0
  42. package/templates/v2/styleguides/go.md +29 -0
  43. package/templates/v2/styleguides/gradle.md +28 -0
  44. package/templates/v2/styleguides/html-css.md +39 -0
  45. package/templates/v2/styleguides/index.md +27 -0
  46. package/templates/v2/styleguides/java.md +27 -0
  47. package/templates/v2/styleguides/javascript.md +27 -0
  48. package/templates/v2/styleguides/kotlin.md +26 -0
  49. package/templates/v2/styleguides/maven.md +28 -0
  50. package/templates/v2/styleguides/python.md +27 -0
  51. package/templates/v2/styleguides/react.md +28 -0
  52. package/templates/v2/styleguides/swift.md +27 -0
  53. package/templates/v2/styleguides/swiftui.md +27 -0
  54. package/templates/v2/styleguides/typescript.md +26 -0
  55. package/templates/v2/track/bug.md +14 -0
  56. package/templates/v2/track/execution.json +19 -0
  57. package/templates/v2/track/learning.md +39 -0
  58. package/templates/v2/track/plan.md +39 -0
  59. package/templates/v2/track/revert-operation.json +17 -0
  60. package/templates/v2/track/revise-operation.json +18 -0
  61. package/templates/v2/track/revision.md +36 -0
  62. package/templates/v2/track/spec.md +38 -0
  63. package/templates/v2/track/state.json +31 -0
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "cadre-ai",
3
- "version": "3.3.0",
3
+ "version": "3.5.0",
4
4
  "description": "Cross-agent, human-governed software delivery harness",
5
5
  "author": {
6
6
  "name": "Vishal Kumar",
@@ -19,7 +19,8 @@
19
19
  "agent-workflows",
20
20
  "mcp",
21
21
  "codex",
22
- "claude"
22
+ "claude",
23
+ "zed"
23
24
  ],
24
25
  "type": "module",
25
26
  "packageManager": "pnpm@11.4.0",
@@ -7,11 +7,11 @@ description: Archive one or more completed Cadre tracks in one approved, resumab
7
7
 
8
8
  Archive one or more `completed` tracks in a single batch. Read `.cadre/workflow.md`, every artifact and recorded commit for every selected track, the full pattern catalog, all active track specs/plans and marked learning seeds, and relevant implementation files. Read existing pattern and learning files before proposing changes.
9
9
 
10
- 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 preview 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.
10
+ 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
11
 
12
- Call `project_status` first and use its embedded structured validation; do not repeat `state_validate` at command entry. If the Cadre MCP is unavailable, stop without starting or advancing an archive batch.
12
+ Call `project_status` first with `view: "project"` and use its embedded structured validation; do not repeat `state_validate` at command entry. If the Cadre MCP is unavailable, stop without starting or advancing an archive batch.
13
13
 
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; do not call `template_catalog`. The declared mutation surface is `archive_batch_preview`/`archive_batch_apply` followed by `archive_batch_record_preview`/`archive_batch_record_apply`; do not inspect the installed runtime or tool catalog for alternatives.
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; use resources only when an individual ID must be discovered. 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.
15
15
 
16
16
  Expected human decision count is one for the complete batch. Ask again only when its selection, content, or consequences change.
17
17
 
@@ -20,9 +20,9 @@ Expected human decision count is one for the complete batch. Ask again only when
20
20
  3. If an in-progress `.cadre/operations/archive-<timestamp>.json` exists, reconcile it before accepting a new batch. Resume from its first incomplete checkpoint. If its journal, files, Git state, or expected commit disagree, stop and present the mismatch.
21
21
  4. Distill durable, evidenced learning across the selected tracks as one corpus; discard track-specific trivia. Merge, replace, split, or retire existing patterns when justified, preserving provenance to every contributing track/phase/task commit. Reconcile overlapping or conflicting learning once so batch order cannot silently change the result.
22
22
  5. 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
- 6. Call `archive_batch_preview` with structured updates: `pattern` plus slug, `pattern_index`, or `active_track_seed` plus track ID. Fetch exact template IDs (`project/pattern`, `project/patterns/index`, and `track/learning`) when needed. Present its complete moves, lifecycle states, content diffs, generated index, and expected commits as one proposal and obtain one explicit approval.
24
- 7. After approval, pass only the returned proposal token to `archive_batch_apply`. Commit all approved moves and derived changes together using the proposal's expected commit.
25
- 8. Call `archive_batch_record_preview` with the project root and batch ID; it derives the actual current HEAD. Verify its deterministic provenance update, then pass only its proposal token to apply. This bookkeeping needs no second approval. Create `cadre(archive): record batch <batch-id>`.
23
+ 6. Call `candidate_stage_prepare` for `archive-<proposal-id>`, then write every proposed pattern, pattern-index, and active-track seed beneath the returned stage at its eventual `.cadre/` relative path. Fetch known templates with `template_get_many`. Call `archive_batch_candidate` with `mode: "prepare"`, that candidate ID, and body-free update descriptors. Present its complete manifest, diffs, moves, lifecycle states, generated index, and expected commits as one proposal bound to its digest.
24
+ 7. After approval, call only `{ 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 without another approval. Create `cadre(archive): record batch <batch-id>`, then remove only the matching candidate stage.
26
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.
27
27
 
28
28
  If interrupted before the archive commit, reconcile the batch journal and resume its first incomplete track or artifact through the same approved input. If the worktree is clean and HEAD matches the journal's expected commit and base relationship, treat the archive commit as successful and record that SHA. If the SHA is recorded but follow-up state is uncommitted, finish only the state commit. Never repeat completed moves, redistill from a partial selection, or start a second archive batch while one is active.
@@ -13,19 +13,20 @@ At every required clarification or approval boundary, show a concise summary or
13
13
 
14
14
  1. Resolve the exact project root. Inspect its manifests, source layout, tests, agent guidance, Git status, and recent history. Run `git rev-parse --show-toplevel`: if it succeeds, never initialize a nested repository; if it fails, record that the approved root requires `git init`. Ask which root to use if the boundary is materially ambiguous. Read every existing file before proposing an edit.
15
15
  2. Explicitly classify the context as `greenfield` or `brownfield`, with evidence. A substantive implementation, behavior, user/data/interface contract, or delivery history is brownfield. If a scaffold, prototype, migration, or incomplete evidence makes the classification unclear, ask a blocking question before drafting or mutating anything.
16
- 3. Call `project_status` when `.cadre/project.json` exists and use its embedded structured validation; do not repeat `state_validate` at command entry. Reconcile its setup journal, worktree, and recent commits. Resume the recorded checkpoint exactly; do not restart or overwrite setup. Offer `$refresh` or `$status` only after completed setup.
17
- 4. Call `template_get_many` once for `project/product`, `project/guidelines`, `project/tech-stack`, `project/workflow`, and `project/styleguides/general`. Retain that versioned bundle across approval turns and do not refetch it unless its version or content hash changes. `patterns/index.md`, `.gitignore`, `project.json`, `tracks.md`, and the empty lifecycle directories are initialization outputs derived by the MCP; do not render or pass them as caller-supplied files. For greenfield work, use explicit user intent and ask about missing material product/stack choices. For brownfield work, distinguish evidenced current reality from desired change and preserve deliberate conventions.
16
+ 3. Call `project_status` with `view: "project"` when `.cadre/project.json` exists and use its embedded structured validation; do not repeat `state_validate` at command entry. Reconcile its setup journal, worktree, and recent commits. Resume the recorded checkpoint exactly; do not restart or overwrite setup. Offer `$refresh` or `$status` only after completed setup.
17
+ 4. Call `template_get_many` once for `project/product`, `project/guidelines`, and `project/tech-stack`. Retain that versioned bundle across approval turns and do not refetch it unless its version or content hash changes. Use each response's `artifactPath` as its eventual `.cadre/`-relative destination. `workflow.md`, selected default styleguides, `patterns/index.md`, `.gitignore`, `project.json`, `tracks.md`, and the empty lifecycle directories are initialization outputs generated by the MCP; stage only an explicitly edited workflow or styleguide override. For greenfield work, use explicit user intent and ask about missing material product/stack choices. For brownfield work, distinguish evidenced current reality from desired change and preserve deliberate conventions.
18
18
  5. Draft `product.md`, `guidelines.md`, and `tech-stack.md`. Resolve any material ambiguity through targeted questions; do not invent product behavior, constraints, or stack decisions.
19
19
  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
20
  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
- 8. Call `project_init_preview` with only the proposed caller-supplied files and metadata. Do not pass `patterns/index.md` or any other MCP-derived output. Expected human decision count is one when root, classification, and material configuration choices are clear. Present one complete initialization envelope containing concise product/engineering/stack summaries, workflow identity and summary, styleguide set and amendments, the complete target-path and SHA-256 manifest, generated-state summary, context classification, project root, Git disposition, and consequences. After explicit confirmation, pass only its opaque proposal token to `project_init_apply`. This one approval authorizes unchanged Git initialization, validation, setup commits, derived `tracks.md`, and provenance bookkeeping; do not add later approval prompts for those deterministic consequences. The apply atomically creates mutable `.cadre` state and approved context only; it never installs a runtime or template copies there.
21
+ 8. Call `candidate_stage_prepare` for candidate `create`; it creates or resumes `<project-root>/.cadre/stage/create/` and enforces `/stage/` in `<project-root>/.cadre/.gitignore`. The bootstrap `.cadre` may contain only `.gitignore` and `stage` before apply. Write required `product.md`, `guidelines.md`, and `tech-stack.md` there—for example, product goes to `<project-root>/.cadre/stage/create/product.md`—plus only requested `workflow.md` or `styleguides/*.md` overrides. Never write `<project-root>/.cadre/init/*` or canonical project artifacts before apply. Do not pass artifact bodies through MCP; pass only exact staged relative paths. Call `project_init_candidate` with `mode: "prepare"`, those paths, selected logical `styleguideIds`, and metadata. It generates unchanged workflow/styleguide defaults, binds every generated or overridden artifact into the digest, and returns `approval_required` plus a proposal token. Expected human decision count is one when configuration choices are clear. Present one complete authorization envelope bound to that digest. After explicit confirmation, call the same tool with only `{ mode: "apply", proposalToken }`. Never make those two calls consecutively without the human decision between them. This one approval authorizes unchanged Git initialization, validation, setup commits, derived `tracks.md`, and provenance bookkeeping; do not add later approval prompts for those deterministic consequences.
22
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
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_preview` and pass only its proposal token to apply. Commit the bookkeeping as `cadre(create): record setup commit` without another prompt and report the concise final result.
24
+ 11. Call `setup_record_commit`; it records the actual current HEAD. If the index needs regeneration, call `tracks_render` once; it validates and writes the deterministic index atomically. Commit the bookkeeping as `cadre(create): record setup commit` without another prompt and report the concise final result.
25
25
 
26
26
  ## Resume protocol
27
27
 
28
28
  - `git-pending`: initialize Git only when the journal says `initialize`; verify the exact approved root and record the checkpoint.
29
+ - `.cadre/stage/create` with only the bootstrap `.gitignore`: re-read the candidate manifest and resume approval or apply; never reconstruct its content from conversation memory.
29
30
  - `commit-pending` plus matching dirty artifacts: validate and create the expected artifact commit.
30
31
  - Clean worktree plus matching expected HEAD/base relationship: treat the artifact commit as successful and record that SHA; never repeat it.
31
32
  - Recorded setup SHA plus dirty bookkeeping: finish only the follow-up state commit.
@@ -1,106 +1,57 @@
1
1
  ---
2
2
  name: implement
3
- description: Execute or resume an approved Cadre plan as a dependency DAG, using parallel workers by default when safe, sequential execution when requested, isolated Git worktrees, main-agent integration, incremental learning, verification, and commit provenance. Use for the implement command on a planned or in-progress track.
3
+ description: Execute or resume an approved Cadre plan as a dependency DAG, using bounded parallel workers when useful, isolated Git worktrees, verified integration, learning, and commit provenance. Use for implement on a planned or in-progress track.
4
4
  ---
5
5
 
6
6
  # Cadre Implement
7
7
 
8
- Treat the approved `plan.md` as the source of truth. Implement only `planned` or `in_progress` tracks. The main agent is the sole scheduler and Cadre-state owner: workers must never spawn workers, edit `.cadre/**`, merge branches, resolve integration conflicts, remove worktrees, or record human approval.
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.
9
9
 
10
- At every required clarification or manual-verification boundary, show concise evidence. 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 execution ID, node ID, and verified commit. 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.
10
+ 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
11
 
12
- Call `project_status`, `execution_graph_validate`, and `worktree_status` before selecting work. Use the structured validation embedded in `project_status`; do not repeat `state_validate` at command entry. If the required Cadre MCP is unavailable, stop at the current checkpoint.
12
+ ## Conditional references
13
13
 
14
- ## Select and persist execution modes
14
+ Read only the references required by current state:
15
15
 
16
- - Default to `parallel` when the human does not specify a mode.
17
- - Use `sequential` only when explicitly requested.
18
- - Parallel mode creates workers only when at least two safe executable nodes are ready. Otherwise execute in main without worktree overhead.
19
- - Bound worker count by ready nodes, host capacity, and the workflow maximum.
20
- - Persist requested/effective mode in the execution journal. Changing it during execution requires a clean safe boundary, a presented proposal, and approval.
16
+ - parallel or delegated work: `references/parallel-workers.md`
17
+ - `governed` approval mode: `references/governed-mode.md`
18
+ - an integration conflict: `references/conflict-handling.md`
19
+ - interrupted or inconsistent execution: `references/resume-recovery.md`
21
20
 
22
- Select and persist one approval mode independently of scheduling:
21
+ ## Entry and modes
23
22
 
24
- - `governed`: present every regular task diff before commit, every conflict resolution, every manual-verification barrier, and every integration or other material mutation required by the approved workflow.
25
- - `phase` (default): run all regular work inside a phase autonomously, but pause once for each phase's final `User Manual Verification` task.
26
- - `autonomous`: run regular work and phase-level verification autonomously. Pause only for the `Track-level User Manual Verification` task.
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`, `execution_graph_validate`, `execution_status`, or a separate worktree call at entry. Stop if `upgradeRequired` is true or the MCP is unavailable.
24
+ 2. Read `.cadre/workflow.md`, track spec/plan/learning/state, relevant dependency learning, pattern/styleguide context, and repository instructions. Read before editing.
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.
26
+ 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
27
 
28
- Use `phase` unless the human explicitly requests `governed` or `autonomous`. On resume, inherit the journaled mode. Record it in both the execution journal and active track operation. A mode authorizes only work already bounded by the approved spec and plan; any material ambiguity, scope divergence, failed required check, unsafe state, or need for new authority is a blocker or clarification, not an approval prompt. Changing approval mode during execution requires an approved clean boundary and a journaled update.
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`.
29
29
 
30
- For a new execution, the human's `implement` invocation authorizes an exact execution start using the requested modes or their documented defaults. Call `execution_start_preview`, then pass only its opaque `proposalToken` to `execution_start_apply`. Do not add an execution-start approval prompt outside `governed`; report a concise start summary and proceed. The server derives the execution ID, timestamp, and current Git base. Generated bookkeeping is a deterministic consequence of the same authorization. For an existing `implement` operation, reconcile it instead of creating another execution.
30
+ 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
31
 
32
- ## Resume before scheduling
32
+ ## Execute ready work
33
33
 
34
- 1. Read `.cadre/workflow.md`, project and track state, spec, plan, execution journal, marked Pattern Seed, dependency-phase learning, patterns/styleguides, and declared track dependencies.
35
- 2. Reconcile journal nodes with worker identities, `git worktree list`, branch tips, dirty files, commits, and merges. Never repeat a committed or integrated node.
36
- 3. Block when a declared track dependency is not completed or archived after completion.
37
- 4. Stop and present any journal/Git mismatch. Never reset, discard, reconstruct, force-delete, or silently restart.
34
+ Use the scheduler returned by the preflight or latest mutation receipt. Plan order only breaks ties.
38
35
 
39
- ## Preflight host permissions
36
+ - Execute one ready task directly in main when delegation adds no value. Use standalone `execution_checkpoint` for its `start`, `record_commit`, blockers/resume, manual verification, and `complete` transitions.
37
+ - Delegate only independent or cohesive work. Read `references/parallel-workers.md` before doing so.
38
+ - 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.
39
+ - A `.cadre/**`-only bookkeeping commit does not invalidate product verification while product files, tests, inputs, and verification policy remain unchanged.
40
40
 
41
- Before creating workers, inspect the approved plan, repository scripts, lockfiles, and likely verification commands. Distinguish host security permission from Cadre lifecycle approval: a shell/network/listener prompt authorizes the host operation only; it does not approve an artifact, commit, merge, manual-verification result, or state transition.
41
+ For a delegated node, the normal lifecycle is four MCP calls:
42
42
 
43
- - Use already-approved commands and prefixes without asking again. Never request permission speculatively or retry equivalent command spellings to obtain a different prompt.
44
- - Centralize shared dependency installation, registry access, image pulls, code generation, and other network preparation in main before workers start. Workers should use locked/offline modes when the repository supports them.
45
- - Prefer existing repository scripts and narrowly scoped commands. Do not combine unrelated or differently privileged shell segments into one command, because the host evaluates each segment independently.
46
- - Run independent read-only repository inspections and checks in parallel when the host supports parallel tool calls. Keep only commands with a real data, mutation, or Git dependency sequential.
47
- - Avoid scaffolding modes that create nested repositories or require deleting generated `.git` directories. Inspect generator options and target directories first.
48
- - When a required permission is not already available, request one narrow reusable command prefix with the exact reason. If a worker encounters an unexpected prompt, it stops and reports the exact blocked command to main instead of issuing repeated variants.
43
+ 1. `worktree_create` creates or reconciles the derived worktree and records `start` with its path and branch.
44
+ 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.
45
+ 3. `integration` with `mode: "prepare"` validates and merges immediately in `phase`/`autonomous`, recording `record_integration` in its receipt. In `governed` it returns `approval_required`; after human approval call only `{ mode: "apply", proposalToken }`. Never make the governed calls consecutively without human input.
46
+ 4. `worktree_cleanup` verifies integration, removes the worktree/branch, and records `complete` when all invariants hold.
49
47
 
50
- ## Schedule the DAG
48
+ 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.
51
49
 
52
- The Cadre tools named in this skill are declared contracts: call them directly. Do not list the global tool catalog, rediscover schemas, or probe previews to learn legal transitions. Call compact `execution_status` when resuming or when no mutation response is available; pass `nodeId` only when focused detail is required. Use `execution_checkpoint_preview` with a semantic event (`start`, `record_commit`, `record_integration`, `record_verification`, `complete`, `block`, or `resume`); it expands the event into all required legal transitions and returns a compact receipt. Pass only its `proposalToken` to `execution_checkpoint_apply`, then reuse the returned compact `derivedStatus`; do not request the complete journal after each event.
50
+ ## Verification, learning, and finish
53
51
 
54
- Never checkpoint evidence before it exists. `record_commit` consumes the verified commit and its authorization; `record_integration` consumes the merge commit and post-merge verification; `record_verification` records a manual barrier. Plan display order breaks scheduling ties only.
52
+ - 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.
53
+ - After the barrier, integrate the phase, record dependency-aware learning 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.
54
+ - The final `Track-level User Manual Verification` runs in main against fully integrated canonical HEAD and always requires explicit human approval.
55
+ - 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` once. It atomically writes completed execution, plan markers, `ready_for_review` track state, and `tracks.md`; do not repair them separately or ask for another approval.
55
56
 
56
- - A root phase reads the Pattern Seed. Any other phase reads learning from all declared dependency phases.
57
- - Treat the track as a hierarchical DAG: phase dependencies determine active phases, task dependencies determine ready work inside each running phase, and main schedules one global ready queue subject to `maxWorkers`. Different phases may use different execution modes concurrently.
58
- - Every non-trivial active phase uses a main-owned integration worktree. A phase `workerId` is a temporary execution lease, not ownership of that worktree. Use direct main execution for one ready task, a phase worker for a tightly coupled sequential chain when delegation is already justified, and task-worker fan-out when at least two independent tasks in that phase are ready.
59
- - A phase has only one mutating execution mode at a time, but may switch modes at a clean checkpoint. Before phase-worker-to-task-worker fan-out, finish and record the current task, verify the phase worktree is clean, record its HEAD in the phase verification, release the phase worker through a `running`-to-`running` node update with `workerId: null`, and keep that worker inactive. Main may assign a new phase worker only after every active task worker in that phase is completed and its integration/cleanup is recorded.
60
- - Create every task-worker wave from the same recorded clean phase HEAD. Merge ready tasks into the phase worktree one at a time; derive the next wave only after those merges, so downstream tasks start from the updated phase HEAD.
61
- - The main agent creates every worker. On Codex, use an available implementation worker subagent with the bounded prompt below. On Claude Code, prefer the plugin-provided `cadre-phase-worker` and `cadre-task-worker`. Do not use Claude agent teams.
62
- - If only one safe execution node is ready, execute it in main.
63
- - Phase and task worktrees are siblings. Use `worktree_create_preview`, then apply only its proposal token. The MCP derives both the task phase and correct parent HEAD, so omit `phaseId` and `baseCommit`. Record the returned absolute path/branch with a `start` checkpoint before spawning. In `phase` and `autonomous`, these deterministic mutations run without another approval.
64
-
65
- ### Worker prompt contract
66
-
67
- Provide the exact absolute worktree, track/execution/node IDs, approved outcome, dependencies and learning to read, relevant files, required checks, and expected Conventional Commit scope. State explicitly:
68
-
69
- - operate only in the assigned worktree and read files before editing;
70
- - edit product files only and never edit `.cadre/**`;
71
- - do not spawn agents, merge, rebase, reset, clean up, or force Git operations;
72
- - a phase worker must stop at a requested clean handoff, report the committed phase HEAD and clean status, and remain inactive while task workers for that phase run;
73
- - run focused verification and return changed files, tests/checks, risks, learning candidates, and the proposed commit message for the current task;
74
- - in `governed`, stop after each regular task with that task's changes uncommitted at `awaiting_approval` until main presents them and the human approves;
75
- - in `phase` or `autonomous`, return each regular task's uncommitted diff and evidence to main for scope review; after main confirms it stays within the approved task and required checks pass, commit only that task without a human prompt;
76
- - after commit, return the SHA and do not begin the next phase task until main confirms the checkpoint is recorded.
77
-
78
- ## Approve, commit, and integrate
79
-
80
- 1. Transition a worker node from `running` to `awaiting_approval` with its verification summary in `governed`; in `phase` or `autonomous`, record the same evidence at the autonomous commit checkpoint without presenting a human approval prompt.
81
- 2. Main always reads the worker diff and evidence. In `governed`, present them to the human. In `phase` or `autonomous`, confirm that the diff stays inside the approved task and that required checks pass; stop for clarification only when intent or authority is materially ambiguous.
82
- 3. Direct the worker to create its Conventional Commit, verify the worktree is clean, and record its SHA as `committed`. In `phase` or `autonomous`, record approval evidence as authorization by the persisted approval mode rather than claiming a new human approval.
83
- 4. For a task worker, call `integration_preview` for the exact task merge. The MCP derives its parent as the registered phase worktree when one exists, otherwise the canonical worktree. Use the canonical fallback only for an explicitly direct, single-task phase; create a phase integration worktree before delegated work in multi-task or phase-verified delivery. In `governed`, show the merge when required by the workflow. In `phase` or `autonomous`, apply a clean in-scope merge without another approval. A task executed directly by main or internally by a phase worker is already on its parent branch: verify its commit is reachable and do not invent an integration step. For a phase worktree, use the same digest gate for phase-to-canonical integration. Never squash.
84
- 5. If integration reports conflicts, mark `conflicted`. Resolve task conflicts in the phase worktree and phase conflicts in main, read every conflicted file and both sides, and rerun combined verification. In `governed`, present the resolution for approval. In `phase` or `autonomous`, apply and record an unambiguous in-scope resolution autonomously; stop for clarification when the resolution requires a material product or scope choice.
85
- 6. For a worker worktree, mark the node `integrated`, then preview/apply worktree cleanup. Cleanup must refuse dirty, conflicted, or unintegrated work and must not force branch deletion. Cleanups in `phase` and `autonomous` never create a separate approval prompt.
86
- 7. Mark a task complete after its worker integration, or after its approved direct/phase-worker commit is verified on the parent branch. The execution journal is the live provenance source; finalization writes the plan markers atomically.
87
-
88
- Every regular task in a phase has its own Conventional Commit and distinct recorded SHA, including tasks executed sequentially by one phase worker. Manual-verification nodes may record the approved phase-head or merge evidence instead of inventing an empty commit. A phase must remain `running` until every sibling task and its manual-verification barrier are `completed`; only then may it advance to approval, commit, integration, and cleanup.
89
-
90
- Git commits are durability and provenance boundaries, not journal-transition boundaries. Keep each product task's required Conventional Commit, but combine Cadre-only plan, learning, journal, and index bookkeeping once per phase checkpoint and once at the final ready-for-review checkpoint. Do not create a Git commit for each intermediate execution status or for worktree create/integrate/cleanup metadata alone.
91
-
92
- ## Verification barriers and learning
93
-
94
- - Phase `User Manual Verification` is a derived barrier over all sibling tasks. After task workers are quiescent, prepare technical evidence in the phase worktree through an active phase worker when present, otherwise through main. In `governed` and `phase`, present this final phase task once and record the human approval. In `autonomous`, verify and record it under the persisted mode without a human prompt.
95
- - Record verification evidence with its command, working directory, result, and verified product HEAD/tree. Reuse a passing result while product files, test inputs, and required verification policy are unchanged. A commit that changes only `.cadre/**` bookkeeping does not invalidate product verification and must not trigger the same full suite again.
96
- - After the barrier is approved or authorized, automatically checkpoint the journal, integrate the phase branch, record every task commit, the phase completion merge SHA, and dependency-aware phase learning in canonical `plan.md`/`learning.md`, and commit `cadre(implement): record <track-id> <phase-id>`. Keep the phase node `integrated`, clean its worktree, and only then mark the phase `completed` and start dependents. Cleanup also accepts an already-`completed` node as interruption recovery, without reopening that terminal state. Do not split those deterministic consequences into additional approvals in `phase` or `autonomous`.
97
- - Track-level `User Manual Verification` is a derived barrier over every phase. Execute it only in main, against the fully integrated canonical worktree, and obtain explicit human approval in all modes.
98
-
99
- ## Complete execution
100
-
101
- When all journal nodes and plan tasks are complete, all phase learning/provenance is recorded, all worktrees are removed, and track verification is approved:
102
-
103
- 1. Run the relevant full checks and inspect the final diff/history.
104
- 2. Record that approval with `record_verification`, then call `execution_finish_preview`. It derives HEAD/time and atomically proposes plan commit markers, the completed journal, `ready_for_review` state, and `tracks.md`; pass only its proposal token to apply. Do not repair markers or the index separately, and do not ask for another approval.
105
-
106
- Never mark a track `completed`; only an approved clean `review` may do that.
57
+ Never mark a track `completed`; only an approved clean review may do that.
@@ -0,0 +1,5 @@
1
+ # Conflict handling
2
+
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
+
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.
@@ -0,0 +1,7 @@
1
+ # Governed mode
2
+
3
+ Governed mode requires human review of each regular task diff before its commit, every conflict resolution, each manual-verification barrier, and each integration or other material mutation required by the approved workflow.
4
+
5
+ Record a ready diff as `awaiting_approval` with verification evidence, present it once, and proceed only after explicit approval. Bind integration approval to the `integration` prepare digest. After approval call the same tool with only `{ mode: "apply", proposalToken }`; changed content or Git/state drift requires a fresh prepare and decision.
6
+
7
+ Do not convert deterministic bookkeeping or cleanup following the approved unchanged operation into another decision.
@@ -0,0 +1,9 @@
1
+ # Parallel and delegated workers
2
+
3
+ Use bounded parallelism only when at least two safe nodes are ready; otherwise work in main. Bound workers by ready nodes, host capacity, and workflow limits. The phase DAG controls active phases and same-phase task dependencies control task readiness.
4
+
5
+ Use a main-owned phase integration worktree for non-trivial phases. Create task waves from the same clean recorded phase HEAD and integrate a wave before deriving downstream work. Only one mutating execution mode may own a phase at a time.
6
+
7
+ Every worker prompt includes its absolute worktree, track/execution/node IDs, approved outcome, dependencies and learning, relevant files, checks, and commit scope. Require the worker to read before editing, change product files only, avoid `.cadre/**`, avoid agent spawning and Git integration/history operations, run focused verification, and return changed files, checks, risks, learning, and proposed commit message. The worker returns an uncommitted diff for main scope review, then commits only after main authorizes it under the persisted approval mode. It returns the SHA and waits.
8
+
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.
@@ -0,0 +1,10 @@
1
+ # Resume and recovery
2
+
3
+ Reconcile the implementation status receipt with worker identities, branches, `git worktree list`, worktree cleanliness, branch tips, commits, merges, and canonical HEAD. Never repeat a committed or integrated node.
4
+
5
+ - Existing matching worktree but missing `start`: retry `worktree_create` to record only the transition.
6
+ - Existing merge commit but missing integration transition: retry `integration` so it records the journal receipt.
7
+ - Removed verified worktree but node still integrated: retry `worktree_cleanup` to record completion.
8
+ - Dirty, conflicted, divergent, unexpected, or unreachable state: stop and present the mismatch.
9
+
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.
@@ -9,12 +9,12 @@ Read `.cadre/workflow.md`, `project.json`, all project context files, the last r
9
9
 
10
10
  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.
11
11
 
12
- Call `project_status` first and use its embedded structured validation; do not repeat `state_validate` at command entry. If the Cadre MCP or required versioned template is unavailable, stop without changing project context.
12
+ Call `project_status` first with `view: "project"` and use its embedded structured validation; do not repeat `state_validate` at command entry. If it reports `upgradeRequired`, include the v1→v2 workflow and runtime/template version changes in the explicit refresh proposal; never rewrite them automatically. If the Cadre MCP or required versioned template is unavailable, stop without changing project context.
13
13
 
14
14
  1. Determine evidence sources: user input, committed repository changes, completed tracks, or a combination.
15
15
  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
16
  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
17
  4. Assess impact on all active track specs, plans, and marked Pattern Seed sections in learning files. Apply the same impact analysis as `$revise`, but include every exact cascading track change in the refresh authorization envelope instead of starting separate approval cycles. Ask only if a material impact remains uncertain after inspection.
18
- 5. Call `template_get_many` once for `project/refresh` and `project/refresh-operation`, retain the versioned bundle, render `refreshes/refresh-<ts>.md`, and prepare `.cadre/operations/refresh-<ts>.json` with the evidence range, decisions, affected files and tracks, expected commits, approval, checkpoint, and progress. Expected human decision count is one for a fully assessed refresh. Present project-context diffs, active-work dispositions, cascading track changes, generated index updates, validation, commits, and provenance bookkeeping as one exact proposal.
19
- 6. After approval and before any context or track write, persist the refresh operation journal. Resume an existing matching journal from its first incomplete artifact; never replace it. Apply only authorized changes, advancing its checkpoint and artifact progress after each write. Append project and track history, reseed affected active tracks, then preview and apply `tracks.md` through its MCP digest gate and call `state_validate` without another prompt.
20
- 7. Commit `cadre(refresh): update project context`, 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. 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.
18
+ 5. Call `template_get_many` once for `project/refresh` and `project/refresh-operation`, then `candidate_stage_prepare` for `refresh-<ts>`. Render the refresh record and every exact project/track update beneath the returned stage. For a legacy project, include the compact v2 workflow, `runtimeVersion: 3.4.0`, `templateSetVersion: v2`, and `/stage/` ignore rule. Call `candidate_inspect` once for the complete stage. Expected human decision count is one for a fully assessed refresh. Present project-context diffs, active-work dispositions, cascading changes, manifest, index updates, validation, commits, and provenance as one proposal bound to its digest.
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. Append project and track history, reseed affected active tracks, 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.
@@ -9,16 +9,16 @@ Load `.cadre/workflow.md`, project/track state, spec, plan, learning, review/rev
9
9
 
10
10
  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.
11
11
 
12
- Call `project_status` first and use its embedded structured validation; do not repeat `state_validate` at command entry. If the Cadre MCP is unavailable, stop without beginning the revert.
12
+ Call `project_status` first with `view: "implementation"` and `trackId` for active work, otherwise `view: "track"`; use its embedded structured validation and do not repeat `state_validate` at command entry. If the Cadre MCP is unavailable, stop without beginning the revert.
13
13
 
14
14
  Expected human decision count is one on the clean path. The exact revert proposal authorizes additive Git reversals, tests, plan/state/learning reconciliation, generated indexes, commits, and provenance bookkeeping when their content and consequences remain unchanged.
15
15
 
16
16
  1. Resolve the exact task, phase, or track and its worker commits, task-to-phase merge commits, phase-to-canonical merge commits, and execution journal. Detect shared commits, later overlapping edits, active workers/worktrees, dirty changes, and dependent work.
17
- 2. Build a revert proposal: commits in safe reverse order, conflicts/overlaps, expected file changes, state rollback, invalidated learning/patterns/marked learning seeds, and downstream impacts.
18
- 3. Present the proposal, exact Git operations, expected resulting diff, downstream reconciliation, verification, generated index, and commits as one authorization envelope. Wait for explicit approval. Never use destructive reset/checkout or rewrite public history by default.
19
- 4. Call `template_get_many` for `track/revert-operation`, render the approved operation into `state.json.operation`, and persist it before any Git mutation. Record the target kind/ID, safe reverse commit order, base commit, expected reconciliation commit, approved artifacts, approval time, checkpoint, and applied revert commits. Resume a matching operation; never replace it.
17
+ 2. Build the exact additive revert proposal, call `candidate_stage_prepare` for `revert-<track-id>`, and render every proposed state/plan/learning reconciliation file beneath the returned stage. The Git reversal remains an exact operation/commit proposal rather than a staged product mutation.
18
+ 3. Call `candidate_inspect` once for the staged reconciliation set, supplying the post-revert `targetStatus` when it includes `plan.md`. Present the manifest, graph result, Git operations, expected diff, downstream reconciliation, verification, index, and commits as one authorization envelope bound to its digest. Never rewrite public history by default.
19
+ 4. Call `template_get_many` for `track/revert-operation`, render the approved operation into `state.json.operation`, and persist it before any Git mutation. Record the target kind/ID, safe reverse commit order, base commit, expected reconciliation commit, approved manifest digest and path/hash entries, approval time, checkpoint, and applied revert commits. Resume a matching operation; never replace it.
20
20
  5. Reach the authorized quiescent execution boundary before reverting. Use `git revert` to create additive reversal commits, using the correct mainline parent for an approved merge-commit revert. After each successful revert commit, record its SHA and advance the operation checkpoint. If a conflict has one unambiguous in-scope resolution that preserves the approved resulting semantics, resolve and verify it inside the envelope. If it introduces a material choice or changes the proposed result, stop and present one corrected proposal rather than accumulating per-file approval prompts.
21
- 6. Reconcile plan checkboxes without erasing provenance, append a revert history entry, set the earliest affected task/phase back to pending or blocked, and mark dependent tracks for approved revision/reseed as needed.
22
- 7. Run relevant tests, report the resulting diffs, preview `tracks.md` and pass only its proposal token to apply, then validate. Commit Cadre bookkeeping as `cadre(revert): reconcile <track-id>`, record that commit, clear the operation, and create a follow-up record commit when the bookkeeping cannot be included safely. Do not turn these deterministic consequences into a second approval. On resume, never repeat a revert SHA already recorded by the operation.
21
+ 6. Promote only the approved staged Cadre files, verify their canonical hashes, reconcile plan checkboxes without erasing provenance, append a revert history entry, set the earliest affected task/phase back to pending or blocked, and mark dependent tracks for approved revision/reseed as needed.
22
+ 7. Run relevant tests, report the resulting diffs, call `tracks_render` once, then validate. Commit Cadre bookkeeping as `cadre(revert): reconcile <track-id>` without staging `.cadre/stage/`, record that commit, clear the operation, and create a follow-up record commit when the bookkeeping cannot be included safely. Remove only the matching candidate stage after provenance is recorded. Do not turn these deterministic consequences into a second approval. On resume, never repeat a revert SHA already recorded by the operation.
23
23
 
24
24
  If exact commit provenance is missing or commits mix unrelated work, stop with a precise manual recovery plan.
@@ -7,15 +7,15 @@ description: Review a Cadre track that is ready for review, present evidence-bac
7
7
 
8
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.
9
9
 
10
- 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 preview 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.
10
+ 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
11
 
12
- Call `project_status` first and use its embedded structured validation; do not repeat `state_validate` at command entry. If the Cadre MCP is unavailable, stop without changing review state.
12
+ Call `project_status` first with `view: "track"` and `trackId`; use its embedded structured validation and do not repeat `state_validate` at command entry. If the Cadre MCP is unavailable, stop without changing review state.
13
13
 
14
14
  ## Read context once
15
15
 
16
16
  Build one bounded context inventory from `project_status`, the current track paths, and the reviewed Git range. Read each required artifact once. Do not run a line-count pass before reading, repeat `rg --files` discovery, or reread a whole file after truncated output; continue from the first unread line. During consecutive review cycles in the same flow, reuse unchanged product, workflow, pattern, and styleguide context and verify it by Git path/hash; reread the current state, plan, execution, new review range, and affected files/callers. Use batched parallel reads where independent.
17
17
 
18
- The declared review mutation surface is `review_complete_preview`/`review_complete_apply` 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.
18
+ 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
19
 
20
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.
21
21
 
@@ -24,11 +24,11 @@ Expected human decision count is one per review cycle when the human accepts the
24
24
  1. Determine the commit range from the plan's recorded task commits. Inspect diffs and affected callers, tests, security boundaries, error paths, compatibility, acceptance criteria, and non-functional requirements.
25
25
  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
26
  3. Prepare one decision-ready proposal before asking for approval:
27
- - If findings exist, call `template_get_many` for `track/bug`, retain the versioned result, and draft the exact bug artifact plus the recommended dependency-aware remediation phases for all actionable findings. Every regular task declares same-phase dependencies, every added phase declares the phases it consumes and ends in the derived `User Manual Verification` barrier. Renumber the final phase/tasks as needed, reset that final manual barrier and phase completion to pending, and preserve its prior verification provenance in the review cycle/execution journal rather than leaving a second final phase. Call `execution_graph_validate_draft` with the complete proposed plan Markdown and target status `in_progress`; do not validate the stale canonical plan or create a temporary project copy.
28
- - Present the findings, exact artifact/plan diff, consequences, and choices together. One response may approve both the finding disposition and the unchanged exact artifacts. The human may instead request a subset or different remediation, reject all findings while explicitly accepting their risks and approve clean completion, or stop without mutation.
27
+ - If findings exist, call `template_get_many` for `track/bug`, call `candidate_stage_prepare` for `review-<track-id>`, and draft the exact bug artifacts plus replacement `plan.md` beneath the returned stage. Every added phase declares dependencies and ends in the derived manual-verification barrier. Preserve prior verification provenance. Do not pass plan Markdown through MCP, validate the stale canonical plan, or create a temporary project copy.
28
+ - Call `candidate_inspect` once for the complete staged bug/plan set with `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.
29
29
  - 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.
30
30
  - If no findings exist, present clean-review evidence and the exact completion transition once, then ask approval to complete the track.
31
- 4. For approved changes, record a resumable `review` operation before changing the bug artifact, plan, or state. Increment the plan revision, set state to `in_progress`, reset review readiness, and record the review cycle. Call `tracks_render_preview` and pass only its proposal token to apply, validate, and commit `cadre(review): request changes for <track-id>`. 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. The prior completed execution remains historical until `implement` starts a new execution ID for the changed graph.
32
- 5. For an approved clean review, call `review_complete_preview` with the range start, exact approval record, and accepted risks. It derives and verifies the current execution HEAD, range end, and timestamp. Pass only its proposal token to apply; this writes completed state and the derived index together. Do not repeat index or validation calls when its result is current. Commit `cadre(review): complete <track-id>`.
31
+ 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.
32
+ 5. For an approved clean review, call `review_complete` with `mode: "prepare"`, the range start, exact approval record, and accepted risks. Present its `approval_required` proposal. After approval, call only `{ mode: "apply", proposalToken }`; never make the two calls consecutively without human input. This writes completed state and the derived index together. Commit `cadre(review): complete <track-id>`.
33
33
 
34
34
  Repeat review → implement → review until a human approves a clean review. Only this command may mark a track completed.
@@ -9,7 +9,7 @@ Read `.cadre/workflow.md`, the full target track, its dependencies, all tracks t
9
9
 
10
10
  At every required clarification or approval boundary, show a concise impact summary or focused diff. Inspect the active host policy before calling `workflow_elicit`: if the task context reports approval policy `never`, including Codex Full Access, skip the form and ask the same short question once in chat. Otherwise prefer `workflow_elicit`, using `clarification` for at most three questions and `approval` bound to the exact revision proposal checkpoint. Treat only an `approved` result as approval. If it returns `fallback_required`, or immediately returns `declined` while the task explicitly reports policy `never`, ask the same short question once in chat; the latter is policy rejection, not a human decline. Never request secrets or retry the form.
11
11
 
12
- Call `project_status` first and use its embedded structured validation; do not repeat `state_validate` at command entry. If the Cadre MCP is unavailable, stop without modifying the track.
12
+ Call `project_status` first with `view: "implementation"` and `trackId` for active work, otherwise `view: "track"`; use its embedded structured validation and do not repeat `state_validate` at command entry. If the Cadre MCP is unavailable, stop without modifying the track.
13
13
 
14
14
  ## Route by current status
15
15
 
@@ -28,9 +28,9 @@ Expected human decision count is one when the requested change and partial-work
28
28
  2. Restate the requested change and identify specification, acceptance, plan, learning seed/phase history, review readiness, and state consequences. Inspect active and dirty task work. When it overlaps the requested change, include its exact disposition—complete, preserve as superseded, or additive revert—in the combined revision proposal rather than creating a separate approval when that disposition can be safely assessed in advance.
29
29
  3. Apply the workflow clarification gate. Ask when materially different interpretations remain for the desired outcome, scope, acceptance criteria, compatibility, dependency changes, treatment of completed or partial work, or whether dependent tracks should change now. Do not infer permission to invalidate approved work.
30
30
  4. Trace transitive dependent tracks. For each, classify impact as none, reseed-only, plan change, spec change, or invalidated work, with evidence. If evidence cannot resolve a material impact, ask before choosing a classification.
31
- 5. Call `template_get_many` once for `track/revision` and `track/revise-operation`, and retain the versioned bundle. Render `revisions/revision-<ts>.md` and draft exact diffs for every affected artifact. Record source and target status, the base commit, affected phases/tasks, completed and partial-work disposition, review impact, dependency impact, and verification work. Preserve completed tasks and commit markers; append or explicitly supersede work rather than erasing provenance.
32
- 6. Increment the track revision exactly once. Increment the specification revision only if `spec.md` changes and the plan revision only if `plan.md` changes; keep the revision values in `state.json`, `spec.md`, `plan.md`, and the marked Pattern Seed consistent. Preserve completed task provenance, update explicit regular phase/task dependencies, and restore derived manual-verification barriers. When the plan changes, call `execution_graph_validate_draft` with the complete proposed plan Markdown and the intended post-approval target status; do not validate the stale canonical plan or create a temporary project copy. A changed plan graph uses a new execution ID; never reuse a completed or superseded execution journal.
33
- 7. Present the target revision, partial-work disposition, quiescence actions, all cascading dependent-track changes, validation evidence, lifecycle transitions, expected commits, generated index updates, and provenance bookkeeping together. Wait for one explicit approval. Partial approval narrows the change set and requires a fresh impact assessment, transition calculation, and proposal.
34
- 8. Before changing approved artifacts, write the rendered `revise` operation into every affected track's `state.json`. Use the same expected commit, record each approved artifact and per-artifact progress, and advance the durable checkpoint after each write.
35
- 9. Apply only the authorized changes, update relevant marked Pattern Seed sections without overwriting phase learning, set the approved source-to-target states, mark the earliest affected plan nodes pending in the replacement execution graph, and append track-local history. Do not add singular active phase/task fields to track state. Preview `tracks.md` and pass only its proposal token to apply without another prompt.
31
+ 5. Call `template_get_many` once for `track/revision` and `track/revise-operation`, then `candidate_stage_prepare` for `revise-<track-id>`. Render `revisions/revision-<ts>.md` and every exact affected artifact beneath the returned stage, preserving eventual track-relative paths. Preserve completed provenance.
32
+ 6. Increment revisions exactly once and restore derived manual-verification barriers. A changed plan uses a new execution ID. Do not pass plan Markdown through MCP, validate the stale canonical plan, or create a temporary project copy.
33
+ 7. Call `candidate_inspect` once for every staged revision and cascading artifact, supplying the intended `targetStatus` when `plan.md` is present. Present the target revision, manifest, graph summary, partial-work disposition, dependent changes, lifecycle transitions, commits, and bookkeeping together, bound to its digest. Partial approval requires a fresh inspection.
34
+ 8. Before changing approved artifacts, write the rendered `revise` operation into every affected track's `state.json`. Use the same expected commit, record the approved manifest digest and path/hash entries, record per-artifact progress, and advance the durable checkpoint after each promoted staged file.
35
+ 9. Promote only the authorized staged changes, verify their canonical hashes, update relevant marked Pattern Seed sections without overwriting phase learning, set the approved source-to-target states, mark the earliest affected plan nodes pending in the replacement execution graph, and append track-local history. Do not add singular active phase/task fields to track state. Call `tracks_render` once without another prompt. Never stage `.cadre/stage/`; remove only the matching candidate stage after its canonical hashes and commits are recorded.
36
36
  10. Call `state_validate` and commit `cadre(revise): update <track-id>`. Reconcile interruption using the workflow journal rules. Record the commit in every revision entry, clear each completed operation, and use a follow-up `cadre(revise): record <track-id>` commit when bookkeeping cannot be part of the artifact commit. These unchanged deterministic consequences remain inside the revision authorization envelope.
@@ -7,7 +7,7 @@ description: Validate and summarize current Cadre project, track, dependency, ph
7
7
 
8
8
  Read `.cadre/workflow.md`, `project.json`, generated `tracks.md`, and track-local state/spec/plan files discovered under both `tracks/` and `archive/`. Read dependency state from each track's `state.json`, never from `tracks.md`. This command is read-only. If the Cadre MCP is unavailable, stop and report it; do not use a copied or reconstructed runtime.
9
9
 
10
- Call `project_status` and `worktree_status` with the exact project root. Use the structured validation embedded in `project_status`; do not repeat `state_validate`. For every active implementation operation, also call `execution_status`. If their results disagree with files you read, report the inconsistency rather than repairing it.
10
+ Call `project_status` once with the exact root and the narrowest view: `project` for an overview, `track` plus `trackId` for one lifecycle, or `implementation` plus `trackId` and optional `executionId` for DAG, scheduler, and worktree state. Use its embedded validation; do not repeat `state_validate`, `execution_status`, or a separate worktree read at entry. If results disagree with files you read, report the inconsistency rather than repairing it.
11
11
 
12
12
  Present:
13
13
 
@@ -13,17 +13,17 @@ At every required clarification or approval boundary, show a concise summary or
13
13
 
14
14
  Read `.cadre/workflow.md`, `project.json`, `product.md`, `guidelines.md`, `tech-stack.md`, relevant styleguides, `patterns/index.md`, and every declared dependency. Before editing an existing artifact, read it and its directly relevant context; never guess its contents.
15
15
 
16
- Call `project_status` first and use its embedded structured validation; do not repeat `state_validate` at command entry. If required Cadre MCP tools are unavailable, stop; never recreate templates or runtime logic from memory.
16
+ Call `project_status` first with `view: "project"` for a new track or `view: "track"` plus `trackId` when resuming, and use its embedded structured validation; do not repeat `state_validate` at command entry. If required Cadre MCP tools are unavailable, stop; never recreate templates or runtime logic from memory.
17
17
 
18
18
  ## Procedure
19
19
 
20
20
  1. Normalize a stable track ID. Look for its state at the status-derived active or archive location. If track state exists, reconcile its operation journal, working tree, and recent commits first. Resume the recorded checkpoint; never replace or restart an interrupted track. Otherwise determine title, type, goal, scope, dependencies, risks, and unknowns with the human.
21
21
  2. Apply the workflow clarification gate before drafting. Ask targeted questions whenever repository evidence and the request do not clearly establish a material choice such as feature versus bug, in/out of scope behavior, affected users/interfaces/data, compatibility or rollout expectations, acceptance measures, dependency tracks, or whether existing behavior must be preserved. Do not silently choose an interpretation.
22
- 3. Call `template_get_many` once for `track/spec`, `track/state`, `track/plan`, and `track/learning`; retain the versioned bundle through the decision. Render the functional requirements, non-functional requirements, acceptance criteria, additional information, dependency impact, and proposed track state.
23
- 4. Draft an acyclic phase/task graph from that proposed specification. Every regular phase explicitly declares phase dependencies and every regular task explicitly declares same-phase task dependencies. Do not repeat derived barriers: each phase's final `User Manual Verification` depends on every sibling task, while the final `Track-level User Manual Verification` phase contains only its manual task and depends on every preceding phase. Include tests, formatting, documentation, and Definition of Done work explicitly. Call `execution_graph_validate_draft` with the proposed plan Markdown and target status `planned`; resolve every unknown reference, cycle, missing declaration, or material ambiguity before approval. Do not write an unapproved plan into `.cadre/` or create a temporary project copy for validation.
22
+ 3. Call `template_get_many` once for `track/spec`, `track/state`, `track/plan`, and `track/learning`; retain the versioned bundle through the decision. Call `candidate_stage_prepare` for `track-<track-id>`, then write proposed `spec.md`, `plan.md`, and `learning.md` beneath the returned `.cadre/stage/track-<track-id>/` path. This Git-ignored stage is the durable proposal, not approved canonical state.
23
+ 4. Draft an acyclic phase/task graph from that proposed specification. Every regular phase explicitly declares phase dependencies and every regular task explicitly declares same-phase task dependencies. Do not repeat derived barriers: each phase's final `User Manual Verification` depends on every sibling task, while the final `Track-level User Manual Verification` phase contains only its manual task and depends on every preceding phase. Include tests, formatting, documentation, and Definition of Done work explicitly. Do not pass plan Markdown through MCP, write it into canonical `.cadre/`, or create a temporary project copy for validation.
24
24
  5. Build the marked `Pattern Seed` section at the top of `learning.md` from patterns relevant to the proposed spec and plan. Root phases read the seed; other phases read learning from their declared dependency phases. Cite pattern file paths and explain relevance. Do not invent patterns.
25
- 6. Expected human decision count is one for a clear new track. Present the exact specification, state summary, validated plan graph, learning seed, two planned commits, lifecycle transition to `planned`, and deterministic derived-state consequences as one authorization envelope. A human may explicitly request staged specification/plan review; otherwise do not create a specification-only approval prompt. Changed scope or plan content requires one corrected combined proposal.
26
- 7. After approval, create/update track state with one operation journal covering `spec.md`, `plan.md`, and `learning.md`, then write all three exact approved artifacts to the durable worktree before the first commit so a resumed session never has to reconstruct approved plan content from conversation memory. Direct writes are intentional; do not search for an undeclared mutation tool. Validate the specification, preview/apply derived `tracks.md`, stage only the specification-stage files, commit `cadre(track): specify <track-id>`, and record its SHA while the approved plan/learning remain journaled dirty artifacts. Preserve and transition the same approval envelope into planning instead of clearing it or asking again. Validate `plan.md` and `learning.md`, set status to `planned`, preview/apply `tracks.md`, commit `cadre(track): plan <track-id>`, record its SHA, clear the operation, set checkpoint `ready`, and commit `cadre(track): record plan <track-id>`. All generated indexes, validation, commits, and state-record bookkeeping are unchanged deterministic consequences and require no additional approval.
25
+ 6. Call `candidate_inspect` once for candidate `track-<track-id>`, exactly `spec.md`, `plan.md`, and `learning.md`, and `targetStatus: "planned"`. Resolve all graph errors before approval. Expected human decision count is one for a clear new track. Present the exact specification, state summary, graph summary, learning seed, manifest, two planned commits, lifecycle transition, and deterministic consequences as one authorization envelope bound to its digest; do not create a specification-only approval prompt. Changed staged content requires one fresh inspection and corrected proposal.
26
+ 7. After approval, create/update track state with one operation journal covering `spec.md`, `plan.md`, and `learning.md`, including the approved manifest digest and path/hash entries. Copy all three exact staged artifacts into the durable `.cadre/tracks/<track-id>/` worktree before the first commit, verify their hashes again, and retain the candidate stage until that verification succeeds so a resumed session never has to reconstruct approved content from conversation memory. Direct writes are intentional; do not search for an undeclared mutation tool. Validate the specification, call `tracks_render` once, stage only the specification-stage files and never `.cadre/stage/`, commit `cadre(track): specify <track-id>`, and record its SHA while the approved plan/learning remain journaled dirty artifacts. Preserve and transition the same approval envelope into planning instead of clearing it or asking again. Validate `plan.md` and `learning.md`, set status to `planned`, call `tracks_render` once, commit `cadre(track): plan <track-id>`, record its SHA, clear the operation, set checkpoint `ready`, and commit `cadre(track): record plan <track-id>`. Remove only the matching candidate stage after its canonical hashes and commits are recorded. All generated indexes, validation, commits, and state-record bookkeeping are unchanged deterministic consequences and require no additional approval.
27
27
 
28
28
  For either track commit, reconcile interruptions before continuing:
29
29
 
@@ -0,0 +1 @@
1
+
@@ -0,0 +1,8 @@
1
+ # Cadre-managed temporary execution worktrees
2
+ /.worktrees/
3
+
4
+ # Disposable Wisp output
5
+ /wisps/
6
+
7
+ # Unapproved candidate artifacts
8
+ /stage/
@@ -0,0 +1,25 @@
1
+ # Engineering Guidelines
2
+
3
+ ## Architecture
4
+
5
+ {{ARCHITECTURE_GUIDANCE}}
6
+
7
+ ## Testing strategy
8
+
9
+ {{TEST_STRATEGY}}
10
+
11
+ ## Security and privacy
12
+
13
+ {{SECURITY_PRIVACY}}
14
+
15
+ ## Reliability and observability
16
+
17
+ {{RELIABILITY_OBSERVABILITY}}
18
+
19
+ ## Documentation and compatibility
20
+
21
+ {{DOCUMENTATION_COMPATIBILITY}}
22
+
23
+ ## Repository-specific commands
24
+
25
+ {{REPOSITORY_COMMANDS}}
@@ -0,0 +1,6 @@
1
+ # Pattern Catalog
2
+
3
+ Patterns are created only by distilling completed, cleanly reviewed tracks during archival.
4
+
5
+ | Pattern | Summary | Provenance | Supersedes |
6
+ | --- | --- | --- | --- |