@try-works/dsh-recursive-mode 0.1.3 → 0.1.4
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.
- package/cordis.patch.yml +15 -10
- package/lib/bootstrap.d.ts +9 -2
- package/lib/client/apply-guard.d.ts +14 -0
- package/lib/client/board.d.ts +5 -4
- package/lib/client/contract.d.ts +57 -24
- package/lib/client/host-api.d.ts +26 -0
- package/lib/client/index.d.ts +16 -9
- package/lib/client/inspector.d.ts +3 -3
- package/lib/client/slots.d.ts +4 -6
- package/lib/client/strip.d.ts +4 -3
- package/lib/client/use-live.d.ts +9 -0
- package/lib/client.js +252 -174
- package/lib/index.d.ts +11 -11
- package/lib/index.js +972 -4504
- package/lib/init-templates.d.ts +41 -0
- package/lib/live-route.d.ts +69 -0
- package/lib/phase-rules.d.ts +34 -0
- package/lib/runtime.d.ts +24 -17
- package/lib/snapshot.d.ts +11 -0
- package/package.json +4 -3
- package/preset/recursive/agent.cordis.yml +7 -4
- package/preset/recursive/preset.yml +1 -1
- package/references/agents-block.md +95 -0
- package/references/artifact-template.md +2574 -0
- package/references/bodies/claude.md +7 -0
- package/references/bodies/codex-agents.md +95 -0
- package/references/bodies/copilot.md +7 -0
- package/references/bodies/cursorrules.md +7 -0
- package/references/bodies/decisions.md +5 -0
- package/references/bodies/delegated-verification.md +49 -0
- package/references/bodies/memory-router.md +45 -0
- package/references/bodies/phase8-skill-memory.md +48 -0
- package/references/bodies/plans-bridge.md +43 -0
- package/references/bodies/recursive-agents-router.md +64 -0
- package/references/bodies/skill-discovery.md +51 -0
- package/references/bodies/skill-memory-router.md +42 -0
- package/references/bodies/state.md +5 -0
- package/references/bootstrap/RECURSIVE.md +2362 -0
- package/references/scripts/__pycache__/recursive_phase_rules.cpython-314.pyc +0 -0
- package/references/scripts/lint-recursive-run.ps1 +25 -0
- package/references/scripts/lint-recursive-run.py +2870 -0
- package/references/scripts/recursive-closeout.ps1 +38 -0
- package/references/scripts/recursive-closeout.py +541 -0
- package/references/scripts/recursive-init.ps1 +515 -0
- package/references/scripts/recursive-init.py +356 -0
- package/references/scripts/recursive-lock.ps1 +26 -0
- package/references/scripts/recursive-lock.py +302 -0
- package/references/scripts/recursive-review-bundle.ps1 +58 -0
- package/references/scripts/recursive-review-bundle.py +503 -0
- package/references/scripts/recursive-router-cli-configure.ps1 +2 -0
- package/references/scripts/recursive-router-cli-configure.py +9 -0
- package/references/scripts/recursive-router-cli-init.ps1 +2 -0
- package/references/scripts/recursive-router-cli-init.py +9 -0
- package/references/scripts/recursive-router-cli-invoke.ps1 +2 -0
- package/references/scripts/recursive-router-cli-invoke.py +9 -0
- package/references/scripts/recursive-router-cli-probe.ps1 +2 -0
- package/references/scripts/recursive-router-cli-probe.py +9 -0
- package/references/scripts/recursive-router-cli-resolve.ps1 +2 -0
- package/references/scripts/recursive-router-cli-resolve.py +9 -0
- package/references/scripts/recursive-router-cli-validate.ps1 +2 -0
- package/references/scripts/recursive-router-cli-validate.py +9 -0
- package/references/scripts/recursive-router-configure.ps1 +27 -0
- package/references/scripts/recursive-router-configure.py +74 -0
- package/references/scripts/recursive-router-init.ps1 +17 -0
- package/references/scripts/recursive-router-init.py +29 -0
- package/references/scripts/recursive-router-invoke.ps1 +47 -0
- package/references/scripts/recursive-router-invoke.py +103 -0
- package/references/scripts/recursive-router-probe.ps1 +25 -0
- package/references/scripts/recursive-router-probe.py +44 -0
- package/references/scripts/recursive-router-resolve.ps1 +26 -0
- package/references/scripts/recursive-router-resolve.py +46 -0
- package/references/scripts/recursive-router-validate.ps1 +17 -0
- package/references/scripts/recursive-router-validate.py +27 -0
- package/references/scripts/recursive-status.ps1 +23 -0
- package/references/scripts/recursive-status.py +2124 -0
- package/references/scripts/recursive-subagent-action.ps1 +98 -0
- package/references/scripts/recursive-subagent-action.py +197 -0
- package/references/scripts/recursive-training-extract.ps1 +23 -0
- package/references/scripts/recursive-training-extract.py +99 -0
- package/references/scripts/recursive-training-grpo.ps1 +52 -0
- package/references/scripts/recursive-training-grpo.py +1341 -0
- package/references/scripts/recursive-training-loader.ps1 +78 -0
- package/references/scripts/recursive-training-loader.py +558 -0
- package/references/scripts/recursive-training-mcp.ps1 +29 -0
- package/references/scripts/recursive-training-mcp.py +261 -0
- package/references/scripts/recursive-training-phase8-trigger.ps1 +55 -0
- package/references/scripts/recursive-training-phase8-trigger.py +137 -0
- package/references/scripts/recursive-training-sync.ps1 +29 -0
- package/references/scripts/recursive-training-sync.py +183 -0
- package/references/scripts/recursive_phase_rules.py +367 -0
- package/references/scripts/recursive_router_cli_lib.py +2 -0
- package/references/scripts/recursive_router_lib.py +2282 -0
- package/references/scripts/verify-locks.ps1 +25 -0
- package/references/scripts/verify-locks.py +353 -0
- package/scripts/__pycache__/lint-recursive-run.cpython-314.pyc +0 -0
- package/scripts/__pycache__/recursive_phase_rules.cpython-314.pyc +0 -0
- package/scripts/install-preset.cmd +7 -0
- package/scripts/install-preset.js +101 -0
- package/scripts/lint-recursive-run.py +7 -5
- package/scripts/test-recursive-mode-smoke.ts +29 -28
- package/src/bootstrap.ts +253 -39
- package/src/client/apply-guard.ts +23 -0
- package/src/client/board.tsx +0 -0
- package/src/client/contract.ts +72 -24
- package/src/client/host-api.ts +90 -0
- package/src/client/index.ts +22 -11
- package/src/client/inspector.tsx +7 -9
- package/src/client/slots.ts +70 -26
- package/src/client/strip.tsx +9 -9
- package/src/client/use-live.ts +52 -0
- package/src/index.ts +89 -146
- package/src/init-templates.ts +276 -0
- package/src/live-route.ts +163 -0
- package/src/phase-rules.ts +262 -0
- package/src/policy.ts +28 -4
- package/src/runtime.ts +129 -77
- package/src/snapshot.ts +104 -0
- package/lib/client/node.d.ts +0 -71
- package/lib/events.d.ts +0 -173
- package/lib/projection.d.ts +0 -29
- package/src/client/node.ts +0 -156
- package/src/events.ts +0 -173
- package/src/projection.ts +0 -237
|
@@ -0,0 +1,2362 @@
|
|
|
1
|
+
## Canonical location
|
|
2
|
+
|
|
3
|
+
This file is the canonical source of truth for how agents work in this repository.
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
## Scope
|
|
8
|
+
|
|
9
|
+
This file defines:
|
|
10
|
+
|
|
11
|
+
- ExecPlans: a single, self-contained, novice-guiding execution plan for complex work.
|
|
12
|
+
- recursive-mode: a stage-gated, repo-document workflow that prevents "context rot" by making static repo documents the source of truth across phases, with explicit coverage and approval gates.
|
|
13
|
+
|
|
14
|
+
# recursive-mode workflow
|
|
15
|
+
|
|
16
|
+
recursive-mode is an extension of ExecPlans designed to prevent "context rot." In recursive-mode, substantive requirements and plans must live in static repository documents. Prompts must not carry requirements or plans; prompts only instruct an agent which phase to execute and which repo file(s) to use as inputs and outputs.
|
|
17
|
+
|
|
18
|
+
recursive-mode is recommended for: multi-step debugging, platform-specific behavior, risky refactors, migrations, or any change where an AS-IS analysis, explicit validation, and manual QA sign-off are necessary.
|
|
19
|
+
|
|
20
|
+
## Non-negotiable recursive-mode rules
|
|
21
|
+
|
|
22
|
+
1) Repo documents are the source of truth.
|
|
23
|
+
|
|
24
|
+
At the start of each phase, the agent must read the phase input document(s) from disk (including applicable addenda; see Addenda policy below) and treat them as authoritative. Conversational context may be used only to issue commands ("run Phase 2 using these file paths"), not to carry requirements.
|
|
25
|
+
|
|
26
|
+
2) Prompts are commands, not specifications.
|
|
27
|
+
|
|
28
|
+
Do not paste substantive requirements, acceptance criteria, test cases, or implementation plans into prompts. Place them in repo documents, then reference paths in the prompt.
|
|
29
|
+
|
|
30
|
+
3) One-way phases.
|
|
31
|
+
|
|
32
|
+
Within a phase, the agent may iterate on that phase's outputs until gates pass. After advancing to the next phase, the agent must not edit prior-phase artifacts. If a later phase discovers missing or incorrect information in an earlier phase, use an addendum in the current phase (see Addenda policy).
|
|
33
|
+
|
|
34
|
+
4) Explicit gates are mandatory.
|
|
35
|
+
|
|
36
|
+
Every phase output must end with:
|
|
37
|
+
- Coverage Gate: prove the output doc addresses everything relevant in the input doc (including input addenda).
|
|
38
|
+
- Approval Gate: prove the output is ready to proceed.
|
|
39
|
+
|
|
40
|
+
Manual QA approval depends on the declared `QA Execution Mode` in the Manual QA artifact. Human and hybrid QA require explicit user sign-off. Agent-operated QA does not.
|
|
41
|
+
|
|
42
|
+
5) Missing scaffold must be bootstrapped automatically.
|
|
43
|
+
|
|
44
|
+
If recursive-mode is invoked in a repository that does not yet contain the required `/.recursive/` scaffold and bridge docs, the agent should run the supported bootstrap installer automatically before continuing. Do not require the user to perform a separate manual bootstrap step unless no supported runtime is available to execute the installer.
|
|
45
|
+
|
|
46
|
+
## Global artifacts (across all recursive-mode runs)
|
|
47
|
+
|
|
48
|
+
recursive-mode uses two global documents shared by all requirements:
|
|
49
|
+
|
|
50
|
+
- `/.recursive/DECISIONS.md` — a global decision ledger and index of all completed (or aborted) runs. Each entry must reference the run folder and capture what changed and why.
|
|
51
|
+
- `/.recursive/STATE.md` — a global "current state of the app" document. It must reflect what is true now, not what was intended.
|
|
52
|
+
|
|
53
|
+
These two files are updated in later phases (see Phase 6 and Phase 7).
|
|
54
|
+
|
|
55
|
+
## Separate memory plane
|
|
56
|
+
|
|
57
|
+
recursive-mode maintains a separate durable memory plane under:
|
|
58
|
+
|
|
59
|
+
- `/.recursive/memory/MEMORY.md`
|
|
60
|
+
- `/.recursive/memory/domains/`
|
|
61
|
+
- `/.recursive/memory/patterns/`
|
|
62
|
+
- `/.recursive/memory/incidents/`
|
|
63
|
+
- `/.recursive/memory/episodes/`
|
|
64
|
+
- `/.recursive/memory/training/`
|
|
65
|
+
- `/.recursive/memory/skills/SKILLS.md`
|
|
66
|
+
- `/.recursive/memory/skills/availability/`
|
|
67
|
+
- `/.recursive/memory/skills/usage/`
|
|
68
|
+
- `/.recursive/memory/skills/issues/`
|
|
69
|
+
- `/.recursive/memory/skills/patterns/`
|
|
70
|
+
- `/.recursive/memory/archive/`
|
|
71
|
+
|
|
72
|
+
These are memory docs. They are distinct from:
|
|
73
|
+
|
|
74
|
+
- `/.recursive/STATE.md`
|
|
75
|
+
- `/.recursive/DECISIONS.md`
|
|
76
|
+
- `/.recursive/RECURSIVE.md`
|
|
77
|
+
- `/.codex/AGENTS.md`
|
|
78
|
+
- `/AGENTS.md`
|
|
79
|
+
- `/.agent/PLANS.md`
|
|
80
|
+
|
|
81
|
+
Those files remain control-plane docs and must not be repurposed as memory.
|
|
82
|
+
|
|
83
|
+
Required read behavior:
|
|
84
|
+
|
|
85
|
+
- At the start of every new session, read `/.recursive/STATE.md` to understand the current state of the app and codebase.
|
|
86
|
+
- At the start of every new session, read `/.recursive/DECISIONS.md` to understand prior work and the reasoning behind it.
|
|
87
|
+
- At the start of every new session, read `/.recursive/memory/MEMORY.md` to understand the memory router, taxonomy, and freshness policy.
|
|
88
|
+
- At the start of every new recursive-mode run, re-read `/.recursive/STATE.md`, `/.recursive/DECISIONS.md`, and `/.recursive/memory/MEMORY.md` before creating or updating run artifacts.
|
|
89
|
+
- At the start of every new recursive-mode run, use `/.recursive/DECISIONS.md` to identify any prior recursive-mode runs relevant to the new requirement or AS-IS analysis.
|
|
90
|
+
- If relevant prior runs are found, read only the docs needed from those runs to understand the affected codebase areas before writing the new run artifacts.
|
|
91
|
+
- If no relevant prior runs are identified, skip that step.
|
|
92
|
+
- After reading `MEMORY.md`, load only the memory docs relevant to the current task. Do not load the entire memory tree by default.
|
|
93
|
+
- If the task may benefit from prior experiential learnings, load only the relevant docs under `/.recursive/memory/training/` and `/.recursive/memory/domains/`, preferably by using the training loader with filesystem-backed discovery.
|
|
94
|
+
- If the optional `recursive-training` skill is installed, run `/.recursive/scripts/recursive-training-loader.py` after reading `MEMORY.md` and before planning or implementation whenever the task may benefit from experiential memory. If no automatic hook is wired, the agent must still manually load relevant training docs from the memory index when they matter.
|
|
95
|
+
- If the run plans delegated review, subagent help, review bundles, smoke harness portability work, or other skill-sensitive execution, load `/.recursive/memory/skills/SKILLS.md` and the relevant skill-memory shards before planning or auditing.
|
|
96
|
+
- Prefer `Status: CURRENT` memory docs for planning/execution.
|
|
97
|
+
- `Status: SUSPECT` memory docs may be used as leads but must be revalidated before trust.
|
|
98
|
+
- `Status: STALE` and `Status: DEPRECATED` are excluded from default retrieval unless doing explicit historical investigation.
|
|
99
|
+
|
|
100
|
+
## Recursive run directory layout (per requirement)
|
|
101
|
+
|
|
102
|
+
Each recursive-mode run uses a stable folder:
|
|
103
|
+
|
|
104
|
+
`/.recursive/run/<run-id>/`
|
|
105
|
+
|
|
106
|
+
Required per-run artifacts:
|
|
107
|
+
|
|
108
|
+
- `00-requirements.md`
|
|
109
|
+
- `00-worktree.md` (REQUIRED - worktree isolation)
|
|
110
|
+
- `01-as-is.md`
|
|
111
|
+
- `02-to-be-plan.md`
|
|
112
|
+
- `03-implementation-summary.md`
|
|
113
|
+
- `04-test-summary.md`
|
|
114
|
+
- `05-manual-qa.md`
|
|
115
|
+
- `06-decisions-update.md`
|
|
116
|
+
- `07-state-update.md`
|
|
117
|
+
- `08-memory-impact.md`
|
|
118
|
+
- `addenda/` (see Addenda policy)
|
|
119
|
+
- `evidence/` (standardized evidence artifacts; screenshots/logs/perf/traces)
|
|
120
|
+
|
|
121
|
+
The run folder is the durable record for the requirement. It must be sufficient to understand and reproduce work without relying on chat logs.
|
|
122
|
+
|
|
123
|
+
When beginning a new run, use `/.recursive/DECISIONS.md` to locate earlier run folders relevant to the current requirement or AS-IS analysis. If any are found, read only the prior run artifacts most relevant to the same subsystem, workflow, or architectural area being changed. If none are found, skip this step.
|
|
124
|
+
|
|
125
|
+
## Memory taxonomy, metadata, and freshness
|
|
126
|
+
|
|
127
|
+
`MEMORY.md` is the router/index for the memory plane. It must remain concise and act as:
|
|
128
|
+
|
|
129
|
+
- registry
|
|
130
|
+
- retrieval guide
|
|
131
|
+
- freshness policy
|
|
132
|
+
- sharding guide
|
|
133
|
+
- ownership map
|
|
134
|
+
|
|
135
|
+
It must not become a giant knowledge dump.
|
|
136
|
+
|
|
137
|
+
Supported memory doc types:
|
|
138
|
+
|
|
139
|
+
- `index`
|
|
140
|
+
- `domain`
|
|
141
|
+
- `pattern`
|
|
142
|
+
- `incident`
|
|
143
|
+
- `episode`
|
|
144
|
+
- `training`
|
|
145
|
+
|
|
146
|
+
Skill memory is a first-class part of the memory plane. Use `/.recursive/memory/skills/SKILLS.md` as the skill-memory router and shard durable skill knowledge under:
|
|
147
|
+
|
|
148
|
+
- `skills/availability/` for environment-specific capability probes and availability notes
|
|
149
|
+
- `skills/usage/` for stable skill fit and usage guidance
|
|
150
|
+
- `skills/issues/` for recurring skill failures or confusing behavior
|
|
151
|
+
- `skills/patterns/` for reusable multi-skill operating patterns
|
|
152
|
+
|
|
153
|
+
Training memory is a separate first-class part of the memory plane. Use `/.recursive/memory/training/` for experiential learnings extracted from completed recursive-mode runs and keyed by recurring task type, workflow shape, or other reusable operational pattern.
|
|
154
|
+
|
|
155
|
+
Phase 8 must update skill memory when a run teaches the repository something durable about skill availability, skill fit, delegated review quality, or repeated workflow friction.
|
|
156
|
+
Phase 8 must also record a run-local skill-usage capture before deciding what, if anything, is worth promoting into durable skill memory.
|
|
157
|
+
|
|
158
|
+
Every durable memory doc except `MEMORY.md` must include metadata near the top with at least:
|
|
159
|
+
|
|
160
|
+
- `Type`
|
|
161
|
+
- `Status`
|
|
162
|
+
- `Scope`
|
|
163
|
+
- `Owns-Paths`
|
|
164
|
+
- `Watch-Paths`
|
|
165
|
+
- `Source-Runs`
|
|
166
|
+
- `Validated-At-Commit`
|
|
167
|
+
- `Last-Validated`
|
|
168
|
+
- `Tags`
|
|
169
|
+
|
|
170
|
+
Optional metadata fields:
|
|
171
|
+
|
|
172
|
+
- `Parent`
|
|
173
|
+
- `Children`
|
|
174
|
+
- `Supersedes`
|
|
175
|
+
- `Superseded-By`
|
|
176
|
+
|
|
177
|
+
Allowed memory statuses:
|
|
178
|
+
|
|
179
|
+
- `CURRENT` — authoritative enough for planning and execution
|
|
180
|
+
- `SUSPECT` — may be read as a lead but must be revalidated before trust
|
|
181
|
+
- `STALE` — excluded from default retrieval
|
|
182
|
+
- `DEPRECATED` — historical only; excluded from default retrieval
|
|
183
|
+
- `DRAFT` — candidate memory, not yet durable
|
|
184
|
+
|
|
185
|
+
Freshness rules:
|
|
186
|
+
|
|
187
|
+
- `domain` docs use `Owns-Paths` for primary ownership of code surfaces.
|
|
188
|
+
- `pattern` and `incident` docs may declare `Watch-Paths` without being the primary owner.
|
|
189
|
+
- `training` docs do not own product paths; they should use `Watch-Paths` or equivalent applicability guidance to record where the learning tends to apply.
|
|
190
|
+
- If a final validated code diff touches a path matched by `Owns-Paths` or `Watch-Paths`, that memory doc must be reviewed in Phase 8.
|
|
191
|
+
- Affected `CURRENT` docs must be downgraded to `SUSPECT` until semantic review is complete.
|
|
192
|
+
- Only after semantic review against final code, `STATE.md`, and `DECISIONS.md` may a `SUSPECT` doc return to `CURRENT`.
|
|
193
|
+
- If changed code paths have no matching owning `domain` doc, Phase 8 must either create a new domain memory doc or record an explicit uncovered-path follow-up.
|
|
194
|
+
|
|
195
|
+
Sharding rules:
|
|
196
|
+
|
|
197
|
+
- The memory model supports recursive splits such as `BACKEND.md` -> `BACKEND-api.md`, `BACKEND-db.md`, `BACKEND-jobs.md`.
|
|
198
|
+
- After a split, the parent doc becomes a summary/router and must not duplicate the full child content.
|
|
199
|
+
- Split a memory doc when it covers mostly independent modules, broad invalidation keeps making it too noisy, or retrieval materially improves with narrower child docs.
|
|
200
|
+
|
|
201
|
+
## Workflow Profiles
|
|
202
|
+
|
|
203
|
+
New runs should declare:
|
|
204
|
+
|
|
205
|
+
- `Workflow version: recursive-mode-audit-v2`
|
|
206
|
+
|
|
207
|
+
Compatibility aliases:
|
|
208
|
+
|
|
209
|
+
- `recursive-mode-audit-v1` for the earlier strict-audit profile
|
|
210
|
+
- `memory-phase8` for the earlier phase8-aware workflow
|
|
211
|
+
- legacy runs with no late-phase marker
|
|
212
|
+
|
|
213
|
+
`recursive-mode-audit-v2` is the current stable profile. It keeps the audited-phase contract from v1 and adds a lossless Phase 1/Phase 2 handoff:
|
|
214
|
+
|
|
215
|
+
- Phase 1 must include `## Source Requirement Inventory`
|
|
216
|
+
- Phase 2 must include `## Requirement Mapping`
|
|
217
|
+
- Phase 2 must include `## Plan Drift Check`
|
|
218
|
+
- Phase 2 `## Requirement Completion Status` uses planning dispositions such as `planned`, `planned-via-merge`, and `planned-indirectly`
|
|
219
|
+
|
|
220
|
+
`recursive-mode-audit-v1` remains supported for backward compatibility, but it does not require the stricter source-inventory and Phase 2 guardrail sections.
|
|
221
|
+
|
|
222
|
+
## Recursive phases
|
|
223
|
+
|
|
224
|
+
Recursive phases are stage-gated. The next phase uses the previous phase's output as input.
|
|
225
|
+
|
|
226
|
+
## Mandatory audit loop for audited phases
|
|
227
|
+
|
|
228
|
+
The following are audited phases:
|
|
229
|
+
|
|
230
|
+
- Phase 1 — AS-IS
|
|
231
|
+
- Phase 1.5 — Root Cause (when present)
|
|
232
|
+
- Phase 2 — TO-BE plan
|
|
233
|
+
- Phase 3 — Implementation summary
|
|
234
|
+
- Phase 3.5 — Code review (when present)
|
|
235
|
+
- Phase 4 — Test summary
|
|
236
|
+
- Phase 6 — Decisions update
|
|
237
|
+
- Phase 7 — State update
|
|
238
|
+
- Phase 8 — Memory impact
|
|
239
|
+
|
|
240
|
+
For every audited phase in `recursive-mode-audit-v1` and `recursive-mode-audit-v2`, the phase contract is:
|
|
241
|
+
|
|
242
|
+
1. Draft or revise the phase artifact.
|
|
243
|
+
2. Re-read the effective upstream artifacts.
|
|
244
|
+
3. Reconcile against the diff basis recorded in `00-worktree.md`.
|
|
245
|
+
4. Run the phase audit.
|
|
246
|
+
5. If gaps or drift remain, stay in the current phase.
|
|
247
|
+
6. Repair the work.
|
|
248
|
+
7. Re-run the audit.
|
|
249
|
+
8. Only after `Audit: PASS` may `Coverage: PASS` and `Approval: PASS`.
|
|
250
|
+
9. Only then may the artifact lock.
|
|
251
|
+
|
|
252
|
+
Mandatory audit recording for every audited phase:
|
|
253
|
+
|
|
254
|
+
- `Audit Execution Mode: subagent` or `Audit Execution Mode: self-audit`
|
|
255
|
+
- `Subagent Availability: available` or `Subagent Availability: unavailable`
|
|
256
|
+
- `Subagent Capability Probe:` with the concrete capability check or environmental fact used
|
|
257
|
+
- `Delegation Decision Basis:` explaining why delegation was or was not used
|
|
258
|
+
- `Delegation Override Reason:` required when `Subagent Availability: available` but `Audit Execution Mode: self-audit`
|
|
259
|
+
- `Audit Inputs Provided:` with the exact artifact paths, diff basis, changed files, and code references used
|
|
260
|
+
|
|
261
|
+
Every audited phase must also record:
|
|
262
|
+
|
|
263
|
+
- `## Subagent Contribution Verification`
|
|
264
|
+
- `## Requirement Completion Status`
|
|
265
|
+
|
|
266
|
+
When delegated work materially contributes, `## Subagent Contribution Verification` must record:
|
|
267
|
+
|
|
268
|
+
- `Reviewed Action Records:`
|
|
269
|
+
- `Main-Agent Verification Performed:`
|
|
270
|
+
- `Acceptance Decision: accepted|partially accepted|rejected`
|
|
271
|
+
- `Refresh Handling:`
|
|
272
|
+
- `Repair Performed After Verification:`
|
|
273
|
+
|
|
274
|
+
Controller verification references must be real. `Main-Agent Verification Performed` should cite existing files, diff-owned paths, bundles, or recursive artifacts actually checked by the controller, and any paths cited in `Repair Performed After Verification` should also resolve.
|
|
275
|
+
|
|
276
|
+
If subagents are available and the full context bundle can be assembled, delegated audit/review is the default path.
|
|
277
|
+
If the controller keeps `Audit Execution Mode: self-audit` despite available subagents, it must record `Delegation Override Reason` with the concrete reason the controller chose not to delegate.
|
|
278
|
+
If subagents are unavailable, the main agent must perform the same audit itself. Audit rigor is not optional.
|
|
279
|
+
|
|
280
|
+
## Canonical delegated review bundle
|
|
281
|
+
|
|
282
|
+
Delegated review and audit should use a canonical review bundle stored under:
|
|
283
|
+
|
|
284
|
+
- `/.recursive/run/<run-id>/evidence/review-bundles/`
|
|
285
|
+
|
|
286
|
+
Use `recursive-review-bundle` when possible to package the handoff. A valid bundle must include:
|
|
287
|
+
|
|
288
|
+
- phase name and artifact path
|
|
289
|
+
- artifact content hash
|
|
290
|
+
- reviewer role
|
|
291
|
+
- upstream artifacts to reread
|
|
292
|
+
- relevant addenda
|
|
293
|
+
- relevant prior recursive evidence
|
|
294
|
+
- relevant control-plane docs when needed
|
|
295
|
+
- normalized diff basis from `00-worktree.md`
|
|
296
|
+
- changed file list
|
|
297
|
+
- targeted code references
|
|
298
|
+
- evidence references
|
|
299
|
+
- phase-specific audit questions
|
|
300
|
+
- required output shape
|
|
301
|
+
|
|
302
|
+
For Phase 3.5, the phase artifact should record `Review Bundle Path` in `## Review Metadata`.
|
|
303
|
+
If repairs materially change the reviewed scope, refresh the bundle before re-audit.
|
|
304
|
+
`recursive-review-bundle` auto-discovers relevant addenda by default. Do not silently omit them from delegated review context.
|
|
305
|
+
The written Phase 3.5 review must cite the bundle path plus bundle-grounded upstream artifacts, relevant addenda, and changed files or code references in the review narrative, not only in metadata boilerplate.
|
|
306
|
+
|
|
307
|
+
## Canonical router policy for delegated model calls
|
|
308
|
+
|
|
309
|
+
Canonical routing files live under:
|
|
310
|
+
|
|
311
|
+
- `/.recursive/config/recursive-router.json`
|
|
312
|
+
- `/.recursive/config/recursive-router-discovered.json`
|
|
313
|
+
|
|
314
|
+
When the controller or any recursive subskill is about to call another model or external CLI for delegated audit, review, bounded implementation, or other routed subagent work, it must re-read the routing policy and discovery inventory from disk immediately before choosing the CLI/model.
|
|
315
|
+
|
|
316
|
+
Do not rely on stale chat context, earlier prompt text, or previously remembered route selections when these files may have changed during the run.
|
|
317
|
+
|
|
318
|
+
If routed delegation has been requested or the current task is already operating under routed policy, prefer the canonical `recursive-router` resolve/invoke path over hardcoded provider or model strings.
|
|
319
|
+
|
|
320
|
+
An active configured external route is policy, not a hint. When the selected role resolves to `external-cli`, the controller must dispatch through the canonical resolve/invoke path before claiming that delegated role was satisfied. Do not substitute local implementation, testing, review, or audit work just because the local path is faster or the change seems narrow.
|
|
321
|
+
|
|
322
|
+
If the effective route is unresolved, blocked, or falls back to `self-audit` or local execution, record that outcome explicitly in the phase artifact or subagent action record instead of silently bypassing routing.
|
|
323
|
+
|
|
324
|
+
When running from an isolated worktree, the routing policy and discovery inventory must be present and current in that worktree before route resolution. Discovery inventory is local and may be untracked, so refresh it with the router probe or copy the intended inventory from the controller/source repo before invoking a routed role.
|
|
325
|
+
|
|
326
|
+
The orchestrator may reject routed output after checking it against actual files, actual diffs, and actual recursive artifacts, then repair locally. If that happens, record the routed rejection and the concrete local repair; do not present the repair as evidence that the routed role performed or verified the work.
|
|
327
|
+
|
|
328
|
+
If `recursive-router-invoke` returns `success: false`, records a nonzero `exit_code`, or returns findings that the bounded routed role is responsible for fixing, the attempt is not acceptable phase evidence. Preserve routed output, stdout/stderr captures, and invocation metadata under `/.recursive/run/<run-id>/evidence/router/`, record a failed action record or phase note, instruct the routed role to fix the concrete issue when that role has bounded ownership, rerun the routed invocation, and repeat controller verification. If the route cannot produce an acceptable zero-exit result, record the fallback before relying on local repair or self-audit evidence.
|
|
329
|
+
|
|
330
|
+
When routed delegation is used, the relevant phase artifact, review bundle, or action record should cite:
|
|
331
|
+
|
|
332
|
+
- `Routing Config Path`
|
|
333
|
+
- `Routing Discovery Path`
|
|
334
|
+
- `Routed CLI`
|
|
335
|
+
- `Routed Model`
|
|
336
|
+
|
|
337
|
+
## Canonical subagent action records
|
|
338
|
+
|
|
339
|
+
Any meaningful subagent invocation must leave a durable action record under:
|
|
340
|
+
|
|
341
|
+
- `/.recursive/run/<run-id>/subagents/`
|
|
342
|
+
|
|
343
|
+
Routed assistant output, raw transcripts, stdout/stderr captures, and invocation metadata are evidence, not action records. Store them under the run evidence tree, preferably `/.recursive/run/<run-id>/evidence/router/`, and cite them from the generated action record. Initial prompt bundles are dispatch inputs for a concrete run; keep them under a run-scoped prompt-bundle location such as `/.recursive/run/<run-id>/router-prompts/` and cite them as `Prompt Bundle Path`. Do not bootstrap top-level `/.recursive/router-prompts/` in reusable repos. Do not place raw transcript Markdown files directly in `subagents/`; the run linter treats every Markdown file in that directory as a canonical subagent action record.
|
|
344
|
+
|
|
345
|
+
The action record is the canonical claim record for what the subagent says it did. The main agent must verify that record against the actual worktree diff, the actual files, the review bundle when present, and the relevant recursive artifacts before accepting the result.
|
|
346
|
+
|
|
347
|
+
Each action record must include:
|
|
348
|
+
|
|
349
|
+
- metadata (`Subagent ID`, `Run ID`, `Phase`, `Purpose`, `Execution Mode`, `Timestamp`)
|
|
350
|
+
- inputs provided (`Current Artifact`, `Upstream Artifacts`, `Addenda`, `Review Bundle`, `Diff Basis`, `Code Refs`, `Memory Refs`, `Audit / Task Questions`)
|
|
351
|
+
- claimed actions taken
|
|
352
|
+
- claimed file impact (`Created`, `Modified`, `Reviewed`, `Relevant but Untouched`)
|
|
353
|
+
- claimed artifact impact (`Read`, `Updated`, `Evidence Used`)
|
|
354
|
+
- claimed findings
|
|
355
|
+
- verification handoff
|
|
356
|
+
|
|
357
|
+
For meaningful delegated work, the action record must not be content-free. A `none everywhere` action record is not sufficient evidence for a passing audited phase.
|
|
358
|
+
|
|
359
|
+
For delegated review and audit, `Current Artifact` should normally point at the stable artifact the subagent actually reviewed, not a mutable controller-authored phase receipt that will keep changing after the subagent returns. If the referenced artifact changes materially after the subagent worked, refresh the action record before relying on it for lockable evidence.
|
|
360
|
+
|
|
361
|
+
If a phase materially used subagent work, the phase artifact must cite the reviewed action record paths in `## Subagent Contribution Verification` and must record whether the main agent accepted or rejected each one.
|
|
362
|
+
|
|
363
|
+
Main-agent verification must be grounded, not ceremonial. For meaningful delegated work, the controller must verify:
|
|
364
|
+
|
|
365
|
+
- claimed file impact against the actual diff-owned file set
|
|
366
|
+
- claimed artifact reads or updates against files that actually exist
|
|
367
|
+
- bundle claims against the current review bundle and reviewed artifact hash
|
|
368
|
+
- requirement, plan, addenda, and prior recursive docs that materially informed acceptance
|
|
369
|
+
- whether repairs after delegated work invalidated stale delegated context and required refresh
|
|
370
|
+
|
|
371
|
+
If those checks are incomplete, the delegated result must be treated as unaccepted and the phase must fall back to self-audit for lockable completion evidence.
|
|
372
|
+
|
|
373
|
+
## Skill discovery and capability extension
|
|
374
|
+
|
|
375
|
+
When a run needs a specialized capability that is not already available, do not improvise blindly. Prefer this escalation order:
|
|
376
|
+
|
|
377
|
+
1. If the `find-skills` skill is already available, use it first.
|
|
378
|
+
2. Otherwise use the Skills CLI directly.
|
|
379
|
+
3. If no suitable skill is found, proceed with built-in capability and record that no suitable external skill was available.
|
|
380
|
+
|
|
381
|
+
Useful Skills CLI commands:
|
|
382
|
+
|
|
383
|
+
- `npx skills find <query>`
|
|
384
|
+
- `npx skills add <package-or-repo>`
|
|
385
|
+
- `npx skills add <package-or-repo> --skill <skill-name>`
|
|
386
|
+
- `npx skills check`
|
|
387
|
+
- `npx skills update`
|
|
388
|
+
|
|
389
|
+
For discovery and evaluation, prefer skills with:
|
|
390
|
+
|
|
391
|
+
- meaningful install counts
|
|
392
|
+
- reputable publishers or source organizations
|
|
393
|
+
- healthy upstream repositories and documentation
|
|
394
|
+
|
|
395
|
+
If a run materially depends on skill discovery, record the result in Phase 8 under `## Run-Local Skill Usage Capture` and promote only durable, reusable conclusions into `/.recursive/memory/skills/`.
|
|
396
|
+
|
|
397
|
+
## Reusable-skill repository hygiene
|
|
398
|
+
|
|
399
|
+
Some repos use recursive-mode to improve a reusable skill, workflow, or template rather than to ship a normal product change. In those repos:
|
|
400
|
+
|
|
401
|
+
- do not commit current-session run folders under `/.recursive/run/<run-id>/`
|
|
402
|
+
- do not commit evidence logs, review bundles, subagent action records, or temp outputs as durable repo state unless they are intentional test fixtures
|
|
403
|
+
- do not update `STATE.md`, `DECISIONS.md`, or durable memory docs with session-specific implementation history unless that content is intentionally promoted as generic reusable guidance
|
|
404
|
+
- do not elevate environment-specific observations into durable memory without generalizing them first
|
|
405
|
+
|
|
406
|
+
Before closeout in a reusable-skill repo, run the packaged `check-reusable-repo-hygiene` helper and confirm the shipped repo contains only reusable workflow/skill content, not session residue.
|
|
407
|
+
For repo-improvement work in a reusable-skill repo, the task is not complete until the final handoff snapshot is clean:
|
|
408
|
+
|
|
409
|
+
- no committed run-instance artifacts
|
|
410
|
+
- no committed generated local residue such as `__pycache__/` or `*.pyc`
|
|
411
|
+
- no disposable validation outputs
|
|
412
|
+
- no temp-path residue
|
|
413
|
+
- no dirty worktree at handoff time
|
|
414
|
+
|
|
415
|
+
Run the packaged `check-reusable-repo-hygiene` helper with `--require-clean-git` as the final cleanliness check before calling the repo handoff-ready.
|
|
416
|
+
|
|
417
|
+
## Phase definitions
|
|
418
|
+
|
|
419
|
+
Phase 0 — Worktree Isolation (REQUIRED)
|
|
420
|
+
- Input: Git repository state, user preferences
|
|
421
|
+
- Output: `/.recursive/run/<run-id>/00-worktree.md`
|
|
422
|
+
- **The Iron Law:** NEVER WORK ON MAIN/MASTER BRANCH WITHOUT EXPLICIT CONSENT
|
|
423
|
+
- **TODO Requirement:** Phase artifact MUST include `## TODO` section with checkable items
|
|
424
|
+
- **TODO Enforcement:** ALL TODO items must be checked off before locking
|
|
425
|
+
- Creates isolated git worktree at `.worktrees/<run-id>/` (or configured location)
|
|
426
|
+
- Verifies worktree directory is git-ignored (if project-local)
|
|
427
|
+
- Runs project setup (auto-detects: npm install, cargo build, pip install, etc.)
|
|
428
|
+
- Verifies clean test baseline (all tests passing before changes)
|
|
429
|
+
- Records reusable diff basis metadata for later audits:
|
|
430
|
+
- baseline type
|
|
431
|
+
- baseline reference
|
|
432
|
+
- comparison reference
|
|
433
|
+
- normalized baseline
|
|
434
|
+
- normalized comparison
|
|
435
|
+
- normalized diff command
|
|
436
|
+
- any non-default basis notes
|
|
437
|
+
- `recursive-init` should prefill a safe default diff basis from the current `HEAD` commit when possible so Phase 0 starts from executable metadata instead of placeholders
|
|
438
|
+
- If Phase 0 changes the chosen baseline later, it must update the entire diff-basis block together and re-run lint before locking
|
|
439
|
+
- Must be LOCKED before Phase 1 can begin
|
|
440
|
+
- **All subsequent phases execute in worktree context**
|
|
441
|
+
|
|
442
|
+
Phase 0 — Requirements (user-created first)
|
|
443
|
+
- Input: chat discussion outside the repo documents
|
|
444
|
+
- Output: `/.recursive/run/<run-id>/00-requirements.md`
|
|
445
|
+
- **TODO Requirement:** Phase artifact MUST include `## TODO` section with checkable items
|
|
446
|
+
- **TODO Enforcement:** ALL TODO items must be checked off before locking
|
|
447
|
+
|
|
448
|
+
Phase 1 — AS-IS analysis
|
|
449
|
+
- Input: `00-requirements.md` (plus addenda)
|
|
450
|
+
- Output: `01-as-is.md`
|
|
451
|
+
- Audit must reread earlier relevant run docs when they matter to the same subsystem, workflow, or architecture area
|
|
452
|
+
- Audit must record which upstream artifacts and prior recursive evidence were reread
|
|
453
|
+
- In `recursive-mode-audit-v2`, Phase 1 must include `## Source Requirement Inventory` so each source obligation is indexed with a source quote, normalized summary, and disposition before Phase 2 planning begins
|
|
454
|
+
- **TODO Requirement:** Phase artifact MUST include `## TODO` section with checkable items
|
|
455
|
+
- **TODO Enforcement:** ALL TODO items must be checked off before locking
|
|
456
|
+
|
|
457
|
+
Phase 1.5 — Root Cause Analysis (Debug Mode, optional)
|
|
458
|
+
- Input: `01-as-is.md` (plus addenda)
|
|
459
|
+
- Output: `01.5-root-cause.md`
|
|
460
|
+
- **Use when:** Requirement involves debugging a bug, test failure, or unexpected behavior
|
|
461
|
+
- **The Iron Law:** NO FIXES WITHOUT ROOT CAUSE INVESTIGATION FIRST
|
|
462
|
+
- Audit must confirm the root cause, not just the symptom, and must fail if the fix strategy is still guesswork
|
|
463
|
+
- **TODO Requirement:** Phase artifact MUST include `## TODO` section with checkable items
|
|
464
|
+
- **TODO Enforcement:** ALL TODO items must be checked off before locking
|
|
465
|
+
- Must be LOCKED before Phase 2 when present
|
|
466
|
+
|
|
467
|
+
Phase 2 — TO-BE plan (ExecPlan-grade)
|
|
468
|
+
- Input: `01-as-is.md` (plus addenda) and by reference `00-requirements.md`
|
|
469
|
+
- If Phase 1.5 exists: also input `01.5-root-cause.md` (plus addenda)
|
|
470
|
+
- Output: `02-to-be-plan.md`
|
|
471
|
+
- Audit must fail unless:
|
|
472
|
+
- every in-scope `R#` is planned in `recursive-mode-audit-v1`
|
|
473
|
+
- every Phase 1 source-inventory item is accounted for in `recursive-mode-audit-v2`
|
|
474
|
+
- targeted files/modules are concrete
|
|
475
|
+
- tests and QA coverage are concrete
|
|
476
|
+
- expected change surface is concrete enough for later diff reconciliation
|
|
477
|
+
- In `recursive-mode-audit-v2`, Phase 2 must include `## Requirement Mapping`, `## Plan Drift Check`, and plan-stage `## Requirement Completion Status`
|
|
478
|
+
- In `recursive-mode-audit-v2`, vague umbrella restatements are invalid unless `## Requirement Mapping` explicitly records the covered source-inventory items and any merge rationale
|
|
479
|
+
- Phase 2 owns planning completeness plus the expected product/worktree change surface only; later `/.recursive/DECISIONS.md`, `/.recursive/STATE.md`, and `/.recursive/memory/**` churn must not retroactively invalidate a locked Phase 2 artifact
|
|
480
|
+
- **TODO Requirement:** Phase artifact MUST include `## TODO` section with checkable items
|
|
481
|
+
- **TODO Enforcement:** ALL TODO items must be checked off before locking
|
|
482
|
+
|
|
483
|
+
Phase 3 — Implementation (TDD discipline)
|
|
484
|
+
- Input: `02-to-be-plan.md` (plus addenda)
|
|
485
|
+
- Output: `03-implementation-summary.md`
|
|
486
|
+
- **The Iron Law:** NO PRODUCTION CODE WITHOUT A FAILING TEST FIRST
|
|
487
|
+
- Must declare `TDD Mode: strict|pragmatic` in the TDD Compliance Log
|
|
488
|
+
- Strict mode is the default and requires explicit RED and GREEN evidence paths under `/.recursive/run/<run-id>/evidence/`
|
|
489
|
+
- Pragmatic mode is allowed only with an explicit exception rationale plus compensating validation evidence
|
|
490
|
+
- Must include TDD Compliance Log documenting RED-GREEN-REFACTOR cycles or the explicit pragmatic exception
|
|
491
|
+
- All requirements must have tests written before implementation
|
|
492
|
+
- Audit must reconcile:
|
|
493
|
+
- `00-requirements.md`
|
|
494
|
+
- `02-to-be-plan.md`
|
|
495
|
+
- actual product/worktree changed files vs claimed scope
|
|
496
|
+
- required implementation and test evidence
|
|
497
|
+
- Phase 3 owns drift reconciliation for product/worktree paths; downstream addenda may compensate for upstream plan gaps without editing locked history
|
|
498
|
+
- Subagents may assist with bounded, disjoint implementation sub-phases, but the controller remains responsible for the audit loop
|
|
499
|
+
- **TODO Requirement:** Phase artifact MUST include `## TODO` section with checkable items for each sub-phase
|
|
500
|
+
- **TODO Enforcement:** ALL TODO items must be checked off before locking
|
|
501
|
+
|
|
502
|
+
Phase 3.5 — Code Review (optional but fully audited when present)
|
|
503
|
+
- Input: `02-to-be-plan.md` and `03-implementation-summary.md`
|
|
504
|
+
- Output: `03.5-code-review.md`
|
|
505
|
+
- **Use when:** High-risk changes, complex sub-phases, or extra confidence needed
|
|
506
|
+
- Delegated review is valid only with the full context bundle
|
|
507
|
+
- Before delegated dispatch, re-read `/.recursive/config/recursive-router.json` and `/.recursive/config/recursive-router-discovered.json` as required by `## Canonical router policy for delegated model calls`
|
|
508
|
+
- Prefer a canonical review bundle under `/.recursive/run/<run-id>/evidence/review-bundles/` and record its path in the phase artifact
|
|
509
|
+
- `## Changed Files Reviewed` must not be empty, and `## Targeted Code References` should overlap the changed-file scope being reviewed
|
|
510
|
+
- Audit must explicitly review requirements, plan alignment, product/worktree diff ownership, code quality, test adequacy, and TDD compliance
|
|
511
|
+
- If blocking issues remain, this phase must FAIL and send the run back to Phase 3 repair
|
|
512
|
+
- **TODO Requirement:** Phase artifact MUST include `## TODO` section with checkable items
|
|
513
|
+
- **TODO Enforcement:** ALL TODO items must be checked off before locking
|
|
514
|
+
- Must be LOCKED before Phase 4 if present
|
|
515
|
+
|
|
516
|
+
Phase 4 - Tests and validation
|
|
517
|
+
- Input: `02-to-be-plan.md`, `03-implementation-summary.md`, and `03.5-code-review.md` when present
|
|
518
|
+
- Output: `04-test-summary.md`
|
|
519
|
+
- Use `recursive-closeout` as the standard starting scaffold for Phase 4 so the required sections, header fields, and effective-input lists are populated before authoring the final receipt
|
|
520
|
+
- Before running tests, perform a pre-test implementation audit against requirements, plan, current product/worktree diff ownership, changed files, and required test files/commands
|
|
521
|
+
- If the pre-test audit finds unfinished in-scope work, return to Phase 3 repair before relying on test results
|
|
522
|
+
- Test execution may be parallelized only inside the active phase and only after the pre-test audit is complete
|
|
523
|
+
- **TODO Requirement:** Phase artifact MUST include `## TODO` section with checkable items
|
|
524
|
+
- **TODO Enforcement:** ALL TODO items must be checked off before locking
|
|
525
|
+
|
|
526
|
+
Phase 5 — Manual QA
|
|
527
|
+
- Input: QA scenarios defined in `02-to-be-plan.md` (plus addenda) and the implemented system
|
|
528
|
+
- Output: `05-manual-qa.md` (completed with observed results and the declared QA execution mode)
|
|
529
|
+
- Use `recursive-closeout` as the standard starting scaffold for Phase 5; when a preview-server log is available, capture the actual served URL from that log instead of copying the requested port blindly
|
|
530
|
+
- Must declare `QA Execution Mode: human|agent-operated|hybrid`
|
|
531
|
+
- Human mode requires user sign-off
|
|
532
|
+
- Agent-operated mode requires execution record, tools used, and evidence paths, but not human sign-off
|
|
533
|
+
- Hybrid mode requires both execution record/evidence and user sign-off
|
|
534
|
+
- **TODO Requirement:** Phase artifact MUST include `## TODO` section with checkable items
|
|
535
|
+
- **TODO Enforcement:** ALL TODO items must be checked off before locking
|
|
536
|
+
- **Special:** A user-facing PAUSE is required only for human or hybrid QA execution
|
|
537
|
+
|
|
538
|
+
Phase 6 — Global DECISIONS update
|
|
539
|
+
- Input: `05-manual-qa.md`, all prior run artifacts (including addenda), current `/.recursive/DECISIONS.md`, and the validated repo state
|
|
540
|
+
- Output: update/append `/.recursive/DECISIONS.md` with a new run entry that references the run folder docs
|
|
541
|
+
- Output: `06-decisions-update.md` as a compact delta receipt documenting the exact changes made
|
|
542
|
+
- Use `recursive-closeout` as the standard starting scaffold for this late receipt so the delta-oriented structure is present before authoring details
|
|
543
|
+
- Audit must verify the ledger matches the run folder, reviewed final product/worktree paths, `/.recursive/DECISIONS.md`, and validated outcomes
|
|
544
|
+
- The receipt should point to the final ledger entry and summarize only the delta; do not restate large sections of `DECISIONS.md`
|
|
545
|
+
|
|
546
|
+
Phase 7 — Global STATE update
|
|
547
|
+
- Input: `06-decisions-update.md`, the run's DECISIONS entry, current `/.recursive/STATE.md`, and the validated repo state
|
|
548
|
+
- Output: update `/.recursive/STATE.md` to reflect the current state after the change
|
|
549
|
+
- Output: `07-state-update.md` as a compact delta receipt documenting the exact changes made
|
|
550
|
+
- Use `recursive-closeout` as the standard starting scaffold for this late receipt so header inputs/outputs and audited sections stay aligned with tooling
|
|
551
|
+
- Audit must verify `STATE.md` reflects what is true now in the codebase implied by the reviewed final product/worktree paths plus `/.recursive/STATE.md`
|
|
552
|
+
- The receipt should summarize the delta and reference the final state doc rather than duplicating it
|
|
553
|
+
|
|
554
|
+
Phase 8 — Memory maintenance and impact review
|
|
555
|
+
- Input: final validated run artifacts, updated `/.recursive/DECISIONS.md`, updated `/.recursive/STATE.md`, `/.recursive/memory/MEMORY.md`, and affected memory docs
|
|
556
|
+
- Output: updated docs under `/.recursive/memory/*`
|
|
557
|
+
- Output: `08-memory-impact.md` as a compact delta receipt documenting freshness review, status changes, uncovered paths, and any new/split/deprecated memory docs
|
|
558
|
+
- Use `recursive-closeout` as the standard starting scaffold for this late receipt so memory-closeout sections start from a lint-aligned structure instead of hand-built markdown
|
|
559
|
+
- Audit must verify memory updates and status transitions against reviewed final product/worktree paths, touched memory docs, prior memory truth, `STATE.md`, and `DECISIONS.md`
|
|
560
|
+
- Must include `## Run-Local Skill Usage Capture` with concrete availability / attempted / used / worked-well / issue / recommendation fields whenever skill usage is relevant to the run
|
|
561
|
+
- Must include `## Skill Memory Promotion Review` explaining what durable lessons were promoted, what stayed run-local, and why
|
|
562
|
+
- If the optional `recursive-training` skill is installed, run `/.recursive/scripts/recursive-training-phase8-trigger.py` immediately after `08-memory-impact.md` locks to extract or refresh cross-run experiential learnings.
|
|
563
|
+
- `recursive-lock` does not invoke training by itself. After Phase 8 locks, either run the trigger directly or re-run `recursive-closeout --phase 08` (without `--force`) so the helper can call `recursive-training-phase8-trigger.py --auto`.
|
|
564
|
+
- Treat trigger/GRPO exit `2` (extractor unavailable) and exit `3` (zero items written) as unsuccessful training; do not claim the memory plane was updated.
|
|
565
|
+
- **TODO Requirement:** Phase artifact MUST include `## TODO` section with checkable items
|
|
566
|
+
- **TODO Enforcement:** ALL TODO items must be checked off before locking
|
|
567
|
+
- **Completion rule:** the run is not fully complete before Phase 8 passes
|
|
568
|
+
- The receipt should summarize the changed memory docs and outcomes, not restate full memory documents
|
|
569
|
+
|
|
570
|
+
## Recursive prompt contract (how users should invoke phases)
|
|
571
|
+
|
|
572
|
+
Recursive prompts must be concise and path-based. A good prompt:
|
|
573
|
+
- names the phase,
|
|
574
|
+
- names the input file path(s),
|
|
575
|
+
- names the required output file path(s),
|
|
576
|
+
- instructs the agent to enforce Audit, Coverage, and Approval gates when applicable,
|
|
577
|
+
- avoids pasting substantive content.
|
|
578
|
+
|
|
579
|
+
Example prompt pattern:
|
|
580
|
+
|
|
581
|
+
"Run Recursive Phase 2. Input: `/.recursive/run/<run-id>/01-as-is.md` (and addenda). Output: `/.recursive/run/<run-id>/02-to-be-plan.md` as an ExecPlan per `/.recursive/RECURSIVE.md`. Enforce the audit loop plus Coverage and Approval gates. Do not paste requirements into the prompt; only reference repo files."
|
|
582
|
+
|
|
583
|
+
## Required structure for every recursive-mode phase artifact (headers + gates)
|
|
584
|
+
|
|
585
|
+
Every per-run recursive-mode artifact (`00-requirements.md` through `08-memory-impact.md`, plus any addendum files) must begin with a short header and must end with Coverage and Approval gates.
|
|
586
|
+
|
|
587
|
+
For audited phases in `recursive-mode-audit-v1` and `recursive-mode-audit-v2`, the artifact must also contain explicit audit sections before Coverage and Approval, including:
|
|
588
|
+
|
|
589
|
+
- `## Audit Context`
|
|
590
|
+
- `## Effective Inputs Re-read`
|
|
591
|
+
- `## Earlier Phase Reconciliation`
|
|
592
|
+
- `## Subagent Contribution Verification`
|
|
593
|
+
- `## Worktree Diff Audit`
|
|
594
|
+
- `## Gaps Found`
|
|
595
|
+
- `## Repair Work Performed`
|
|
596
|
+
- `## Requirement Completion Status`
|
|
597
|
+
- `## Audit Verdict`
|
|
598
|
+
|
|
599
|
+
The following phases must also include `## Prior Recursive Evidence Reviewed`:
|
|
600
|
+
|
|
601
|
+
- Phase 1
|
|
602
|
+
- Phase 2
|
|
603
|
+
- Phase 4
|
|
604
|
+
- Phase 7
|
|
605
|
+
- Phase 8
|
|
606
|
+
|
|
607
|
+
Additional v2-only required sections:
|
|
608
|
+
|
|
609
|
+
- Phase 1 must include `## Source Requirement Inventory`
|
|
610
|
+
- Phase 2 must include `## Requirement Mapping`
|
|
611
|
+
- Phase 2 must include `## Plan Drift Check`
|
|
612
|
+
|
|
613
|
+
### Required header fields (top of file)
|
|
614
|
+
|
|
615
|
+
Each artifact must start with the following fields in plain markdown:
|
|
616
|
+
|
|
617
|
+
- Run: `/.recursive/run/<run-id>/`
|
|
618
|
+
- Phase: `01 AS-IS` (or the relevant phase number/name)
|
|
619
|
+
- Status: `DRAFT` or `LOCKED`
|
|
620
|
+
- Inputs: list repo-relative paths read to produce this artifact (include addenda when applicable)
|
|
621
|
+
- Outputs: list repo-relative paths written by this phase (usually this file, sometimes additional files)
|
|
622
|
+
- Scope note: one short paragraph stating what this artifact is intended to decide/enable
|
|
623
|
+
|
|
624
|
+
Example header:
|
|
625
|
+
|
|
626
|
+
Run: `/.recursive/run/<run-id>/`
|
|
627
|
+
Phase: `02 TO-BE plan`
|
|
628
|
+
Status: `DRAFT`
|
|
629
|
+
Inputs:
|
|
630
|
+
- `/.recursive/run/<run-id>/01-as-is.md`
|
|
631
|
+
- `/.recursive/run/<run-id>/addenda/01-as-is.addendum-01.md`
|
|
632
|
+
Outputs:
|
|
633
|
+
- `/.recursive/run/<run-id>/02-to-be-plan.md`
|
|
634
|
+
Scope note: This document defines the planned changes and how to validate them.
|
|
635
|
+
|
|
636
|
+
When Status is `LOCKED`, append these fields to the header:
|
|
637
|
+
|
|
638
|
+
- LockedAt: ISO8601 timestamp
|
|
639
|
+
- LockHash: SHA-256 of normalized artifact content at lock time (LF newlines; `LockHash:` line removed)
|
|
640
|
+
|
|
641
|
+
### Required audit fields for audited phases
|
|
642
|
+
|
|
643
|
+
Inside `## Audit Context`, record:
|
|
644
|
+
|
|
645
|
+
- `Audit Execution Mode: subagent` or `Audit Execution Mode: self-audit`
|
|
646
|
+
- `Subagent Availability: available` or `Subagent Availability: unavailable`
|
|
647
|
+
- `Subagent Capability Probe:`
|
|
648
|
+
- `Delegation Decision Basis:`
|
|
649
|
+
- `Delegation Override Reason:` when available subagents were not used
|
|
650
|
+
- `Audit Inputs Provided:` followed by explicit artifact paths, diff basis, changed files, and targeted code references
|
|
651
|
+
|
|
652
|
+
Inside `## Worktree Diff Audit`, record at minimum:
|
|
653
|
+
|
|
654
|
+
- `Baseline type:`
|
|
655
|
+
- `Baseline reference:`
|
|
656
|
+
- `Comparison reference:`
|
|
657
|
+
- `Normalized baseline:`
|
|
658
|
+
- `Normalized comparison:`
|
|
659
|
+
- `Normalized diff command:`
|
|
660
|
+
- `Planned or claimed changed files:`
|
|
661
|
+
- `Actual changed files reviewed:`
|
|
662
|
+
- `Unexplained drift:`
|
|
663
|
+
|
|
664
|
+
`00-worktree.md` is the source of truth for diff basis. `Baseline reference` records the human-facing source ref chosen in Phase 0. `Normalized baseline` records the exact commit that later audits execute against. `Comparison reference` records the intended comparison target, and `Normalized diff command` is the executable command string derived from those values.
|
|
665
|
+
|
|
666
|
+
`recursive-init` should prefill these fields from the current `HEAD` commit when possible, but Phase 0 remains responsible for correcting them if the real worktree context differs. Tooling must fail in Phase 0, not guess later, when the baseline type, references, or normalized command are missing, ambiguous, or inconsistent.
|
|
667
|
+
|
|
668
|
+
Inside `## Requirement Completion Status`, list every in-scope requirement or source-inventory ID using machine-checkable bullets such as:
|
|
669
|
+
|
|
670
|
+
- `R1 | Status: implemented | Changed Files: /path/to/file | Implementation Evidence: /path/to/file, /path/to/artifact`
|
|
671
|
+
- `R2 | Status: verified | Changed Files: /path/to/file | Implementation Evidence: /path/to/file | Verification Evidence: /path/to/test-summary.md`
|
|
672
|
+
- `R3 | Status: deferred | Rationale: [why] | Deferred By: /.recursive/run/<run-id>/addenda/...`
|
|
673
|
+
- `R4 | Status: out-of-scope | Rationale: [why] | Scope Decision: /.recursive/run/<run-id>/addenda/...`
|
|
674
|
+
- `R5 | Status: blocked | Rationale: [why] | Blocking Evidence: /path/to/log, /path/to/artifact`
|
|
675
|
+
- `R6 | Status: superseded by approved addendum | Addendum: /.recursive/run/<run-id>/addenda/...`
|
|
676
|
+
|
|
677
|
+
In `recursive-mode-audit-v2` Phase 2, use planning dispositions instead of implementation dispositions:
|
|
678
|
+
|
|
679
|
+
- `R1 | Status: planned | Implementation Surface: /path/to/file | Verification Surface: /path/to/test-or-artifact | QA Surface: /path/to/manual-qa-or-scenario`
|
|
680
|
+
- `SRC-001 | Status: planned-via-merge | Implementation Surface: /path/to/file | Verification Surface: /path/to/test-or-artifact | QA Surface: not-applicable-with-rationale | Rationale: [why the merge is lossless]`
|
|
681
|
+
- `SRC-002 | Status: planned-indirectly | Implementation Surface: /path/to/file | Verification Surface: /path/to/test-or-artifact | QA Surface: not-applicable-with-rationale | Rationale: [why the obligation is satisfied indirectly]`
|
|
682
|
+
|
|
683
|
+
Mentioning an `R#` only in Traceability is never sufficient for completion proof.
|
|
684
|
+
|
|
685
|
+
Status expectations:
|
|
686
|
+
|
|
687
|
+
- `implemented` requires `Changed Files` plus concrete implementation evidence paths.
|
|
688
|
+
- `verified` requires `Changed Files`, concrete implementation evidence, and concrete verification evidence.
|
|
689
|
+
- `deferred`, `out-of-scope`, and `superseded by approved addendum` require explicit approved rationale/decision references.
|
|
690
|
+
- `blocked` requires concrete blocking evidence, not only narrative prose.
|
|
691
|
+
- Requirement entries must not mix contradictory fields from other statuses.
|
|
692
|
+
- In product/worktree-diff phases, the requirement dispositions should collectively account for the diff-owned changed files rather than leaving changed implementation files unclaimed by any `R#`.
|
|
693
|
+
- Final closeout artifacts must not leave in-scope requirements at `implemented` or `blocked`.
|
|
694
|
+
|
|
695
|
+
### Phase-scoped diff ownership
|
|
696
|
+
|
|
697
|
+
The `## Worktree Diff Audit` section is phase-scoped, not a permanent promise that every earlier artifact must explain the repository's eventual end-state diff forever.
|
|
698
|
+
|
|
699
|
+
- Phase 2 owns planning completeness plus the expected product/worktree change surface.
|
|
700
|
+
- Phase 3, Phase 3.5, and Phase 4 own the actual product/worktree diff and must reconcile implementation drift there.
|
|
701
|
+
- Phase 6 owns `/.recursive/DECISIONS.md` plus the reviewed final product/worktree paths.
|
|
702
|
+
- Phase 7 owns `/.recursive/STATE.md` plus the reviewed final product/worktree paths.
|
|
703
|
+
- Phase 8 owns `/.recursive/memory/**` plus the reviewed final product/worktree paths.
|
|
704
|
+
- Late control-plane or memory churn must not retroactively invalidate an earlier locked planning artifact.
|
|
705
|
+
- If later phases discover a real upstream gap, record it via a current-phase upstream-gap addendum and compensate downstream instead of editing locked history.
|
|
706
|
+
|
|
707
|
+
### Required gate sections (end of file)
|
|
708
|
+
|
|
709
|
+
Every artifact must end with these two sections:
|
|
710
|
+
|
|
711
|
+
#### Coverage Gate
|
|
712
|
+
|
|
713
|
+
State whether the artifact covers everything relevant in the phase input docs. Coverage must be proven mechanically via requirement IDs:
|
|
714
|
+
|
|
715
|
+
- Phase 0 Requirements establishes stable requirement IDs (R1, R2, …) and Out of Scope IDs (OOS1, OOS2, …).
|
|
716
|
+
- Downstream artifacts must map each requirement ID to where it is addressed in that artifact and/or where evidence exists.
|
|
717
|
+
- If a requirement is intentionally deferred, say so explicitly and record the rationale.
|
|
718
|
+
|
|
719
|
+
The Coverage Gate must conclude with one of:
|
|
720
|
+
|
|
721
|
+
- Coverage: PASS
|
|
722
|
+
- Coverage: FAIL (and list what is missing and how it will be added before proceeding)
|
|
723
|
+
|
|
724
|
+
For audited phases:
|
|
725
|
+
|
|
726
|
+
- `Coverage: PASS` is invalid unless `Audit: PASS`.
|
|
727
|
+
- If any in-scope `R#` is unmapped, Coverage must be `FAIL`.
|
|
728
|
+
- If upstream reconciliation is incomplete, Coverage must be `FAIL`.
|
|
729
|
+
|
|
730
|
+
#### Approval Gate
|
|
731
|
+
|
|
732
|
+
State whether the artifact is ready to proceed to the next phase. The Approval Gate must be objective wherever possible (repro is unambiguous, plan includes runnable commands, tests pass, etc.).
|
|
733
|
+
|
|
734
|
+
Manual QA is the exception to purely document-driven progression, but the required sign-off depends on `QA Execution Mode`. Human and hybrid runs require explicit user sign-off. Agent-operated runs require explicit execution metadata and evidence instead.
|
|
735
|
+
|
|
736
|
+
The Approval Gate must conclude with one of:
|
|
737
|
+
|
|
738
|
+
- Approval: PASS
|
|
739
|
+
- Approval: FAIL (and list what must change before proceeding)
|
|
740
|
+
|
|
741
|
+
For audited phases:
|
|
742
|
+
|
|
743
|
+
- `Approval: PASS` is invalid unless `Audit: PASS`.
|
|
744
|
+
- Approval must be `FAIL` if unresolved in-scope gaps remain.
|
|
745
|
+
- Approval must be `FAIL` if unexplained diff drift remains.
|
|
746
|
+
- Approval must be `FAIL` if a required audit section is missing.
|
|
747
|
+
|
|
748
|
+
## Locking and immutability (phase advancement rules)
|
|
749
|
+
|
|
750
|
+
Recursive phases are one-way. Iteration is allowed within a phase, but after a phase advances, earlier artifacts must not be edited.
|
|
751
|
+
|
|
752
|
+
### DRAFT vs LOCKED
|
|
753
|
+
|
|
754
|
+
- While a phase is in progress, its output artifact status is `DRAFT`. The agent may revise it until both gates pass.
|
|
755
|
+
- When both gates pass, the agent must lock the artifact with `.recursive/scripts/recursive-lock.py` or `.recursive/scripts/recursive-lock.ps1`. The lock command is the primary supported path and must:
|
|
756
|
+
1) verify the artifact is lockable,
|
|
757
|
+
2) set Status to `LOCKED`,
|
|
758
|
+
3) set `LockedAt`,
|
|
759
|
+
4) compute `LockHash` (SHA-256),
|
|
760
|
+
5) then allow the run to proceed to the next phase.
|
|
761
|
+
|
|
762
|
+
After an artifact is `LOCKED`, it must not be edited. If something is later discovered to be missing or wrong, use an addendum in the current phase (see Addenda policy).
|
|
763
|
+
|
|
764
|
+
### No backtracking rule
|
|
765
|
+
|
|
766
|
+
If the agent is in Phase N, it must not modify artifacts from Phase < N. If a Phase < N artifact is incomplete or incorrect, the agent must record the gap via a current-phase upstream-gap addendum and proceed forward without editing the locked earlier artifact.
|
|
767
|
+
|
|
768
|
+
### How to compute LockHash
|
|
769
|
+
|
|
770
|
+
When locking an artifact, compute the SHA-256 hash from a **normalized** representation of the
|
|
771
|
+
artifact text to avoid self-referential hashes and platform-specific newline differences.
|
|
772
|
+
|
|
773
|
+
**Canonical rule (this repo):** `LockHash` is the SHA-256 of the artifact content after:
|
|
774
|
+
1) normalizing newlines to `\n` (LF), and
|
|
775
|
+
2) removing the `LockHash:` line entirely (including its trailing newline, if present).
|
|
776
|
+
|
|
777
|
+
This makes `LockHash` stable across Windows/macOS/Linux and avoids the paradox of hashing a file
|
|
778
|
+
that contains its own hash.
|
|
779
|
+
|
|
780
|
+
#### Preferred: use the lock command
|
|
781
|
+
|
|
782
|
+
Use `.recursive/scripts/recursive-lock.py` (cross-platform) or `.recursive/scripts/recursive-lock.ps1` (PowerShell) to lock a draft artifact. Those commands validate lockability, write `Status: LOCKED`, write `LockedAt`, and compute `LockHash` using the canonical normalization rules.
|
|
783
|
+
|
|
784
|
+
#### Secondary: verify an existing lock
|
|
785
|
+
|
|
786
|
+
Use `.recursive/scripts/verify-locks.py` (cross-platform) or `.recursive/scripts/verify-locks.ps1` (PowerShell) to verify and (optionally) fix mismatched hashes on already locked artifacts.
|
|
787
|
+
|
|
788
|
+
#### Manual computation examples
|
|
789
|
+
|
|
790
|
+
**Bash (GNU coreutils):**
|
|
791
|
+
|
|
792
|
+
sed '/^LockHash:/d' /.recursive/run/<run-id>/01-as-is.md | tr -d '\r' | sha256sum
|
|
793
|
+
|
|
794
|
+
**PowerShell (Windows PowerShell 5.1 / PowerShell 7+):**
|
|
795
|
+
|
|
796
|
+
$p = "/.recursive/run/<run-id>/01-as-is.md"
|
|
797
|
+
$t = Get-Content -LiteralPath $p -Raw -Encoding UTF8
|
|
798
|
+
$n = ($t -replace "`r`n","`n") -replace "(?m)^LockHash:.*(?:`n|$)",""
|
|
799
|
+
$b = [System.Text.Encoding]::UTF8.GetBytes($n)
|
|
800
|
+
$h = [System.Security.Cryptography.SHA256]::Create().ComputeHash($b)
|
|
801
|
+
($h | ForEach-Object { $_.ToString("x2") }) -join ""
|
|
802
|
+
|
|
803
|
+
Record the resulting 64-character lowercase hex digest as `LockHash`.
|
|
804
|
+
|
|
805
|
+
## Addenda (mandatory)
|
|
806
|
+
|
|
807
|
+
Addenda are used to preserve immutability while allowing discovery, and to ensure "effective input" is not lost to context rot.
|
|
808
|
+
|
|
809
|
+
All addenda live under:
|
|
810
|
+
|
|
811
|
+
`/.recursive/run/<run-id>/addenda/`
|
|
812
|
+
|
|
813
|
+
### Stage-local addenda (same stage)
|
|
814
|
+
|
|
815
|
+
Stage-local addenda supplement a stage artifact without requiring destructive edits.
|
|
816
|
+
|
|
817
|
+
Naming:
|
|
818
|
+
|
|
819
|
+
- `<base-filename>.addendum-01.md`
|
|
820
|
+
- `<base-filename>.addendum-02.md`
|
|
821
|
+
- ... and so on
|
|
822
|
+
|
|
823
|
+
Examples:
|
|
824
|
+
|
|
825
|
+
- `01-as-is.addendum-01.md`
|
|
826
|
+
- `02-to-be-plan.addendum-01.md`
|
|
827
|
+
|
|
828
|
+
### Upstream-gap addenda (current stage records a gap in a locked earlier stage)
|
|
829
|
+
|
|
830
|
+
If, in Phase N, the agent discovers missing or incorrect information in a LOCKED Phase < N artifact, the agent must not edit the earlier artifact. Instead it must create a current-phase upstream-gap addendum.
|
|
831
|
+
|
|
832
|
+
Naming:
|
|
833
|
+
|
|
834
|
+
`<current-base>.upstream-gap.<prior-base>.addendum-01.md`
|
|
835
|
+
|
|
836
|
+
Examples (while in Phase 4, discovering a gap in Phase 2):
|
|
837
|
+
|
|
838
|
+
- `04-test-summary.upstream-gap.02-to-be-plan.addendum-01.md`
|
|
839
|
+
|
|
840
|
+
The upstream-gap addendum must:
|
|
841
|
+
- state the gap,
|
|
842
|
+
- explain how it was discovered (evidence),
|
|
843
|
+
- state the implications for the current and later phases,
|
|
844
|
+
- state how the current phase compensates (tests added, plan deviation recorded, etc.).
|
|
845
|
+
|
|
846
|
+
### Mandatory "effective input" read rule
|
|
847
|
+
|
|
848
|
+
When a phase declares an input artifact (for example `01-as-is.md`), the agent must treat the effective input as:
|
|
849
|
+
|
|
850
|
+
- the base file, plus
|
|
851
|
+
- all matching stage-local addenda in lexical order, plus
|
|
852
|
+
- any current-phase upstream-gap addenda that compensate for locked-history gaps relevant to that phase.
|
|
853
|
+
|
|
854
|
+
The agent must explicitly list all input addenda in the output artifact's header under Inputs.
|
|
855
|
+
If relevant addenda exist, the phase artifact must also re-read them in `## Effective Inputs Re-read` and reconcile them in `## Earlier Phase Reconciliation`.
|
|
856
|
+
|
|
857
|
+
### Meaningful diff only
|
|
858
|
+
|
|
859
|
+
Diff audit is about meaningful repository changes, not incidental runtime debris.
|
|
860
|
+
Transient byproducts such as `__pycache__/`, `*.pyc`, `.pytest_cache/`, `.mypy_cache/`, and `.ruff_cache/` are excluded from diff-audit enforcement unless the repository intentionally tracks them.
|
|
861
|
+
|
|
862
|
+
### Addenda locking
|
|
863
|
+
|
|
864
|
+
Addenda follow the same DRAFT/LOCKED rule:
|
|
865
|
+
- If an addendum is created during an active phase, it is `DRAFT` until the phase locks.
|
|
866
|
+
- When the phase locks, any stage-local addenda and upstream-gap addenda created in that phase must be locked as well.
|
|
867
|
+
|
|
868
|
+
## Requirement IDs and traceability (mandatory for Coverage Gate)
|
|
869
|
+
|
|
870
|
+
Recursive coverage must be mechanical. The Phase 0 requirements document must define stable IDs and acceptance criteria.
|
|
871
|
+
|
|
872
|
+
### Requirements document requirements (Phase 0)
|
|
873
|
+
|
|
874
|
+
`00-requirements.md` must include:
|
|
875
|
+
|
|
876
|
+
- Requirement IDs: R1, R2, …
|
|
877
|
+
- Out of Scope IDs: OOS1, OOS2, …
|
|
878
|
+
- Observable acceptance criteria for each R# (what a human can do/see)
|
|
879
|
+
- Constraints (if any) that are non-negotiable
|
|
880
|
+
|
|
881
|
+
### Downstream traceability rule
|
|
882
|
+
|
|
883
|
+
Every downstream artifact must include a short "Traceability" section that maps each R# to where it is addressed and what evidence exists.
|
|
884
|
+
|
|
885
|
+
- In analysis and plan phases, evidence may be code pointers, planned tests, and described verification steps.
|
|
886
|
+
- In implementation and validation phases, evidence should be concrete: file paths, diffs, logs, test results, and runtime observations.
|
|
887
|
+
- Vague statements such as "all requirements covered" are invalid unless each in-scope `R#` is mapped explicitly.
|
|
888
|
+
|
|
889
|
+
If a requirement is deferred, it must be explicitly marked as deferred with rationale and its impact on acceptance.
|
|
890
|
+
|
|
891
|
+
For `recursive-mode-audit-v1`, audited phases must also record:
|
|
892
|
+
|
|
893
|
+
- which upstream artifacts were re-read
|
|
894
|
+
- which prior recursive run docs were reviewed when relevant
|
|
895
|
+
- how current claims reconcile with the actual diff basis
|
|
896
|
+
|
|
897
|
+
## Formatting exception for Manual QA
|
|
898
|
+
|
|
899
|
+
This document prefers prose-first writing and discourages tables. Manual QA is the exception.
|
|
900
|
+
|
|
901
|
+
The Phase 5 Manual QA artifact (`05-manual-qa.md`) may use a compact table to present scenarios, expected outcomes, and observed outcomes if it materially improves clarity. Keep it small and focused.
|
|
902
|
+
|
|
903
|
+
## Minimum content expectations by recursive-mode phase
|
|
904
|
+
|
|
905
|
+
These are minimum expectations. Each artifact must still include the required header and gate sections.
|
|
906
|
+
|
|
907
|
+
Phase 0 — `00-requirements.md` (user-created first)
|
|
908
|
+
- Stable requirement IDs (R1…)
|
|
909
|
+
- Out of scope IDs (OOS1…)
|
|
910
|
+
- Acceptance criteria per R#
|
|
911
|
+
- Constraints and assumptions
|
|
912
|
+
- Traceability is not required here, but must be enabled by the IDs
|
|
913
|
+
|
|
914
|
+
Phase 1 — `01-as-is.md`
|
|
915
|
+
- Repro steps (novice-runnable)
|
|
916
|
+
- Current behavior description tied to requirement IDs
|
|
917
|
+
- Relevant code pointers by full path (files, functions/modules)
|
|
918
|
+
- Known unknowns (explicit)
|
|
919
|
+
- Evidence snippets where possible (logs, screenshots described, etc.)
|
|
920
|
+
|
|
921
|
+
Phase 2 — `02-to-be-plan.md` (ExecPlan-grade)
|
|
922
|
+
- Must comply with all ExecPlan requirements in this file
|
|
923
|
+
- Must include:
|
|
924
|
+
- concrete edits by file path and location
|
|
925
|
+
- commands to run
|
|
926
|
+
- tests to add/run
|
|
927
|
+
- manual QA scenarios
|
|
928
|
+
- idempotence/recovery guidance
|
|
929
|
+
- Must include traceability mapping R# -> planned change + validation
|
|
930
|
+
|
|
931
|
+
Phase 6 — `06-decisions-update.md`
|
|
932
|
+
- Exact `DECISIONS.md` edits made for the run
|
|
933
|
+
- Rationale for any ledger structural changes
|
|
934
|
+
- Traceability back to the validated run artifacts
|
|
935
|
+
|
|
936
|
+
Phase 7 — `07-state-update.md`
|
|
937
|
+
- Exact `STATE.md` edits made for the run
|
|
938
|
+
- Current-state truths updated to match the validated implementation
|
|
939
|
+
- Rationale for any major interpretation changes
|
|
940
|
+
|
|
941
|
+
Phase 8 — `08-memory-impact.md`
|
|
942
|
+
- Final diff basis and changed-path analysis
|
|
943
|
+
- Affected memory docs and temporary/final statuses
|
|
944
|
+
- Explicit handling for uncovered changed paths
|
|
945
|
+
- Router/parent refresh notes when memory splits or summaries changed
|
|
946
|
+
|
|
947
|
+
## Large requirements: Implementation sub-phases (required when scope is large or risky)
|
|
948
|
+
|
|
949
|
+
Some requirements are too large or risky to implement safely as a single "Phase 3 then Phase 5" blob. In these cases, the work must be decomposed into ordered sub-phases. Each sub-phase has its own implementation steps, an implementation checklist, and an explicit set of tests that must be run and pass before proceeding.
|
|
950
|
+
|
|
951
|
+
This is not a new top-level recursive-mode phase. Sub-phases are a required structure inside Phase 2 planning and Phase 3/5 execution.
|
|
952
|
+
|
|
953
|
+
### When sub-phases are mandatory
|
|
954
|
+
|
|
955
|
+
Use sub-phases when any of the following are true:
|
|
956
|
+
|
|
957
|
+
- The change touches multiple subsystems (UI + state + persistence + backend, etc.).
|
|
958
|
+
- The change is expected to take more than one focused development session.
|
|
959
|
+
- The risk of regressions is non-trivial (touches critical flows, input handling, playback, persistence, auth, payments, etc.).
|
|
960
|
+
- The requirement includes multiple user-visible behaviors that can be delivered incrementally.
|
|
961
|
+
|
|
962
|
+
If sub-phases are not used for a large change, the Phase 2 Approval Gate must be FAIL unless the plan explicitly justifies why a single pass is safe.
|
|
963
|
+
|
|
964
|
+
### Where sub-phases live (Phase 2: `02-to-be-plan.md`)
|
|
965
|
+
|
|
966
|
+
When sub-phases are used, `02-to-be-plan.md` must include a section titled:
|
|
967
|
+
|
|
968
|
+
"Implementation Sub-phases"
|
|
969
|
+
|
|
970
|
+
Under it, define sub-phases as `SP1`, `SP2`, … in order. Each sub-phase must include:
|
|
971
|
+
|
|
972
|
+
1) Scope and purpose
|
|
973
|
+
- A short paragraph describing what will exist at the end of the sub-phase that does not exist before.
|
|
974
|
+
- Explicit mapping to requirement IDs (R#) covered by this sub-phase.
|
|
975
|
+
|
|
976
|
+
2) Implementation checklist (mandatory)
|
|
977
|
+
- A checkbox list of concrete edits/steps. This is allowed even if other narrative sections remain prose-first.
|
|
978
|
+
- Checklist items must name file paths and functions/modules where applicable.
|
|
979
|
+
|
|
980
|
+
3) Tests for this sub-phase (mandatory)
|
|
981
|
+
- A concrete list of tests to run before the sub-phase is considered complete.
|
|
982
|
+
- Include exact commands (repo-specific).
|
|
983
|
+
- Include Playwright scope rules:
|
|
984
|
+
- Prefer a fast Tier A run for the sub-phase (new/changed tests + `@smoke` if applicable).
|
|
985
|
+
- Specify any tags to use (e.g., `@recursive:<run-id>`, `@smoke`).
|
|
986
|
+
- State pass criteria (what "green" means).
|
|
987
|
+
|
|
988
|
+
4) Sub-phase acceptance (mandatory)
|
|
989
|
+
- Observable behavior a human can verify for this increment (even if the requirement is not fully complete yet).
|
|
990
|
+
- Any temporary limitations or feature flags must be stated explicitly.
|
|
991
|
+
|
|
992
|
+
5) Rollback / recovery notes (when relevant)
|
|
993
|
+
- If the sub-phase can leave the repo in a partially migrated state, describe how to recover.
|
|
994
|
+
|
|
995
|
+
Phase 2 Approval Gate must be FAIL unless sub-phases (when required) include checklists and test commands as described above.
|
|
996
|
+
|
|
997
|
+
### Execution rule (Phase 3 + Phase 4 are performed per sub-phase)
|
|
998
|
+
|
|
999
|
+
When implementing a plan with sub-phases, the agent must execute sub-phases sequentially:
|
|
1000
|
+
|
|
1001
|
+
For each sub-phase SPk:
|
|
1002
|
+
|
|
1003
|
+
1) Implement SPk according to the plan checklist.
|
|
1004
|
+
2) Run the SPk test set exactly as specified in the plan.
|
|
1005
|
+
3) If any SPk tests fail:
|
|
1006
|
+
- Do not proceed to the next sub-phase.
|
|
1007
|
+
- Iterate on implementation (and tests, if the plan requires test additions) until SPk tests pass.
|
|
1008
|
+
4) Only after SPk tests pass may the agent proceed to SP(k+1).
|
|
1009
|
+
|
|
1010
|
+
This rule is non-negotiable. The agent must not "finish implementation first and test later" when sub-phases are defined.
|
|
1011
|
+
|
|
1012
|
+
### How to record progress and evidence (Phase 3 and Phase 4 artifacts)
|
|
1013
|
+
|
|
1014
|
+
Phase 3 output (`03-implementation-summary.md`) must include a section:
|
|
1015
|
+
|
|
1016
|
+
"Sub-phase Implementation Summary"
|
|
1017
|
+
|
|
1018
|
+
For each SPk, record:
|
|
1019
|
+
- files touched (paths),
|
|
1020
|
+
- key behavior changes,
|
|
1021
|
+
- any deviations from the Phase 2 plan (with rationale and evidence pointers).
|
|
1022
|
+
|
|
1023
|
+
Phase 4 output (`04-test-summary.md`) must be organized by sub-phase when sub-phases exist:
|
|
1024
|
+
|
|
1025
|
+
- SP1: commands executed + results + artifact paths
|
|
1026
|
+
- SP2: commands executed + results + artifact paths
|
|
1027
|
+
- …
|
|
1028
|
+
|
|
1029
|
+
The Phase 4 Approval Gate must be FAIL unless every sub-phase's required tests have been executed and are passing (or an explicit decision with mitigation is recorded, and the requirement's constraints allow it).
|
|
1030
|
+
|
|
1031
|
+
### Plan amendments during implementation (without editing locked Phase 2)
|
|
1032
|
+
|
|
1033
|
+
Phase 2 artifacts are locked before Phase 3 begins. If, during Phase 3/5, the agent discovers that the locked plan is missing steps, missing tests, incorrect assumptions, or requires sequencing changes, the agent must not edit the locked `02-to-be-plan.md`.
|
|
1034
|
+
|
|
1035
|
+
Instead, the agent must create a current-phase upstream-gap addendum that functions as a "plan amendment" for the remaining work.
|
|
1036
|
+
|
|
1037
|
+
- Addendum location: `/.recursive/run/<run-id>/addenda/`
|
|
1038
|
+
- Naming (examples):
|
|
1039
|
+
- `03-implementation-summary.upstream-gap.02-to-be-plan.addendum-01.md`
|
|
1040
|
+
- `04-test-summary.upstream-gap.02-to-be-plan.addendum-01.md`
|
|
1041
|
+
|
|
1042
|
+
Each plan-amendment addendum must:
|
|
1043
|
+
- state what in the plan was missing/incorrect,
|
|
1044
|
+
- provide evidence for why the amendment is needed,
|
|
1045
|
+
- specify the amended steps/tests for the remaining sub-phases,
|
|
1046
|
+
- state the impact on traceability (which R# are affected),
|
|
1047
|
+
- and be treated as part of the effective plan input for the remainder of the run.
|
|
1048
|
+
|
|
1049
|
+
When plan amendments exist, subsequent sub-phases must follow the effective plan (base plan + relevant amendment addenda).
|
|
1050
|
+
|
|
1051
|
+
## Playwright tagging for recursive-mode runs and implementation sub-phases (required)
|
|
1052
|
+
|
|
1053
|
+
When recursive-mode uses implementation sub-phases (SP1, SP2, …), Playwright tests must be taggable so the agent can run fast, targeted Tier A validations per sub-phase and broader Tier B regressions at appropriate points.
|
|
1054
|
+
|
|
1055
|
+
### Required tags
|
|
1056
|
+
|
|
1057
|
+
All Playwright tests added or modified as part of a recursive-mode run must include the run tag:
|
|
1058
|
+
|
|
1059
|
+
- `@recursive:<run-id>`
|
|
1060
|
+
|
|
1061
|
+
When sub-phases exist, tests must also be tagged with the sub-phase tag:
|
|
1062
|
+
|
|
1063
|
+
- `@sp1`, `@sp2`, … corresponding to the sub-phase that introduced or modified the test
|
|
1064
|
+
|
|
1065
|
+
If the repository maintains a smoke tier, critical-path guardrail tests must also be tagged:
|
|
1066
|
+
|
|
1067
|
+
- `@smoke`
|
|
1068
|
+
|
|
1069
|
+
These tags may be applied at the `test.describe()` level or on individual tests, but they must be queryable via Playwright's `--grep` or equivalent mechanism used by the repository.
|
|
1070
|
+
|
|
1071
|
+
### Tagging examples (informative)
|
|
1072
|
+
|
|
1073
|
+
A test introduced in SP2 of run `01-example` should be discoverable by grepping for:
|
|
1074
|
+
|
|
1075
|
+
- `@recursive:01-example` and `@sp2`
|
|
1076
|
+
|
|
1077
|
+
A smoke guardrail test relevant to the run should be discoverable by:
|
|
1078
|
+
|
|
1079
|
+
- `@smoke` (and optionally also `@recursive:<run-id>` if it was changed in the run)
|
|
1080
|
+
|
|
1081
|
+
### Tier A / Tier B command requirements (must be specified in the plan)
|
|
1082
|
+
|
|
1083
|
+
When sub-phases exist, the TO-BE plan (`02-to-be-plan.md`) must specify Playwright commands for:
|
|
1084
|
+
|
|
1085
|
+
Tier A (per sub-phase, fast loop)
|
|
1086
|
+
|
|
1087
|
+
- Run the tests introduced/modified in the current sub-phase:
|
|
1088
|
+
- `@recursive:<run-id>` + `@spK`
|
|
1089
|
+
- Plus any required smoke guardrails for affected flows:
|
|
1090
|
+
- `@smoke` (optionally scoped further if the repo supports it)
|
|
1091
|
+
|
|
1092
|
+
Tier B (broader regression)
|
|
1093
|
+
|
|
1094
|
+
- Run all tests for the run:
|
|
1095
|
+
- `@recursive:<run-id>` (all sub-phases)
|
|
1096
|
+
- Optionally run the full suite, or all `@smoke`, or broader tags as required by constraints.
|
|
1097
|
+
|
|
1098
|
+
The plan must record the exact repo-specific commands (package manager, scripts, env vars) rather than generic placeholders.
|
|
1099
|
+
|
|
1100
|
+
### Execution rule (non-negotiable)
|
|
1101
|
+
|
|
1102
|
+
For each sub-phase SPk:
|
|
1103
|
+
|
|
1104
|
+
- The agent must run Tier A for SPk and require it to be green before starting SP(k+1).
|
|
1105
|
+
- If Tier A fails, fix and rerun until green. Do not proceed.
|
|
1106
|
+
- Tier B must be run before locking Phase 4 unless an explicit constraint in `00-requirements.md` allows a narrower run.
|
|
1107
|
+
|
|
1108
|
+
### Test summary rule (Phase 4)
|
|
1109
|
+
|
|
1110
|
+
When sub-phases exist, the test summary (`04-test-summary.md`) must record Playwright results by sub-phase:
|
|
1111
|
+
|
|
1112
|
+
- SPk Tier A command(s) + results + artifact paths
|
|
1113
|
+
- Any Tier B run(s) + results + artifact paths
|
|
1114
|
+
|
|
1115
|
+
If a failure is flaky, the summary must record the rerun commands and outcomes, and the mitigation applied.
|
|
1116
|
+
|
|
1117
|
+
## Playwright test placement and naming conventions (required)
|
|
1118
|
+
|
|
1119
|
+
To keep recursive-mode runs discoverable, reviewable, and fast to validate per sub-phase, Playwright tests must follow a consistent placement and naming convention.
|
|
1120
|
+
|
|
1121
|
+
### Respect existing repository conventions first (non-negotiable)
|
|
1122
|
+
|
|
1123
|
+
Before creating new Playwright tests or moving existing ones, the agent must determine the repository's current Playwright layout by inspecting:
|
|
1124
|
+
|
|
1125
|
+
- Playwright config (e.g., `playwright.config.ts` / `.js`) for `testDir`, and
|
|
1126
|
+
- package scripts that run Playwright (e.g., `package.json` scripts).
|
|
1127
|
+
|
|
1128
|
+
If the repo already has an established Playwright test directory and naming pattern, new tests must follow it. Do not introduce a second Playwright test tree.
|
|
1129
|
+
|
|
1130
|
+
If the repository does not have an established Playwright test directory, the agent may create one, but must record the decision and rationale in the Decision Log and keep the structure minimal.
|
|
1131
|
+
|
|
1132
|
+
### Standard test directory selection rule
|
|
1133
|
+
|
|
1134
|
+
When the repository already has a Playwright `testDir`, use it as the canonical location for new tests.
|
|
1135
|
+
|
|
1136
|
+
If `testDir` is not set and no obvious convention exists, use one of the following defaults (in this priority order), choosing the first that matches existing patterns in the repo:
|
|
1137
|
+
|
|
1138
|
+
1) `tests/e2e/`
|
|
1139
|
+
2) `e2e/`
|
|
1140
|
+
3) `playwright/tests/`
|
|
1141
|
+
|
|
1142
|
+
The Phase 2 plan must record the chosen directory path(s) explicitly.
|
|
1143
|
+
|
|
1144
|
+
### File naming (required)
|
|
1145
|
+
|
|
1146
|
+
Each new Playwright test file added for a recursive-mode run must include the run id and the sub-phase, and should be readable in file listings without opening the file.
|
|
1147
|
+
|
|
1148
|
+
Required format (kebab-case, TypeScript example):
|
|
1149
|
+
|
|
1150
|
+
- `recursive-<run-id>.sp<k>.<short-topic>.spec.ts`
|
|
1151
|
+
|
|
1152
|
+
Examples:
|
|
1153
|
+
|
|
1154
|
+
- `recursive-01-keyboard-controls-in-deck-settings.sp1.shortcut-discovery.spec.ts`
|
|
1155
|
+
- `recursive-01-keyboard-controls-in-deck-settings.sp2.persistence-guardrail.spec.ts`
|
|
1156
|
+
|
|
1157
|
+
If the repo uses a different extension or suffix (e.g., `.test.ts`), match the repo convention, but keep the `recursive-<run-id>.sp<k>.` prefix.
|
|
1158
|
+
|
|
1159
|
+
### Test title and tag placement (required)
|
|
1160
|
+
|
|
1161
|
+
Tests must include tags in a way that is grep-able via the repo's chosen Playwright filtering mechanism (typically `--grep`).
|
|
1162
|
+
|
|
1163
|
+
Preferred pattern (apply tags at the `test.describe()` level):
|
|
1164
|
+
|
|
1165
|
+
- `test.describe('@recursive:<run-id> @sp<k> <topic>', () => { ... })`
|
|
1166
|
+
|
|
1167
|
+
If a test is part of a smoke tier, include `@smoke` in the same describe title:
|
|
1168
|
+
|
|
1169
|
+
- `test.describe('@smoke @recursive:<run-id> @sp<k> <topic>', () => { ... })`
|
|
1170
|
+
|
|
1171
|
+
Do not rely on brittle text selectors in tests. Prefer stable selectors (`data-testid` or equivalent). If the repo does not use stable selectors today, the plan may introduce `data-testid` additions as part of the requirement, and must record them as part of the implementation checklist.
|
|
1172
|
+
|
|
1173
|
+
### Requirement traceability inside tests (required)
|
|
1174
|
+
|
|
1175
|
+
At the top of each new Playwright test file, include a short comment block that ties the test back to the requirement IDs it covers.
|
|
1176
|
+
|
|
1177
|
+
Example:
|
|
1178
|
+
|
|
1179
|
+
- `// recursive run: <run-id>`
|
|
1180
|
+
- `// Sub-phase: SP<k>`
|
|
1181
|
+
- `// Covers: R1, R3`
|
|
1182
|
+
- `// Guardrails: (if any) R2 (non-regression)`
|
|
1183
|
+
|
|
1184
|
+
This comment is not a substitute for the Traceability section in the recursive-mode artifacts, but it makes tests easier to audit during review.
|
|
1185
|
+
|
|
1186
|
+
### Fixtures and test data placement (recommended; required if new fixtures are added)
|
|
1187
|
+
|
|
1188
|
+
If tests require fixtures, seed data, or static assets, prefer colocating them under a dedicated folder near the test directory to avoid scattering run-specific artifacts across the repo.
|
|
1189
|
+
|
|
1190
|
+
Recommended pattern (adapt to repo conventions):
|
|
1191
|
+
|
|
1192
|
+
- `<playwright-test-dir>/fixtures/recursive/<run-id>/...`
|
|
1193
|
+
|
|
1194
|
+
If the repo already has a fixtures convention, follow it. Any new fixtures directories must be recorded in the Phase 2 plan and listed in Phase 4's touched files.
|
|
1195
|
+
|
|
1196
|
+
### Tier A discovery rule (required)
|
|
1197
|
+
|
|
1198
|
+
Tier A for a sub-phase must be able to target the sub-phase tests without manual selection. Therefore, either:
|
|
1199
|
+
|
|
1200
|
+
- tags must be present and filterable (preferred), or
|
|
1201
|
+
- the plan must specify an equivalent deterministic selection mechanism used by the repo.
|
|
1202
|
+
|
|
1203
|
+
If the repo's Playwright setup cannot reliably filter by tags, the Phase 2 plan must define an alternative (for example, file glob patterns that correspond to `recursive-<run-id>.sp<k>.*`), and must use that alternative consistently throughout Phase 3/5 execution and reporting.
|
|
1204
|
+
|
|
1205
|
+
|
|
1206
|
+
### Testing discipline (TDD + Playwright) - Phase 2 (TO-BE plan) must include a "Testing Strategy" section that specifies:
|
|
1207
|
+
|
|
1208
|
+
- New behavior tests to add (required for features).
|
|
1209
|
+
- Regression-first tests that fail on current behavior (required for bug fixes).
|
|
1210
|
+
- Non-regression guardrail tests for adjacent critical behavior (required whenever existing flows may be impacted).
|
|
1211
|
+
- Exact test file paths and exact commands to run.
|
|
1212
|
+
- Expected pass criteria.
|
|
1213
|
+
|
|
1214
|
+
Phase 3 — `03-implementation-summary.md`
|
|
1215
|
+
- Files touched (repo-relative paths)
|
|
1216
|
+
- What changed and why
|
|
1217
|
+
- Traceability mapping R# -> implementation evidence
|
|
1218
|
+
|
|
1219
|
+
### Testing discipline (TDD + Playwright) - Phase 3 (Implementation) must begin with tests-first:
|
|
1220
|
+
|
|
1221
|
+
- Bug fixes: add a failing regression test first, then implement until it passes.
|
|
1222
|
+
- Features: add tests for the new behavior first (may fail initially), then implement until they pass.
|
|
1223
|
+
|
|
1224
|
+
Phase 4 - `04-test-summary.md`
|
|
1225
|
+
- Tests executed (commands)
|
|
1226
|
+
- Results (pass/fail) with concise evidence
|
|
1227
|
+
- If any required test is failing, the phase must not advance until fixed or explicitly decided with rationale and mitigation recorded
|
|
1228
|
+
|
|
1229
|
+
### Testing discipline (Playwright + validation) - Phase 4 (Tests/validation) must run:
|
|
1230
|
+
|
|
1231
|
+
- Tier A: the new/modified tests for this run plus relevant smoke tests.
|
|
1232
|
+
- Tier B: the full Playwright suite (or a broader tagged set) before locking the phase, unless an explicit constraint in `00-requirements.md` permits a narrower run.
|
|
1233
|
+
|
|
1234
|
+
If Playwright coverage is infeasible or would be flaky for a specific behavior, the plan must explicitly record the exception and mitigation in the Approval Gate (e.g., unit test coverage + manual QA scenario).
|
|
1235
|
+
|
|
1236
|
+
### Playwright evidence capture and `04-test-summary.md` standard (required)
|
|
1237
|
+
|
|
1238
|
+
Playwright is the primary end-to-end regression safety net in this repository. To prevent regressions and make failures diagnosable, recursive-mode must standardize what is recorded in the Phase 4 artifact (`04-test-summary.md`) and how Playwright evidence is captured.
|
|
1239
|
+
|
|
1240
|
+
This section defines requirements for:
|
|
1241
|
+
|
|
1242
|
+
- Phase 2: the TO-BE plan must specify Playwright tests, tags, and how to run them.
|
|
1243
|
+
- Phase 4: the test summary must capture exact commands, results, and where to find debugging artifacts.
|
|
1244
|
+
|
|
1245
|
+
#### Phase 2 requirements (plan must define this up front)
|
|
1246
|
+
|
|
1247
|
+
The ExecPlan-grade TO-BE plan (`02-to-be-plan.md`) must include a "Playwright Plan" subsection that specifies:
|
|
1248
|
+
|
|
1249
|
+
1) Which Playwright tests will be added or modified (file paths) and the intent of each test.
|
|
1250
|
+
2) Tagging strategy for this run:
|
|
1251
|
+
- Tests added for the run must be tagged with `@recursive:<run-id>`.
|
|
1252
|
+
- If the repository uses a smoke tier, critical-path tests must also be tagged `@smoke`.
|
|
1253
|
+
3) Exact commands to run Tier A (fast loop) and Tier B (broader regression), as they apply to this repo's toolchain.
|
|
1254
|
+
4) How the app is started for E2E (or how requests are stubbed):
|
|
1255
|
+
- If a dev server is required, specify the exact start command, base URL, and readiness condition.
|
|
1256
|
+
- If stubbing network calls is required, specify what is stubbed and why.
|
|
1257
|
+
5) Selector strategy: E2E tests must target stable selectors (prefer `data-testid` or equivalent), not brittle text selectors, unless explicitly justified.
|
|
1258
|
+
|
|
1259
|
+
The Phase 2 Approval Gate must be FAIL if the plan does not specify the above items with concrete, repo-specific details.
|
|
1260
|
+
|
|
1261
|
+
#### Phase 4 output requirements (`04-test-summary.md` must include these sections)
|
|
1262
|
+
|
|
1263
|
+
The Phase 4 artifact (`04-test-summary.md`) must be self-sufficient for diagnosing failures. It must contain the following sections in order.
|
|
1264
|
+
|
|
1265
|
+
1) Pre-test implementation audit
|
|
1266
|
+
|
|
1267
|
+
Before any test commands are executed, audit implementation correctness against intent:
|
|
1268
|
+
|
|
1269
|
+
- Compare `03-implementation-summary.md` against `00-requirements.md` and record per-requirement status (implemented / partial / missing) with evidence links.
|
|
1270
|
+
- Compare `03-implementation-summary.md` against `02-to-be-plan.md` and record per step/sub-phase status (implemented / deviated / missing) with evidence links.
|
|
1271
|
+
- For each mismatch, record remediation:
|
|
1272
|
+
- immediate fix in current phase, or
|
|
1273
|
+
- upstream-gap/stage-local addendum path with follow-up action.
|
|
1274
|
+
|
|
1275
|
+
2) Environment
|
|
1276
|
+
|
|
1277
|
+
Record enough environment detail to reproduce:
|
|
1278
|
+
|
|
1279
|
+
- Repo root (path) and run id
|
|
1280
|
+
- Platform (OS) and Node/runtime version
|
|
1281
|
+
- Playwright version
|
|
1282
|
+
- Browser projects executed (e.g., chromium/firefox/webkit) and whether headed/headless
|
|
1283
|
+
- Base URL used (if applicable)
|
|
1284
|
+
|
|
1285
|
+
3) Commands executed (exact)
|
|
1286
|
+
|
|
1287
|
+
List the exact commands actually executed (copy/paste exact shell lines), including:
|
|
1288
|
+
|
|
1289
|
+
- Any build commands
|
|
1290
|
+
- Any dev server start command (and whether it ran in a separate terminal/process)
|
|
1291
|
+
- Tier A Playwright command(s) executed
|
|
1292
|
+
- Tier B Playwright command(s) executed (if required by the run's constraints)
|
|
1293
|
+
|
|
1294
|
+
If the repo uses scripts (e.g., `test:e2e`), record the script and the underlying Playwright invocation if available.
|
|
1295
|
+
|
|
1296
|
+
4) Results summary
|
|
1297
|
+
|
|
1298
|
+
Provide a compact pass/fail summary:
|
|
1299
|
+
|
|
1300
|
+
- Total tests run, passed, failed, skipped
|
|
1301
|
+
- If failures occurred: list failing test titles and file paths
|
|
1302
|
+
- Whether failures are deterministic or flaky (based on reruns described below)
|
|
1303
|
+
|
|
1304
|
+
5) Debugging artifacts (mandatory to locate)
|
|
1305
|
+
|
|
1306
|
+
The summary must state exactly where artifacts were written in this repo and how to open them.
|
|
1307
|
+
|
|
1308
|
+
At minimum, record paths for:
|
|
1309
|
+
|
|
1310
|
+
- Playwright HTML report directory (e.g., `playwright-report/`)
|
|
1311
|
+
- Test results directory (e.g., `test-results/`)
|
|
1312
|
+
- Trace files (if generated)
|
|
1313
|
+
- Screenshots (if generated)
|
|
1314
|
+
- Videos (if generated)
|
|
1315
|
+
|
|
1316
|
+
If the repository uses a custom Playwright config, explicitly cite the config file path that defines these output locations (e.g., `playwright.config.ts`).
|
|
1317
|
+
|
|
1318
|
+
6) Failure diagnosis notes (required when failures exist)
|
|
1319
|
+
|
|
1320
|
+
For each failing test:
|
|
1321
|
+
|
|
1322
|
+
- Failure symptom in one sentence (what did not happen)
|
|
1323
|
+
- Primary suspected root cause (if known)
|
|
1324
|
+
- The most relevant artifact to inspect (report/trace/screenshot/video path)
|
|
1325
|
+
- Any immediate remediation step taken
|
|
1326
|
+
|
|
1327
|
+
7) Rerun policy and flake handling (required)
|
|
1328
|
+
|
|
1329
|
+
To prevent "green by accident," Phase 4 must follow this policy:
|
|
1330
|
+
|
|
1331
|
+
- On any Playwright failure, rerun the failing test(s) in isolation at least once.
|
|
1332
|
+
- If the failure disappears on rerun, treat it as a potential flake and record:
|
|
1333
|
+
- how it was rerun,
|
|
1334
|
+
- whether it reproduced,
|
|
1335
|
+
- and what mitigation was applied (e.g., improved selector, proper waiting condition, deterministic state setup).
|
|
1336
|
+
|
|
1337
|
+
Do not mark Approval PASS if there are unresolved, newly introduced flakes without an explicit decision and mitigation.
|
|
1338
|
+
|
|
1339
|
+
#### Evidence capture policy (how Playwright should be configured/used for recursive-mode)
|
|
1340
|
+
|
|
1341
|
+
Playwright evidence must be sufficient to debug without guesswork.
|
|
1342
|
+
|
|
1343
|
+
- Prefer to have traces available for failures. If traces are not always-on, ensure they are captured on the first retry for failures (or equivalent policy supported by the repo).
|
|
1344
|
+
- Screenshots on failure are strongly recommended.
|
|
1345
|
+
- Videos on failure are recommended for interaction-heavy flows.
|
|
1346
|
+
|
|
1347
|
+
Standardize where evidence lives (per run):
|
|
1348
|
+
|
|
1349
|
+
- Store non-Markdown evidence artifacts under `/.recursive/run/<run-id>/evidence/`:
|
|
1350
|
+
- `evidence/screenshots/`
|
|
1351
|
+
- `evidence/logs/`
|
|
1352
|
+
- `evidence/perf/`
|
|
1353
|
+
- `evidence/traces/` (if applicable)
|
|
1354
|
+
- Phase 4 and Phase 5 artifacts must reference concrete repo-relative paths under `evidence/`.
|
|
1355
|
+
- If the repo generates artifacts elsewhere (e.g., Playwright `test-results/`), either configure output to point at the run folder (preferred) or copy/link the relevant files into the run's `evidence/` directory.
|
|
1356
|
+
|
|
1357
|
+
If the repo's Playwright configuration does not currently produce these artifacts, the plan may introduce minimal, non-invasive configuration changes to enable them (without changing product behavior). Such changes must be recorded in the Decision Log and reflected in the test summary.
|
|
1358
|
+
|
|
1359
|
+
#### Phase 4 Approval Gate requirements
|
|
1360
|
+
|
|
1361
|
+
Phase 4 Approval must be FAIL unless:
|
|
1362
|
+
|
|
1363
|
+
- The tests specified in the plan for Tier A have been run and are passing, or failures have been resolved.
|
|
1364
|
+
- Any required Tier B run (as specified in the plan or constraints) has been completed and is passing, or an explicit decision with mitigation is recorded.
|
|
1365
|
+
- The test summary contains the required sections above and points to concrete artifact paths for any failures that occurred during the phase.
|
|
1366
|
+
|
|
1367
|
+
Phase 5 — `05-manual-qa.md`
|
|
1368
|
+
- Manual QA scenarios (from plan) and observed results
|
|
1369
|
+
- `QA Execution Mode: human|agent-operated|hybrid`
|
|
1370
|
+
- Human/hybrid: explicit user sign-off (name/handle + date + notes)
|
|
1371
|
+
- Agent-operated/hybrid: execution record, tools used, and evidence paths
|
|
1372
|
+
- If the selected mode's required approvals are not yet complete, iterate within this phase until complete or record an explicit abort decision
|
|
1373
|
+
|
|
1374
|
+
Phase 6 — update `/.recursive/DECISIONS.md`
|
|
1375
|
+
- Append a new entry referencing:
|
|
1376
|
+
- the run folder path
|
|
1377
|
+
- all run artifacts (including addenda)
|
|
1378
|
+
- what changed (user-visible behavior)
|
|
1379
|
+
- why (tradeoffs)
|
|
1380
|
+
- how (high-level approach)
|
|
1381
|
+
- what was not done (OOS)
|
|
1382
|
+
- known issues / follow-ups
|
|
1383
|
+
- Record the exact ledger changes in `06-decisions-update.md`
|
|
1384
|
+
|
|
1385
|
+
Phase 7 — update `/.recursive/STATE.md`
|
|
1386
|
+
- Update current-state documentation to reflect the new reality:
|
|
1387
|
+
- features and flags/config
|
|
1388
|
+
- known limitations
|
|
1389
|
+
- operational notes
|
|
1390
|
+
- Record the exact state changes in `07-state-update.md`
|
|
1391
|
+
|
|
1392
|
+
Phase 8 — update `/.recursive/memory/*`
|
|
1393
|
+
- Compute final changed paths from the Phase 0 diff basis
|
|
1394
|
+
- Match changed paths to memory owners/watchers
|
|
1395
|
+
- Downgrade affected `CURRENT` docs to `SUSPECT` before semantic review
|
|
1396
|
+
- Update/create/split/deprecate memory docs as needed
|
|
1397
|
+
- Refresh parent/router docs when child docs changed materially
|
|
1398
|
+
- Record uncovered changed paths explicitly
|
|
1399
|
+
- Lock `08-memory-impact.md`
|
|
1400
|
+
- Do not treat the run as complete before this phase passes
|
|
1401
|
+
|
|
1402
|
+
---
|
|
1403
|
+
|
|
1404
|
+
## Recursive worktree isolation (Phase 0)
|
|
1405
|
+
|
|
1406
|
+
### The Iron Law
|
|
1407
|
+
|
|
1408
|
+
```
|
|
1409
|
+
NEVER WORK ON MAIN/MASTER BRANCH WITHOUT EXPLICIT CONSENT
|
|
1410
|
+
```
|
|
1411
|
+
|
|
1412
|
+
### Why Isolation Matters
|
|
1413
|
+
|
|
1414
|
+
Working directly on main/master branch:
|
|
1415
|
+
- Pollutes production history with WIP commits
|
|
1416
|
+
- Prevents parallel requirement development
|
|
1417
|
+
- Makes it harder to discard abandoned work
|
|
1418
|
+
- Increases risk of accidental production changes
|
|
1419
|
+
|
|
1420
|
+
Git worktrees provide isolated workspaces that:
|
|
1421
|
+
- Share the same repository (no duplicate clones)
|
|
1422
|
+
- Allow parallel development on multiple requirements
|
|
1423
|
+
- Keep main branch clean and linear
|
|
1424
|
+
- Enable easy discard of abandoned work
|
|
1425
|
+
|
|
1426
|
+
### Directory Selection Priority
|
|
1427
|
+
|
|
1428
|
+
1. **Check existing directories** (priority order):
|
|
1429
|
+
- `.worktrees/` (preferred - hidden)
|
|
1430
|
+
- `worktrees/` (alternative)
|
|
1431
|
+
|
|
1432
|
+
2. **Check CLAUDE.md** for explicit preference
|
|
1433
|
+
|
|
1434
|
+
3. **Ask user** if no convention exists
|
|
1435
|
+
- Default: `.worktrees/` (project-local)
|
|
1436
|
+
- Alternative: `~/.config/recursive-mode/worktrees/<project>/` (global)
|
|
1437
|
+
|
|
1438
|
+
### Safety Verification
|
|
1439
|
+
|
|
1440
|
+
**MUST verify directory is git-ignored before creating project-local worktree:**
|
|
1441
|
+
|
|
1442
|
+
```bash
|
|
1443
|
+
git check-ignore -q .worktrees 2>/dev/null || git check-ignore -q worktrees 2>/dev/null
|
|
1444
|
+
```
|
|
1445
|
+
|
|
1446
|
+
If NOT ignored:
|
|
1447
|
+
1. Add to `.gitignore`: `.worktrees/`
|
|
1448
|
+
2. Commit the change
|
|
1449
|
+
3. Then create worktree
|
|
1450
|
+
|
|
1451
|
+
**Why critical:** Prevents committing worktree contents to repository.
|
|
1452
|
+
|
|
1453
|
+
### Worktree Creation Process
|
|
1454
|
+
|
|
1455
|
+
```bash
|
|
1456
|
+
# Detect project name
|
|
1457
|
+
project=$(basename "$(git rev-parse --show-toplevel)")
|
|
1458
|
+
branch_name="recursive/${run_id}"
|
|
1459
|
+
|
|
1460
|
+
# Check current branch
|
|
1461
|
+
current_branch=$(git branch --show-current)
|
|
1462
|
+
|
|
1463
|
+
if [ "$current_branch" = "main" ] || [ "$current_branch" = "master" ]; then
|
|
1464
|
+
# Require explicit consent or auto-create worktree
|
|
1465
|
+
echo "WARNING: On $current_branch branch. Creating worktree..."
|
|
1466
|
+
fi
|
|
1467
|
+
|
|
1468
|
+
# Create worktree with new branch
|
|
1469
|
+
git worktree add "$path" -b "$branch_name"
|
|
1470
|
+
cd "$path"
|
|
1471
|
+
```
|
|
1472
|
+
|
|
1473
|
+
### Main Branch Protection
|
|
1474
|
+
|
|
1475
|
+
When user invokes from main/master:
|
|
1476
|
+
|
|
1477
|
+
```
|
|
1478
|
+
╔════════════════════════════════════════════════════════════╗
|
|
1479
|
+
║ ! MAIN BRANCH PROTECTION ║
|
|
1480
|
+
╠════════════════════════════════════════════════════════════╣
|
|
1481
|
+
║ You are currently on the main/master branch. ║
|
|
1482
|
+
║ ║
|
|
1483
|
+
║ recursive-mode requires isolated worktrees to: ║
|
|
1484
|
+
║ • Prevent accidental commits to production ║
|
|
1485
|
+
║ • Enable parallel requirement development ║
|
|
1486
|
+
║ • Maintain clean main branch history ║
|
|
1487
|
+
║ ║
|
|
1488
|
+
║ Default: Create worktree automatically ║
|
|
1489
|
+
║ (press Ctrl+C to abort) ║
|
|
1490
|
+
╚════════════════════════════════════════════════════════════╝
|
|
1491
|
+
```
|
|
1492
|
+
|
|
1493
|
+
### Project Setup Auto-Detection
|
|
1494
|
+
|
|
1495
|
+
After creating worktree, auto-detect and run setup:
|
|
1496
|
+
|
|
1497
|
+
```bash
|
|
1498
|
+
# Node.js
|
|
1499
|
+
if [ -f package.json ]; then npm install; fi
|
|
1500
|
+
|
|
1501
|
+
# Rust
|
|
1502
|
+
if [ -f Cargo.toml ]; then cargo build; fi
|
|
1503
|
+
|
|
1504
|
+
# Python
|
|
1505
|
+
if [ -f requirements.txt ]; then pip install -r requirements.txt; fi
|
|
1506
|
+
if [ -f pyproject.toml ]; then poetry install; fi
|
|
1507
|
+
|
|
1508
|
+
# Go
|
|
1509
|
+
if [ -f go.mod ]; then go mod download; fi
|
|
1510
|
+
|
|
1511
|
+
# Java/Maven
|
|
1512
|
+
if [ -f pom.xml ]; then mvn compile -q; fi
|
|
1513
|
+
|
|
1514
|
+
# Java/Gradle
|
|
1515
|
+
if [ -f build.gradle ]; then ./gradlew compileJava --quiet; fi
|
|
1516
|
+
|
|
1517
|
+
# .NET
|
|
1518
|
+
if [ -f *.csproj ]; then dotnet restore; fi
|
|
1519
|
+
```
|
|
1520
|
+
|
|
1521
|
+
### Clean Test Baseline
|
|
1522
|
+
|
|
1523
|
+
Verify worktree starts with passing tests:
|
|
1524
|
+
|
|
1525
|
+
```bash
|
|
1526
|
+
# Run appropriate test command
|
|
1527
|
+
npm test # Node.js
|
|
1528
|
+
cargo test # Rust
|
|
1529
|
+
pytest -q # Python
|
|
1530
|
+
go test ./... # Go
|
|
1531
|
+
mvn test -q # Maven
|
|
1532
|
+
./gradlew test # Gradle
|
|
1533
|
+
dotnet test # .NET
|
|
1534
|
+
```
|
|
1535
|
+
|
|
1536
|
+
**If tests fail:**
|
|
1537
|
+
- Document pre-existing failures in Phase 0 artifact
|
|
1538
|
+
- Get explicit consent to proceed
|
|
1539
|
+
- Or fix baseline issues first
|
|
1540
|
+
|
|
1541
|
+
### Worktree Context for All Phases
|
|
1542
|
+
|
|
1543
|
+
Once Phase 0 is complete:
|
|
1544
|
+
- All subsequent phases execute in worktree directory
|
|
1545
|
+
- Git operations target feature branch (`recursive/<run-id>`)
|
|
1546
|
+
- Main branch remains untouched
|
|
1547
|
+
- Development is fully isolated
|
|
1548
|
+
|
|
1549
|
+
### Windows path guidance for Node/Vite/Vitest
|
|
1550
|
+
|
|
1551
|
+
On Windows, prefer running Node-based toolchains from the real worktree path, not from:
|
|
1552
|
+
|
|
1553
|
+
- `subst` drive mappings
|
|
1554
|
+
- Explorer-mapped drive letters
|
|
1555
|
+
- ad hoc path aliases that rewrite the worktree root
|
|
1556
|
+
|
|
1557
|
+
This is especially important for:
|
|
1558
|
+
|
|
1559
|
+
- `vite`
|
|
1560
|
+
- `vitest`
|
|
1561
|
+
- Playwright helpers that resolve repo-relative assets
|
|
1562
|
+
|
|
1563
|
+
Short aliases may still be fine for manual file browsing or editing, but command execution and recorded evidence should use the real filesystem path so module resolution and evidence paths stay stable.
|
|
1564
|
+
|
|
1565
|
+
### Merging Completed Work
|
|
1566
|
+
|
|
1567
|
+
After Phase 8:
|
|
1568
|
+
1. User reviews changes in worktree
|
|
1569
|
+
2. User merges feature branch to main:
|
|
1570
|
+
```bash
|
|
1571
|
+
git checkout main
|
|
1572
|
+
git merge recursive/<run-id>
|
|
1573
|
+
```
|
|
1574
|
+
3. Global artifacts (DECISIONS.md, STATE.md) are part of the merge
|
|
1575
|
+
4. Worktree can be removed when no longer needed:
|
|
1576
|
+
```bash
|
|
1577
|
+
git worktree remove .worktrees/<run-id>
|
|
1578
|
+
```
|
|
1579
|
+
|
|
1580
|
+
---
|
|
1581
|
+
|
|
1582
|
+
## recursive-tdd (Phase 3)
|
|
1583
|
+
|
|
1584
|
+
### The Iron Law
|
|
1585
|
+
|
|
1586
|
+
```
|
|
1587
|
+
NO PRODUCTION CODE WITHOUT A FAILING TEST FIRST
|
|
1588
|
+
```
|
|
1589
|
+
|
|
1590
|
+
### RED-GREEN-REFACTOR Cycle (Mandatory)
|
|
1591
|
+
|
|
1592
|
+
Phase 3 must declare `TDD Mode: strict|pragmatic`.
|
|
1593
|
+
|
|
1594
|
+
- `strict` is the default and requires actual failing-test evidence before implementation plus passing-test evidence after implementation.
|
|
1595
|
+
- `pragmatic` is allowed only when the artifact records a concrete exception reason and compensating validation evidence.
|
|
1596
|
+
|
|
1597
|
+
Every requirement implemented in strict Phase 3 must follow RED-GREEN-REFACTOR discipline:
|
|
1598
|
+
|
|
1599
|
+
#### RED Phase
|
|
1600
|
+
1. Write one minimal test showing what should happen
|
|
1601
|
+
2. Run test, verify it fails for expected reason
|
|
1602
|
+
3. Document failure output in Phase 3 artifact
|
|
1603
|
+
4. **Never skip:** If test passes immediately, the test is wrong - fix it
|
|
1604
|
+
|
|
1605
|
+
#### GREEN Phase
|
|
1606
|
+
1. Write simplest code to pass the test
|
|
1607
|
+
2. Run test, verify it passes
|
|
1608
|
+
3. No additional features, no "while I'm here" improvements
|
|
1609
|
+
4. Document minimal implementation in Phase 3 artifact
|
|
1610
|
+
|
|
1611
|
+
#### REFACTOR Phase
|
|
1612
|
+
1. Clean up: remove duplication, improve names, extract helpers
|
|
1613
|
+
2. Keep tests green throughout
|
|
1614
|
+
3. Never add behavior during refactor
|
|
1615
|
+
4. Document cleanups in Phase 3 artifact
|
|
1616
|
+
|
|
1617
|
+
### Common Process Shortcuts (STOP)
|
|
1618
|
+
|
|
1619
|
+
| Excuse | Reality |
|
|
1620
|
+
|--------|---------|
|
|
1621
|
+
| "This is just a simple fix" | Simple code breaks. Test takes 30 seconds. |
|
|
1622
|
+
| "I'll test after confirming it works" | Tests passing immediately prove nothing. |
|
|
1623
|
+
| "Tests after achieve same goals" | Tests-after = "what does this do?" Tests-first = "what should this do?" |
|
|
1624
|
+
| "Deleting working code is wasteful" | Sunk cost fallacy. Keeping unverified code is technical debt. |
|
|
1625
|
+
| "TDD is dogmatic, I'm being pragmatic" | TDD IS pragmatic. Finds bugs before commit. |
|
|
1626
|
+
|
|
1627
|
+
### TDD Compliance Log (Required in Phase 3 Artifact)
|
|
1628
|
+
|
|
1629
|
+
Every Phase 3 artifact must include:
|
|
1630
|
+
|
|
1631
|
+
```markdown
|
|
1632
|
+
## TDD Compliance Log
|
|
1633
|
+
|
|
1634
|
+
TDD Mode: strict
|
|
1635
|
+
|
|
1636
|
+
RED Evidence:
|
|
1637
|
+
- `/.recursive/run/<run-id>/evidence/logs/red/<file>.log`
|
|
1638
|
+
|
|
1639
|
+
GREEN Evidence:
|
|
1640
|
+
- `/.recursive/run/<run-id>/evidence/logs/green/<file>.log`
|
|
1641
|
+
|
|
1642
|
+
### R1: [requirement description]
|
|
1643
|
+
|
|
1644
|
+
**Test:** `path/to/test.spec.ts` - "[test name]"
|
|
1645
|
+
|
|
1646
|
+
**RED Phase** ([ISO8601]):
|
|
1647
|
+
- Command: [exact command]
|
|
1648
|
+
- Expected failure: [what should fail]
|
|
1649
|
+
- Actual failure: [paste output]
|
|
1650
|
+
- RED verified: ✅
|
|
1651
|
+
|
|
1652
|
+
**GREEN Phase** ([ISO8601]):
|
|
1653
|
+
- Implementation: [minimal change]
|
|
1654
|
+
- Command: [exact command]
|
|
1655
|
+
- Result: PASS
|
|
1656
|
+
- GREEN verified: ✅
|
|
1657
|
+
|
|
1658
|
+
**REFACTOR Phase** ([ISO8601]):
|
|
1659
|
+
- Cleanups: [description]
|
|
1660
|
+
- All tests passing: ✅
|
|
1661
|
+
```
|
|
1662
|
+
|
|
1663
|
+
If `TDD Mode: pragmatic` is used, the artifact must also contain:
|
|
1664
|
+
|
|
1665
|
+
```markdown
|
|
1666
|
+
## Pragmatic TDD Exception
|
|
1667
|
+
|
|
1668
|
+
Exception reason: [why strict RED-first flow was not feasible here]
|
|
1669
|
+
Compensating validation:
|
|
1670
|
+
- [what was done instead]
|
|
1671
|
+
- `/.recursive/run/<run-id>/evidence/<supporting-file>`
|
|
1672
|
+
```
|
|
1673
|
+
|
|
1674
|
+
### Red Flags - DELETE CODE and Start Over
|
|
1675
|
+
|
|
1676
|
+
- Code written before test
|
|
1677
|
+
- Test passes immediately (not testing what you think)
|
|
1678
|
+
- "I'll add tests later"
|
|
1679
|
+
- "This is too simple to test"
|
|
1680
|
+
|
|
1681
|
+
---
|
|
1682
|
+
|
|
1683
|
+
## recursive-debugging (Phase 1.5)
|
|
1684
|
+
|
|
1685
|
+
### When to Use Phase 1.5
|
|
1686
|
+
|
|
1687
|
+
**Mandatory when:**
|
|
1688
|
+
- Requirement is a bug fix
|
|
1689
|
+
- Investigating test failures
|
|
1690
|
+
- Unexpected behavior reported
|
|
1691
|
+
- Performance problems
|
|
1692
|
+
- Integration issues
|
|
1693
|
+
|
|
1694
|
+
**Insert between Phase 1 and Phase 2:**
|
|
1695
|
+
```
|
|
1696
|
+
Phase 1 (AS-IS) -> Phase 1.5 (Root Cause) -> Phase 2 (TO-BE Plan)
|
|
1697
|
+
```
|
|
1698
|
+
|
|
1699
|
+
### The Iron Law
|
|
1700
|
+
|
|
1701
|
+
```
|
|
1702
|
+
NO FIXES WITHOUT ROOT CAUSE INVESTIGATION FIRST
|
|
1703
|
+
```
|
|
1704
|
+
|
|
1705
|
+
### Four Phases of Systematic Debugging
|
|
1706
|
+
|
|
1707
|
+
#### Step 1: Root Cause Investigation
|
|
1708
|
+
1. **Read Error Messages Carefully** - verbatim errors, stack traces, line numbers
|
|
1709
|
+
2. **Reproduce Consistently** - exact steps, frequency, determinism
|
|
1710
|
+
3. **Check Recent Changes** - git history, dependencies, environment
|
|
1711
|
+
4. **Gather Evidence** - multi-layer diagnostics if applicable
|
|
1712
|
+
5. **Trace Data Flow** - backward from error to source
|
|
1713
|
+
|
|
1714
|
+
#### Step 2: Pattern Analysis
|
|
1715
|
+
- Find working examples in codebase
|
|
1716
|
+
- Compare working vs broken
|
|
1717
|
+
- Identify all differences
|
|
1718
|
+
- Understand dependencies
|
|
1719
|
+
|
|
1720
|
+
#### Step 3: Hypothesis and Testing
|
|
1721
|
+
- Form single, clear hypothesis
|
|
1722
|
+
- Test with minimal change
|
|
1723
|
+
- Verify before continuing
|
|
1724
|
+
- If wrong, form NEW hypothesis (don't add more changes)
|
|
1725
|
+
|
|
1726
|
+
#### Step 4: Fix Summary for Phase 2 Planning
|
|
1727
|
+
- Document confirmed root cause
|
|
1728
|
+
- Define minimal fix strategy
|
|
1729
|
+
- Create failing test case
|
|
1730
|
+
- Handoff to Phase 2 for planning
|
|
1731
|
+
|
|
1732
|
+
### Common Process Shortcuts (STOP)
|
|
1733
|
+
|
|
1734
|
+
| Excuse | Reality |
|
|
1735
|
+
|--------|---------|
|
|
1736
|
+
| "I can see the problem, let me fix it" | Seeing symptoms ≠ understanding root cause. |
|
|
1737
|
+
| "Quick fix first, investigate later" | "Later" never happens. Do it right from the start. |
|
|
1738
|
+
| "Emergency, no time for process" | Systematic debugging is FASTER than thrashing. |
|
|
1739
|
+
| "One fix attempt is enough" | First attempts often fail. The process anticipates iteration. |
|
|
1740
|
+
|
|
1741
|
+
### If 3+ Fix Attempts Failed
|
|
1742
|
+
|
|
1743
|
+
**STOP - Question Architecture:**
|
|
1744
|
+
- Pattern indicating architectural problem
|
|
1745
|
+
- Discuss with human partner
|
|
1746
|
+
- Consider refactor vs. symptom fix
|
|
1747
|
+
- Document in Phase 1.5 artifact
|
|
1748
|
+
|
|
1749
|
+
---
|
|
1750
|
+
|
|
1751
|
+
## Recursive Lock Verification
|
|
1752
|
+
|
|
1753
|
+
### The Lock Contract
|
|
1754
|
+
|
|
1755
|
+
Every locked artifact includes:
|
|
1756
|
+
- `Status: LOCKED`
|
|
1757
|
+
- `LockedAt: ISO8601 timestamp`
|
|
1758
|
+
- `LockHash: SHA-256 hash of normalized artifact content (LF newlines; `LockHash:` line removed)`
|
|
1759
|
+
|
|
1760
|
+
### LockHash Computation
|
|
1761
|
+
|
|
1762
|
+
The LockHash is a SHA-256 hash of the normalized artifact content at lock time. See
|
|
1763
|
+
"How to compute LockHash" above for the canonical normalization rules.
|
|
1764
|
+
|
|
1765
|
+
**Preferred:**
|
|
1766
|
+
- use `.recursive/scripts/verify-locks.py` for cross-platform verification (and optional fixing)
|
|
1767
|
+
- use `.recursive/scripts/verify-locks.ps1` when running in PowerShell environments
|
|
1768
|
+
|
|
1769
|
+
**PowerShell:**
|
|
1770
|
+
```powershell
|
|
1771
|
+
$p = "artifact.md"
|
|
1772
|
+
$t = Get-Content -LiteralPath $p -Raw -Encoding UTF8
|
|
1773
|
+
$n = ($t -replace "`r`n","`n") -replace "(?m)^LockHash:.*(?:`n|$)",""
|
|
1774
|
+
$b = [System.Text.Encoding]::UTF8.GetBytes($n)
|
|
1775
|
+
$h = [System.Security.Cryptography.SHA256]::Create().ComputeHash($b)
|
|
1776
|
+
($h | ForEach-Object { $_.ToString("x2") }) -join ""
|
|
1777
|
+
```
|
|
1778
|
+
|
|
1779
|
+
**Shell:**
|
|
1780
|
+
```bash
|
|
1781
|
+
sed '/^LockHash:/d' artifact.md | tr -d '\r' | sha256sum
|
|
1782
|
+
```
|
|
1783
|
+
|
|
1784
|
+
### Lock Validity Rules
|
|
1785
|
+
|
|
1786
|
+
A phase artifact is **lock-valid** only when ALL of the following are true:
|
|
1787
|
+
|
|
1788
|
+
1. **File exists** at specified path
|
|
1789
|
+
2. **Status is LOCKED** (not DRAFT)
|
|
1790
|
+
3. **LockedAt is present** and is valid ISO8601 timestamp
|
|
1791
|
+
4. **LockHash is present** and is 64-character hex string
|
|
1792
|
+
5. **LockHash matches** SHA-256 of normalized artifact content (LF newlines; `LockHash:` line removed)
|
|
1793
|
+
6. **If the artifact is an audited phase in `recursive-mode-audit-v1`, Audit Gate ends with:** `Audit: PASS`
|
|
1794
|
+
7. **Coverage Gate ends with:** `Coverage: PASS`
|
|
1795
|
+
8. **Approval Gate ends with:** `Approval: PASS`
|
|
1796
|
+
|
|
1797
|
+
### Automated Verification
|
|
1798
|
+
|
|
1799
|
+
Use the provided verifier scripts to verify all locks:
|
|
1800
|
+
|
|
1801
|
+
```bash
|
|
1802
|
+
# Verify specific run
|
|
1803
|
+
python ./.recursive/scripts/verify-locks.py --run-id "<run-id>"
|
|
1804
|
+
|
|
1805
|
+
# Scan all runs
|
|
1806
|
+
python ./.recursive/scripts/verify-locks.py
|
|
1807
|
+
|
|
1808
|
+
# Fix incorrect hashes (use with caution)
|
|
1809
|
+
python ./.recursive/scripts/verify-locks.py --run-id "<run-id>" --fix
|
|
1810
|
+
```
|
|
1811
|
+
|
|
1812
|
+
```powershell
|
|
1813
|
+
# Verify specific run
|
|
1814
|
+
.\.agents\skills\recursive-mode\scripts\verify-locks.ps1 -RunId "<run-id>"
|
|
1815
|
+
|
|
1816
|
+
# Scan all runs
|
|
1817
|
+
.\.agents\skills\recursive-mode\scripts\verify-locks.ps1
|
|
1818
|
+
|
|
1819
|
+
# Fix incorrect hashes (use with caution)
|
|
1820
|
+
.\.agents\skills\recursive-mode\scripts\verify-locks.ps1 -RunId "<run-id>" -Fix
|
|
1821
|
+
```
|
|
1822
|
+
|
|
1823
|
+
### Tampering Detection
|
|
1824
|
+
|
|
1825
|
+
If LockHash doesn't match the canonical normalized content:
|
|
1826
|
+
|
|
1827
|
+
1. **File was modified after locking** (tampering)
|
|
1828
|
+
2. **File encoding changed** (e.g., BOM added/removed)
|
|
1829
|
+
3. **Line endings changed** (CRLF vs LF)
|
|
1830
|
+
|
|
1831
|
+
**Action:**
|
|
1832
|
+
- If accidental: Use `verify-locks.py --fix` (or `verify-locks.ps1 -Fix`) to update hash
|
|
1833
|
+
- If intentional modification: This is an anti-pattern. Use addenda instead.
|
|
1834
|
+
|
|
1835
|
+
### Phase Transition Lock Chain
|
|
1836
|
+
|
|
1837
|
+
Before starting Phase N, verify lock chain for all prior phases:
|
|
1838
|
+
|
|
1839
|
+
```
|
|
1840
|
+
Phase 0 (Requirements) -> Phase 0 (Worktree) -> Phase 1 (AS-IS) -> ...
|
|
1841
|
+
LOCKED? LOCKED? LOCKED?
|
|
1842
|
+
```
|
|
1843
|
+
|
|
1844
|
+
**Hard stop:** Do NOT proceed if any prior phase is not lock-valid.
|
|
1845
|
+
|
|
1846
|
+
### Lock Chain Validation in Single-Command Mode
|
|
1847
|
+
|
|
1848
|
+
When user invokes "Implement requirement 'run-id'":
|
|
1849
|
+
|
|
1850
|
+
1. Scan all phases (0 through 6)
|
|
1851
|
+
2. Check each locked artifact's hash
|
|
1852
|
+
3. Identify earliest non-lock-valid phase
|
|
1853
|
+
4. Resume from that phase
|
|
1854
|
+
|
|
1855
|
+
Example output:
|
|
1856
|
+
```
|
|
1857
|
+
Phase 0 Requirements: ✅ LOCKED (valid hash)
|
|
1858
|
+
Phase 0 Worktree: ✅ LOCKED (valid hash)
|
|
1859
|
+
Phase 1: ❌ DRAFT (incomplete)
|
|
1860
|
+
Phase 1-5: ⏳ PENDING
|
|
1861
|
+
|
|
1862
|
+
Resuming Phase 2...
|
|
1863
|
+
```
|
|
1864
|
+
|
|
1865
|
+
---
|
|
1866
|
+
|
|
1867
|
+
## recursive-mode skill priority
|
|
1868
|
+
|
|
1869
|
+
When a requirement involves multiple concerns, use this priority order to determine which skills/phases to apply first:
|
|
1870
|
+
|
|
1871
|
+
### Priority Order
|
|
1872
|
+
|
|
1873
|
+
| Priority | Concern | Action | Skill |
|
|
1874
|
+
|----------|---------|--------|-------|
|
|
1875
|
+
| 1 | **Debugging** (bug fixes) | Run Phase 1.5 Root Cause Analysis first | `recursive-debugging` |
|
|
1876
|
+
| 2 | **Design** (new features) | Run full Phase 1 AS-IS Analysis | Core workflow |
|
|
1877
|
+
| 3 | **Implementation** | Proceed to Phase 2+ after analysis complete | Core workflow |
|
|
1878
|
+
| 4 | **Testing** | Use TDD discipline in Phase 3 | `recursive-tdd` |
|
|
1879
|
+
| 5 | **Review** | Run Phase 3.5 Code Review before Phase 4 | `recursive-subagent` (optional) |
|
|
1880
|
+
|
|
1881
|
+
### Decision Rules
|
|
1882
|
+
|
|
1883
|
+
**Rule 1: Debugging First**
|
|
1884
|
+
When requirement mentions bug, crash, test failure, or unexpected behavior:
|
|
1885
|
+
- MUST run Phase 1.5 before Phase 2
|
|
1886
|
+
- Root cause analysis is prerequisite to planning
|
|
1887
|
+
- Exception: None. Never plan a fix without understanding root cause.
|
|
1888
|
+
|
|
1889
|
+
**Rule 2: Design Before Implementation**
|
|
1890
|
+
When requirement is a new feature or enhancement:
|
|
1891
|
+
- MUST complete Phase 1 (AS-IS) before Phase 2
|
|
1892
|
+
- Understanding current state is prerequisite to defining future state
|
|
1893
|
+
- Exception: None. Never plan changes without knowing current state.
|
|
1894
|
+
|
|
1895
|
+
**Rule 3: Testing During Implementation**
|
|
1896
|
+
For all implementation work:
|
|
1897
|
+
- MUST use TDD discipline (RED-GREEN-REFACTOR)
|
|
1898
|
+
- Tests validate implementation against requirements
|
|
1899
|
+
- Exception: None. The Iron Law has no exceptions.
|
|
1900
|
+
|
|
1901
|
+
**Rule 4: Review Before Final Validation**
|
|
1902
|
+
After implementation but before final testing:
|
|
1903
|
+
- Optional Phase 3.5 Code Review
|
|
1904
|
+
- Catch issues early, before manual QA
|
|
1905
|
+
- Exception: User can skip, but must document decision
|
|
1906
|
+
|
|
1907
|
+
### Examples
|
|
1908
|
+
|
|
1909
|
+
Notation:
|
|
1910
|
+
- `0R` = Phase 0 Requirements (`00-requirements.md`)
|
|
1911
|
+
- `0W` = Phase 0 Worktree Isolation (`00-worktree.md`)
|
|
1912
|
+
- `3.5?` = optional Phase 3.5 Code Review (`03.5-code-review.md`)
|
|
1913
|
+
|
|
1914
|
+
| Requirement | Type | Phase Sequence |
|
|
1915
|
+
|-------------|------|----------------|
|
|
1916
|
+
| "Fix login crash" | Bug fix | 0R -> 0W -> 1 -> 1.5 -> 2 -> 3 -> 3.5? -> 4 -> 5 -> 6 -> 7 -> 8 |
|
|
1917
|
+
| "Add dark mode" | Feature | 0R -> 0W -> 1 -> 2 -> 3 -> 3.5? -> 4 -> 5 -> 6 -> 7 -> 8 |
|
|
1918
|
+
| "API returns wrong data" | Bug fix | 0R -> 0W -> 1 -> 1.5 -> 2 -> 3 -> 3.5? -> 4 -> 5 -> 6 -> 7 -> 8 |
|
|
1919
|
+
| "Refactor auth module" | Refactoring | 0R -> 0W -> 1 -> 2 -> 3 -> 3.5? -> 4 -> 5 -> 6 -> 7 -> 8 |
|
|
1920
|
+
|
|
1921
|
+
---
|
|
1922
|
+
|
|
1923
|
+
## recursive-mode hard gates
|
|
1924
|
+
|
|
1925
|
+
Hard gates are non-negotiable checkpoints. Violating a hard gate is a process failure.
|
|
1926
|
+
|
|
1927
|
+
### What is a Hard Gate?
|
|
1928
|
+
|
|
1929
|
+
<HG>
|
|
1930
|
+
A hard gate is a mandatory condition that MUST be satisfied before proceeding.
|
|
1931
|
+
Hard gates are marked with <HG> tags and use absolute language:
|
|
1932
|
+
- "Do NOT proceed until..."
|
|
1933
|
+
- "MUST be..."
|
|
1934
|
+
- "Exception: None"
|
|
1935
|
+
</HG>
|
|
1936
|
+
|
|
1937
|
+
### Universal Hard Gates
|
|
1938
|
+
|
|
1939
|
+
<HG>
|
|
1940
|
+
Do NOT proceed to next phase until:
|
|
1941
|
+
- Current phase artifact is complete
|
|
1942
|
+
- If the phase is audited, `Audit: PASS`
|
|
1943
|
+
- Coverage Gate: PASS
|
|
1944
|
+
- Approval Gate: PASS
|
|
1945
|
+
- Status: LOCKED with LockedAt and LockHash
|
|
1946
|
+
</HG>
|
|
1947
|
+
|
|
1948
|
+
<HG>
|
|
1949
|
+
Do NOT edit locked prior-phase artifacts.
|
|
1950
|
+
If gap discovered, create addendum in current phase.
|
|
1951
|
+
</HG>
|
|
1952
|
+
|
|
1953
|
+
<HG>
|
|
1954
|
+
Do NOT skip or weaken an audit because subagents are unavailable.
|
|
1955
|
+
If delegation is unavailable or the context bundle is incomplete:
|
|
1956
|
+
- record `Audit Execution Mode: self-audit`
|
|
1957
|
+
- perform the full audit locally
|
|
1958
|
+
- repair and re-audit before lock
|
|
1959
|
+
</HG>
|
|
1960
|
+
|
|
1961
|
+
<HG>
|
|
1962
|
+
Do NOT write implementation code before failing test.
|
|
1963
|
+
If code written before test: DELETE IT. Start over.
|
|
1964
|
+
</HG>
|
|
1965
|
+
|
|
1966
|
+
### HG-0: Phase 0 (Worktree) Hard Gate
|
|
1967
|
+
|
|
1968
|
+
<HG>
|
|
1969
|
+
Do NOT proceed to Phase 1 or 2 until Phase 0 is LOCKED with:
|
|
1970
|
+
- Isolated worktree created
|
|
1971
|
+
- Git-ignore verified (if project-local)
|
|
1972
|
+
- Clean test baseline confirmed
|
|
1973
|
+
- LockedAt and LockHash populated
|
|
1974
|
+
|
|
1975
|
+
**Exception:** None. Phase 0 is REQUIRED.
|
|
1976
|
+
</HG>
|
|
1977
|
+
|
|
1978
|
+
### HG-1: Phase 1 -> 2 Hard Gate
|
|
1979
|
+
|
|
1980
|
+
<HG>
|
|
1981
|
+
Do NOT create 02-to-be-plan.md until 01-as-is.md is LOCKED with:
|
|
1982
|
+
- Audit: PASS
|
|
1983
|
+
- Coverage: PASS
|
|
1984
|
+
- Approval: PASS
|
|
1985
|
+
- LockedAt and LockHash populated
|
|
1986
|
+
|
|
1987
|
+
**Exception:** If Phase 1.5 exists, it must ALSO be locked before Phase 2.
|
|
1988
|
+
</HG>
|
|
1989
|
+
|
|
1990
|
+
### HG-2: Phase 1.5 (Debug Mode) Hard Gate
|
|
1991
|
+
|
|
1992
|
+
<HG>
|
|
1993
|
+
Do NOT create TO-BE plan until root cause analysis is complete:
|
|
1994
|
+
- Phase 1.5 artifact is LOCKED
|
|
1995
|
+
- Root cause identified (not just symptom)
|
|
1996
|
+
- Fix strategy defined
|
|
1997
|
+
- Audit: PASS
|
|
1998
|
+
- Coverage: PASS
|
|
1999
|
+
- Approval: PASS
|
|
2000
|
+
|
|
2001
|
+
**Exception:** None. Debug mode requires completion before planning.
|
|
2002
|
+
</HG>
|
|
2003
|
+
|
|
2004
|
+
### HG-3: Phase 3 TDD Hard Gate
|
|
2005
|
+
|
|
2006
|
+
<HG>
|
|
2007
|
+
Do NOT write implementation code until:
|
|
2008
|
+
- Failing test exists and has been run
|
|
2009
|
+
- Test failure is documented in Phase 3 artifact TDD Compliance Log
|
|
2010
|
+
- `TDD Mode` is declared
|
|
2011
|
+
- In `strict` mode, RED phase is verified with actual test output and referenced RED evidence
|
|
2012
|
+
- In `pragmatic` mode, the exception and compensating validation are explicitly recorded
|
|
2013
|
+
|
|
2014
|
+
**Exception:** `TDD Mode: pragmatic` is allowed only when the artifact explicitly records a concrete exception rationale plus compensating validation evidence.
|
|
2015
|
+
</HG>
|
|
2016
|
+
|
|
2017
|
+
### HG-4: Phase 4 -> 5 Hard Gate
|
|
2018
|
+
|
|
2019
|
+
<HG>
|
|
2020
|
+
Do NOT proceed to Manual QA until:
|
|
2021
|
+
- Implementation audit is documented in Phase 4 artifact (against `00-requirements.md` and `02-to-be-plan.md`)
|
|
2022
|
+
- Phase 4 audit verdict is PASS
|
|
2023
|
+
- All tests from Phase 3 are passing
|
|
2024
|
+
- TDD Compliance is verified
|
|
2025
|
+
- Test evidence is documented in Phase 4 artifact
|
|
2026
|
+
- Phase 4 is LOCKED
|
|
2027
|
+
|
|
2028
|
+
**Exception:** None. QA requires complete test evidence.
|
|
2029
|
+
</HG>
|
|
2030
|
+
|
|
2031
|
+
### HG-5: Phase 5 Manual QA Hard Gate
|
|
2032
|
+
|
|
2033
|
+
<HG>
|
|
2034
|
+
Do NOT update DECISIONS.md until:
|
|
2035
|
+
- `QA Execution Mode` is declared in `05-manual-qa.md`
|
|
2036
|
+
- 05-manual-qa.md contains observed results for all scenarios
|
|
2037
|
+
- If mode is `human`, user has explicitly signed off on QA scenarios
|
|
2038
|
+
- If mode is `agent-operated`, execution record, tools used, and evidence paths are recorded
|
|
2039
|
+
- If mode is `hybrid`, both the execution record/evidence and user sign-off are recorded
|
|
2040
|
+
- Approval: PASS is consistent with the declared QA mode
|
|
2041
|
+
- Phase 5 is LOCKED with LockHash matching content
|
|
2042
|
+
|
|
2043
|
+
**Exception:** None. Phase 6 requires QA completion.
|
|
2044
|
+
</HG>
|
|
2045
|
+
|
|
2046
|
+
### HG-6: Phase 6 -> 7 Hard Gate
|
|
2047
|
+
|
|
2048
|
+
<HG>
|
|
2049
|
+
Do NOT update STATE.md until:
|
|
2050
|
+
- `06-decisions-update.md` is lock-valid
|
|
2051
|
+
- `/.recursive/DECISIONS.md` has been updated for the run
|
|
2052
|
+
- the Phase 6 receipt records the exact ledger changes made
|
|
2053
|
+
- the Phase 6 audit confirms the receipt matches final run reality
|
|
2054
|
+
|
|
2055
|
+
**Exception:** None.
|
|
2056
|
+
</HG>
|
|
2057
|
+
|
|
2058
|
+
### HG-7: Phase 7 -> 8 Hard Gate
|
|
2059
|
+
|
|
2060
|
+
<HG>
|
|
2061
|
+
Do NOT begin memory maintenance until:
|
|
2062
|
+
- `07-state-update.md` is lock-valid
|
|
2063
|
+
- `/.recursive/STATE.md` has been updated for the run
|
|
2064
|
+
- `00-worktree.md` records the diff basis for late-phase review
|
|
2065
|
+
- the Phase 7 audit confirms the state summary matches final code reality
|
|
2066
|
+
|
|
2067
|
+
**Exception:** None.
|
|
2068
|
+
</HG>
|
|
2069
|
+
|
|
2070
|
+
### HG-8: Phase 8 Completion Hard Gate
|
|
2071
|
+
|
|
2072
|
+
<HG>
|
|
2073
|
+
Do NOT consider a `recursive-mode-audit-v1` run complete until:
|
|
2074
|
+
- `08-memory-impact.md` is lock-valid
|
|
2075
|
+
- affected memory docs were reviewed or explicitly left `SUSPECT` / `STALE`
|
|
2076
|
+
- uncovered changed paths were handled explicitly
|
|
2077
|
+
- run-local skill usage was captured and any durable promotion decision was recorded when skill usage was relevant
|
|
2078
|
+
- Phase 8 ends with `Audit: PASS`
|
|
2079
|
+
|
|
2080
|
+
**Exception:** Compatibility profiles may remain complete under their own documented contract.
|
|
2081
|
+
</HG>
|
|
2082
|
+
|
|
2083
|
+
### HG-9: Lock Chain Hard Gate (Universal)
|
|
2084
|
+
|
|
2085
|
+
<HG>
|
|
2086
|
+
Do NOT start Phase N unless ALL prior phases (0 through N-1) are lock-valid:
|
|
2087
|
+
- Status: LOCKED
|
|
2088
|
+
- LockedAt: populated
|
|
2089
|
+
- LockHash: matches SHA-256 of content
|
|
2090
|
+
- Audited prior phases end with `Audit: PASS`
|
|
2091
|
+
- Coverage: PASS
|
|
2092
|
+
- Approval: PASS
|
|
2093
|
+
|
|
2094
|
+
**Exception:** None. The lock chain is absolute.
|
|
2095
|
+
</HG>
|
|
2096
|
+
|
|
2097
|
+
### HG-10: Main Branch Protection Hard Gate
|
|
2098
|
+
|
|
2099
|
+
<HG>
|
|
2100
|
+
Do NOT work on main/master branch without:
|
|
2101
|
+
- Explicit user consent
|
|
2102
|
+
- Documentation of risks acknowledged
|
|
2103
|
+
- Recorded reason for exception
|
|
2104
|
+
|
|
2105
|
+
**Default behavior:** Create isolated worktree automatically.
|
|
2106
|
+
</HG>
|
|
2107
|
+
|
|
2108
|
+
### HG-11: TODO Completion Hard Gate (Universal)
|
|
2109
|
+
|
|
2110
|
+
<HG>
|
|
2111
|
+
Do NOT lock any phase artifact or proceed to next phase until:
|
|
2112
|
+
- `## TODO` section exists in current phase artifact
|
|
2113
|
+
- ALL TODO items are checked off ([x])
|
|
2114
|
+
- NO unchecked items remain ([ ] or empty boxes)
|
|
2115
|
+
- No "deferred" or "WIP" items
|
|
2116
|
+
|
|
2117
|
+
**Verification:**
|
|
2118
|
+
1. Search artifact for `[ ]` (unchecked boxes)
|
|
2119
|
+
2. If found: complete the work OR create addendum
|
|
2120
|
+
3. Only proceed when ALL boxes are `[x]`
|
|
2121
|
+
|
|
2122
|
+
**Exception:** None. Complete all todos before locking.
|
|
2123
|
+
</HG>
|
|
2124
|
+
|
|
2125
|
+
### Hard Gate Violations
|
|
2126
|
+
|
|
2127
|
+
If a hard gate is violated:
|
|
2128
|
+
|
|
2129
|
+
1. **STOP** immediately
|
|
2130
|
+
2. **Document** the violation in current phase artifact
|
|
2131
|
+
3. **Return** to the phase that should have been completed
|
|
2132
|
+
4. **Complete** that phase properly
|
|
2133
|
+
5. **Lock** that phase
|
|
2134
|
+
6. **Resume** from where you should have been
|
|
2135
|
+
|
|
2136
|
+
**Never** proceed after a hard gate violation without correcting it.
|
|
2137
|
+
|
|
2138
|
+
---
|
|
2139
|
+
|
|
2140
|
+
## recursive-mode single-command orchestration ("Implement requirement '<run-id>'")
|
|
2141
|
+
|
|
2142
|
+
recursive-mode must be operable via a single short prompt. When the user says:
|
|
2143
|
+
|
|
2144
|
+
- Implement requirement '<run-id>'
|
|
2145
|
+
|
|
2146
|
+
…the agent must execute the recursive-mode workflow end-to-end by reading repo documents, generating missing phase artifacts, enforcing gates, locking artifacts, updating global documents, and maintaining durable memory, without requiring the user to provide long prompts.
|
|
2147
|
+
|
|
2148
|
+
### Accepted invocation forms
|
|
2149
|
+
|
|
2150
|
+
The user does not need to use only one exact phrase. Agents should treat the following as valid recursive-mode entry commands when repo docs provide the actual requirements or plan:
|
|
2151
|
+
|
|
2152
|
+
- `Implement the run`
|
|
2153
|
+
- `Implement run 75`
|
|
2154
|
+
- `Implement requirement '75'`
|
|
2155
|
+
- `Implement the plan`
|
|
2156
|
+
- `Create a new run based on the plan`
|
|
2157
|
+
- `Start a recursive run`
|
|
2158
|
+
|
|
2159
|
+
These are commands, not specifications. The agent must still read the repository documents that define the run inputs before proceeding.
|
|
2160
|
+
|
|
2161
|
+
### Invocation resolution rules
|
|
2162
|
+
|
|
2163
|
+
When the user gives a short invocation command, resolve it like this:
|
|
2164
|
+
|
|
2165
|
+
1. If the command includes an explicit run id, use that run id.
|
|
2166
|
+
2. If the command says `Implement the run` and there is exactly one active or incomplete run under `/.recursive/run/`, use that run.
|
|
2167
|
+
3. If the command says `Implement the plan`, `Create a new run based on the plan`, or `Start a recursive run`, create a new run only when a unique source plan/requirements artifact can be identified from repo docs or from the immediate task context.
|
|
2168
|
+
4. If multiple candidate runs exist and no run id is given, stop and ask the user which run to use.
|
|
2169
|
+
5. If no run exists and no unique source plan/requirements artifact can be identified, stop and ask the user for the plan or requirements path. Do not invent requirements from chat alone.
|
|
2170
|
+
|
|
2171
|
+
### Run folder resolution
|
|
2172
|
+
|
|
2173
|
+
Given `<run-id>`, the agent must locate the run folder at:
|
|
2174
|
+
|
|
2175
|
+
- `/.recursive/run/<run-id>/`
|
|
2176
|
+
|
|
2177
|
+
A valid run folder must contain at minimum:
|
|
2178
|
+
|
|
2179
|
+
- `/.recursive/run/<run-id>/00-requirements.md`
|
|
2180
|
+
|
|
2181
|
+
If the run folder or `00-requirements.md` does not exist, the agent must stop and instruct the user to create it (the agent must not invent requirements).
|
|
2182
|
+
|
|
2183
|
+
### Phase auto-resume and phase selection
|
|
2184
|
+
|
|
2185
|
+
The single-command orchestrator must be idempotent and resumable. On every invocation of "Implement requirement '<run-id>'" the agent must:
|
|
2186
|
+
|
|
2187
|
+
1) Determine the current phase by inspecting which phase outputs exist and whether they are LOCKED.
|
|
2188
|
+
2) If a phase output exists but is DRAFT (or gates are FAIL), resume that phase and iterate until PASS and then lock.
|
|
2189
|
+
3) If a phase output does not exist, start that phase by creating its output artifact (and addenda if needed).
|
|
2190
|
+
4) Never edit artifacts from earlier phases once they are LOCKED. If an earlier phase is missing something, use the Addenda policy (below) to record the gap in the current phase.
|
|
2191
|
+
|
|
2192
|
+
The orchestrator proceeds in order:
|
|
2193
|
+
|
|
2194
|
+
Phase 1: create/lock `01-as-is.md`
|
|
2195
|
+
Phase 2: create/lock `02-to-be-plan.md` (ExecPlan-grade)
|
|
2196
|
+
Phase 3: implement and create/lock `03-implementation-summary.md`
|
|
2197
|
+
Phase 4: run tests and create/lock `04-test-summary.md`
|
|
2198
|
+
Phase 5: create `05-manual-qa.md`, satisfy the selected QA execution mode requirements, and then lock it
|
|
2199
|
+
Phase 6: update global `/.recursive/DECISIONS.md` and create/lock `06-decisions-update.md`
|
|
2200
|
+
Phase 7: update global `/.recursive/STATE.md` and create/lock `07-state-update.md`
|
|
2201
|
+
Phase 8: update `/.recursive/memory/*` and create/lock `08-memory-impact.md`
|
|
2202
|
+
|
|
2203
|
+
### Mandatory "effective input" rule (base + addenda)
|
|
2204
|
+
|
|
2205
|
+
Whenever the orchestrator reads a phase input artifact, it must treat the effective input as:
|
|
2206
|
+
|
|
2207
|
+
- the base artifact, plus
|
|
2208
|
+
- all matching stage-local addenda in `/.recursive/run/<run-id>/addenda/` in lexical order, plus
|
|
2209
|
+
- any current-phase upstream-gap addenda relevant to the locked artifact being compensated.
|
|
2210
|
+
|
|
2211
|
+
The orchestrator must list all effective inputs in the header of each output artifact under Inputs.
|
|
2212
|
+
When relevant addenda exist, the orchestrator must also re-read and reconcile them explicitly in the audited phase body.
|
|
2213
|
+
|
|
2214
|
+
### Phase transition hard-stop lock chain (required)
|
|
2215
|
+
|
|
2216
|
+
Before the orchestrator starts or resumes Phase `N` (`N >= 3`), it must validate that every required prior phase is lock-valid.
|
|
2217
|
+
|
|
2218
|
+
Required prior artifacts by phase:
|
|
2219
|
+
|
|
2220
|
+
- Phase 2: `01-as-is.md`
|
|
2221
|
+
- Phase 2: `02-to-be-plan.md`
|
|
2222
|
+
- Phase 3: `03-implementation-summary.md`
|
|
2223
|
+
- Phase 4: `04-test-summary.md`
|
|
2224
|
+
- Phase 5: `05-manual-qa.md`
|
|
2225
|
+
- Phase 6: `06-decisions-update.md`
|
|
2226
|
+
- Phase 7: `07-state-update.md`
|
|
2227
|
+
- Phase 8: `08-memory-impact.md`
|
|
2228
|
+
|
|
2229
|
+
A phase artifact is lock-valid only if all checks pass:
|
|
2230
|
+
|
|
2231
|
+
1) The base artifact file exists.
|
|
2232
|
+
2) The header contains `Status: LOCKED`.
|
|
2233
|
+
3) The header contains non-empty `LockedAt`.
|
|
2234
|
+
4) The header contains non-empty `LockHash`.
|
|
2235
|
+
5) If the artifact is an audited phase in `recursive-mode-audit-v1`, it ends with `Audit: PASS`.
|
|
2236
|
+
6) The artifact ends with `Coverage: PASS` and `Approval: PASS`.
|
|
2237
|
+
7) Any stage-local addenda for that phase (`addenda/<base>.addendum-*.md`) also satisfy the same required checks for that phase.
|
|
2238
|
+
|
|
2239
|
+
If any lock-valid check fails for a required prior phase:
|
|
2240
|
+
|
|
2241
|
+
- Do not create, edit, or lock any later-phase artifact.
|
|
2242
|
+
- Resume the earliest failing phase and iterate until it is lock-valid.
|
|
2243
|
+
- Report the blocking file path(s) and failed check(s) in the phase notes/output.
|
|
2244
|
+
|
|
2245
|
+
Forbidden phase transitions:
|
|
2246
|
+
|
|
2247
|
+
- Do not create `02-to-be-plan.md` unless `01-as-is.md` is lock-valid.
|
|
2248
|
+
- Do not create `03-implementation-summary.md` unless `02-to-be-plan.md` is lock-valid.
|
|
2249
|
+
- Do not create `04-test-summary.md` unless `03-implementation-summary.md` is lock-valid.
|
|
2250
|
+
- Do not create or complete `05-manual-qa.md` unless `04-test-summary.md` is lock-valid.
|
|
2251
|
+
- Do not start Phase 6 unless `05-manual-qa.md` is lock-valid.
|
|
2252
|
+
- Do not start Phase 7 unless `06-decisions-update.md` is lock-valid.
|
|
2253
|
+
- Do not start Phase 8 unless `07-state-update.md` is lock-valid.
|
|
2254
|
+
|
|
2255
|
+
This hard-stop chain applies in single-command mode and single-phase mode.
|
|
2256
|
+
|
|
2257
|
+
### Strict sequential phase execution (no parallel phase work)
|
|
2258
|
+
|
|
2259
|
+
Recursive phase execution is strictly sequential within a run. Parallel phase work is forbidden.
|
|
2260
|
+
|
|
2261
|
+
Rules:
|
|
2262
|
+
|
|
2263
|
+
1) Exactly one active phase per run at any time.
|
|
2264
|
+
2) The active phase is the earliest phase whose base artifact is missing or not lock-valid.
|
|
2265
|
+
3) While the active phase is unresolved, the agent must not create, edit, or lock artifacts for later phases.
|
|
2266
|
+
4) There must never be more than one phase base artifact in `DRAFT` simultaneously.
|
|
2267
|
+
|
|
2268
|
+
If multiple phase artifacts are found in `DRAFT`:
|
|
2269
|
+
|
|
2270
|
+
- Treat the earliest `DRAFT` phase as the only active phase.
|
|
2271
|
+
- Treat later `DRAFT` phase artifacts as invalid parallel prework.
|
|
2272
|
+
- Do not continue later `DRAFT` artifacts until the active phase becomes lock-valid.
|
|
2273
|
+
- Once the active phase locks, proceed in sequence and recreate/overwrite invalid later-phase `DRAFT` artifacts only when each phase becomes active.
|
|
2274
|
+
|
|
2275
|
+
This rule applies to single-command orchestration and explicit single-phase invocations.
|
|
2276
|
+
|
|
2277
|
+
Scoped exception:
|
|
2278
|
+
|
|
2279
|
+
- read-only audit/review delegation and independent test execution may happen inside the active phase
|
|
2280
|
+
- write-capable subagent work is allowed only for explicitly independent sub-phases with disjoint write scopes
|
|
2281
|
+
- none of these exceptions allow parallel phase advancement or audit-free locking
|
|
2282
|
+
|
|
2283
|
+
### Mandatory gates
|
|
2284
|
+
|
|
2285
|
+
For each phase artifact created or updated, the orchestrator must enforce:
|
|
2286
|
+
|
|
2287
|
+
- Audit Gate: required for audited phases. The artifact must end with `Audit: PASS` or `Audit: FAIL`.
|
|
2288
|
+
- Coverage Gate: PASS only if the output covers everything relevant in the effective inputs (including addenda), proven via Requirement IDs (R1, R2, …).
|
|
2289
|
+
- Approval Gate: PASS only if phase readiness criteria are met.
|
|
2290
|
+
|
|
2291
|
+
For audited phases:
|
|
2292
|
+
|
|
2293
|
+
- run the audit after drafting the phase
|
|
2294
|
+
- if audit finds gaps or drift, repair inside the same phase
|
|
2295
|
+
- rerun the audit
|
|
2296
|
+
- do not allow `Coverage: PASS` or `Approval: PASS` unless `Audit: PASS`
|
|
2297
|
+
|
|
2298
|
+
If any required gate is FAIL, the orchestrator must iterate within the same phase until the phase is truly ready, then lock and proceed.
|
|
2299
|
+
|
|
2300
|
+
### Manual QA execution modes
|
|
2301
|
+
|
|
2302
|
+
Phase 5 must declare `QA Execution Mode: human|agent-operated|hybrid` in `05-manual-qa.md`.
|
|
2303
|
+
|
|
2304
|
+
When the orchestrator reaches Phase 5, it must:
|
|
2305
|
+
|
|
2306
|
+
1) Ensure the plan's QA scenarios are present (from `02-to-be-plan.md` effective content). If missing, create a Phase 5 upstream-gap addendum and include the missing scenarios in `05-manual-qa.md`.
|
|
2307
|
+
2) If mode is `human` or `hybrid`, ask the user to execute the relevant QA scenarios and report results.
|
|
2308
|
+
3) If mode is `agent-operated` or `hybrid`, record the execution agent, tools used, and concrete evidence paths.
|
|
2309
|
+
4) Stop only when user input is still required for the selected mode.
|
|
2310
|
+
|
|
2311
|
+
On the next invocation of "Implement requirement '<run-id>'", if the required QA results or sign-off have been provided, the agent must record them into `05-manual-qa.md`, pass gates, lock Phase 5, and proceed through Phase 6, Phase 7, and Phase 8.
|
|
2312
|
+
|
|
2313
|
+
### Locking rules for single-command execution
|
|
2314
|
+
|
|
2315
|
+
Within a phase, the agent may iterate on that phase's output artifact and create phase-local addenda. For audited phases, iteration must follow `draft -> audit -> repair -> re-audit`. Once all required gates are PASS for a phase, the agent must set Status to LOCKED and record LockedAt and LockHash.
|
|
2316
|
+
|
|
2317
|
+
After locking a phase, the orchestrator must not edit that phase's base artifact or its stage-local addenda.
|
|
2318
|
+
|
|
2319
|
+
### Addenda integration for single-command execution
|
|
2320
|
+
|
|
2321
|
+
If the orchestrator discovers missing or incorrect information in a LOCKED earlier phase, it must not modify that earlier phase. It must create an upstream-gap addendum in the current phase (as defined in the Addenda section) and proceed forward using the current phase's addendum to compensate.
|
|
2322
|
+
|
|
2323
|
+
## recursive-mode operator contract (what the user does)
|
|
2324
|
+
|
|
2325
|
+
To start a recursive-mode run:
|
|
2326
|
+
|
|
2327
|
+
1) Create `/.recursive/run/<run-id>/00-requirements.md` and ensure it contains requirement IDs (R1, R2, …) and acceptance criteria.
|
|
2328
|
+
- New runs should also include `Workflow version: recursive-mode-audit-v2`.
|
|
2329
|
+
2) Invoke: Implement requirement '<run-id>'
|
|
2330
|
+
|
|
2331
|
+
Equivalent short commands are also valid when the repository already contains enough information to resolve the run or source plan:
|
|
2332
|
+
|
|
2333
|
+
- `Implement the run`
|
|
2334
|
+
- `Implement run <run-id>`
|
|
2335
|
+
- `Implement the plan`
|
|
2336
|
+
- `Create a new run based on the plan`
|
|
2337
|
+
- `Start a recursive run`
|
|
2338
|
+
|
|
2339
|
+
If the command is ambiguous, the agent should ask for the run id or the repo path of the source plan/requirements artifact.
|
|
2340
|
+
|
|
2341
|
+
To continue after Manual QA:
|
|
2342
|
+
|
|
2343
|
+
1) Run the requested QA scenarios.
|
|
2344
|
+
2) Provide results in chat (pass/fail notes per scenario).
|
|
2345
|
+
3) Invoke again: Implement requirement '<run-id>' and complete through Phase 8.
|
|
2346
|
+
|
|
2347
|
+
## Legacy compatibility
|
|
2348
|
+
|
|
2349
|
+
Older runs are not blindly retrofitted.
|
|
2350
|
+
|
|
2351
|
+
- Runs with `Workflow version: recursive-mode-audit-v1` in `00-requirements.md` use the strict audit-loop workflow and must satisfy the audited-phase rules in this document.
|
|
2352
|
+
- Runs with `Workflow version: memory-phase8` in `00-requirements.md` are phase8-aware compatibility runs and must complete through `06-decisions-update.md`, `07-state-update.md`, and `08-memory-impact.md`.
|
|
2353
|
+
- Runs that already contain any of the `06/07/08` receipt artifacts are also treated as phase8-aware runs.
|
|
2354
|
+
- Runs with no phase8 marker and no late-phase receipts may be treated as legacy runs by tooling and are not required to backfill the new receipt artifacts automatically.
|
|
2355
|
+
- When a legacy run is explicitly resumed under the new strict workflow, add `Workflow version: recursive-mode-audit-v2` to `00-requirements.md` so tools can enforce the stronger contract.
|
|
2356
|
+
|
|
2357
|
+
<!-- RECURSIVE-MODE-SKILL:START -->
|
|
2358
|
+
## recursive-mode skill integration
|
|
2359
|
+
|
|
2360
|
+
The recursive-mode skill operationalizes this document's workflow rules during execution.
|
|
2361
|
+
Use it for recursive-mode prompts such as Implement requirement 'run-id' and phase-specific commands.
|
|
2362
|
+
<!-- RECURSIVE-MODE-SKILL:END -->
|