@try-works/dsh-recursive-mode 0.1.3 → 0.1.5

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 (126) hide show
  1. package/cordis.patch.yml +15 -10
  2. package/lib/bootstrap.d.ts +9 -2
  3. package/lib/client/apply-guard.d.ts +14 -0
  4. package/lib/client/board.d.ts +5 -4
  5. package/lib/client/contract.d.ts +57 -24
  6. package/lib/client/host-api.d.ts +26 -0
  7. package/lib/client/index.d.ts +16 -9
  8. package/lib/client/inspector.d.ts +3 -3
  9. package/lib/client/slots.d.ts +4 -6
  10. package/lib/client/strip.d.ts +4 -3
  11. package/lib/client/use-live.d.ts +9 -0
  12. package/lib/client.js +252 -174
  13. package/lib/fs-intent.d.ts +34 -0
  14. package/lib/index.d.ts +12 -11
  15. package/lib/index.js +1008 -4507
  16. package/lib/init-templates.d.ts +41 -0
  17. package/lib/live-route.d.ts +69 -0
  18. package/lib/phase-rules.d.ts +34 -0
  19. package/lib/policy.d.ts +1 -1
  20. package/lib/runtime.d.ts +24 -17
  21. package/lib/snapshot.d.ts +11 -0
  22. package/package.json +4 -3
  23. package/preset/recursive/agent.cordis.yml +7 -4
  24. package/preset/recursive/preset.yml +1 -1
  25. package/references/agents-block.md +95 -0
  26. package/references/artifact-template.md +2574 -0
  27. package/references/bodies/claude.md +7 -0
  28. package/references/bodies/codex-agents.md +95 -0
  29. package/references/bodies/copilot.md +7 -0
  30. package/references/bodies/cursorrules.md +7 -0
  31. package/references/bodies/decisions.md +5 -0
  32. package/references/bodies/delegated-verification.md +49 -0
  33. package/references/bodies/memory-router.md +45 -0
  34. package/references/bodies/phase8-skill-memory.md +48 -0
  35. package/references/bodies/plans-bridge.md +43 -0
  36. package/references/bodies/recursive-agents-router.md +64 -0
  37. package/references/bodies/skill-discovery.md +51 -0
  38. package/references/bodies/skill-memory-router.md +42 -0
  39. package/references/bodies/state.md +5 -0
  40. package/references/bootstrap/RECURSIVE.md +2362 -0
  41. package/references/scripts/__pycache__/recursive_phase_rules.cpython-314.pyc +0 -0
  42. package/references/scripts/lint-recursive-run.ps1 +25 -0
  43. package/references/scripts/lint-recursive-run.py +2870 -0
  44. package/references/scripts/recursive-closeout.ps1 +38 -0
  45. package/references/scripts/recursive-closeout.py +541 -0
  46. package/references/scripts/recursive-init.ps1 +515 -0
  47. package/references/scripts/recursive-init.py +356 -0
  48. package/references/scripts/recursive-lock.ps1 +26 -0
  49. package/references/scripts/recursive-lock.py +302 -0
  50. package/references/scripts/recursive-review-bundle.ps1 +58 -0
  51. package/references/scripts/recursive-review-bundle.py +503 -0
  52. package/references/scripts/recursive-router-cli-configure.ps1 +2 -0
  53. package/references/scripts/recursive-router-cli-configure.py +9 -0
  54. package/references/scripts/recursive-router-cli-init.ps1 +2 -0
  55. package/references/scripts/recursive-router-cli-init.py +9 -0
  56. package/references/scripts/recursive-router-cli-invoke.ps1 +2 -0
  57. package/references/scripts/recursive-router-cli-invoke.py +9 -0
  58. package/references/scripts/recursive-router-cli-probe.ps1 +2 -0
  59. package/references/scripts/recursive-router-cli-probe.py +9 -0
  60. package/references/scripts/recursive-router-cli-resolve.ps1 +2 -0
  61. package/references/scripts/recursive-router-cli-resolve.py +9 -0
  62. package/references/scripts/recursive-router-cli-validate.ps1 +2 -0
  63. package/references/scripts/recursive-router-cli-validate.py +9 -0
  64. package/references/scripts/recursive-router-configure.ps1 +27 -0
  65. package/references/scripts/recursive-router-configure.py +74 -0
  66. package/references/scripts/recursive-router-init.ps1 +17 -0
  67. package/references/scripts/recursive-router-init.py +29 -0
  68. package/references/scripts/recursive-router-invoke.ps1 +47 -0
  69. package/references/scripts/recursive-router-invoke.py +103 -0
  70. package/references/scripts/recursive-router-probe.ps1 +25 -0
  71. package/references/scripts/recursive-router-probe.py +44 -0
  72. package/references/scripts/recursive-router-resolve.ps1 +26 -0
  73. package/references/scripts/recursive-router-resolve.py +46 -0
  74. package/references/scripts/recursive-router-validate.ps1 +17 -0
  75. package/references/scripts/recursive-router-validate.py +27 -0
  76. package/references/scripts/recursive-status.ps1 +23 -0
  77. package/references/scripts/recursive-status.py +2124 -0
  78. package/references/scripts/recursive-subagent-action.ps1 +98 -0
  79. package/references/scripts/recursive-subagent-action.py +197 -0
  80. package/references/scripts/recursive-training-extract.ps1 +23 -0
  81. package/references/scripts/recursive-training-extract.py +99 -0
  82. package/references/scripts/recursive-training-grpo.ps1 +52 -0
  83. package/references/scripts/recursive-training-grpo.py +1341 -0
  84. package/references/scripts/recursive-training-loader.ps1 +78 -0
  85. package/references/scripts/recursive-training-loader.py +558 -0
  86. package/references/scripts/recursive-training-mcp.ps1 +29 -0
  87. package/references/scripts/recursive-training-mcp.py +261 -0
  88. package/references/scripts/recursive-training-phase8-trigger.ps1 +55 -0
  89. package/references/scripts/recursive-training-phase8-trigger.py +137 -0
  90. package/references/scripts/recursive-training-sync.ps1 +29 -0
  91. package/references/scripts/recursive-training-sync.py +183 -0
  92. package/references/scripts/recursive_phase_rules.py +367 -0
  93. package/references/scripts/recursive_router_cli_lib.py +2 -0
  94. package/references/scripts/recursive_router_lib.py +2282 -0
  95. package/references/scripts/verify-locks.ps1 +25 -0
  96. package/references/scripts/verify-locks.py +353 -0
  97. package/scripts/__pycache__/lint-recursive-run.cpython-314.pyc +0 -0
  98. package/scripts/__pycache__/recursive_phase_rules.cpython-314.pyc +0 -0
  99. package/scripts/install-preset.cmd +7 -0
  100. package/scripts/install-preset.js +101 -0
  101. package/scripts/lint-recursive-run.py +7 -5
  102. package/scripts/test-recursive-mode-smoke.ts +29 -28
  103. package/src/bootstrap.ts +253 -39
  104. package/src/client/apply-guard.ts +23 -0
  105. package/src/client/board.tsx +0 -0
  106. package/src/client/contract.ts +72 -24
  107. package/src/client/host-api.ts +90 -0
  108. package/src/client/index.ts +22 -11
  109. package/src/client/inspector.tsx +7 -9
  110. package/src/client/slots.ts +70 -26
  111. package/src/client/strip.tsx +9 -9
  112. package/src/client/use-live.ts +52 -0
  113. package/src/fs-intent.ts +84 -0
  114. package/src/index.ts +100 -155
  115. package/src/init-templates.ts +276 -0
  116. package/src/live-route.ts +163 -0
  117. package/src/phase-rules.ts +262 -0
  118. package/src/policy.ts +29 -5
  119. package/src/runtime.ts +129 -77
  120. package/src/snapshot.ts +104 -0
  121. package/lib/client/node.d.ts +0 -71
  122. package/lib/events.d.ts +0 -173
  123. package/lib/projection.d.ts +0 -29
  124. package/src/client/node.ts +0 -156
  125. package/src/events.ts +0 -173
  126. package/src/projection.ts +0 -237
@@ -0,0 +1,2574 @@
1
+ # recursive-mode Artifact Writing Guide and Templates
2
+
3
+ Use this file when writing any per-run artifact in:
4
+ - `/.recursive/run/<run-id>/00-worktree.md`
5
+ - `/.recursive/run/<run-id>/00-requirements.md`
6
+ - `/.recursive/run/<run-id>/01-as-is.md`
7
+ - `/.recursive/run/<run-id>/01.5-root-cause.md`
8
+ - `/.recursive/run/<run-id>/02-to-be-plan.md`
9
+ - `/.recursive/run/<run-id>/03-implementation-summary.md`
10
+ - `/.recursive/run/<run-id>/03.5-code-review.md`
11
+ - `/.recursive/run/<run-id>/04-test-summary.md`
12
+ - `/.recursive/run/<run-id>/05-manual-qa.md`
13
+ - `/.recursive/run/<run-id>/06-decisions-update.md`
14
+ - `/.recursive/run/<run-id>/07-state-update.md`
15
+ - `/.recursive/run/<run-id>/08-memory-impact.md`
16
+ - `/.recursive/run/<run-id>/addenda/*.md`
17
+
18
+ This guide is intentionally prescriptive so two different agents produce equivalent artifacts.
19
+
20
+ ## Table of Contents
21
+
22
+ - [Quick Start Checklist](#quick-start-checklist)
23
+ - [Required Header (All Artifacts)](#required-header-all-artifacts)
24
+ - [Universal Sections (All Artifacts Except `00-requirements.md`)](#universal-sections-all-artifacts-except-00-requirementsmd)
25
+ - [Memory Metadata Block (Durable Memory Docs)](#memory-metadata-block-durable-memory-docs)
26
+ - [Evidence Directory (Per Run)](#evidence-directory-per-run)
27
+ - [Review Bundle Template](#review-bundle-template)
28
+ - [Subagent Action Record Template](#subagent-action-record-template)
29
+ - [Phase-by-Phase Authoring Templates](#phase-by-phase-authoring-templates)
30
+ - [Phase 0 Template (`00-worktree.md`) - Isolation REQUIRED](#phase-0-template-00-worktreemd---isolation-required)
31
+ - [Phase 0 Requirements Template (`00-requirements.md`)](#phase-0-requirements-template-00-requirementsmd)
32
+ - [Phase 1 Template (`01-as-is.md`)](#phase-1-template-01-as-ismd)
33
+ - [Phase 1.5 Template (`01.5-root-cause.md`) - Debug Mode Only](#phase-15-template-015-root-causemd---debug-mode-only)
34
+ - [Phase 2 Template (`02-to-be-plan.md`, ExecPlan Grade)](#phase-2-template-02-to-be-planmd-execplan-grade)
35
+ - [Phase 3 Template (`03-implementation-summary.md`)](#phase-3-template-03-implementation-summarymd)
36
+ - [Phase 3.5 Template (`03.5-code-review.md`) - Optional](#phase-35-template-035-code-reviewmd---optional)
37
+ - [Phase 4 Template (`04-test-summary.md`)](#phase-4-template-04-test-summarymd)
38
+ - [Phase 5 Template (`05-manual-qa.md`)](#phase-5-template-05-manual-qamd)
39
+ - [Phase 6 Template (`06-decisions-update.md`)](#phase-6-template-06-decisions-updatemd)
40
+ - [Phase 7 Template (`07-state-update.md`)](#phase-7-template-07-state-updatemd)
41
+ - [Phase 8 Template (`08-memory-impact.md`)](#phase-8-template-08-memory-impactmd)
42
+ - [Addenda Templates](#addenda-templates)
43
+ - [Stage-Local Addendum](#stage-local-addendum)
44
+ - [Upstream-Gap Addendum](#upstream-gap-addendum)
45
+ - [Artifact Linting (Structure + TODO Discipline)](#artifact-linting-structure--todo-discipline)
46
+ - [Locking Commands](#locking-commands)
47
+ - [Common Failure Modes (Use as Pre-Lock Checklist)](#common-failure-modes-use-as-pre-lock-checklist)
48
+ - [Lock Verification](#lock-verification)
49
+
50
+ ## Quick Start Checklist
51
+
52
+ 1. Resolve the run id and exact output path.
53
+ 2. **Ensure `00-requirements.md` exists, then create/lock Phase 0 worktree (`00-worktree.md`) before Phase 1+ (isolated workspace setup).**
54
+ 3. **If writing Phase 3 or later, verify all prior phase artifacts are lock-valid before proceeding.**
55
+ 4. Verify phase isolation: only the current phase may be `DRAFT`; do not proceed if a prior phase is unresolved.
56
+ 5. Determine effective inputs:
57
+ - base input files for this phase
58
+ - plus stage-local addenda for each base input, lexical order
59
+ - plus current-phase upstream-gap addenda when they compensate for locked-history gaps you must account for now
60
+ 6. Write the required header with exact input/output paths.
61
+ 7. Write phase-specific content sections from this guide.
62
+ 8. For audited phases, write the audit sections and complete the `draft -> audit -> repair -> re-audit` loop.
63
+ 9. Write `Traceability`, `Coverage Gate`, and `Approval Gate`.
64
+ 10. Perform a pre-lock completeness check using this template's required sections and gates.
65
+ 11. Verify LockHash matches SHA-256 of content before locking.
66
+ 12. Lock only after all required gates pass (`Status`, `LockedAt`, `LockHash`).
67
+
68
+ ## Required Header (All Artifacts)
69
+
70
+ ```md
71
+ Run: `/.recursive/run/<run-id>/`
72
+ Phase: `0N <phase-name>`
73
+ Status: `DRAFT`
74
+ Inputs:
75
+ - `/<path-to-input-1>`
76
+ - `/<path-to-input-2>`
77
+ Outputs:
78
+ - `/<path-to-this-output>`
79
+ Scope note: One short paragraph describing what this artifact decides or enables.
80
+ ```
81
+
82
+ When locking, append:
83
+
84
+ ```md
85
+ LockedAt: `YYYY-MM-DDTHH:MM:SSZ`
86
+ LockHash: `<sha256-hex>`
87
+ ```
88
+
89
+ ## Universal Sections (All Artifacts Except `00-requirements.md`)
90
+
91
+ Traceability is not required in `00-requirements.md`, but every downstream artifact (Phase 1+) must include it.
92
+
93
+ ```md
94
+ ## Traceability
95
+
96
+ - `R1` -> [where this artifact addresses it] | Evidence: [files, commands, observations]
97
+ - `R2` -> [where this artifact addresses it] | Evidence: [files, commands, observations]
98
+ - `R3` -> Deferred in this phase | Rationale: [...] | Impact: [...]
99
+ ```
100
+
101
+ ```md
102
+ ## Coverage Gate
103
+
104
+ - Effective inputs reviewed:
105
+ - `/<base-input-1>`
106
+ - `/<matching-addendum-1>`
107
+ - `/<matching-addendum-2>`
108
+ - Requirement coverage check:
109
+ - `R1`: Covered at [section]
110
+ - `R2`: Covered at [section]
111
+ - `R3`: Deferred [why]
112
+ - Out-of-scope confirmation:
113
+ - `OOS1`: unchanged
114
+ - `OOS2`: unchanged
115
+
116
+ Coverage: PASS
117
+ ```
118
+
119
+ ```md
120
+ ## Approval Gate
121
+
122
+ - Objective readiness checks:
123
+ - [artifact is internally consistent]
124
+ - [commands are runnable and specific]
125
+ - [tests/QA expectations are explicit for this phase]
126
+ - [no required section is missing]
127
+ - Remaining blockers:
128
+ - none
129
+
130
+ Approval: PASS
131
+ ```
132
+
133
+ If either gate fails, set `FAIL` and list exact fixes required before proceeding.
134
+
135
+ ## Universal Audit Sections (Audited Phases)
136
+
137
+ Use this block in every audited phase for `recursive-mode-audit-v1` and `recursive-mode-audit-v2`:
138
+
139
+ ```md
140
+ ## Audit Context
141
+
142
+ Audit Execution Mode: self-audit / subagent
143
+ Subagent Availability: available / unavailable
144
+ Subagent Capability Probe: [what proved availability or unavailability]
145
+ Delegation Decision Basis: [why self-audit or delegation was chosen]
146
+ Delegation Override Reason: [required when subagents were available but self-audit was still chosen]
147
+ Audit Inputs Provided:
148
+ - `/.recursive/run/<run-id>/00-requirements.md`
149
+ - `/.recursive/run/<run-id>/00-worktree.md`
150
+ - [other upstream artifacts]
151
+ - Changed files:
152
+ - `path/to/file`
153
+ - Targeted code references:
154
+ - `path/to/file`
155
+
156
+ ## Effective Inputs Re-read
157
+
158
+ - `/.recursive/run/<run-id>/...`
159
+
160
+ ## Earlier Phase Reconciliation
161
+
162
+ - Upstream artifact:
163
+ - Claim carried forward:
164
+ - Current reconciliation:
165
+
166
+ ## Subagent Contribution Verification
167
+
168
+ - Reviewed Action Records: `none` / `/.recursive/run/<run-id>/subagents/<record>.md`
169
+ - Main-Agent Verification Performed: `path/to/file`, `/.recursive/run/<run-id>/artifact.md`, diff-owned paths actually checked by the controller
170
+ - Acceptance Decision: `accepted|partially accepted|rejected`
171
+ - Refresh Handling: [whether the bundle/action record was refreshed after repairs or why no refresh was needed]
172
+ - Repair Performed After Verification: `none` / [concrete repair paths or artifact updates performed after checking delegated work]
173
+
174
+ Controller verification rule:
175
+
176
+ - `Main-Agent Verification Performed` should cite real files or recursive artifacts that exist, not placeholder prose
177
+ - if `Repair Performed After Verification` cites paths, those paths should also exist
178
+ - if `Subagent Availability` is `available` and `Audit Execution Mode` is `self-audit`, `Delegation Override Reason` should state the concrete reason the controller chose not to delegate
179
+ - these fields may be written inline or as multi-line bullet lists; lint/status should accept either form as long as the cited paths and decisions are concrete
180
+
181
+ ## Worktree Diff Audit
182
+
183
+ - Baseline type: `local commit|local branch|remote ref|merge-base derived`
184
+ - Baseline reference: `origin/main` / `main` / `<commit>`
185
+ - Comparison reference: `working-tree` / `HEAD` / `<branch-or-ref>`
186
+ - Normalized baseline: `<commit-sha>`
187
+ - Normalized comparison: `working-tree` / `<commit-sha>`
188
+ - Normalized diff command: `git diff --name-only <normalized-basis>`
189
+ - Planned or claimed changed files:
190
+ - `path/to/file`
191
+ - Actual changed files reviewed:
192
+ - `path/to/file`
193
+ - Unexplained drift:
194
+ - none / [explain]
195
+
196
+ Incidental runtime noise such as `__pycache__/`, `*.pyc`, `.pytest_cache/`, `.mypy_cache/`, and `.ruff_cache/` is excluded from meaningful diff audit unless the repo intentionally tracks it.
197
+
198
+ For Phase 0 specifically, `recursive-init` should prefill a safe executable default from the current `HEAD` commit when possible. If you later choose a different baseline, update `Baseline reference`, `Normalized baseline`, `Comparison reference`, `Normalized comparison`, and `Normalized diff command` together and rerun lint before locking.
199
+
200
+ ## Phase-Scoped Diff Ownership
201
+
202
+ Treat `## Worktree Diff Audit` as phase-scoped, not as a permanent obligation for every earlier artifact to explain the eventual end-state diff forever.
203
+
204
+ - Phase 2 owns planning completeness plus the expected product/worktree change surface.
205
+ - Phase 3, Phase 3.5, and Phase 4 own the actual product/worktree diff.
206
+ - Phase 6 owns `/.recursive/DECISIONS.md` plus the reviewed final product/worktree paths.
207
+ - Phase 7 owns `/.recursive/STATE.md` plus the reviewed final product/worktree paths.
208
+ - Phase 8 owns `/.recursive/memory/**` plus the reviewed final product/worktree paths.
209
+ - Late control-plane or memory churn must not retroactively invalidate an earlier locked planning artifact.
210
+ - If a later phase discovers a real upstream gap, create a current-phase upstream-gap addendum and compensate there instead of editing locked history.
211
+
212
+ ## Gaps Found
213
+
214
+ - none / [list in-scope gaps, missing evidence, or drift]
215
+
216
+ ## Repair Work Performed
217
+
218
+ - none / [list repairs made before re-audit]
219
+
220
+ ## Requirement Completion Status
221
+
222
+ - `R1 | Status: implemented | Changed Files: /path/to/file | Implementation Evidence: /path/to/file, /path/to/artifact`
223
+ - `R2 | Status: verified | Changed Files: /path/to/file | Implementation Evidence: /path/to/file | Verification Evidence: /path/to/test-summary.md`
224
+ - `R3 | Status: deferred | Rationale: [why] | Deferred By: /.recursive/run/<run-id>/addenda/...`
225
+ - `R4 | Status: out-of-scope | Rationale: [why] | Scope Decision: /.recursive/run/<run-id>/addenda/...`
226
+ - `R5 | Status: blocked | Rationale: [why] | Blocking Evidence: /path/to/log, /path/to/artifact`
227
+ - `R6 | Status: superseded by approved addendum | Addendum: /.recursive/run/<run-id>/addenda/...`
228
+
229
+ Use status-specific evidence fields rather than a generic `Evidence:` field:
230
+
231
+ - `implemented` -> `Changed Files` and `Implementation Evidence`
232
+ - `verified` -> `Changed Files`, `Implementation Evidence`, and `Verification Evidence`
233
+ - `deferred` -> `Deferred By` or `Addendum`
234
+ - `out-of-scope` -> `Scope Decision` or `Addendum`
235
+ - `blocked` -> `Blocking Evidence`
236
+
237
+ Contradiction rule:
238
+
239
+ - do not mix fields from conflicting statuses in one `R#` entry
240
+ - do not mark a requirement `implemented` or `verified` without concrete changed-file refs
241
+ - do not mark a requirement `verified` without verification evidence that is stronger than merely restating implementation evidence
242
+ - in phases that own product/worktree diff, every diff-owned changed file should appear under some in-scope requirement's `Changed Files`
243
+
244
+ ## Audit Verdict
245
+
246
+ - Audit summary:
247
+ - Follow-up required before lock:
248
+ - Audit: FAIL
249
+ ```
250
+
251
+ Additional audited-phase requirement:
252
+
253
+ - Phase 1, Phase 2, Phase 4, Phase 7, and Phase 8 must also include `## Prior Recursive Evidence Reviewed`.
254
+ - Do not set `Coverage: PASS` or `Approval: PASS` unless `Audit: PASS`.
255
+ - Phase 8 must also include `## Run-Local Skill Usage Capture` and `## Skill Memory Promotion Review`.
256
+
257
+ ## Memory Metadata Block (Durable Memory Docs)
258
+
259
+ Every durable memory doc under `/.recursive/memory/` except `MEMORY.md` must include this metadata block near the top.
260
+
261
+ ```md
262
+ Type: `domain|pattern|incident|episode`
263
+ Status: `CURRENT|SUSPECT|STALE|DEPRECATED|DRAFT`
264
+ Scope: `<what this memory doc covers>`
265
+ Owns-Paths:
266
+ - `path/or/glob/**`
267
+ Watch-Paths:
268
+ - `path/or/glob/**`
269
+ Source-Runs:
270
+ - `/.recursive/run/<run-id>/`
271
+ Validated-At-Commit: `<git-sha>`
272
+ Last-Validated: `YYYY-MM-DDTHH:MM:SSZ`
273
+ Tags:
274
+ - `tag-one`
275
+ - `tag-two`
276
+ Parent: `<optional parent memory doc path>`
277
+ Children:
278
+ - `<optional child memory doc path>`
279
+ Supersedes:
280
+ - `<optional older memory doc path>`
281
+ Superseded-By:
282
+ - `<optional newer memory doc path>`
283
+ ```
284
+
285
+ Notes:
286
+ - `MEMORY.md` is the router/index and does not require the metadata block.
287
+ - `SKILLS.md` is the skill-memory router/index and does not require the metadata block.
288
+ - `Owns-Paths` may be empty for non-domain docs, but the field must exist.
289
+ - `Watch-Paths` may be empty, but the field must exist.
290
+ - Phase 8 should downgrade affected `CURRENT` docs to `SUSPECT` until semantic revalidation is complete.
291
+
292
+ ## Evidence Directory (Per Run)
293
+
294
+ To keep Phase 4/5 fast and reproducible, store all non-Markdown evidence artifacts under a standard folder:
295
+
296
+ - `/.recursive/run/<run-id>/evidence/`
297
+ - `screenshots/` (UI screenshots, failure screenshots)
298
+ - `logs/` (console/server/CI excerpts)
299
+ - `perf/` (profiles, measurements, benchmarks)
300
+ - `traces/` (Playwright traces, HARs; if applicable)
301
+ - `review-bundles/` (canonical delegated review handoff files)
302
+ - `other/` (fallback)
303
+
304
+ Per-run delegated work records live under:
305
+
306
+ - `/.recursive/run/<run-id>/subagents/`
307
+
308
+ Reference these artifacts in Phase 3/4/5 using repo-relative paths.
309
+
310
+ ## Review Bundle Template
311
+
312
+ Use this when delegating a Phase 3.5 review or any other review/audit that needs a reproducible context handoff. Prefer generating it with `recursive-review-bundle`.
313
+ The helper auto-discovers relevant addenda by default; do not trim them out unless you are deliberately debugging bundle generation.
314
+
315
+ ```md
316
+ Run: `/.recursive/run/<run-id>/`
317
+ Bundle Type: `review-bundle`
318
+ Phase: `03.5 Code Review`
319
+ Role: `code-reviewer`
320
+ Artifact path: `/.recursive/run/<run-id>/03.5-code-review.md`
321
+ Artifact Content Hash: `<sha256>`
322
+
323
+ ## Routing
324
+
325
+ - Routed CLI: `none`
326
+ - Routed Model: `none`
327
+ - Routing Config Path: `none`
328
+ - Routing Discovery Path: `none`
329
+
330
+ ## Upstream Artifacts
331
+
332
+ - `/.recursive/run/<run-id>/00-requirements.md`
333
+ - `/.recursive/run/<run-id>/00-worktree.md`
334
+ - `/.recursive/run/<run-id>/02-to-be-plan.md`
335
+ - `/.recursive/run/<run-id>/03-implementation-summary.md`
336
+
337
+ ## Addenda
338
+
339
+ - none / `/.recursive/run/<run-id>/addenda/...`
340
+
341
+ ## Prior Recursive Evidence
342
+
343
+ - none / `/.recursive/run/<run-id>/...`
344
+ - none / `/.recursive/memory/...`
345
+
346
+ ## Control-Plane Docs
347
+
348
+ - none / `/.recursive/DECISIONS.md`
349
+ - none / `/.recursive/STATE.md`
350
+
351
+ ## Diff Basis
352
+
353
+ - Baseline type:
354
+ - Baseline reference:
355
+ - Comparison reference:
356
+ - Normalized baseline:
357
+ - Normalized comparison:
358
+ - Normalized diff command:
359
+
360
+ ## Changed Files
361
+
362
+ - `path/to/file`
363
+
364
+ ## Targeted Code References
365
+
366
+ - `path/to/file`
367
+
368
+ ## Evidence References
369
+
370
+ - `/.recursive/run/<run-id>/evidence/logs/...`
371
+
372
+ ## Audit Questions
373
+
374
+ - Which `R#` remain incomplete or weakly evidenced?
375
+ - Which changed files drift from the plan or implementation claims?
376
+ - Is TDD and test evidence sufficient for this phase?
377
+ - What must be repaired before lock?
378
+
379
+ ## Required Output
380
+
381
+ - Findings ordered by severity
382
+ - Missing evidence or traceability gaps
383
+ - Concrete repair recommendations
384
+ - Final verdict suitable for `Audit: PASS` or `Audit: FAIL`
385
+ ```
386
+
387
+ Review-artifact expectation:
388
+
389
+ - The written review narrative should cite the `Review Bundle Path`, at least one upstream artifact from the bundle, relevant addenda when present, and changed files or code refs from the bundle.
390
+ - Relevant addenda should appear in the bundle automatically unless auto-discovery is intentionally disabled for debugging.
391
+ - `## Changed Files Reviewed` and `## Targeted Code References` should be concrete, non-empty, and grounded in the changed-file scope being reviewed.
392
+ - Main-agent acceptance should record how delegated claims were checked against actual files, actual recursive artifacts, actual diff scope, and any repairs performed after verification.
393
+
394
+ ## Subagent Action Record Template
395
+
396
+ Use this when a meaningful subagent invocation contributes to a phase outcome. The record is a durable claim log that the main agent must verify before accepting the work.
397
+
398
+ ```md
399
+ # Subagent Action Record
400
+
401
+ ## Metadata
402
+ - Subagent ID:
403
+ - Run ID:
404
+ - Phase:
405
+ - Purpose:
406
+ - Execution Mode:
407
+ - Timestamp:
408
+ - Action Record Path:
409
+
410
+ ## Inputs Provided
411
+ - Current Artifact:
412
+ - Artifact Content Hash:
413
+ - Upstream Artifacts:
414
+ - Addenda:
415
+ - Review Bundle:
416
+ - Diff Basis:
417
+ - Code Refs:
418
+ - Memory Refs:
419
+ - Audit / Task Questions:
420
+
421
+ ## Routing
422
+ - Router Used:
423
+ - Routed Role:
424
+ - Routed CLI:
425
+ - Routed Model:
426
+ - Routing Config Path:
427
+ - Routing Discovery Path:
428
+ - Routing Resolution Basis:
429
+ - Routing Fallback Reason:
430
+ - CLI Probe Summary:
431
+ - Prompt Bundle Path:
432
+ - Invocation Exit Code:
433
+ - Output Capture Paths:
434
+
435
+ ## Claimed Actions Taken
436
+ - [bullet list]
437
+
438
+ ## Claimed File Impact
439
+ ### Created
440
+ - path
441
+ ### Modified
442
+ - path
443
+ ### Reviewed
444
+ - path
445
+ ### Relevant but Untouched
446
+ - path
447
+
448
+ ## Claimed Artifact Impact
449
+ ### Read
450
+ - artifact path
451
+ ### Updated
452
+ - artifact path
453
+ ### Evidence Used
454
+ - evidence path
455
+
456
+ ## Claimed Findings
457
+ - [bullet list]
458
+
459
+ ## Verification Handoff
460
+ - Inspect these files first:
461
+ - Reconcile these diffs:
462
+ - Cross-check these artifacts:
463
+ - Known uncertainties:
464
+ ```
465
+
466
+ Meaningfulness rule:
467
+
468
+ - For materially contributing delegated work, `## Claimed Actions Taken` cannot be `none`.
469
+ - `## Claimed File Impact` should cite concrete created, modified, reviewed, or relevant untouched files.
470
+ - `## Claimed Artifact Impact` should cite recursive artifacts or evidence paths actually used.
471
+ - `Artifact Content Hash` should match the current artifact content at the time the controller accepts the record.
472
+ - For delegated review or audit, prefer a stable reviewed artifact for `Current Artifact` instead of a mutable controller-authored phase receipt draft. If that artifact changes materially, refresh the action record.
473
+ - The controller should verify the record against actual changed files, actual recursive artifacts, the review bundle when present, and earlier locked recursive docs before acceptance.
474
+
475
+ ## Phase-by-Phase Authoring Templates
476
+
477
+ For Phases 4-8, prefer starting from `recursive-closeout` rather than hand-authoring a blank markdown file. The helper scaffolds the required headings, audited sections, and late-phase input/output lists before you fill in the final receipt content.
478
+
479
+ ## Phase 0 Template (`00-worktree.md`) - Isolation REQUIRED
480
+
481
+ Required outcome:
482
+ - Isolated git worktree created on feature branch
483
+ - Worktree directory verified as git-ignored
484
+ - Project setup completed
485
+ - Clean test baseline verified
486
+ - Main branch protection confirmed
487
+
488
+ ```md
489
+ Run: `/.recursive/run/<run-id>/`
490
+ Phase: `00 Worktree Setup`
491
+ Status: `DRAFT`
492
+ Inputs:
493
+ - Current git repository state
494
+ - User preference (for worktree location)
495
+ Outputs:
496
+ - `/.recursive/run/<run-id>/00-worktree.md`
497
+ - Isolated worktree at `[location]`
498
+ Scope note: This document records isolated workspace setup and verifies clean test baseline.
499
+
500
+ ## TODO
501
+
502
+ - [ ] Verify current branch (main/master protection check)
503
+ - [ ] Select worktree location (`.worktrees/<run-id>/` preferred)
504
+ - [ ] Verify worktree directory is git-ignored
505
+ - [ ] Create git worktree with feature branch
506
+ - [ ] Run project setup (npm install, cargo build, etc.)
507
+ - [ ] Verify clean test baseline (all tests passing)
508
+ - [ ] Document worktree location and branch name
509
+ - [ ] Record baseline commit SHA
510
+ - [ ] Record reusable diff basis for later audited phases
511
+
512
+ ## Directory Selection
513
+
514
+ **Convention checked:**
515
+ - [ ] `.worktrees/` exists
516
+ - [ ] `worktrees/` exists
517
+ - [ ] CLAUDE.md preference found
518
+ - [ ] User preference obtained
519
+
520
+ **Selected location:** `.worktrees/` (project-local, hidden)
521
+ **Rationale:** [why this location]
522
+
523
+ ## Safety Verification
524
+
525
+ **Gitignore check:**
526
+ ```bash
527
+ $ git check-ignore -q .worktrees && echo "IGNORED" || echo "NOT IGNORED"
528
+ IGNORED
529
+ ```
530
+
531
+ **Result:** ? Directory is properly ignored
532
+
533
+ (If NOT ignored: added to .gitignore and committed before proceeding)
534
+
535
+ ## Worktree Creation
536
+
537
+ **Current branch before:** `main` (or `master`)
538
+
539
+ **Command:**
540
+ ```bash
541
+ git worktree add .worktrees/<run-id> -b recursive/<run-id>
542
+ ```
543
+
544
+ **Output:**
545
+ ```
546
+ Preparing worktree (new branch 'recursive/<run-id>')
547
+ HEAD is now at abc1234 Previous commit message
548
+ ```
549
+
550
+ **Branch created:** `recursive/<run-id>`
551
+ **Worktree location:** `/full/path/to/project/.worktrees/<run-id>`
552
+
553
+ ## Main Branch Protection
554
+
555
+ **Original branch:** `main`
556
+ **Action:** Created worktree (default behavior)
557
+ **Isolation:** ? Working in isolated worktree
558
+
559
+ (If on main and user insisted: document explicit consent here)
560
+
561
+ ## Project Setup
562
+
563
+ **Detected project type:** [Node.js/Rust/Python/Go/etc.]
564
+
565
+ **Commands executed:**
566
+ ```bash
567
+ cd .worktrees/<run-id>
568
+ [npm install / cargo build / pip install / etc.]
569
+ ```
570
+
571
+ **Output:**
572
+ ```
573
+ [setup output]
574
+ ```
575
+
576
+ **Setup status:** ? Complete / ? Issues noted
577
+
578
+ ## Test Baseline Verification
579
+
580
+ **Command:**
581
+ ```bash
582
+ [npm test / cargo test / pytest / etc.]
583
+ ```
584
+
585
+ **Results:**
586
+ - Total: [N] tests
587
+ - Passed: [N]
588
+ - Failed: [N]
589
+ - Skipped: [N]
590
+
591
+ **Baseline:** ? Clean (all tests passing) / ? Pre-existing failures noted
592
+
593
+ (If failures exist, document and get explicit consent to proceed)
594
+
595
+ ## Worktree Context
596
+
597
+ **All subsequent phases will execute in:**
598
+ - Directory: `.worktrees/<run-id>/`
599
+ - Branch: `recursive/<run-id>`
600
+ - Base commit: `abc1234`
601
+
602
+ ## Diff Basis For Later Audits
603
+
604
+ - Baseline type: `local commit|local branch|remote ref|merge-base derived`
605
+ - Baseline reference: `main` / `origin/main` / `abc1234`
606
+ - Comparison reference: `working-tree` / `HEAD` / `<branch-or-ref>`
607
+ - Normalized baseline: `abc1234`
608
+ - Normalized comparison: `working-tree` / `def5678`
609
+ - Normalized diff command: `git diff --name-only abc1234`
610
+ - Base branch: `main`
611
+ - Worktree branch: `recursive/<run-id>`
612
+ - Diff basis notes: [why this non-default basis was chosen, if applicable]
613
+
614
+ `recursive-init` should prefill this block from the current `HEAD` commit when possible. The executable source of truth is the combination of `Normalized baseline`, `Normalized comparison`, and `Normalized diff command`; Phase 0 lock must fail if those values do not match live git state.
615
+
616
+ ## Traceability
617
+
618
+ - recursive-mode process -> Isolated workspace established | Evidence: worktree at `.worktrees/<run-id>`
619
+
620
+ ## Coverage Gate
621
+
622
+ - [ ] Worktree location selected following priority rules
623
+ - [ ] Directory verified as git-ignored (if project-local)
624
+ - [ ] Worktree created successfully on feature branch
625
+ - [ ] Project setup completed without errors
626
+ - [ ] Clean test baseline verified (all tests passing, or failures documented)
627
+ - [ ] Main branch protection confirmed (working in isolation, or consent documented)
628
+
629
+ Coverage: PASS / FAIL
630
+
631
+ ## Approval Gate
632
+
633
+ - [ ] Isolated workspace ready for development
634
+ - [ ] No pending setup issues
635
+ - [ ] Ready to proceed to Phase 1/2
636
+ - [ ] LockHash matches SHA-256 of content (verified)
637
+
638
+ Approval: PASS / FAIL
639
+
640
+ LockedAt: `YYYY-MM-DDTHH:MM:SSZ`
641
+ LockHash: `<sha256-hex>`
642
+ ```
643
+
644
+ ## Phase 0 Requirements Template (`00-requirements.md`)
645
+
646
+ Required outcome:
647
+ - stable requirement IDs (`R1`, `R2`, ...)
648
+ - out-of-scope IDs (`OOS1`, `OOS2`, ...)
649
+ - observable acceptance criteria per requirement
650
+ - constraints/assumptions
651
+
652
+ ```md
653
+ Run: `/.recursive/run/<run-id>/`
654
+ Phase: `00 Requirements`
655
+ Status: `DRAFT`
656
+ Workflow version: `recursive-mode-audit-v2`
657
+ Inputs:
658
+ - [chat summary or source notes if captured in repo]
659
+ Outputs:
660
+ - `/.recursive/run/<run-id>/00-requirements.md`
661
+ Scope note: This document defines stable requirement identifiers and acceptance criteria.
662
+
663
+ ## TODO
664
+
665
+ - [ ] Elicit requirements from user/context
666
+ - [ ] Define requirement identifiers (R1, R2, ...)
667
+ - [ ] Write acceptance criteria for each requirement
668
+ - [ ] Document out of scope items (OOS1, OOS2, ...)
669
+ - [ ] List constraints and assumptions
670
+ - [ ] Complete Coverage Gate checklist
671
+ - [ ] Complete Approval Gate checklist
672
+
673
+ ## Requirements
674
+
675
+ ### `R1` <short title>
676
+ Description:
677
+ Acceptance criteria:
678
+ - [observable condition 1]
679
+ - [observable condition 2]
680
+
681
+ ### `R2` <short title>
682
+ Description:
683
+ Acceptance criteria:
684
+ - [...]
685
+
686
+ ## Out of Scope
687
+
688
+ - `OOS1`: ...
689
+ - `OOS2`: ...
690
+
691
+ ## Constraints
692
+
693
+ - ...
694
+
695
+ ## Coverage Gate
696
+ ...
697
+ Coverage: PASS
698
+
699
+ ## Approval Gate
700
+ ...
701
+ Approval: PASS
702
+ ```
703
+
704
+ ## Phase 1 Template (`01-as-is.md`)
705
+
706
+ Required outcome:
707
+ - novice-runnable repro
708
+ - current behavior tied to `R#`
709
+ - concrete code pointers
710
+ - known unknowns
711
+
712
+ ```md
713
+ Run: `/.recursive/run/<run-id>/`
714
+ Phase: `01 AS-IS`
715
+ Status: `DRAFT`
716
+ Inputs:
717
+ - `/.recursive/run/<run-id>/00-requirements.md`
718
+ - `/.recursive/run/<run-id>/addenda/00-requirements.addendum-01.md` [if present]
719
+ Outputs:
720
+ - `/.recursive/run/<run-id>/01-as-is.md`
721
+ Scope note: This document captures current behavior and evidence before changes.
722
+
723
+ ## TODO
724
+
725
+ - [ ] Read and understand requirements from Phase 1
726
+ - [ ] Read and understand requirements from Phase 0
727
+ - [ ] Create novice-runnable reproduction steps
728
+ - [ ] Document current behavior for each requirement (R1, R2, ...)
729
+ - [ ] Identify and record relevant code pointers
730
+ - [ ] List known unknowns
731
+ - [ ] Gather evidence (logs, screenshots, outputs)
732
+ - [ ] Review relevant prior recursive evidence for the affected area
733
+ - [ ] Assemble audit context bundle
734
+ - [ ] Run phase audit
735
+ - [ ] Repair gaps and re-audit until `Audit: PASS`
736
+ - [ ] Create traceability mapping
737
+ - [ ] Complete Coverage Gate checklist
738
+ - [ ] Complete Approval Gate checklist
739
+
740
+ ## Reproduction Steps (Novice-Runnable)
741
+
742
+ 1. ...
743
+ 2. ...
744
+ 3. ...
745
+
746
+ ## Current Behavior by Requirement
747
+
748
+ - `R1`: [what currently happens]
749
+ - `R2`: [what currently happens]
750
+
751
+ ## Relevant Code Pointers
752
+
753
+ - `path/to/file.ext`: [why relevant]
754
+ - `path/to/other.ext`: [why relevant]
755
+
756
+ ## Known Unknowns
757
+
758
+ - ...
759
+
760
+ ## Evidence
761
+
762
+ - Command output: ...
763
+ - Log snippet: ...
764
+ - UI observation: ...
765
+
766
+ ## Audit Context
767
+
768
+ Audit Execution Mode: self-audit / subagent
769
+ Subagent Availability: available / unavailable
770
+ Audit Inputs Provided:
771
+ - `/.recursive/run/<run-id>/00-requirements.md`
772
+ - `/.recursive/run/<run-id>/00-worktree.md`
773
+ - Changed files:
774
+ - none yet / `path`
775
+ - Targeted code references:
776
+ - `path/to/file`
777
+
778
+ ## Effective Inputs Re-read
779
+
780
+ - `/.recursive/run/<run-id>/00-requirements.md`
781
+ - [phase-local addenda]
782
+
783
+ ## Prior Recursive Evidence Reviewed
784
+
785
+ - Prior run id:
786
+ - Docs read:
787
+ - Reused insight:
788
+ - Superseded or contradicted:
789
+
790
+ ## Earlier Phase Reconciliation
791
+
792
+ - `00-requirements.md`:
793
+ - Requirement coverage status:
794
+ - Unknowns carried forward:
795
+
796
+ ## Worktree Diff Audit
797
+
798
+ - Diff basis used: `git diff --name-only <base-commit>..HEAD`
799
+ - Base branch:
800
+ - Worktree branch:
801
+ - Base commit:
802
+ - Planned or claimed changed files:
803
+ - none yet / `path`
804
+ - Actual changed files reviewed:
805
+ - none yet / `path`
806
+ - Unexplained drift:
807
+ - none
808
+
809
+ ## Gaps Found
810
+
811
+ - none / [list gaps]
812
+
813
+ ## Repair Work Performed
814
+
815
+ - none / [list repairs]
816
+
817
+ ## Audit Verdict
818
+
819
+ - Summary:
820
+ - Audit: FAIL / PASS
821
+
822
+ ## Traceability
823
+ ...
824
+
825
+ ## Coverage Gate
826
+ ...
827
+ Coverage: PASS
828
+
829
+ ## Approval Gate
830
+ ...
831
+ Approval: PASS
832
+ ```
833
+
834
+ ## Phase 1.5 Template (`01.5-root-cause.md`) - Debug Mode Only
835
+
836
+ Required outcome:
837
+ - systematic root cause analysis for bug fixes
838
+ - error analysis, reproduction verification, data flow tracing
839
+ - documented hypothesis testing
840
+ - root cause summary for Phase 2 planning
841
+
842
+ **Use when:** Requirement involves fixing a bug, test failure, or investigating unexpected behavior.
843
+
844
+ ```md
845
+ Run: `/.recursive/run/<run-id>/`
846
+ Phase: `01.5 Root Cause Analysis`
847
+ Status: `DRAFT`
848
+ Inputs:
849
+ - `/.recursive/run/<run-id>/01-as-is.md`
850
+ - [relevant addenda]
851
+ Outputs:
852
+ - `/.recursive/run/<run-id>/01.5-root-cause.md`
853
+ Scope note: This document records systematic debugging process and identified root cause before any fix is attempted.
854
+
855
+ ## TODO
856
+
857
+ - [ ] Analyze error messages and stack traces
858
+ - [ ] Verify reproduction (confirm bug is reproducible)
859
+ - [ ] Review recent changes (git history, dependencies)
860
+ - [ ] Gather evidence (logs, data flow, state inspection)
861
+ - [ ] Trace data flow to identify source
862
+ - [ ] Analyze patterns (working vs broken comparisons)
863
+ - [ ] Form and test hypotheses
864
+ - [ ] Confirm root cause (not just symptom)
865
+ - [ ] Define fix strategy for Phase 2
866
+ - [ ] Assemble audit context bundle
867
+ - [ ] Run phase audit
868
+ - [ ] Repair gaps and re-audit until `Audit: PASS`
869
+ - [ ] Complete Coverage Gate checklist
870
+ - [ ] Complete Approval Gate checklist
871
+
872
+ ## Error Analysis
873
+
874
+ **Error Message:** [verbatim]
875
+ **Stack Trace:** [key frames]
876
+ **File:Line:** [locations]
877
+ **Key Insight:** [what the error is telling you]
878
+
879
+ ## Reproduction Verification
880
+
881
+ **Steps:**
882
+ 1. [exact step]
883
+ 2. [exact step]
884
+ 3. [exact step]
885
+
886
+ **Reproducible:** Yes / No / Intermittent
887
+ **Frequency:** [X out of Y attempts]
888
+ **Deterministic:** Yes / No
889
+
890
+ ## Recent Changes Analysis
891
+
892
+ **Git History:** [relevant commits]
893
+ **Dependency Changes:** [if applicable]
894
+ **Environment:** [OS, runtime versions]
895
+ **Likely Culprit:** [most suspicious change]
896
+
897
+ ## Evidence Gathering (Multi-Layer if applicable)
898
+
899
+ **Layer 1: [Component]**
900
+ - Input: [data]
901
+ - Output: [data]
902
+ - Status: ? Working / ? Broken
903
+
904
+ **Failure Boundary:** [where it breaks]
905
+
906
+ ## Data Flow Trace
907
+
908
+ **Error Location:** [file:line - function]
909
+ **Bad Value:** [what was wrong]
910
+
911
+ **Call Stack (backward):**
912
+ 1. `functionA()` at fileA:line - received [value]
913
+ 2. `functionB()` at fileB:line - passed [value]
914
+ 3. [source] `functionC()` at fileC:line - ORIGIN
915
+
916
+ ## Pattern Analysis
917
+
918
+ **Working Example:** [file:location]
919
+ **Broken Code:** [file:location]
920
+
921
+ **Key Differences:**
922
+ | Aspect | Working | Broken |
923
+ |--------|---------|--------|
924
+ | [X] | [value] | [value] |
925
+
926
+ ## Hypothesis Testing
927
+
928
+ ### Hypothesis 1
929
+ **Statement:** [clear hypothesis]
930
+ **Test:** [minimal change]
931
+ **Result:** [confirmed/rejected]
932
+
933
+ ### Hypothesis 2 (if needed)
934
+ [...]
935
+
936
+ **Confirmed Root Cause:** [final hypothesis]
937
+
938
+ ## Root Cause Summary
939
+
940
+ **Root Cause:** [one sentence]
941
+ **Location:** [file:line]
942
+ **Detailed Explanation:** [paragraph]
943
+ **Fix Strategy:** [approach for Phase 2]
944
+ **Test Strategy:** [how to verify fix]
945
+
946
+ ## Audit Context
947
+
948
+ Audit Execution Mode: self-audit / subagent
949
+ Subagent Availability: available / unavailable
950
+ Audit Inputs Provided:
951
+ - `/.recursive/run/<run-id>/01-as-is.md`
952
+ - `/.recursive/run/<run-id>/00-worktree.md`
953
+ - Changed files:
954
+ - `path/to/file`
955
+ - Targeted code references:
956
+ - `path/to/file`
957
+
958
+ ## Effective Inputs Re-read
959
+
960
+ - `/.recursive/run/<run-id>/01-as-is.md`
961
+ - [phase-local addenda]
962
+
963
+ ## Earlier Phase Reconciliation
964
+
965
+ - `01-as-is.md`:
966
+ - Reproduction status:
967
+ - Evidence carried forward:
968
+
969
+ ## Worktree Diff Audit
970
+
971
+ - Diff basis used: `git diff --name-only <base-commit>..HEAD`
972
+ - Base branch:
973
+ - Worktree branch:
974
+ - Base commit:
975
+ - Planned or claimed changed files:
976
+ - `path/to/file`
977
+ - Actual changed files reviewed:
978
+ - `path/to/file`
979
+ - Unexplained drift:
980
+ - none
981
+
982
+ ## Gaps Found
983
+
984
+ - none / [list unresolved gaps]
985
+
986
+ ## Repair Work Performed
987
+
988
+ - none / [list repairs]
989
+
990
+ ## Audit Verdict
991
+
992
+ - Summary:
993
+ - Audit: FAIL / PASS
994
+
995
+ ## Traceability
996
+
997
+ - R# (Bug fix requirement) -> Root cause identified at [location] | Evidence: [section]
998
+
999
+ ## Coverage Gate
1000
+
1001
+ - [ ] Error messages analyzed
1002
+ - [ ] Reproduction verified
1003
+ - [ ] Recent changes reviewed
1004
+ - [ ] Data flow traced to source
1005
+ - [ ] Pattern analysis completed
1006
+ - [ ] Hypothesis tested and confirmed
1007
+ - [ ] Root cause documented (not just symptom)
1008
+ - [ ] Fix strategy defined
1009
+
1010
+ Coverage: PASS / FAIL
1011
+
1012
+ ## Approval Gate
1013
+
1014
+ - [ ] Root cause identified at source (not just symptom location)
1015
+ - [ ] Fix approach clear and minimal
1016
+ - [ ] Test strategy defined
1017
+ - [ ] No "quick fix" attempts made
1018
+ - [ ] Ready to proceed to Phase 2 with fix plan
1019
+
1020
+ Approval: PASS / FAIL
1021
+ ```
1022
+
1023
+ ## Phase 2 Template (`02-to-be-plan.md`, ExecPlan Grade)
1024
+
1025
+ Required outcome:
1026
+ - concrete edits by file and location
1027
+ - exact commands
1028
+ - tests to add/run
1029
+ - manual QA scenarios
1030
+ - recovery/idempotence
1031
+ - traceability mapping `R# -> planned change + validation`
1032
+ - sub-phases (`SP1`, `SP2`, ...) when scope/risk is large
1033
+
1034
+ ```md
1035
+ Run: `/.recursive/run/<run-id>/`
1036
+ Phase: `02 TO-BE plan`
1037
+ Status: `DRAFT`
1038
+ Inputs:
1039
+ - `/.recursive/run/<run-id>/01-as-is.md`
1040
+ - `/.recursive/run/<run-id>/00-requirements.md`
1041
+ - `/.recursive/run/<run-id>/addenda/01-as-is.addendum-01.md` [if present]
1042
+ Outputs:
1043
+ - `/.recursive/run/<run-id>/02-to-be-plan.md`
1044
+ Scope note: This document defines the implementation and validation plan.
1045
+
1046
+ ## TODO
1047
+
1048
+ - [ ] Read Phase 1 (AS-IS) and Phase 0 (Requirements) artifacts
1049
+ - [ ] If Phase 1.5 exists: incorporate root cause findings
1050
+ - [ ] Define sub-phases (SP1, SP2, ...) if scope/risk is large
1051
+ - [ ] Specify concrete file changes (what, where, how)
1052
+ - [ ] Define implementation steps in sequence
1053
+ - [ ] Design testing strategy (new + regression + guardrail)
1054
+ - [ ] Document Playwright test plan (if applicable)
1055
+ - [ ] Define manual QA scenarios
1056
+ - [ ] Review relevant prior recursive evidence for the affected area
1057
+ - [ ] Assemble audit context bundle
1058
+ - [ ] Run phase audit
1059
+ - [ ] Repair gaps and re-audit until `Audit: PASS`
1060
+ - [ ] Create traceability mapping (R# -> changes -> validation)
1061
+ - [ ] Complete Coverage Gate checklist
1062
+ - [ ] Complete Approval Gate checklist
1063
+
1064
+ ## Planned Changes by File
1065
+
1066
+ - `path/to/file.ext`: [exact change]
1067
+ - `path/to/file2.ext`: [exact change]
1068
+
1069
+ ## Implementation Steps
1070
+
1071
+ 1. ...
1072
+ 2. ...
1073
+ 3. ...
1074
+
1075
+ ## Testing Strategy
1076
+
1077
+ - New behavior tests: ...
1078
+ - Regression tests: ...
1079
+ - Guardrail tests: ...
1080
+ - Commands:
1081
+ - `...`
1082
+ - `...`
1083
+
1084
+ ## Playwright Plan (if applicable)
1085
+
1086
+ - Tags: `@recursive:<run-id>`, `@sp1`, `@smoke`
1087
+ - Tier A command(s): `...`
1088
+ - Tier B command(s): `...`
1089
+ - Evidence outputs: `playwright-report/`, `test-results/`
1090
+
1091
+ ## Manual QA Scenarios
1092
+
1093
+ 1. Scenario:
1094
+ - Steps:
1095
+ - Expected:
1096
+
1097
+ 2. Scenario:
1098
+ - Steps:
1099
+ - Expected:
1100
+
1101
+ ## Idempotence and Recovery
1102
+
1103
+ - Re-run safety notes:
1104
+ - Rollback notes:
1105
+
1106
+ ## Implementation Sub-phases
1107
+
1108
+ ### `SP1` <name>
1109
+ Scope and requirement mapping:
1110
+ - Covers: `R1`, `R3`
1111
+
1112
+ Implementation checklist:
1113
+ - [ ] edit `path/to/file.ext` ...
1114
+ - [ ] add test `path/to/test.spec.ts` ...
1115
+
1116
+ Tests for this sub-phase:
1117
+ - `...`
1118
+ - Pass criteria: ...
1119
+
1120
+ Sub-phase acceptance:
1121
+ - ...
1122
+
1123
+ ### `SP2` <name>
1124
+ [same structure]
1125
+
1126
+ ## Audit Context
1127
+
1128
+ Audit Execution Mode: self-audit / subagent
1129
+ Subagent Availability: available / unavailable
1130
+ Audit Inputs Provided:
1131
+ - `/.recursive/run/<run-id>/00-requirements.md`
1132
+ - `/.recursive/run/<run-id>/00-worktree.md`
1133
+ - `/.recursive/run/<run-id>/01-as-is.md`
1134
+ - [relevant addenda]
1135
+ - Changed files:
1136
+ - anticipated `path/to/file`
1137
+ - Targeted code references:
1138
+ - `path/to/file`
1139
+
1140
+ ## Effective Inputs Re-read
1141
+
1142
+ - `/.recursive/run/<run-id>/00-requirements.md`
1143
+ - `/.recursive/run/<run-id>/01-as-is.md`
1144
+ - [phase-local addenda]
1145
+
1146
+ ## Prior Recursive Evidence Reviewed
1147
+
1148
+ - Prior run id:
1149
+ - Docs read:
1150
+ - Reused insight:
1151
+ - Superseded or contradicted:
1152
+
1153
+ ## Earlier Phase Reconciliation
1154
+
1155
+ - `00-requirements.md`:
1156
+ - each in-scope `R#` planned:
1157
+ - `01-as-is.md`:
1158
+ - current behavior reconciled:
1159
+ - `01.5-root-cause.md`:
1160
+ - fix strategy incorporated:
1161
+
1162
+ ## Worktree Diff Audit
1163
+
1164
+ - Diff basis used: `git diff --name-only <base-commit>..HEAD`
1165
+ - Base branch:
1166
+ - Worktree branch:
1167
+ - Base commit:
1168
+ - Planned or claimed changed files:
1169
+ - `path/to/file`
1170
+ - Actual changed files reviewed:
1171
+ - none yet / `path/to/file`
1172
+ - Unexplained drift:
1173
+ - none
1174
+
1175
+ Note: incidental runtime byproducts such as `__pycache__/`, `*.pyc`, `.pytest_cache/`, `.mypy_cache/`, and `.ruff_cache/` are excluded from meaningful diff audit unless the repository intentionally tracks them.
1176
+
1177
+ ## Gaps Found
1178
+
1179
+ - none / [list planning gaps or missing concreteness]
1180
+
1181
+ ## Repair Work Performed
1182
+
1183
+ - none / [list plan repairs made before re-audit]
1184
+
1185
+ ## Audit Verdict
1186
+
1187
+ - Summary:
1188
+ - Audit: FAIL / PASS
1189
+
1190
+ ## Traceability
1191
+ ...
1192
+
1193
+ ## Coverage Gate
1194
+ ...
1195
+ Coverage: PASS
1196
+
1197
+ ## Approval Gate
1198
+ ...
1199
+ Approval: PASS
1200
+ ```
1201
+
1202
+ ## Phase 3 Template (`03-implementation-summary.md`)
1203
+
1204
+ Required outcome:
1205
+ - what changed, where, why
1206
+ - implementation evidence
1207
+ - **TDD compliance log (RED-GREEN-REFACTOR for each requirement)**
1208
+ - deviations from plan (if any)
1209
+
1210
+ ```md
1211
+ Run: `/.recursive/run/<run-id>/`
1212
+ Phase: `03 Implementation`
1213
+ Status: `DRAFT`
1214
+ Inputs:
1215
+ - `/.recursive/run/<run-id>/02-to-be-plan.md`
1216
+ - `/.recursive/run/<run-id>/addenda/02-to-be-plan.addendum-01.md` [if present]
1217
+ Outputs:
1218
+ - `/.recursive/run/<run-id>/03-implementation-summary.md`
1219
+ Scope note: This document records completed code changes, TDD compliance, and implementation evidence.
1220
+
1221
+ ## TODO
1222
+
1223
+ - [ ] Read locked Phase 2 (TO-BE) plan
1224
+ - [ ] Determine execution mode (Parallel vs Sequential)
1225
+ - [ ] For each sub-phase (SP1, SP2, ...):
1226
+ - [ ] Implement per plan (TDD discipline)
1227
+ - [ ] Write tests BEFORE code (RED phase)
1228
+ - [ ] Make tests pass (GREEN phase)
1229
+ - [ ] Refactor while keeping tests green
1230
+ - [ ] Self-review / subagent review
1231
+ - [ ] Run integration tests
1232
+ - [ ] Complete TDD Compliance Log for all requirements
1233
+ - [ ] Document any plan deviations
1234
+ - [ ] Record implementation evidence (diffs, logs)
1235
+ - [ ] Assemble audit context bundle
1236
+ - [ ] Run implementation audit against requirements, plan, and actual diff
1237
+ - [ ] Repair gaps and re-audit until `Audit: PASS`
1238
+ - [ ] Complete Coverage Gate checklist
1239
+ - [ ] Complete Approval Gate checklist
1240
+
1241
+ ## Changes Applied
1242
+
1243
+ - `path/to/file.ext`: [change summary]
1244
+ - `path/to/file2.ext`: [change summary]
1245
+
1246
+ ## Sub-phase Implementation Summary
1247
+
1248
+ - `SP1`: [what shipped, files touched, notes]
1249
+ - `SP2`: [what shipped, files touched, notes]
1250
+
1251
+ ## TDD Compliance Log
1252
+
1253
+ **The Iron Law:** NO PRODUCTION CODE WITHOUT A FAILING TEST FIRST.
1254
+
1255
+ TDD Mode: strict / pragmatic
1256
+
1257
+ RED Evidence:
1258
+ - `/.recursive/run/<run-id>/evidence/logs/red/<file>.log`
1259
+
1260
+ GREEN Evidence:
1261
+ - `/.recursive/run/<run-id>/evidence/logs/green/<file>.log`
1262
+
1263
+ ### Requirement R1 ([description])
1264
+
1265
+ **Test:** `path/to/test.spec.ts` - "[test name]"
1266
+
1267
+ **RED Phase** ([ISO8601 timestamp]):
1268
+ ```bash
1269
+ [exact command run]
1270
+ [test failure output - showing it failed correctly]
1271
+ ```
1272
+ - Expected failure: [what should fail]
1273
+ - Actual failure: [what actually failed]
1274
+ - RED verified: ? / ?
1275
+
1276
+ **GREEN Phase** ([ISO8601 timestamp]):
1277
+ - Implementation: [minimal change made]
1278
+ ```bash
1279
+ [exact command run]
1280
+ [test pass output]
1281
+ ```
1282
+ - GREEN verified: ? / ?
1283
+
1284
+ **REFACTOR Phase** ([ISO8601 timestamp]):
1285
+ - Cleanups: [description of improvements]
1286
+ - All tests still passing: ? / ?
1287
+
1288
+ **Final State:** [All tests passing / Issues noted]
1289
+
1290
+ ### Requirement R2 (Bug Fix - Regression Test)
1291
+
1292
+ **Regression Test:** `path/to/regression.test.ts` - "[test name]"
1293
+
1294
+ **RED Phase** ([ISO8601 timestamp]):
1295
+ - Bug reproduced: [evidence]
1296
+ - RED verified: ? / ?
1297
+
1298
+ **GREEN Phase** ([ISO8601 timestamp]):
1299
+ - Fix applied: [minimal change]
1300
+ - GREEN verified: ? / ?
1301
+
1302
+ **REFACTOR:** [N/A or description]
1303
+
1304
+ **Final State:** [Test passes, bug fixed]
1305
+
1306
+ ### TDD Red Flags Check
1307
+
1308
+ - [ ] No code written before failing test
1309
+ - [ ] All RED phases documented with failure output
1310
+ - [ ] All GREEN phases documented with minimal implementation
1311
+ - [ ] No tests passing immediately (would indicate wrong test)
1312
+ - [ ] No "tests to be added later"
1313
+
1314
+ ## Pragmatic TDD Exception
1315
+
1316
+ Only include this section when `TDD Mode: pragmatic`.
1317
+
1318
+ Exception reason:
1319
+ Compensating validation:
1320
+ - `/.recursive/run/<run-id>/evidence/<supporting-file>`
1321
+
1322
+ ## Plan Deviations
1323
+
1324
+ - Deviation:
1325
+ - Why:
1326
+ - Impact:
1327
+ - Evidence:
1328
+
1329
+ ## Implementation Evidence
1330
+
1331
+ - Diff pointers:
1332
+ - Runtime evidence:
1333
+ - Build/lint results:
1334
+
1335
+ ## Audit Context
1336
+
1337
+ Audit Execution Mode: self-audit / subagent
1338
+ Subagent Availability: available / unavailable
1339
+ Audit Inputs Provided:
1340
+ - `/.recursive/run/<run-id>/00-requirements.md`
1341
+ - `/.recursive/run/<run-id>/00-worktree.md`
1342
+ - `/.recursive/run/<run-id>/02-to-be-plan.md`
1343
+ - [relevant addenda]
1344
+ - Changed files:
1345
+ - `path/to/file`
1346
+ - Targeted code references:
1347
+ - `path/to/file`
1348
+ - Review inputs:
1349
+ - failing tests
1350
+ - changed code
1351
+ - build/test evidence
1352
+
1353
+ ## Effective Inputs Re-read
1354
+
1355
+ - `/.recursive/run/<run-id>/00-requirements.md`
1356
+ - `/.recursive/run/<run-id>/02-to-be-plan.md`
1357
+ - [phase-local addenda]
1358
+
1359
+ ## Earlier Phase Reconciliation
1360
+
1361
+ - `00-requirements.md`:
1362
+ - in-scope `R#` implemented:
1363
+ - `02-to-be-plan.md`:
1364
+ - planned steps/sub-phases completed:
1365
+ - deviations explained:
1366
+
1367
+ ## Worktree Diff Audit
1368
+
1369
+ - Diff basis used: `git diff --name-only <base-commit>..HEAD`
1370
+ - Base branch:
1371
+ - Worktree branch:
1372
+ - Base commit:
1373
+ - Planned or claimed changed files:
1374
+ - `path/to/file`
1375
+ - Actual changed files reviewed:
1376
+ - `path/to/file`
1377
+ - Unexplained drift:
1378
+ - none / [explain]
1379
+
1380
+ ## Gaps Found
1381
+
1382
+ - none / [list unfinished requirements, drift, or missing evidence]
1383
+
1384
+ ## Repair Work Performed
1385
+
1386
+ - none / [list repairs completed before re-audit]
1387
+
1388
+ ## Audit Verdict
1389
+
1390
+ - Summary:
1391
+ - Audit: FAIL / PASS
1392
+
1393
+ ## Traceability
1394
+ ...
1395
+
1396
+ ## Coverage Gate
1397
+
1398
+ - [ ] All requirements (R1..Rn) have implementation
1399
+ - [ ] All sub-phases completed
1400
+ - [ ] TDD Compliance Log complete for all requirements
1401
+ - [ ] No production code without preceding failing test
1402
+ - [ ] Plan deviations documented (if any)
1403
+ - [ ] Implementation evidence recorded
1404
+
1405
+ TDD Compliance: PASS / FAIL
1406
+ Coverage: PASS / FAIL
1407
+
1408
+ ## Approval Gate
1409
+
1410
+ - [ ] Implementation matches Phase 2 TO-BE plan (or deviations documented)
1411
+ - [ ] All tests passing
1412
+ - [ ] Build/lint clean
1413
+ - [ ] TDD Iron Law followed (no code before tests)
1414
+ - [ ] `Audit: PASS` recorded before phase lock
1415
+
1416
+ Approval: PASS / FAIL
1417
+ ```
1418
+
1419
+ ## Phase 3.5 Template (`03.5-code-review.md`) - Optional
1420
+
1421
+ Required outcome:
1422
+ - Independent review of Phase 3 implementation against plan
1423
+ - Code quality assessment
1424
+ - Issue classification (Critical/Important/Minor)
1425
+ - Clear verdict (Approved / Changes Required)
1426
+
1427
+ ```md
1428
+ Run: `/.recursive/run/<run-id>/`
1429
+ Phase: `03.5 Code Review`
1430
+ Status: `DRAFT`
1431
+ Inputs:
1432
+ - `/.recursive/run/<run-id>/02-to-be-plan.md`
1433
+ - `/.recursive/run/<run-id>/03-implementation-summary.md`
1434
+ - Git range: BASE_SHA..HEAD_SHA
1435
+ Outputs:
1436
+ - `/.recursive/run/<run-id>/03.5-code-review.md`
1437
+ Scope note: This document records independent review of implementation against plan and coding standards.
1438
+
1439
+ ## TODO
1440
+
1441
+ - [ ] Read Phase 2 plan and Phase 3 implementation summary
1442
+ - [ ] Review git diff (BASE_SHA..HEAD_SHA)
1443
+ - [ ] Assess plan alignment for each requirement (R1, R2, ...)
1444
+ - [ ] Assess plan alignment for each sub-phase (SP1, SP2, ...)
1445
+ - [ ] Evaluate code quality (architecture, naming, error handling)
1446
+ - [ ] Evaluate test quality (coverage, edge cases)
1447
+ - [ ] Verify TDD compliance
1448
+ - [ ] Categorize issues (Critical/Important/Minor)
1449
+ - [ ] Document positive findings
1450
+ - [ ] Record recommendations
1451
+ - [ ] Render verdict (Approved / Changes Required)
1452
+ - [ ] Generate or refresh the canonical review bundle
1453
+ - [ ] Run review audit against requirements, plan, and actual diff
1454
+ - [ ] Repair issues and re-audit until `Audit: PASS`
1455
+ - [ ] Complete Coverage Gate checklist
1456
+ - [ ] Complete Approval Gate checklist
1457
+
1458
+ ## Review Scope
1459
+
1460
+ - Sub-phases reviewed: SP1, SP2, ...
1461
+ - Git range reviewed: [BASE_SHA]..[HEAD_SHA]
1462
+
1463
+ ## Plan Alignment Assessment
1464
+
1465
+ - **R1**: [description]
1466
+ - Plan requirement: [what was planned]
1467
+ - Implementation: [what was done]
1468
+ - Aligned: OK / WARN / FAIL
1469
+ - Notes: [deviations if any]
1470
+
1471
+ - **SP1**: [description]
1472
+ - Plan specification: [what was specified]
1473
+ - Implementation: [what was done]
1474
+ - Aligned: OK / WARN / FAIL
1475
+ - Notes: [deviations if any]
1476
+
1477
+ ## Code Quality Assessment
1478
+
1479
+ ### Architecture & Design
1480
+ - SOLID principles: OK / WARN / FAIL
1481
+ - Separation of concerns: OK / WARN / FAIL
1482
+ - Integration with existing code: OK / WARN / FAIL
1483
+
1484
+ ### Code Quality
1485
+ - Naming conventions: OK / WARN / FAIL
1486
+ - Error handling: OK / WARN / FAIL
1487
+ - Type safety: OK / WARN / FAIL
1488
+ - Maintainability: OK / WARN / FAIL
1489
+
1490
+ ### Test Quality
1491
+ - Test coverage adequate: OK / WARN / FAIL
1492
+ - Test quality: OK / WARN / FAIL
1493
+ - Edge cases covered: OK / WARN / FAIL
1494
+
1495
+ ### TDD Compliance
1496
+ - All production code preceded by failing tests: OK / WARN / FAIL
1497
+ - TDD cycles documented: OK / WARN / FAIL
1498
+ - Strict mode includes concrete RED and GREEN evidence paths: OK / WARN / FAIL
1499
+ - Pragmatic mode has explicit exception rationale and compensating evidence: OK / WARN / FAIL
1500
+ - No evidence of "code first, test later": OK / WARN / FAIL
1501
+
1502
+ ## Issues Found
1503
+
1504
+ ### Critical (must fix before proceeding)
1505
+ 1. **[Issue name]**
1506
+ - **Location:** `file:line`
1507
+ - **Problem:** [description]
1508
+ - **Recommendation:** [specific fix]
1509
+
1510
+ ### Important (should fix)
1511
+ 1. **[Issue name]**
1512
+ - **Location:** `file:line`
1513
+ - **Problem:** [description]
1514
+ - **Recommendation:** [specific fix]
1515
+
1516
+ ### Minor (suggestions)
1517
+ 1. **[Issue name]**
1518
+ - **Suggestion:** [description]
1519
+
1520
+ ## Positive Findings
1521
+
1522
+ - [What was done well]
1523
+
1524
+ ## Recommendations
1525
+
1526
+ - **Immediate:** [what to fix now]
1527
+ - **Future:** [improvements for later]
1528
+
1529
+ ## Verdict
1530
+
1531
+ - [ ] **APPROVED** - Ready to proceed to Phase 4
1532
+ - [ ] **APPROVED WITH NOTES** - Minor issues, can proceed
1533
+ - [ ] **CHANGES REQUIRED** - Fix issues, then re-review
1534
+
1535
+ ## Review Metadata
1536
+
1537
+ - Reviewer: [agent name / self-review]
1538
+ - Review Execution Mode: subagent / self-audit
1539
+ - Review Bundle Path: `/.recursive/run/<run-id>/evidence/review-bundles/<bundle>.md`
1540
+ - Bundle Scope Summary: [what the bundle covered]
1541
+ - Reviewer Receipt: [review comment id / local note / n/a]
1542
+ - Review duration: [time spent]
1543
+ - Files reviewed: [count]
1544
+ - Lines of code reviewed: [count]
1545
+
1546
+ ## Audit Context
1547
+
1548
+ Audit Execution Mode: self-audit / subagent
1549
+ Subagent Availability: available / unavailable
1550
+ Audit Inputs Provided:
1551
+ - `/.recursive/run/<run-id>/00-requirements.md`
1552
+ - `/.recursive/run/<run-id>/00-worktree.md`
1553
+ - `/.recursive/run/<run-id>/02-to-be-plan.md`
1554
+ - `/.recursive/run/<run-id>/03-implementation-summary.md`
1555
+ - Changed files:
1556
+ - `path/to/file`
1557
+ - Targeted code references:
1558
+ - `path/to/file`
1559
+
1560
+ ## Effective Inputs Re-read
1561
+
1562
+ - `/.recursive/run/<run-id>/00-requirements.md`
1563
+ - `/.recursive/run/<run-id>/02-to-be-plan.md`
1564
+ - `/.recursive/run/<run-id>/03-implementation-summary.md`
1565
+ - [phase-local addenda]
1566
+
1567
+ ## Earlier Phase Reconciliation
1568
+
1569
+ - Requirements vs implementation:
1570
+ - Plan vs implementation:
1571
+ - Prior fixes vs remaining issues:
1572
+
1573
+ ## Worktree Diff Audit
1574
+
1575
+ - Diff basis used: `git diff --name-only <base-commit>..HEAD`
1576
+ - Base branch:
1577
+ - Worktree branch:
1578
+ - Base commit:
1579
+ - Planned or claimed changed files:
1580
+ - `path/to/file`
1581
+ - Actual changed files reviewed:
1582
+ - `path/to/file`
1583
+ - Unexplained drift:
1584
+ - none / [explain]
1585
+
1586
+ ## Gaps Found
1587
+
1588
+ - none / [list blocking issues, drift, or missing evidence]
1589
+
1590
+ ## Repair Work Performed
1591
+
1592
+ - none / [list repairs completed before re-audit]
1593
+
1594
+ ## Audit Verdict
1595
+
1596
+ - Summary:
1597
+ - Audit: FAIL / PASS
1598
+
1599
+ ## Traceability
1600
+ ...
1601
+
1602
+ ## Coverage Gate
1603
+
1604
+ - [ ] All sub-phases reviewed
1605
+ - [ ] Plan alignment verified for all requirements
1606
+ - [ ] Code quality assessed
1607
+ - [ ] Issues categorized by severity
1608
+ - [ ] Verdict recorded
1609
+ - [ ] `Audit: PASS` recorded before phase lock
1610
+
1611
+ Coverage: PASS / FAIL
1612
+
1613
+ ## Approval Gate
1614
+
1615
+ - [ ] Review completed objectively
1616
+ - [ ] Issues clearly documented
1617
+ - [ ] Verdict justified
1618
+ - [ ] Ready for Phase 4 (if approved)
1619
+
1620
+ Approval: PASS / FAIL
1621
+ ```
1622
+
1623
+ ## Phase 4 Template (`04-test-summary.md`)
1624
+
1625
+ Required outcome:
1626
+ - pre-test implementation audit against requirements and TO-BE plan
1627
+ - exact commands executed
1628
+ - pass/fail outcomes
1629
+ - evidence artifact locations (standardized under `/.recursive/run/<run-id>/evidence/`)
1630
+ - flake/retry notes
1631
+ - parallel test execution summary (if applicable)
1632
+
1633
+ ```md
1634
+ Run: `/.recursive/run/<run-id>/`
1635
+ Phase: `04 Test Summary`
1636
+ Status: `DRAFT`
1637
+ Inputs:
1638
+ - `/.recursive/run/<run-id>/02-to-be-plan.md`
1639
+ - `/.recursive/run/<run-id>/03-implementation-summary.md`
1640
+ - `/.recursive/run/<run-id>/03.5-code-review.md` [if present]
1641
+ - [relevant addenda]
1642
+ Outputs:
1643
+ - `/.recursive/run/<run-id>/04-test-summary.md`
1644
+ Scope note: This document records test execution evidence and readiness.
1645
+
1646
+ ## TODO
1647
+
1648
+ - [ ] Read Phase 2 plan and Phase 3 implementation summary
1649
+ - [ ] Audit implementation summary against `00-requirements.md` and `02-to-be-plan.md`
1650
+ - [ ] Determine test execution mode (Parallel vs Sequential)
1651
+ - [ ] Execute unit tests (document commands and results)
1652
+ - [ ] Execute integration tests (document commands and results)
1653
+ - [ ] Execute E2E Tier A tests (document commands and results)
1654
+ - [ ] Execute Tier B regression tests (if applicable)
1655
+ - [ ] Document any failures and diagnostics
1656
+ - [ ] Note any flake/retry occurrences
1657
+ - [ ] Verify TDD compliance (all Phase 3 tests passing)
1658
+ - [ ] Review relevant prior recursive evidence for the affected area
1659
+ - [ ] Assemble audit context bundle
1660
+ - [ ] Run pre-test audit and post-test audit
1661
+ - [ ] Repair gaps and re-audit until `Audit: PASS`
1662
+ - [ ] Complete Coverage Gate checklist
1663
+ - [ ] Complete Approval Gate checklist
1664
+
1665
+ ## Pre-Test Implementation Audit
1666
+
1667
+ - Requirement alignment (`00-requirements.md`): list each requirement and confirm implemented/not implemented with evidence.
1668
+ - Plan alignment (`02-to-be-plan.md`): list planned steps/sub-phases and confirm implemented/not implemented with evidence.
1669
+ - Mismatches found:
1670
+ - [ ] None
1671
+ - [ ] Yes (document each mismatch and required addendum or fix before proceeding)
1672
+
1673
+ ## Environment
1674
+
1675
+ - OS:
1676
+ - Runtime versions:
1677
+ - Test framework versions:
1678
+ - Base URL / server mode:
1679
+
1680
+ ## Execution Mode
1681
+
1682
+ - **Mode:** Parallel / Sequential
1683
+ - **Subagent Usage:**
1684
+ - Unit tests: [subagent name] / Main agent
1685
+ - Integration tests: [subagent name] / Main agent
1686
+ - E2E tests: [subagent name] / Main agent
1687
+ - **Parallel execution time:** [X] minutes (vs [Y] estimated sequential)
1688
+
1689
+ ## Commands Executed (Exact)
1690
+
1691
+ - `...`
1692
+ - `...`
1693
+
1694
+ ## Results Summary
1695
+
1696
+ - Total:
1697
+ - Passed:
1698
+ - Failed:
1699
+ - Skipped:
1700
+
1701
+ ## Evidence and Artifacts
1702
+
1703
+ Store and reference artifacts under:
1704
+ - `/.recursive/run/<run-id>/evidence/`
1705
+ - `evidence/screenshots/`
1706
+ - `evidence/logs/`
1707
+ - `evidence/perf/`
1708
+ - `evidence/traces/` (if applicable)
1709
+
1710
+ ## By Sub-phase
1711
+
1712
+ - `SP1`:
1713
+ - Tier A command(s):
1714
+ - Result:
1715
+ - Evidence path(s):
1716
+ - `SP2`:
1717
+ - Tier A command(s):
1718
+ - Result:
1719
+ - Evidence path(s):
1720
+
1721
+ ## Tier B / Broader Regression
1722
+
1723
+ - Command(s):
1724
+ - Result:
1725
+ - Evidence path(s):
1726
+
1727
+ ## Failures and Diagnostics (if any)
1728
+
1729
+ - Failing test:
1730
+ - Symptom:
1731
+ - Suspected cause:
1732
+ - Artifact path:
1733
+ - Mitigation:
1734
+
1735
+ ## Flake/Rerun Notes
1736
+
1737
+ - Rerun command:
1738
+ - Outcome:
1739
+ - Deterministic or flaky:
1740
+
1741
+ ## Audit Context
1742
+
1743
+ Audit Execution Mode: self-audit / subagent
1744
+ Subagent Availability: available / unavailable
1745
+ Audit Inputs Provided:
1746
+ - `/.recursive/run/<run-id>/00-requirements.md`
1747
+ - `/.recursive/run/<run-id>/00-worktree.md`
1748
+ - `/.recursive/run/<run-id>/02-to-be-plan.md`
1749
+ - `/.recursive/run/<run-id>/03-implementation-summary.md`
1750
+ - `/.recursive/run/<run-id>/03.5-code-review.md` [if present]
1751
+ - Changed files:
1752
+ - `path/to/file`
1753
+ - Targeted code references:
1754
+ - `path/to/file`
1755
+ - Test file references:
1756
+ - `path/to/test`
1757
+
1758
+ ## Effective Inputs Re-read
1759
+
1760
+ - `/.recursive/run/<run-id>/00-requirements.md`
1761
+ - `/.recursive/run/<run-id>/02-to-be-plan.md`
1762
+ - `/.recursive/run/<run-id>/03-implementation-summary.md`
1763
+ - `/.recursive/run/<run-id>/03.5-code-review.md` [if present]
1764
+ - [phase-local addenda]
1765
+
1766
+ ## Prior Recursive Evidence Reviewed
1767
+
1768
+ - Prior run id:
1769
+ - Docs read:
1770
+ - Reused insight:
1771
+ - Superseded or contradicted:
1772
+
1773
+ ## Earlier Phase Reconciliation
1774
+
1775
+ - Requirements vs implementation:
1776
+ - Plan vs implementation:
1777
+ - Review findings vs repairs:
1778
+
1779
+ ## Worktree Diff Audit
1780
+
1781
+ - Diff basis used: `git diff --name-only <base-commit>..HEAD`
1782
+ - Base branch:
1783
+ - Worktree branch:
1784
+ - Base commit:
1785
+ - Planned or claimed changed files:
1786
+ - `path/to/file`
1787
+ - Actual changed files reviewed:
1788
+ - `path/to/file`
1789
+ - Unexplained drift:
1790
+ - none / [explain]
1791
+
1792
+ ## Gaps Found
1793
+
1794
+ - none / [list unfinished work, drift, or missing tests]
1795
+
1796
+ ## Repair Work Performed
1797
+
1798
+ - none / [list repairs completed before re-audit]
1799
+
1800
+ ## Audit Verdict
1801
+
1802
+ - Summary:
1803
+ - Audit: FAIL / PASS
1804
+
1805
+ ## Traceability
1806
+ ...
1807
+
1808
+ ## Coverage Gate
1809
+ ...
1810
+ Coverage: PASS
1811
+
1812
+ ## Approval Gate
1813
+ ...
1814
+ Approval: PASS
1815
+ ```
1816
+
1817
+ ## Phase 5 Template (`05-manual-qa.md`)
1818
+
1819
+ Required outcome:
1820
+ - plan scenarios executed according to the selected QA mode
1821
+ - observed outcomes
1822
+ - explicit `QA Execution Mode`
1823
+ - required sign-off and/or execution evidence for that mode
1824
+
1825
+ Compact table is allowed in this phase.
1826
+
1827
+ ```md
1828
+ Run: `/.recursive/run/<run-id>/`
1829
+ Phase: `05 Manual QA`
1830
+ Status: `DRAFT`
1831
+ Inputs:
1832
+ - `/.recursive/run/<run-id>/02-to-be-plan.md`
1833
+ - [relevant addenda]
1834
+ Outputs:
1835
+ - `/.recursive/run/<run-id>/05-manual-qa.md`
1836
+ Scope note: This document records QA outcomes, the execution mode used, and the required evidence/sign-off for that mode.
1837
+ QA Execution Mode: human / agent-operated / hybrid
1838
+
1839
+ ## TODO
1840
+
1841
+ - [ ] Read Phase 2 plan (QA scenarios)
1842
+ - [ ] Declare QA execution mode
1843
+ - [ ] Present QA scenarios to the user if human input is required
1844
+ - [ ] **PAUSE if needed:** Wait for user execution/sign-off when the selected mode requires it
1845
+ - [ ] Record observed outcomes for each scenario
1846
+ - [ ] Document pass/fail status
1847
+ - [ ] Record QA execution metadata and evidence
1848
+ - [ ] Record user sign-off if the selected mode requires it
1849
+ - [ ] Complete Coverage Gate checklist
1850
+ - [ ] Complete Approval Gate checklist
1851
+
1852
+ ## QA Scenarios and Results
1853
+
1854
+ | Scenario | Expected | Observed | Pass/Fail | Notes |
1855
+ | --- | --- | --- | --- | --- |
1856
+ | ... | ... | ... | ... | ... |
1857
+
1858
+ ## Evidence and Artifacts
1859
+
1860
+ Store and reference artifacts under:
1861
+ - `/.recursive/run/<run-id>/evidence/`
1862
+ - `evidence/screenshots/` (screenshots, videos-as-files)
1863
+ - `evidence/logs/` (console/server output excerpts)
1864
+ - `evidence/perf/` (if QA included perf checks)
1865
+
1866
+ ## QA Execution Record
1867
+
1868
+ QA Execution Mode: human / agent-operated / hybrid
1869
+ - Agent Executor:
1870
+ - Tools Used:
1871
+ - Evidence:
1872
+ - `/.recursive/run/<run-id>/evidence/<file>`
1873
+
1874
+ ## User Sign-Off
1875
+
1876
+ - Approved by:
1877
+ - Date:
1878
+ - Notes:
1879
+
1880
+ ## Traceability
1881
+ ...
1882
+
1883
+ ## Coverage Gate
1884
+
1885
+ - [ ] QA scenarios from Phase 2 are represented
1886
+ - [ ] Observed results are recorded for all executed scenarios
1887
+ - [ ] QA execution mode is declared
1888
+ - [ ] Required execution metadata/evidence for that mode is present
1889
+
1890
+ Coverage: PASS / FAIL
1891
+
1892
+ ## Approval Gate
1893
+
1894
+ - [ ] The selected QA mode's completion requirements are satisfied
1895
+ - [ ] Human sign-off is present if mode is `human` or `hybrid`
1896
+ - [ ] Agent execution evidence is present if mode is `agent-operated` or `hybrid`
1897
+
1898
+ Approval: PASS / FAIL
1899
+ ```
1900
+
1901
+ If the selected QA mode is not yet complete, keep `Approval: FAIL` and list what is pending.
1902
+
1903
+ ## Phase 6 Template (`06-decisions-update.md`)
1904
+
1905
+ Required outcome:
1906
+ - `/.recursive/DECISIONS.md` updated for the run
1907
+ - exact ledger delta recorded in a lockable receipt
1908
+ - rationale for any ledger structure changes documented
1909
+
1910
+ ```md
1911
+ Run: `/.recursive/run/<run-id>/`
1912
+ Phase: `06 Decisions Update`
1913
+ Status: `DRAFT`
1914
+ Inputs:
1915
+ - `/.recursive/run/<run-id>/05-manual-qa.md`
1916
+ - `/.recursive/DECISIONS.md`
1917
+ - [relevant addenda]
1918
+ Outputs:
1919
+ - `/.recursive/DECISIONS.md`
1920
+ - `/.recursive/run/<run-id>/06-decisions-update.md`
1921
+ Scope note: This document records the exact `DECISIONS.md` updates made for the completed run.
1922
+
1923
+ ## TODO
1924
+
1925
+ - [ ] Read locked Phase 5 manual QA artifact
1926
+ - [ ] Update `/.recursive/DECISIONS.md` with the run outcome
1927
+ - [ ] Record a concise delta summary of the `DECISIONS.md` edits
1928
+ - [ ] Document rationale for any structural ledger changes
1929
+ - [ ] Verify run references and late-phase links are correct
1930
+ - [ ] Assemble audit context bundle
1931
+ - [ ] Audit receipt against final run folder and actual repo state
1932
+ - [ ] Repair gaps and re-audit until `Audit: PASS`
1933
+ - [ ] Complete Coverage Gate checklist
1934
+ - [ ] Complete Approval Gate checklist
1935
+
1936
+ ## Decisions Changes Applied
1937
+
1938
+ - Updated path or section:
1939
+ - Run entry added or edited:
1940
+ - Structural edits:
1941
+
1942
+ ## Rationale
1943
+
1944
+ - Why these ledger changes were needed:
1945
+ - Why this run belongs in this section/index:
1946
+
1947
+ ## Resulting Decision Entry
1948
+
1949
+ ```md
1950
+ [quote or summarize only the final run entry excerpt needed for audit; prefer a short excerpt plus path over pasting large ledger sections]
1951
+ ```
1952
+
1953
+ ## Audit Context
1954
+
1955
+ Audit Execution Mode: self-audit / subagent
1956
+ Subagent Availability: available / unavailable
1957
+ Audit Inputs Provided:
1958
+ - `/.recursive/run/<run-id>/05-manual-qa.md`
1959
+ - `/.recursive/run/<run-id>/00-worktree.md`
1960
+ - `/.recursive/DECISIONS.md`
1961
+ - Changed files:
1962
+ - `/.recursive/DECISIONS.md`
1963
+ - final product paths reviewed
1964
+
1965
+ ## Effective Inputs Re-read
1966
+
1967
+ - `/.recursive/run/<run-id>/05-manual-qa.md`
1968
+ - [relevant addenda]
1969
+ - `/.recursive/DECISIONS.md`
1970
+
1971
+ ## Earlier Phase Reconciliation
1972
+
1973
+ - Manual QA outcome reflected:
1974
+ - Run outcome and scope reflected:
1975
+ - Follow-ups and OOS reflected:
1976
+
1977
+ ## Worktree Diff Audit
1978
+
1979
+ - Diff basis used: `git diff --name-only <base-commit>..HEAD`
1980
+ - Base branch:
1981
+ - Worktree branch:
1982
+ - Base commit:
1983
+ - Planned or claimed changed files:
1984
+ - `/.recursive/DECISIONS.md`
1985
+ - Actual changed files reviewed:
1986
+ - `/.recursive/DECISIONS.md`
1987
+ - final product paths reviewed
1988
+ - Unexplained drift:
1989
+ - none / [explain]
1990
+
1991
+ ## Gaps Found
1992
+
1993
+ - none / [list receipt or ledger gaps]
1994
+
1995
+ ## Repair Work Performed
1996
+
1997
+ - none / [list repairs completed before re-audit]
1998
+
1999
+ ## Audit Verdict
2000
+
2001
+ - Summary:
2002
+ - Audit: FAIL / PASS
2003
+
2004
+ ## Traceability
2005
+ ...
2006
+
2007
+ ## Coverage Gate
2008
+ ...
2009
+ Coverage: PASS
2010
+
2011
+ ## Approval Gate
2012
+ ...
2013
+ Approval: PASS
2014
+ ```
2015
+
2016
+ ## Phase 7 Template (`07-state-update.md`)
2017
+
2018
+ Required outcome:
2019
+ - `/.recursive/STATE.md` updated to reflect post-change reality
2020
+ - exact state delta recorded in a lockable receipt
2021
+ - rationale for any interpretation changes documented
2022
+
2023
+ ```md
2024
+ Run: `/.recursive/run/<run-id>/`
2025
+ Phase: `07 State Update`
2026
+ Status: `DRAFT`
2027
+ Inputs:
2028
+ - `/.recursive/run/<run-id>/06-decisions-update.md`
2029
+ - `/.recursive/STATE.md`
2030
+ - `/.recursive/DECISIONS.md`
2031
+ - [relevant addenda]
2032
+ Outputs:
2033
+ - `/.recursive/STATE.md`
2034
+ - `/.recursive/run/<run-id>/07-state-update.md`
2035
+ Scope note: This document records the exact `STATE.md` changes made after the run was validated.
2036
+
2037
+ ## TODO
2038
+
2039
+ - [ ] Read locked Phase 6 decisions receipt
2040
+ - [ ] Update `/.recursive/STATE.md` with current truths from the validated implementation
2041
+ - [ ] Record a concise delta summary of the `STATE.md` edits
2042
+ - [ ] Document any major interpretation changes
2043
+ - [ ] Verify the updated state matches the implemented system
2044
+ - [ ] Review relevant prior recursive evidence for the affected area
2045
+ - [ ] Assemble audit context bundle
2046
+ - [ ] Audit receipt against final code reality and state truth
2047
+ - [ ] Repair gaps and re-audit until `Audit: PASS`
2048
+ - [ ] Complete Coverage Gate checklist
2049
+ - [ ] Complete Approval Gate checklist
2050
+
2051
+ ## State Changes Applied
2052
+
2053
+ - Updated path or section:
2054
+ - Current truth changed:
2055
+ - Removed or superseded statement:
2056
+
2057
+ ## Rationale
2058
+
2059
+ - Why these state changes were needed:
2060
+ - Why any interpretation changed:
2061
+
2062
+ ## Resulting State Summary
2063
+
2064
+ - Link or section updated: `/.recursive/STATE.md#[section]`
2065
+ - Current behavior delta:
2066
+ - Current limitations delta:
2067
+ - Operational notes delta:
2068
+
2069
+ ## Audit Context
2070
+
2071
+ Audit Execution Mode: self-audit / subagent
2072
+ Subagent Availability: available / unavailable
2073
+ Audit Inputs Provided:
2074
+ - `/.recursive/run/<run-id>/00-worktree.md`
2075
+ - `/.recursive/run/<run-id>/06-decisions-update.md`
2076
+ - `/.recursive/STATE.md`
2077
+ - `/.recursive/DECISIONS.md`
2078
+ - Changed files:
2079
+ - `/.recursive/STATE.md`
2080
+ - final product paths reviewed
2081
+
2082
+ ## Effective Inputs Re-read
2083
+
2084
+ - `/.recursive/run/<run-id>/06-decisions-update.md`
2085
+ - `/.recursive/STATE.md`
2086
+ - `/.recursive/DECISIONS.md`
2087
+ - [relevant addenda]
2088
+
2089
+ ## Prior Recursive Evidence Reviewed
2090
+
2091
+ - Prior run id:
2092
+ - Docs read:
2093
+ - Reused insight:
2094
+ - Superseded or contradicted:
2095
+
2096
+ ## Earlier Phase Reconciliation
2097
+
2098
+ - Decisions receipt reflected:
2099
+ - Current product truths reflected:
2100
+ - Known limitations reflected:
2101
+
2102
+ ## Worktree Diff Audit
2103
+
2104
+ - Diff basis used: `git diff --name-only <base-commit>..HEAD`
2105
+ - Base branch:
2106
+ - Worktree branch:
2107
+ - Base commit:
2108
+ - Planned or claimed changed files:
2109
+ - `/.recursive/STATE.md`
2110
+ - Actual changed files reviewed:
2111
+ - `/.recursive/STATE.md`
2112
+ - final product paths reviewed
2113
+ - Unexplained drift:
2114
+ - none / [explain]
2115
+
2116
+ ## Gaps Found
2117
+
2118
+ - none / [list missing or inaccurate state claims]
2119
+
2120
+ ## Repair Work Performed
2121
+
2122
+ - none / [list repairs completed before re-audit]
2123
+
2124
+ ## Audit Verdict
2125
+
2126
+ - Summary:
2127
+ - Audit: FAIL / PASS
2128
+
2129
+ ## Traceability
2130
+ ...
2131
+
2132
+ ## Coverage Gate
2133
+ ...
2134
+ Coverage: PASS
2135
+
2136
+ ## Approval Gate
2137
+ ...
2138
+ Approval: PASS
2139
+ ```
2140
+
2141
+ ## Phase 8 Template (`08-memory-impact.md`)
2142
+
2143
+ Required outcome:
2144
+ - changed paths analyzed against the memory plane
2145
+ - affected memory docs reviewed and updated
2146
+ - uncovered changed paths handled explicitly
2147
+ - final memory statuses recorded
2148
+ - run-local skill usage captured before durable promotion decisions
2149
+ - durable skill-memory promotions justified explicitly
2150
+ - receipt remains a concise delta summary that points to final memory docs rather than duplicating them
2151
+
2152
+ ```md
2153
+ Run: `/.recursive/run/<run-id>/`
2154
+ Phase: `08 Memory Impact`
2155
+ Status: `DRAFT`
2156
+ Inputs:
2157
+ - `/.recursive/run/<run-id>/00-worktree.md`
2158
+ - `/.recursive/run/<run-id>/01-as-is.md`
2159
+ - `/.recursive/run/<run-id>/02-to-be-plan.md`
2160
+ - `/.recursive/run/<run-id>/03-implementation-summary.md`
2161
+ - `/.recursive/run/<run-id>/04-test-summary.md`
2162
+ - `/.recursive/run/<run-id>/05-manual-qa.md`
2163
+ - `/.recursive/run/<run-id>/06-decisions-update.md`
2164
+ - `/.recursive/run/<run-id>/07-state-update.md`
2165
+ - `/.recursive/DECISIONS.md`
2166
+ - `/.recursive/STATE.md`
2167
+ - `/.recursive/memory/MEMORY.md`
2168
+ - `/.recursive/memory/skills/SKILLS.md`
2169
+ - [affected memory docs]
2170
+ - [relevant addenda]
2171
+ Outputs:
2172
+ - `/.recursive/run/<run-id>/08-memory-impact.md`
2173
+ - [updated memory docs]
2174
+ Scope note: This document records memory freshness review and durable memory maintenance after the run is fully validated.
2175
+
2176
+ ## TODO
2177
+
2178
+ - [ ] Read diff basis from `00-worktree.md`
2179
+ - [ ] Compute final changed paths
2180
+ - [ ] Exclude run-artifact churn unless explicitly relevant
2181
+ - [ ] Match changed paths to memory doc owners/watchers
2182
+ - [ ] Identify uncovered changed paths
2183
+ - [ ] Downgrade affected `CURRENT` docs to `SUSPECT` before review
2184
+ - [ ] Semantically review affected docs against final code + `STATE.md` + `DECISIONS.md`
2185
+ - [ ] Update/create/split/deprecate memory docs as needed
2186
+ - [ ] Promote durable skill lessons into `/.recursive/memory/skills/` or record why no promotion was needed
2187
+ - [ ] Refresh parent/router docs if child memory changed materially
2188
+ - [ ] Record final memory statuses
2189
+ - [ ] Review relevant prior recursive evidence for the affected area
2190
+ - [ ] Assemble audit context bundle
2191
+ - [ ] Audit memory updates against diff, state, decisions, and prior memory truth
2192
+ - [ ] Repair gaps and re-audit until `Audit: PASS`
2193
+ - [ ] Complete Coverage Gate checklist
2194
+ - [ ] Complete Approval Gate checklist
2195
+
2196
+ ## Diff Basis
2197
+
2198
+ - Base commit / anchor:
2199
+ - Head commit / comparison target:
2200
+ - Exclusions applied:
2201
+
2202
+ ## Changed Paths Review
2203
+
2204
+ - Changed path:
2205
+ - Owning doc(s):
2206
+ - Watching doc(s):
2207
+ - Review result:
2208
+
2209
+ ## Affected Memory Docs
2210
+
2211
+ - `/.recursive/memory/domains/<doc>.md`
2212
+ - Prior status:
2213
+ - Temporary downgrade:
2214
+ - Final status:
2215
+ - Change summary:
2216
+ - Final doc path to review:
2217
+ - `/.recursive/memory/skills/<category>/<doc>.md`
2218
+ - Prior status:
2219
+ - Final status:
2220
+ - Skill lesson captured:
2221
+
2222
+ ## Uncovered Paths
2223
+
2224
+ - Changed path without owner:
2225
+ - Action: [created new domain doc / explicit follow-up]
2226
+ - Follow-up path or note:
2227
+
2228
+ ## Router and Parent Refresh
2229
+
2230
+ - `/.recursive/memory/MEMORY.md` changes:
2231
+ - `/.recursive/memory/skills/SKILLS.md` changes:
2232
+ - Parent doc updates:
2233
+
2234
+ ## Final Status Summary
2235
+
2236
+ - Restored to `CURRENT`:
2237
+ - Left as `SUSPECT`:
2238
+ - Marked `STALE`:
2239
+ - Deprecated / archived:
2240
+
2241
+ ## Run-Local Skill Usage Capture
2242
+
2243
+ - Skill Usage Relevance: `relevant|not-relevant`
2244
+ - Available Skills:
2245
+ - Skills Sought:
2246
+ - Skills Attempted:
2247
+ - Skills Used:
2248
+ - Worked Well:
2249
+ - Issues Encountered:
2250
+ - Future Guidance:
2251
+ - Promotion Candidates:
2252
+
2253
+ ## Skill Memory Promotion Review
2254
+
2255
+ - Durable Skill Lessons Promoted:
2256
+ - Generalized Guidance Updated:
2257
+ - Run-Local Observations Left Unpromoted:
2258
+ - Promotion Decision Rationale:
2259
+
2260
+ ## Audit Context
2261
+
2262
+ Audit Execution Mode: self-audit / subagent
2263
+ Subagent Availability: available / unavailable
2264
+ Audit Inputs Provided:
2265
+ - `/.recursive/run/<run-id>/00-worktree.md`
2266
+ - final validated run artifacts
2267
+ - `/.recursive/DECISIONS.md`
2268
+ - `/.recursive/STATE.md`
2269
+ - `/.recursive/memory/MEMORY.md`
2270
+ - `/.recursive/memory/skills/SKILLS.md`
2271
+ - affected memory docs
2272
+ - Changed files:
2273
+ - final product paths reviewed
2274
+ - memory doc paths reviewed
2275
+
2276
+ ## Effective Inputs Re-read
2277
+
2278
+ - `/.recursive/run/<run-id>/00-worktree.md`
2279
+ - `/.recursive/run/<run-id>/03-implementation-summary.md`
2280
+ - `/.recursive/run/<run-id>/04-test-summary.md`
2281
+ - `/.recursive/run/<run-id>/06-decisions-update.md`
2282
+ - `/.recursive/run/<run-id>/07-state-update.md`
2283
+ - `/.recursive/DECISIONS.md`
2284
+ - `/.recursive/STATE.md`
2285
+ - `/.recursive/memory/MEMORY.md`
2286
+ - affected memory docs
2287
+ - [relevant addenda]
2288
+
2289
+ ## Prior Recursive Evidence Reviewed
2290
+
2291
+ - Prior run id:
2292
+ - Docs read:
2293
+ - Reused insight:
2294
+ - Superseded or contradicted:
2295
+
2296
+ ## Earlier Phase Reconciliation
2297
+
2298
+ - Final diff vs memory ownership:
2299
+ - State update vs memory truth:
2300
+ - Decisions update vs memory truth:
2301
+
2302
+ ## Worktree Diff Audit
2303
+
2304
+ - Diff basis used: `git diff --name-only <base-commit>..HEAD`
2305
+ - Base branch:
2306
+ - Worktree branch:
2307
+ - Base commit:
2308
+ - Planned or claimed changed files:
2309
+ - memory-impact targets
2310
+ - Actual changed files reviewed:
2311
+ - final product paths reviewed
2312
+ - memory doc paths reviewed
2313
+ - Unexplained drift:
2314
+ - none / [explain]
2315
+
2316
+ ## Gaps Found
2317
+
2318
+ - none / [list uncovered paths, stale memory, or unresolved status transitions]
2319
+
2320
+ ## Repair Work Performed
2321
+
2322
+ - none / [list repairs completed before re-audit]
2323
+
2324
+ ## Audit Verdict
2325
+
2326
+ - Summary:
2327
+ - Audit: FAIL / PASS
2328
+
2329
+ ## Traceability
2330
+ ...
2331
+
2332
+ ## Coverage Gate
2333
+ ...
2334
+ Coverage: PASS
2335
+
2336
+ ## Approval Gate
2337
+ ...
2338
+ Approval: PASS
2339
+ ```
2340
+
2341
+ ## Addenda Templates
2342
+
2343
+ ## Stage-Local Addendum
2344
+
2345
+ File name:
2346
+ - `<base>.addendum-01.md`
2347
+
2348
+ ```md
2349
+ Run: `/.recursive/run/<run-id>/`
2350
+ Phase: `<current phase>`
2351
+ Status: `DRAFT`
2352
+ Inputs:
2353
+ - `<base artifact>`
2354
+ Outputs:
2355
+ - `/.recursive/run/<run-id>/addenda/<base>.addendum-01.md`
2356
+ Scope note: This addendum supplements phase-local content without changing locked history.
2357
+
2358
+ ## TODO
2359
+
2360
+ - [ ] Add the missing information
2361
+ - [ ] Update Traceability/Coverage implications in the current phase artifact (if needed)
2362
+ - [ ] Complete Coverage Gate checklist
2363
+ - [ ] Complete Approval Gate checklist
2364
+
2365
+ ## Addendum Content
2366
+
2367
+ - Added/clarified information:
2368
+ - Rationale:
2369
+ - Impact on phase output:
2370
+
2371
+ ## Coverage Gate
2372
+ ...
2373
+ Coverage: PASS
2374
+
2375
+ ## Approval Gate
2376
+ ...
2377
+ Approval: PASS
2378
+ ```
2379
+
2380
+ ## Upstream-Gap Addendum
2381
+
2382
+ File name:
2383
+ - `<current>.upstream-gap.<prior>.addendum-01.md`
2384
+
2385
+ ```md
2386
+ Run: `/.recursive/run/<run-id>/`
2387
+ Phase: `<current phase>`
2388
+ Status: `DRAFT`
2389
+ Inputs:
2390
+ - `<current phase inputs>`
2391
+ - `<locked prior artifact>`
2392
+ Outputs:
2393
+ - `/.recursive/run/<run-id>/addenda/<current>.upstream-gap.<prior>.addendum-01.md`
2394
+ Scope note: This addendum records a discovered gap in a locked upstream artifact.
2395
+
2396
+ ## TODO
2397
+
2398
+ - [ ] Record the upstream gap precisely
2399
+ - [ ] Add discovery evidence (commands, files, outputs)
2400
+ - [ ] State impact and compensation plan
2401
+ - [ ] Update current-phase planning/implementation accordingly
2402
+ - [ ] Complete Coverage Gate checklist
2403
+ - [ ] Complete Approval Gate checklist
2404
+
2405
+ ## Gap Statement
2406
+
2407
+ - Missing or incorrect upstream content:
2408
+
2409
+ ## Discovery Evidence
2410
+
2411
+ - How the gap was found:
2412
+ - Supporting evidence:
2413
+
2414
+ ## Impact
2415
+
2416
+ - Impact on current phase:
2417
+ - Impact on later phases:
2418
+
2419
+ ## Compensation Plan
2420
+
2421
+ - Tests, validation, or process compensations applied now:
2422
+
2423
+ ## Traceability Impact
2424
+
2425
+ - Affected requirements: `R#`, `R#`
2426
+
2427
+ ## Coverage Gate
2428
+ ...
2429
+ Coverage: PASS
2430
+
2431
+ ## Approval Gate
2432
+ ...
2433
+ Approval: PASS
2434
+ ```
2435
+
2436
+ ## Artifact Linting (Structure + TODO Discipline)
2437
+
2438
+ Before locking (or when a lock verification fails unexpectedly), lint the run artifacts for required header fields, required section headings, and TODO completion rules:
2439
+
2440
+ ```powershell
2441
+ # Python (cross-platform):
2442
+ python ./.agents/skills/recursive-mode/scripts/lint-recursive-run.py --run-id "<run-id>"
2443
+ # Or, when running from this repo:
2444
+ python ./.recursive/scripts/lint-recursive-run.py --run-id "<run-id>"
2445
+ python3 ./.agents/skills/recursive-mode/scripts/lint-recursive-run.py --run-id "<run-id>"
2446
+ python3 ./.recursive/scripts/lint-recursive-run.py --run-id "<run-id>"
2447
+
2448
+ # Treat WARN as FAIL
2449
+ python ./.agents/skills/recursive-mode/scripts/lint-recursive-run.py --run-id "<run-id>" --strict
2450
+ python ./.recursive/scripts/lint-recursive-run.py --run-id "<run-id>" --strict
2451
+ python3 ./.agents/skills/recursive-mode/scripts/lint-recursive-run.py --run-id "<run-id>" --strict
2452
+ python3 ./.recursive/scripts/lint-recursive-run.py --run-id "<run-id>" --strict
2453
+
2454
+ # Lint specific run
2455
+ .\.agents\skills\recursive-mode\scripts\lint-recursive-run.ps1 -RunId "<run-id>"
2456
+ # Or, when running from this repo:
2457
+ .\scripts\lint-recursive-run.ps1 -RunId "<run-id>"
2458
+
2459
+ # Treat WARN as FAIL
2460
+ .\.agents\skills\recursive-mode\scripts\lint-recursive-run.ps1 -RunId "<run-id>" -Strict
2461
+ .\scripts\lint-recursive-run.ps1 -RunId "<run-id>" -Strict
2462
+ ```
2463
+
2464
+ ## Locking Commands
2465
+
2466
+ Preferred:
2467
+
2468
+ ```powershell
2469
+ # Python (cross-platform)
2470
+ python ./.agents/skills/recursive-mode/scripts/recursive-lock.py --run-id "<run-id>" --artifact "<artifact>.md"
2471
+ # Or, when running from this repo:
2472
+ python ./.recursive/scripts/recursive-lock.py --run-id "<run-id>" --artifact "<artifact>.md"
2473
+ python3 ./.agents/skills/recursive-mode/scripts/recursive-lock.py --run-id "<run-id>" --artifact "<artifact>.md"
2474
+ python3 ./.recursive/scripts/recursive-lock.py --run-id "<run-id>" --artifact "<artifact>.md"
2475
+
2476
+ # PowerShell
2477
+ .\.agents\skills\recursive-mode\scripts\recursive-lock.ps1 -RunId "<run-id>" -Artifact "<artifact>.md"
2478
+ # Or, when running from this repo:
2479
+ .\scripts\recursive-lock.ps1 -RunId "<run-id>" -Artifact "<artifact>.md"
2480
+ ```
2481
+
2482
+ The lock command is the primary supported path. It must refuse to lock artifacts whose required gates or lint-critical structure are still invalid.
2483
+
2484
+ Manual fallback for hash computation only:
2485
+
2486
+ PowerShell:
2487
+
2488
+ ```powershell
2489
+ $p = '.recursive/run/<run-id>/<artifact>.md'
2490
+ $t = Get-Content -LiteralPath $p -Raw -Encoding UTF8
2491
+ $n = ($t -replace "`r`n","`n") -replace "(?m)^LockHash:.*(?:`n|$)",""
2492
+ $b = [System.Text.Encoding]::UTF8.GetBytes($n)
2493
+ $h = [System.Security.Cryptography.SHA256]::Create().ComputeHash($b)
2494
+ ($h | ForEach-Object { $_.ToString("x2") }) -join ""
2495
+ ```
2496
+
2497
+ Shell:
2498
+
2499
+ ```bash
2500
+ sed '/^LockHash:/d' .recursive/run/<run-id>/<artifact>.md | tr -d '\r' | sha256sum
2501
+ ```
2502
+
2503
+ ## Common Failure Modes (Use as Pre-Lock Checklist)
2504
+
2505
+ - Missing one or more effective-input addenda under `Inputs`.
2506
+ - Relevant addenda exist but are not re-read in `## Effective Inputs Re-read`.
2507
+ - Relevant addenda exist but are not reconciled in `## Earlier Phase Reconciliation`.
2508
+ - Coverage Gate says PASS but does not map every `R#`.
2509
+ - Approval Gate says PASS with unresolved blockers.
2510
+ - `Traceability` references vague evidence instead of concrete files/commands.
2511
+ - Artifact locked without `LockedAt` and `LockHash`.
2512
+ - **LockHash does not match SHA-256 of normalized content (tampering detected).**
2513
+ - Editing locked prior-phase artifacts instead of writing addenda.
2514
+ - Delegated review has a bundle file but the written review does not cite upstream artifacts, relevant addenda, or changed files/code refs from that bundle.
2515
+ - Diff audit is failing on transient runtime noise because incidental cache files were mistaken for meaningful repo changes.
2516
+ - Working on main/master branch without explicit consent documented.
2517
+ - Worktree directory not git-ignored (project-local worktrees).
2518
+ - Baseline tests failing (pre-existing issues not documented).
2519
+
2520
+ ## Lock Verification
2521
+
2522
+ ### Automated Verification
2523
+
2524
+ Use the provided script to verify all locks in a run:
2525
+
2526
+ ```bash
2527
+ # Verify specific run
2528
+ python ./.agents/skills/recursive-mode/scripts/verify-locks.py --run-id "<run-id>"
2529
+ # Or, when running from this repo:
2530
+ python ./.recursive/scripts/verify-locks.py --run-id "<run-id>"
2531
+ python3 ./.agents/skills/recursive-mode/scripts/verify-locks.py --run-id "<run-id>"
2532
+ python3 ./.recursive/scripts/verify-locks.py --run-id "<run-id>"
2533
+
2534
+ # Fix incorrect hashes (use with caution)
2535
+ python ./.agents/skills/recursive-mode/scripts/verify-locks.py --run-id "<run-id>" --fix
2536
+ # Or, when running from this repo:
2537
+ python ./.recursive/scripts/verify-locks.py --run-id "<run-id>" --fix
2538
+ python3 ./.agents/skills/recursive-mode/scripts/verify-locks.py --run-id "<run-id>" --fix
2539
+ python3 ./.recursive/scripts/verify-locks.py --run-id "<run-id>" --fix
2540
+ ```
2541
+
2542
+ ```powershell
2543
+ # Verify specific run
2544
+ .\.agents\skills\recursive-mode\scripts\verify-locks.ps1 -RunId "<run-id>"
2545
+ # Or, when running from this repo:
2546
+ .\scripts\verify-locks.ps1 -RunId "<run-id>"
2547
+
2548
+ # Fix incorrect hashes (use with caution)
2549
+ .\.agents\skills\recursive-mode\scripts\verify-locks.ps1 -RunId "<run-id>" -Fix
2550
+ # Or, when running from this repo:
2551
+ .\scripts\verify-locks.ps1 -RunId "<run-id>" -Fix
2552
+ ```
2553
+
2554
+ ### Manual Verification
2555
+
2556
+ Compute SHA-256 hash:
2557
+
2558
+ **PowerShell:**
2559
+ ```powershell
2560
+ $p = '.recursive/run/<run-id>/<artifact>.md'
2561
+ $t = Get-Content -LiteralPath $p -Raw -Encoding UTF8
2562
+ $n = ($t -replace "`r`n","`n") -replace "(?m)^LockHash:.*(?:`n|$)",""
2563
+ $b = [System.Text.Encoding]::UTF8.GetBytes($n)
2564
+ $h = [System.Security.Cryptography.SHA256]::Create().ComputeHash($b)
2565
+ ($h | ForEach-Object { $_.ToString("x2") }) -join ""
2566
+ ```
2567
+
2568
+ **Shell:**
2569
+ ```bash
2570
+ sed '/^LockHash:/d' .recursive/run/<run-id>/<artifact>.md | tr -d '\r' | sha256sum
2571
+ ```
2572
+
2573
+ Compare computed hash with `LockHash` in artifact header. They must match exactly.
2574
+