prizmkit 1.1.57 → 1.1.60

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (188) hide show
  1. package/bin/create-prizmkit.js +8 -6
  2. package/bundled/VERSION.json +3 -3
  3. package/bundled/adapters/codex/agent-adapter.js +38 -0
  4. package/bundled/adapters/codex/paths.js +27 -0
  5. package/bundled/adapters/codex/rules-adapter.js +30 -0
  6. package/bundled/adapters/codex/settings-adapter.js +27 -0
  7. package/bundled/adapters/codex/skill-adapter.js +65 -0
  8. package/bundled/adapters/codex/team-adapter.js +37 -0
  9. package/bundled/dev-pipeline/.env.example +2 -1
  10. package/bundled/dev-pipeline/README.md +10 -7
  11. package/bundled/dev-pipeline/lib/common.sh +278 -37
  12. package/bundled/dev-pipeline/run-bugfix.sh +10 -61
  13. package/bundled/dev-pipeline/run-feature.sh +10 -78
  14. package/bundled/dev-pipeline/run-recovery.sh +10 -46
  15. package/bundled/dev-pipeline/run-refactor.sh +10 -61
  16. package/bundled/dev-pipeline/scripts/generate-bootstrap-prompt.py +17 -7
  17. package/bundled/dev-pipeline/scripts/generate-bugfix-prompt.py +9 -3
  18. package/bundled/dev-pipeline/scripts/generate-refactor-prompt.py +9 -3
  19. package/bundled/dev-pipeline/scripts/utils.py +6 -4
  20. package/bundled/dev-pipeline-windows/.env.example +28 -0
  21. package/bundled/dev-pipeline-windows/README.md +30 -0
  22. package/bundled/dev-pipeline-windows/SCHEMA_ANALYSIS.md +525 -0
  23. package/bundled/dev-pipeline-windows/assets/feature-list-example.json +146 -0
  24. package/bundled/dev-pipeline-windows/assets/prizm-dev-team-integration.md +138 -0
  25. package/bundled/dev-pipeline-windows/launch-bugfix-daemon.ps1 +9 -0
  26. package/bundled/dev-pipeline-windows/launch-feature-daemon.ps1 +9 -0
  27. package/bundled/dev-pipeline-windows/launch-refactor-daemon.ps1 +9 -0
  28. package/bundled/dev-pipeline-windows/lib/common.ps1 +432 -0
  29. package/bundled/dev-pipeline-windows/lib/daemon.ps1 +140 -0
  30. package/bundled/dev-pipeline-windows/lib/pipeline.ps1 +446 -0
  31. package/bundled/dev-pipeline-windows/lib/reset.ps1 +87 -0
  32. package/bundled/dev-pipeline-windows/reset-bug.ps1 +9 -0
  33. package/bundled/dev-pipeline-windows/reset-feature.ps1 +9 -0
  34. package/bundled/dev-pipeline-windows/reset-refactor.ps1 +9 -0
  35. package/bundled/dev-pipeline-windows/run-bugfix.ps1 +9 -0
  36. package/bundled/dev-pipeline-windows/run-feature.ps1 +9 -0
  37. package/bundled/dev-pipeline-windows/run-recovery.ps1 +76 -0
  38. package/bundled/dev-pipeline-windows/run-refactor.ps1 +9 -0
  39. package/bundled/dev-pipeline-windows/scripts/check-session-status.py +228 -0
  40. package/bundled/dev-pipeline-windows/scripts/cleanup-logs.py +192 -0
  41. package/bundled/dev-pipeline-windows/scripts/detect-stuck.py +530 -0
  42. package/bundled/dev-pipeline-windows/scripts/generate-bootstrap-prompt.py +1737 -0
  43. package/bundled/dev-pipeline-windows/scripts/generate-bugfix-prompt.py +685 -0
  44. package/bundled/dev-pipeline-windows/scripts/generate-recovery-prompt.py +805 -0
  45. package/bundled/dev-pipeline-windows/scripts/generate-refactor-prompt.py +763 -0
  46. package/bundled/dev-pipeline-windows/scripts/init-bugfix-pipeline.py +316 -0
  47. package/bundled/dev-pipeline-windows/scripts/init-dev-team.py +134 -0
  48. package/bundled/dev-pipeline-windows/scripts/init-pipeline.py +380 -0
  49. package/bundled/dev-pipeline-windows/scripts/init-refactor-pipeline.py +399 -0
  50. package/bundled/dev-pipeline-windows/scripts/parse-stream-progress.py +388 -0
  51. package/bundled/dev-pipeline-windows/scripts/patch-completion-notes.py +191 -0
  52. package/bundled/dev-pipeline-windows/scripts/update-bug-status.py +864 -0
  53. package/bundled/dev-pipeline-windows/scripts/update-checkpoint.py +173 -0
  54. package/bundled/dev-pipeline-windows/scripts/update-feature-status.py +1501 -0
  55. package/bundled/dev-pipeline-windows/scripts/update-refactor-status.py +1073 -0
  56. package/bundled/dev-pipeline-windows/scripts/utils.py +542 -0
  57. package/bundled/dev-pipeline-windows/templates/agent-prompts/critic-plan-challenge.md +7 -0
  58. package/bundled/dev-pipeline-windows/templates/agent-prompts/dev-fix.md +7 -0
  59. package/bundled/dev-pipeline-windows/templates/agent-prompts/dev-implement.md +30 -0
  60. package/bundled/dev-pipeline-windows/templates/agent-prompts/dev-resume.md +5 -0
  61. package/bundled/dev-pipeline-windows/templates/agent-prompts/reviewer-review.md +7 -0
  62. package/bundled/dev-pipeline-windows/templates/bootstrap-prompt.md +46 -0
  63. package/bundled/dev-pipeline-windows/templates/bootstrap-tier1.md +43 -0
  64. package/bundled/dev-pipeline-windows/templates/bootstrap-tier2.md +43 -0
  65. package/bundled/dev-pipeline-windows/templates/bootstrap-tier3.md +43 -0
  66. package/bundled/dev-pipeline-windows/templates/bug-fix-list-schema.json +263 -0
  67. package/bundled/dev-pipeline-windows/templates/bugfix-bootstrap-prompt.md +320 -0
  68. package/bundled/dev-pipeline-windows/templates/feature-list-schema.json +237 -0
  69. package/bundled/dev-pipeline-windows/templates/refactor-bootstrap-prompt.md +331 -0
  70. package/bundled/dev-pipeline-windows/templates/refactor-list-schema.json +270 -0
  71. package/bundled/dev-pipeline-windows/templates/sections/ac-verification-checklist.md +13 -0
  72. package/bundled/dev-pipeline-windows/templates/sections/checkpoint-system.md +91 -0
  73. package/bundled/dev-pipeline-windows/templates/sections/context-budget-rules.md +33 -0
  74. package/bundled/dev-pipeline-windows/templates/sections/critical-paths-agent.md +10 -0
  75. package/bundled/dev-pipeline-windows/templates/sections/critical-paths-full.md +12 -0
  76. package/bundled/dev-pipeline-windows/templates/sections/critical-paths-lite.md +7 -0
  77. package/bundled/dev-pipeline-windows/templates/sections/directory-convention-agent.md +8 -0
  78. package/bundled/dev-pipeline-windows/templates/sections/directory-convention-full.md +9 -0
  79. package/bundled/dev-pipeline-windows/templates/sections/directory-convention-lite.md +6 -0
  80. package/bundled/dev-pipeline-windows/templates/sections/failure-capture.md +21 -0
  81. package/bundled/dev-pipeline-windows/templates/sections/feature-context.md +31 -0
  82. package/bundled/dev-pipeline-windows/templates/sections/phase-browser-verification-auto.md +72 -0
  83. package/bundled/dev-pipeline-windows/templates/sections/phase-browser-verification-opencli.md +63 -0
  84. package/bundled/dev-pipeline-windows/templates/sections/phase-browser-verification.md +62 -0
  85. package/bundled/dev-pipeline-windows/templates/sections/phase-commit-full.md +71 -0
  86. package/bundled/dev-pipeline-windows/templates/sections/phase-commit.md +64 -0
  87. package/bundled/dev-pipeline-windows/templates/sections/phase-context-snapshot-agent-suffix.md +23 -0
  88. package/bundled/dev-pipeline-windows/templates/sections/phase-context-snapshot-base.md +24 -0
  89. package/bundled/dev-pipeline-windows/templates/sections/phase-context-snapshot-lite-suffix.md +12 -0
  90. package/bundled/dev-pipeline-windows/templates/sections/phase-critic-plan-full.md +53 -0
  91. package/bundled/dev-pipeline-windows/templates/sections/phase-critic-plan.md +32 -0
  92. package/bundled/dev-pipeline-windows/templates/sections/phase-implement-agent.md +37 -0
  93. package/bundled/dev-pipeline-windows/templates/sections/phase-implement-full.md +50 -0
  94. package/bundled/dev-pipeline-windows/templates/sections/phase-implement-lite.md +52 -0
  95. package/bundled/dev-pipeline-windows/templates/sections/phase-plan-agent.md +27 -0
  96. package/bundled/dev-pipeline-windows/templates/sections/phase-plan-lite.md +27 -0
  97. package/bundled/dev-pipeline-windows/templates/sections/phase-review-agent.md +27 -0
  98. package/bundled/dev-pipeline-windows/templates/sections/phase-review-full.md +29 -0
  99. package/bundled/dev-pipeline-windows/templates/sections/phase-specify-plan-full.md +77 -0
  100. package/bundled/dev-pipeline-windows/templates/sections/phase0-init.md +13 -0
  101. package/bundled/dev-pipeline-windows/templates/sections/phase0-test-baseline.md +23 -0
  102. package/bundled/dev-pipeline-windows/templates/sections/session-context.md +5 -0
  103. package/bundled/dev-pipeline-windows/templates/sections/subagent-timeout-recovery.md +6 -0
  104. package/bundled/dev-pipeline-windows/templates/sections/test-failure-recovery-agent.md +67 -0
  105. package/bundled/dev-pipeline-windows/templates/sections/test-failure-recovery-lite.md +58 -0
  106. package/bundled/dev-pipeline-windows/templates/session-status-schema.json +83 -0
  107. package/bundled/skills/_metadata.json +1 -1
  108. package/bundled/skills/app-planner/SKILL.md +26 -18
  109. package/bundled/skills/app-planner/references/architecture-decisions.md +9 -5
  110. package/bundled/skills/app-planner/references/frontend-design-guide.md +1 -1
  111. package/bundled/skills/feature-planner/SKILL.md +9 -2
  112. package/bundled/skills/prizmkit-init/SKILL.md +7 -6
  113. package/bundled/skills/recovery-workflow/scripts/detect-recovery-state.py +2 -0
  114. package/bundled/skills-windows/app-planner/SKILL.md +639 -0
  115. package/bundled/skills-windows/app-planner/assets/app-design-guide.md +101 -0
  116. package/bundled/skills-windows/app-planner/references/architecture-decisions.md +52 -0
  117. package/bundled/skills-windows/app-planner/references/brainstorm-guide.md +101 -0
  118. package/bundled/skills-windows/app-planner/references/frontend-design-guide.md +71 -0
  119. package/bundled/skills-windows/app-planner/references/project-brief-guide.md +82 -0
  120. package/bundled/skills-windows/app-planner/references/red-team-checklist.md +40 -0
  121. package/bundled/skills-windows/app-planner/references/rules/backend/derivation-rules.md +609 -0
  122. package/bundled/skills-windows/app-planner/references/rules/backend/fixed-rules.md +285 -0
  123. package/bundled/skills-windows/app-planner/references/rules/backend/question-bank.md +249 -0
  124. package/bundled/skills-windows/app-planner/references/rules/backend/template.md +173 -0
  125. package/bundled/skills-windows/app-planner/references/rules/database/derivation-rules.md +373 -0
  126. package/bundled/skills-windows/app-planner/references/rules/database/fixed-rules.md +211 -0
  127. package/bundled/skills-windows/app-planner/references/rules/database/question-bank.md +184 -0
  128. package/bundled/skills-windows/app-planner/references/rules/database/template.md +158 -0
  129. package/bundled/skills-windows/app-planner/references/rules/frontend/derivation-rules.md +810 -0
  130. package/bundled/skills-windows/app-planner/references/rules/frontend/fixed-rules.md +188 -0
  131. package/bundled/skills-windows/app-planner/references/rules/frontend/question-bank.md +302 -0
  132. package/bundled/skills-windows/app-planner/references/rules/frontend/template.md +320 -0
  133. package/bundled/skills-windows/app-planner/references/rules/mobile/derivation-rules.md +639 -0
  134. package/bundled/skills-windows/app-planner/references/rules/mobile/fixed-rules.md +290 -0
  135. package/bundled/skills-windows/app-planner/references/rules/mobile/question-bank.md +232 -0
  136. package/bundled/skills-windows/app-planner/references/rules/mobile/template.md +175 -0
  137. package/bundled/skills-windows/bug-fix-workflow/SKILL.md +415 -0
  138. package/bundled/skills-windows/bug-planner/SKILL.md +395 -0
  139. package/bundled/skills-windows/bug-planner/assets/bug-confirmation-template.md +43 -0
  140. package/bundled/skills-windows/bug-planner/references/critic-and-verification.md +44 -0
  141. package/bundled/skills-windows/bug-planner/references/error-recovery.md +73 -0
  142. package/bundled/skills-windows/bug-planner/references/input-formats.md +53 -0
  143. package/bundled/skills-windows/bug-planner/references/schema-validation.md +25 -0
  144. package/bundled/skills-windows/bug-planner/references/severity-rules.md +16 -0
  145. package/bundled/skills-windows/bug-planner/scripts/validate-bug-list.py +322 -0
  146. package/bundled/skills-windows/bugfix-pipeline-launcher/SKILL.md +380 -0
  147. package/bundled/skills-windows/feature-pipeline-launcher/SKILL.md +441 -0
  148. package/bundled/skills-windows/feature-pipeline-launcher/scripts/preflight-check.py +462 -0
  149. package/bundled/skills-windows/feature-planner/SKILL.md +401 -0
  150. package/bundled/skills-windows/feature-planner/assets/evaluation-guide.md +64 -0
  151. package/bundled/skills-windows/feature-planner/assets/planning-guide.md +214 -0
  152. package/bundled/skills-windows/feature-planner/references/browser-interaction.md +59 -0
  153. package/bundled/skills-windows/feature-planner/references/completeness-review.md +57 -0
  154. package/bundled/skills-windows/feature-planner/references/decomposition-patterns.md +75 -0
  155. package/bundled/skills-windows/feature-planner/references/error-recovery.md +90 -0
  156. package/bundled/skills-windows/feature-planner/references/incremental-feature-planning.md +112 -0
  157. package/bundled/skills-windows/feature-planner/references/new-project-planning.md +85 -0
  158. package/bundled/skills-windows/feature-planner/scripts/validate-and-generate.py +1029 -0
  159. package/bundled/skills-windows/feature-workflow/SKILL.md +531 -0
  160. package/bundled/skills-windows/prizmkit-init/SKILL.md +356 -0
  161. package/bundled/skills-windows/prizmkit-init/assets/project-brief-template.md +82 -0
  162. package/bundled/skills-windows/prizmkit-init/references/config-schema.md +68 -0
  163. package/bundled/skills-windows/prizmkit-init/references/rules/layer-detection.md +41 -0
  164. package/bundled/skills-windows/prizmkit-init/references/tech-stack-catalog.md +13 -0
  165. package/bundled/skills-windows/prizmkit-init/references/update-supplement.md +9 -0
  166. package/bundled/skills-windows/recovery-workflow/SKILL.md +456 -0
  167. package/bundled/skills-windows/recovery-workflow/evals/evals.json +46 -0
  168. package/bundled/skills-windows/recovery-workflow/scripts/detect-recovery-state.py +544 -0
  169. package/bundled/skills-windows/refactor-pipeline-launcher/SKILL.md +406 -0
  170. package/bundled/skills-windows/refactor-planner/SKILL.md +540 -0
  171. package/bundled/skills-windows/refactor-planner/assets/planning-guide.md +292 -0
  172. package/bundled/skills-windows/refactor-planner/references/behavior-preservation.md +301 -0
  173. package/bundled/skills-windows/refactor-planner/references/refactor-scoping-guide.md +221 -0
  174. package/bundled/skills-windows/refactor-planner/scripts/validate-and-generate-refactor.py +858 -0
  175. package/bundled/skills-windows/refactor-workflow/SKILL.md +503 -0
  176. package/package.json +3 -2
  177. package/src/clean.js +73 -2
  178. package/src/config.js +159 -50
  179. package/src/detect-platform.js +16 -8
  180. package/src/external-skills.js +26 -19
  181. package/src/index.js +31 -9
  182. package/src/manifest.js +6 -2
  183. package/src/metadata.js +43 -5
  184. package/src/platforms.js +36 -0
  185. package/src/prompts.js +31 -6
  186. package/src/runtimes.js +20 -0
  187. package/src/scaffold.js +314 -110
  188. package/src/upgrade.js +81 -41
@@ -0,0 +1,53 @@
1
+ ### Plan Challenge — Critic Agent(s)
2
+
3
+ **Guard**: Verify critic agent file exists before spawning:
4
+ ```powershell
5
+ if (Test-Path "{{CRITIC_SUBAGENT_PATH}}") { "CRITIC:READY" } else { "CRITIC:MISSING" }
6
+ ```
7
+ If CRITIC:MISSING — skip this phase entirely and proceed. Log: "Critic agent not installed — skipping Plan Challenge."
8
+
9
+ **Choose ONE path based on `{{CRITIC_COUNT}}`:**
10
+
11
+ **If {{CRITIC_COUNT}} = 1 → Single Critic** (skip to CP-2.5 after this):
12
+
13
+ **Spawn Agent**:
14
+ | Parameter | Value |
15
+ |-----------|-------|
16
+ | subagent_type | prizm-dev-team-critic |
17
+ | mode | plan |
18
+ | run_in_background | false |
19
+
20
+ **Prompt**:
21
+ > {{AGENT_PROMPT_CRITIC_PLAN_CHALLENGE}}
22
+
23
+ **If {{CRITIC_COUNT}} = 3 → Multi-Critic Voting** (skip Single Critic above):
24
+
25
+ Spawn 3 Critic agents sequentially (each with mode="plan", run_in_background=false), each with a different focus lens:
26
+
27
+ Critic-A prompt (append to base prompt above):
28
+ > "**Focus Lens: Architecture & Scalability.** Prioritize: architectural pattern fit, scalability implications, over-engineering risks, component boundary design.
29
+ > Write `.prizmkit/specs/{{FEATURE_SLUG}}/challenge-report-A.md`."
30
+
31
+ Critic-B prompt (append to base prompt above):
32
+ > "**Focus Lens: Data Model & Edge Cases.** Prioritize: data model design fit, entity relationships, edge cases in business logic, missing boundary conditions.
33
+ > Write `.prizmkit/specs/{{FEATURE_SLUG}}/challenge-report-B.md`."
34
+
35
+ Critic-C prompt (append to base prompt above):
36
+ > "**Focus Lens: Security & Performance.** Prioritize: security attack surface, authentication/authorization gaps, performance bottlenecks, resource leaks.
37
+ > Write `.prizmkit/specs/{{FEATURE_SLUG}}/challenge-report-C.md`."
38
+
39
+ After all critics return, read all 3 reports:
40
+ - Challenge raised by **2/3 or more** critics → **must respond** (adjust plan or justify why not)
41
+ - Challenge raised by **1/3 only** → logged in context-snapshot but not blocking
42
+ - Max 1 plan revision round.
43
+
44
+ **CP-2.5**: Plan challenges reviewed and resolved.
45
+
46
+
47
+ **Checkpoint update**: Run the update script to set step `critic-plan-review` to `"completed"`:
48
+ ```powershell
49
+ Invoke-PrizmPython {{PIPELINE_DIR}}\scripts\update-checkpoint.py `
50
+ --checkpoint-path {{CHECKPOINT_PATH}} `
51
+ --step critic-plan-review `
52
+ --status completed
53
+ ```
@@ -0,0 +1,32 @@
1
+ ### Plan Challenge — Critic Agent
2
+
3
+ **Guard**: Verify critic agent file exists before spawning:
4
+ ```powershell
5
+ if (Test-Path "{{CRITIC_SUBAGENT_PATH}}") { "CRITIC:READY" } else { "CRITIC:MISSING" }
6
+ ```
7
+ If CRITIC:MISSING — skip this phase entirely and proceed. Log: "Critic agent not installed — skipping Plan Challenge."
8
+
9
+ **Spawn Agent**:
10
+ | Parameter | Value |
11
+ |-----------|-------|
12
+ | subagent_type | prizm-dev-team-critic |
13
+ | mode | plan |
14
+ | run_in_background | false |
15
+
16
+ **Prompt**:
17
+ > {{AGENT_PROMPT_CRITIC_PLAN_CHALLENGE}}
18
+
19
+ Wait for Critic to return.
20
+ - Read challenge-report.md. For items marked CRITICAL/HIGH: decide whether to adjust plan.md or document why the plan stands.
21
+ - Max 1 plan revision round.
22
+
23
+ **CP-2.5**: Plan challenges reviewed and resolved.
24
+
25
+
26
+ **Checkpoint update**: Run the update script to set step `critic-plan-review` to `"completed"`:
27
+ ```powershell
28
+ Invoke-PrizmPython {{PIPELINE_DIR}}\scripts\update-checkpoint.py `
29
+ --checkpoint-path {{CHECKPOINT_PATH}} `
30
+ --step critic-plan-review `
31
+ --status completed
32
+ ```
@@ -0,0 +1,37 @@
1
+ ### Implement — Dev Subagent
2
+
3
+ **Build artifacts rule** (passed to Dev): After any build/compile command (`go build`, `npm run build`, `tsc`, etc.), ensure the output binary or build directory is in `.gitignore`. Never commit compiled binaries, build output, or generated artifacts.
4
+
5
+ **Dependency version gate (BLOCKING — pass to Dev agent)**: Before running ANY package install command (`npm install`, `pip install`, `cargo build`, `go mod tidy`, `bundle install`, etc.):
6
+ 1. Every version number in the dependency manifest MUST be verified against the real registry (see Context Budget Rules §9)
7
+ 2. If a scaffold tool generated a `package.json` / `requirements.txt` / etc., verify the versions it wrote too — scaffold tools can emit outdated versions
8
+ 3. Do NOT proceed with install until all versions are confirmed real. Violation = wasted timeout cycles that can crash the session
9
+
10
+ **Scaffold file rule (pass to Dev agent)**: After running any init/scaffold command, record generated files in context-snapshot.md under `### Scaffold Files (do not re-read)`. Never re-read these files — their content is standard boilerplate (see Context Budget Rules §8). When spawning subagents, explicitly list scaffold files so they skip reading them.
11
+
12
+ **Spawn Agent**:
13
+ | Parameter | Value |
14
+ |-----------|-------|
15
+ | subagent_type | prizm-dev-team-dev |
16
+ | run_in_background | false |
17
+
18
+ **Prompt**:
19
+ > {{AGENT_PROMPT_DEV_IMPLEMENT}}
20
+
21
+ Wait for Dev to return. All tasks must be `[x]`, tests pass.
22
+
23
+ **Gate Check — Implementation Log**:
24
+ After Dev agent returns, verify the Implementation Log was written:
25
+ ```powershell
26
+ if (Select-String -Path .prizmkit/specs/{{FEATURE_SLUG}}/context-snapshot.md -Pattern "## Implementation Log" -Quiet) { "GATE:PASS" } else { "GATE:MISSING" }
27
+ ```
28
+ If GATE:MISSING — send message to Dev (re-spawn if needed): "Write the '## Implementation Log' section to context-snapshot.md before I can proceed to review. Include: files changed/created, key decisions, deviations from plan, notable discoveries."
29
+
30
+
31
+ **Checkpoint update**: Run the update script to set step `prizmkit-implement` to `"completed"`:
32
+ ```powershell
33
+ Invoke-PrizmPython {{PIPELINE_DIR}}\scripts\update-checkpoint.py `
34
+ --checkpoint-path {{CHECKPOINT_PATH}} `
35
+ --step prizmkit-implement `
36
+ --status completed
37
+ ```
@@ -0,0 +1,50 @@
1
+ ### Implement — Dev Agent
2
+
3
+ **Build artifacts rule** (passed to Dev): After any build/compile command (`go build`, `npm run build`, `tsc`, etc.), ensure the output binary or build directory is in `.gitignore`. Never commit compiled binaries, build output, or generated artifacts.
4
+
5
+ **Dependency version gate (BLOCKING — pass to Dev agent)**: Before running ANY package install command (`npm install`, `pip install`, `cargo build`, `go mod tidy`, `bundle install`, etc.):
6
+ 1. Every version number in the dependency manifest MUST be verified against the real registry (see Context Budget Rules §9)
7
+ 2. If a scaffold tool generated a `package.json` / `requirements.txt` / etc., verify the versions it wrote too — scaffold tools can emit outdated versions
8
+ 3. Do NOT proceed with install until all versions are confirmed real. Violation = wasted timeout cycles that can crash the session
9
+
10
+ **Scaffold file rule (pass to Dev agent)**: After running any init/scaffold command, record generated files in context-snapshot.md under `### Scaffold Files (do not re-read)`. Never re-read these files — their content is standard boilerplate (see Context Budget Rules §8). When spawning subagents, explicitly list scaffold files so they skip reading them.
11
+
12
+ Before spawning Dev, check plan.md Tasks section:
13
+ ```powershell
14
+ Select-String -Pattern '^\- \[ \]' .prizmkit/specs/{{FEATURE_SLUG}}/plan.md 2>$null
15
+ ```
16
+ - If result is `0` (all tasks already `[x]`) → **SKIP this phase**, go directly to Review. Do NOT spawn Dev.
17
+ - If result is non-zero → spawn Dev agent below.
18
+
19
+ **Spawn Agent**:
20
+ | Parameter | Value |
21
+ |-----------|-------|
22
+ | subagent_type | prizm-dev-team-dev |
23
+ | run_in_background | false |
24
+
25
+ **Prompt**:
26
+ > {{AGENT_PROMPT_DEV_IMPLEMENT}}
27
+
28
+ **Gate Check — Implementation Log**:
29
+ After Dev agent returns, verify the Implementation Log was written:
30
+ ```powershell
31
+ if (Select-String -Path .prizmkit/specs/{{FEATURE_SLUG}}/context-snapshot.md -Pattern "## Implementation Log" -Quiet) { "GATE:PASS" } else { "GATE:MISSING" }
32
+ ```
33
+ If GATE:MISSING — send message to Dev (re-spawn if needed): "Write the '## Implementation Log' section to context-snapshot.md before I can proceed to review. Include: files changed/created, key decisions, deviations from plan, notable discoveries."
34
+
35
+ Wait for Dev to return. **If Dev times out before all tasks are `[x]`**:
36
+ 1. Check progress: `Select-String -Pattern '^\- \[ \]' .prizmkit/specs/{{FEATURE_SLUG}}/plan.md`
37
+ 2. If any tasks remain: re-spawn Dev with this recovery prompt:
38
+ > {{AGENT_PROMPT_DEV_RESUME}}
39
+ 3. Max 2 recovery retries. After 2 failures, orchestrator implements remaining tasks directly.
40
+
41
+ All tasks `[x]`, tests pass.
42
+
43
+
44
+ **Checkpoint update**: Run the update script to set step `prizmkit-implement` to `"completed"`:
45
+ ```powershell
46
+ Invoke-PrizmPython {{PIPELINE_DIR}}\scripts\update-checkpoint.py `
47
+ --checkpoint-path {{CHECKPOINT_PATH}} `
48
+ --step prizmkit-implement `
49
+ --status completed
50
+ ```
@@ -0,0 +1,52 @@
1
+ ### Implement + Test
2
+
3
+ **Build artifacts**: After any build/compile command (`go build`, `npm run build`, `tsc`, etc.), ensure the output binary or build directory is in `.gitignore`:
4
+ ```powershell
5
+ # Example for Go
6
+ if (-not (Select-String -Path .gitignore -Pattern '^/binary-name$' -Quiet -ErrorAction SilentlyContinue)) {
7
+ Add-Content -Path .gitignore -Value '/binary-name'
8
+ }
9
+ ```
10
+ Never commit compiled binaries, build output, or generated artifacts.
11
+
12
+ **Dependency version gate (BLOCKING)**: Before running ANY package install command (`npm install`, `pip install`, `cargo build`, `go mod tidy`, `bundle install`, etc.):
13
+ 1. Every version number in your dependency manifest MUST be verified against the real registry (see Context Budget Rules §9)
14
+ 2. If you used a scaffold tool that generated a `package.json` / `requirements.txt` / etc., verify the versions it wrote too — scaffold tools can emit outdated versions
15
+ 3. Do NOT proceed with install until all versions are confirmed real. Violation = wasted timeout cycles
16
+
17
+ **Scaffold file rule**: After running any init/scaffold command, record generated files in context-snapshot.md under `### Scaffold Files (do not re-read)`. Never re-read these files — their content is standard boilerplate (see Context Budget Rules §8).
18
+
19
+ **3a.** Detect test commands and record baseline:
20
+
21
+ You know this project's tech stack. Identify ALL test commands that apply (e.g., `go test ./...`, `npm test`, `cargo test`, `pytest`, `make test`, etc.). Record them as `TEST_CMDS`. Then record baseline:
22
+ ```powershell
23
+ # Run each test command, capture output
24
+ & {
25
+ {{TEST_CMD}}
26
+ } 2>&1 | Tee-Object (Join-Path $env:TEMP "test-baseline.txt") | Select-Object -Last 20
27
+ ```
28
+
29
+ **3b.** Run `/prizmkit-implement` — this handles the full implementation cycle:
30
+ - Reads plan.md Tasks section from `.prizmkit/specs/{{FEATURE_SLUG}}/`
31
+ - Reads context from `context-snapshot.md` (Prizm docs, TRAPS, file manifest)
32
+ - Implements task-by-task with TDD, marking each `[x]` immediately
33
+ - Creates/updates L2 `.prizm` docs when creating new modules or significantly modifying existing ones — AI selectively decides the modules that warrant L2 based on complexity and importance
34
+ - Runs tests using `TEST_CMD` after each task
35
+ - Writes '## Implementation Log' to `context-snapshot.md`
36
+
37
+ **3c.** After implement completes, verify:
38
+ 1. All tasks in plan.md are `[x]`
39
+ 2. Run the full test suite to ensure nothing is broken
40
+ 3. Verify each acceptance criterion from Section 1 of context-snapshot.md is met — check mentally, do NOT re-read files you already wrote
41
+ 4. If any criterion is not met, fix it now using the convergence-based recovery loop (see Test Failure Recovery Protocol)
42
+
43
+ **CP-2**: All acceptance criteria met, all tests pass.
44
+
45
+
46
+ **Checkpoint update**: Run the update script to set step `prizmkit-implement` to `"completed"`:
47
+ ```powershell
48
+ Invoke-PrizmPython {{PIPELINE_DIR}}\scripts\update-checkpoint.py `
49
+ --checkpoint-path {{CHECKPOINT_PATH}} `
50
+ --step prizmkit-implement `
51
+ --status completed
52
+ ```
@@ -0,0 +1,27 @@
1
+ ### Plan & Tasks
2
+
3
+ ```powershell
4
+ Get-ChildItem .prizmkit/specs/{{FEATURE_SLUG}}/plan.md -ErrorAction SilentlyContinue
5
+ ```
6
+
7
+ If missing, run `/prizmkit-plan` with `artifact_dir=.prizmkit/specs/{{FEATURE_SLUG}}/` to generate `plan.md`:
8
+ - The plan.md should include: architecture — components, interfaces, data flow, files to create/modify, testing approach, and a Tasks section with `[ ]` checkboxes ordered by dependency.
9
+ - Resolve any `[NEEDS CLARIFICATION]` markers using the feature description — do NOT pause for interactive input.
10
+
11
+ **Database Design Gate** (if feature involves data persistence — new tables, schema changes, new entities):
12
+ Before proceeding past CP-1, verify:
13
+ 1. Plan.md Data Model section references existing schema/model files (scan for `*.prisma`, `*.sql`, `migrations/`, `models/`, `*.entity.*` files; read them if not already in context-snapshot)
14
+ 2. All new tables/fields follow existing naming conventions, ID strategy, timestamp patterns, and constraint style
15
+ 3. No `[NEEDS CLARIFICATION]` remains in Data Model section — resolve by reading existing code and making a conservative choice that matches existing patterns. Document the resolution in plan.md.
16
+ 4. If a DB design decision genuinely cannot be resolved from existing code alone, document the assumption made and flag it in the Implementation Log for user review.
17
+
18
+ **CP-1**: plan.md exists with Tasks section.
19
+
20
+
21
+ **Checkpoint update**: Run the update script to set step `prizmkit-plan` to `"completed"`:
22
+ ```powershell
23
+ Invoke-PrizmPython {{PIPELINE_DIR}}\scripts\update-checkpoint.py `
24
+ --checkpoint-path {{CHECKPOINT_PATH}} `
25
+ --step prizmkit-plan `
26
+ --status completed
27
+ ```
@@ -0,0 +1,27 @@
1
+ ### Plan & Tasks
2
+
3
+ ```powershell
4
+ Get-ChildItem .prizmkit/specs/{{FEATURE_SLUG}}/ -ErrorAction SilentlyContinue
5
+ ```
6
+
7
+ If plan.md missing, run `/prizmkit-plan` with `artifact_dir=.prizmkit/specs/{{FEATURE_SLUG}}/`:
8
+ - Pass the feature description and acceptance criteria from the Feature Context section above as input
9
+ - The plan.md should include: key components, data flow, files to create/modify, and a Tasks section with `[ ]` checkboxes (each task = one implementable unit). Keep under 80 lines.
10
+ - Resolve any `[NEEDS CLARIFICATION]` markers using the feature description — do NOT pause for interactive input.
11
+
12
+ **Database Design Gate** (if feature involves data persistence — new tables, schema changes, new entities):
13
+ Before proceeding past CP-1:
14
+ 1. Scan for existing schema files (`*.prisma`, `*.sql`, `migrations/`, `models/`, `*.entity.*`) and read them
15
+ 2. Ensure new tables/fields follow existing naming conventions and constraint patterns
16
+ 3. Resolve all uncertain DB design decisions before writing Tasks — document choices in plan.md
17
+
18
+ **CP-1**: plan.md exists with Tasks section.
19
+
20
+
21
+ **Checkpoint update**: Run the update script to set step `prizmkit-plan` to `"completed"`:
22
+ ```powershell
23
+ Invoke-PrizmPython {{PIPELINE_DIR}}\scripts\update-checkpoint.py `
24
+ --checkpoint-path {{CHECKPOINT_PATH}} `
25
+ --step prizmkit-plan `
26
+ --status completed
27
+ ```
@@ -0,0 +1,27 @@
1
+ ### Review + Test — Code Review
2
+
3
+ Run `/prizmkit-code-review` with `artifact_dir=.prizmkit/specs/{{FEATURE_SLUG}}/`.
4
+
5
+ The skill runs an internal review-fix loop (Reviewer Agent → filter → Dev Agent fix, max 3 rounds) and writes `review-report.md` to the artifact directory.
6
+
7
+ **Gate Check — Review Report**:
8
+ After `/prizmkit-code-review` returns, verify the review report:
9
+ ```powershell
10
+ if (Select-String -Path .prizmkit/specs/{{FEATURE_SLUG}}/review-report.md -Pattern "## Verdict" -Quiet) { "GATE:PASS" } else { "GATE:MISSING" }
11
+ ```
12
+ If GATE:MISSING — re-run `/prizmkit-code-review`.
13
+
14
+ Read `review-report.md` and check the Verdict:
15
+ - `PASS` → proceed to next phase
16
+ - `NEEDS_FIXES` → the skill exhausted its max rounds; log the remaining findings and proceed (do not retry externally)
17
+
18
+ **CP-3**: Review complete, report written.
19
+
20
+
21
+ **Checkpoint update**: Run the update script to set step `prizmkit-code-review` to `"completed"`:
22
+ ```powershell
23
+ Invoke-PrizmPython {{PIPELINE_DIR}}\scripts\update-checkpoint.py `
24
+ --checkpoint-path {{CHECKPOINT_PATH}} `
25
+ --step prizmkit-code-review `
26
+ --status completed
27
+ ```
@@ -0,0 +1,29 @@
1
+ ### Review + Test — Code Review
2
+
3
+ Run `/prizmkit-code-review` with `artifact_dir=.prizmkit/specs/{{FEATURE_SLUG}}/`.
4
+
5
+ The skill runs an internal review-fix loop (Reviewer Agent → filter → Dev Agent fix, max 3 rounds) and writes `review-report.md` to the artifact directory.
6
+
7
+ **Gate Check — Review Report**:
8
+ After `/prizmkit-code-review` returns, verify the review report:
9
+ ```powershell
10
+ if (Select-String -Path .prizmkit/specs/{{FEATURE_SLUG}}/review-report.md -Pattern "## Verdict" -Quiet) { "GATE:PASS" } else { "GATE:MISSING" }
11
+ ```
12
+ If GATE:MISSING — re-run `/prizmkit-code-review`.
13
+
14
+ Read `review-report.md` and check the Verdict:
15
+ - `PASS` → proceed to next phase
16
+ - `NEEDS_FIXES` → the skill exhausted its max rounds; log the remaining findings and proceed (do not retry externally)
17
+
18
+ Run the full test suite: `({{TEST_CMD}}) 2>&1 | Tee-Object (Join-Path $env:TEMP "review-test-out.txt") | Select-Object -Last 20`
19
+
20
+ **CP-3**: Review complete, tests pass, report written.
21
+
22
+
23
+ **Checkpoint update**: Run the update script to set step `prizmkit-code-review` to `"completed"`:
24
+ ```powershell
25
+ Invoke-PrizmPython {{PIPELINE_DIR}}\scripts\update-checkpoint.py `
26
+ --checkpoint-path {{CHECKPOINT_PATH}} `
27
+ --step prizmkit-code-review `
28
+ --status completed
29
+ ```
@@ -0,0 +1,77 @@
1
+ ### Specify + Plan (Full Workflow)
2
+
3
+ Check existing artifacts first:
4
+ ```powershell
5
+ Get-ChildItem .prizmkit/specs/{{FEATURE_SLUG}}/ -ErrorAction SilentlyContinue
6
+ ```
7
+
8
+ - Both (spec.md, plan.md) exist → **SKIP to CP-1**
9
+ - `context-snapshot.md` exists → use it directly, skip context snapshot building
10
+ - Some missing → generate only missing files
11
+
12
+ **Step A — Build Context Snapshot** (skip if `context-snapshot.md` already exists):
13
+
14
+ 1. Read `.prizmkit/prizm-docs/root.prizm` and relevant L1/L2 prizm docs
15
+ 2. Detect source code directories: read KEY_FILES and STRUCTURE sections from `root.prizm` to identify where source code lives (e.g. `src/`, `app/`, `lib/`, `cmd/`, `packages/`, or project root). If `root.prizm` is missing, scan the project tree:
16
+ ```powershell
17
+ Get-ChildItem -Path . -File -Recurse -Depth 2 -Include *.js,*.ts,*.py,*.go,*.java,*.rb,*.rs -ErrorAction SilentlyContinue |
18
+ Where-Object { $_.FullName -notmatch '\\(node_modules|\.git|dist|build|vendor)(\\|$)' } |
19
+ Select-Object -First 30 -ExpandProperty FullName
20
+ ```
21
+ Identify the top-level source directories from the results.
22
+ 3. Scan the detected source directories for files related to this feature; read each one
23
+ 4. Write `.prizmkit/specs/{{FEATURE_SLUG}}/context-snapshot.md`:
24
+ - **Section 1 — Task Brief**: task description + acceptance criteria (copy from above)
25
+ - **Section 2 — Project Structure**: run the following to get a visual directory tree, then paste output:
26
+ ```powershell
27
+ Get-ChildItem -Path . -Directory -Recurse -Depth 2 -ErrorAction SilentlyContinue |
28
+ Where-Object { $_.FullName -notmatch '\\(node_modules|\.git|dist|build|__pycache__|vendor)(\\|$)' } |
29
+ Select-Object -ExpandProperty FullName
30
+ ```
31
+ - **Section 3 — Prizm Context**: full content of root.prizm and relevant L1/L2 docs
32
+ - **Section 4 — File Manifest**: For each file relevant to this feature, list: file path, why it's needed (modify/reference/test), key interface signatures (function names + params + return types). Do NOT include full file content — agents read files on-demand. Format:
33
+ ### Files to Modify
34
+ | File | Why Needed | Key Interfaces |
35
+ |------|-----------|----------------|
36
+ | `<source-dir>/config.js` | Add runtime config layer | `config` (Zod object), `configSchema` |
37
+
38
+ ### Files for Reference
39
+ | File | Why Needed | Key Interfaces |
40
+ |------|-----------|----------------|
41
+ | `<source-dir>/security/permission-guard.js` | Permission check integration | `checkCommandPermission(userId, cmd)` |
42
+
43
+ ### Known TRAPS (from .prizmkit/prizm-docs/)
44
+ - <trap entries extracted from L1/L2 docs>
45
+ - **Section 5 — Existing Tests**: full content of related test files as code blocks
46
+ 5. Confirm: `ls .prizmkit/specs/{{FEATURE_SLUG}}/context-snapshot.md`
47
+
48
+ **After Step A**: Use context-snapshot.md Section 4 File Manifest to guide targeted file reads. Do NOT scan directories or read unrelated files.
49
+
50
+ **Step B — Planning Artifacts** (generate only missing files):
51
+
52
+ ```powershell
53
+ Get-ChildItem .prizmkit/specs/{{FEATURE_SLUG}}/spec.md .prizmkit/specs/{{FEATURE_SLUG}}/plan.md -ErrorAction SilentlyContinue
54
+ ```
55
+
56
+ - spec.md missing: Run `/prizmkit-plan` → generate spec.md. Resolve any `[NEEDS CLARIFICATION]` markers using the task description — do NOT pause for interactive input.
57
+ - plan.md missing: Run `/prizmkit-plan` → generate plan.md (change approach, components, interface design, data model, testing strategy, risk assessment, and Tasks section with `[ ]` checkboxes)
58
+
59
+ > All files go under `.prizmkit/specs/{{FEATURE_SLUG}}/`. Confirm each with `ls` after writing.
60
+
61
+ **Database Design Gate** (if feature involves data persistence — new tables, schema changes, new entities):
62
+ Before proceeding past CP-1, verify:
63
+ 1. Plan.md Data Model section references existing schema/model files (scan for `*.prisma`, `*.sql`, `migrations/`, `models/`, `*.entity.*` files; read them if not already in context-snapshot)
64
+ 2. All new tables/fields follow existing naming conventions, ID strategy, timestamp patterns, and constraint style
65
+ 3. No `[NEEDS CLARIFICATION]` remains in Data Model section — resolve by reading existing code and making a conservative choice that matches existing patterns. Document the resolution in plan.md.
66
+ 4. If a DB design decision genuinely cannot be resolved from existing code alone, document the assumption made and flag it in the Implementation Log for user review.
67
+
68
+ **CP-1**: Both spec.md and plan.md exist.
69
+
70
+
71
+ **Checkpoint update**: Run the update script to set step `context-snapshot-and-plan` to `"completed"`:
72
+ ```powershell
73
+ Invoke-PrizmPython {{PIPELINE_DIR}}\scripts\update-checkpoint.py `
74
+ --checkpoint-path {{CHECKPOINT_PATH}} `
75
+ --step context-snapshot-and-plan `
76
+ --status completed
77
+ ```
@@ -0,0 +1,13 @@
1
+ ### Phase 0: Project Bootstrap
2
+ - Run `/prizmkit-init` (invoke the prizmkit-init skill)
3
+ - Run `Invoke-PrizmPython {{INIT_SCRIPT_PATH}} --project-root {{PROJECT_ROOT}} --feature-id {{FEATURE_ID}} --feature-slug {{FEATURE_SLUG}}`
4
+ - **CP-0**: Verify `.prizmkit/prizm-docs/root.prizm`, `.prizmkit/config.json` exist
5
+
6
+
7
+ **Checkpoint update**: Run the update script to set step `prizmkit-init` to `"completed"`:
8
+ ```powershell
9
+ Invoke-PrizmPython {{PIPELINE_DIR}}\scripts\update-checkpoint.py `
10
+ --checkpoint-path {{CHECKPOINT_PATH}} `
11
+ --step prizmkit-init `
12
+ --status completed
13
+ ```
@@ -0,0 +1,23 @@
1
+ ### Phase 0: Record Test Baseline & Detect Test Commands
2
+
3
+ **Step 1 — Detect test commands**: You know this project's tech stack. Identify ALL test commands that apply (e.g., `go test ./...`, `npm test`, `cargo test`, `pytest`, `make test`, etc.). Record them as `TEST_CMDS`.
4
+
5
+ **Step 2 — Record pre-existing failure baseline**:
6
+ ```powershell
7
+ # Run each test command, capture output
8
+ & {
9
+ {{TEST_CMD}}
10
+ } 2>&1 | Tee-Object (Join-Path $env:TEMP "test-baseline.txt") | Select-Object -Last 20
11
+ ```
12
+ Save the list of **pre-existing failing tests** (if any) as `BASELINE_FAILURES`. These are known failures that existed before this session — Dev must NOT be blamed for them, but must list them in COMPLETION_SIGNAL.
13
+
14
+ > **Test Output Rule**: Always capture test output to a temp file (`tee $env:TEMP\test-out.txt`). Then Select-String the file instead of re-running the suite.
15
+
16
+
17
+ **Checkpoint update**: Run the update script to set step `test-baseline` to `"completed"`:
18
+ ```powershell
19
+ Invoke-PrizmPython {{PIPELINE_DIR}}\scripts\update-checkpoint.py `
20
+ --checkpoint-path {{CHECKPOINT_PATH}} `
21
+ --step test-baseline `
22
+ --status completed
23
+ ```
@@ -0,0 +1,5 @@
1
+ ## Session Context
2
+
3
+ - **Feature ID**: {{FEATURE_ID}} | **Session**: {{SESSION_ID}} | **Run**: {{RUN_ID}}
4
+ - **Complexity**: {{COMPLEXITY}}
5
+ - **Init**: {{INIT_DONE}} | Artifacts: spec={{HAS_SPEC}} plan={{HAS_PLAN}}
@@ -0,0 +1,6 @@
1
+ ## Subagent Timeout Recovery
2
+
3
+ If any agent times out:
4
+ 1. `ls .prizmkit/specs/{{FEATURE_SLUG}}/` — check what exists
5
+ 2. If `context-snapshot.md` exists: open recovery prompt with `"Read .prizmkit/specs/{{FEATURE_SLUG}}/context-snapshot.md for project context and any Implementation Log/Review Notes from previous agents. Run git diff HEAD to see actual code changes already made. Do NOT re-read individual source files unless the File Manifest directs you to."` + only remaining steps + `model: "lite"`
6
+ 3. Max 2 retries per phase. After 2 failures, orchestrator completes the work directly and appends a Recovery Note to context-snapshot.md.
@@ -0,0 +1,67 @@
1
+ ## Test Failure Recovery Protocol
2
+
3
+ When tests fail during implementation (Phase 3 / Phase 4), use **convergence-based recovery** — keep fixing as long as progress is being made.
4
+
5
+ ### Recovery Loop
6
+
7
+ 1. **Run tests and record results**:
8
+ - Count total failures and note the failed tests
9
+ - Compare against baseline (BASELINE_FAILURES) — exclude pre-existing failures
10
+
11
+ 2. **Check termination conditions** (evaluate BEFORE each fix attempt):
12
+ - **All tests pass** → Done. Exit recovery loop.
13
+ - **Plateau detected** — same failure count AND same failing tests for 3 consecutive rounds → AI cannot resolve these failures. Document and exit.
14
+ - **Still making progress** — failure count decreased compared to previous round → Continue fixing.
15
+ - **First round** — no history yet → Proceed to fix.
16
+
17
+ 3. **Fix and iterate**:
18
+ - Analyze remaining failures: root cause (code bug vs. test brittleness vs. environment issue)
19
+ - Categorize:
20
+ - **Pre-existing baseline failure**: Expected, do NOT fix
21
+ - **New regression**: Fix the code
22
+ - **Brittle test**: Fix the test or environment setup
23
+ - Apply fix, re-run `{{TEST_CMD}}`, go back to step 1
24
+
25
+ ### Convergence Tracking
26
+
27
+ Track failures each round. Example: 5→3→3→3→3 = plateau at round 3, stop at round 5 (3/3).
28
+
29
+ **Key rule**: If failures decrease (even by 1), the plateau counter resets to 0.
30
+
31
+ ### Escalation — Dev + Reviewer Workflow
32
+
33
+ When the recovery loop exits with remaining failures:
34
+ - Dev appends failure details to Implementation Log
35
+ - Reviewer agent runs full test suite in Phase 5
36
+ - If Reviewer confirms NEW regressions (not in baseline): mark verdict as `NEEDS_FIXES`
37
+ - If Reviewer confirms only baseline failures remain: proceed with `PASS_WITH_WARNINGS`
38
+
39
+ ### Context-Aware Test Re-run (Performance Optimization)
40
+
41
+ **Skip redundant re-runs**:
42
+ - If Implementation Log section in context-snapshot.md already confirms "all tests passing"
43
+ - → Skip Phase 5 test suite re-run (Reviewer will verify baseline log instead)
44
+ - This avoids rebuilding/re-running tests when already verified
45
+
46
+ **When to re-run**:
47
+ - If Implementation Log is missing or incomplete
48
+ - If any new code was added after the last test run
49
+ - If Reviewer suspects brittleness or environment drift
50
+
51
+ ### Failure Capture Rules
52
+
53
+ If tests remain broken after recovery:
54
+
55
+ ```
56
+ ## Test Failures Encountered
57
+
58
+ - **Test**: [test name/path]
59
+ - Root Cause: [explanation]
60
+ - Category: [pre-existing baseline | new regression | brittle test | environment]
61
+ - Rounds Attempted: [N rounds, plateau at round M]
62
+ - Status: [still failing | requires next session | known limitation]
63
+
64
+ - **Impact on Feature**: [can AC be verified despite failure | blocks AC verification]
65
+ ```
66
+
67
+ **Rule**: If any AC cannot be verified due to test failure, the feature is incomplete. Document in failure-log.md for next session.
@@ -0,0 +1,58 @@
1
+ ## Test Failure Recovery Protocol
2
+
3
+ When tests fail during implementation, use **convergence-based recovery** — keep fixing as long as progress is being made.
4
+
5
+ ### Recovery Loop
6
+
7
+ 1. **Run tests and record results**:
8
+ - Count total failures and note the failed tests
9
+ - Compare against baseline (BASELINE_FAILURES) — exclude pre-existing failures
10
+
11
+ 2. **Check termination conditions** (evaluate BEFORE each fix attempt):
12
+ - **All tests pass** → Done. Exit recovery loop.
13
+ - **Plateau detected** — same failure count AND same failing tests for 3 consecutive rounds → AI cannot resolve these failures. Document and exit.
14
+ - **Still making progress** — failure count decreased compared to previous round → Continue fixing.
15
+ - **First round** — no history yet → Proceed to fix.
16
+
17
+ 3. **Fix and iterate**:
18
+ - Analyze remaining failures: root cause (code bug vs. test brittleness vs. environment issue)
19
+ - Categorize:
20
+ - **Pre-existing baseline failure**: Expected, do NOT fix
21
+ - **New regression**: Fix the code
22
+ - **Brittle test**: Fix the test or environment setup
23
+ - Apply fix, re-run `{{TEST_CMD}}`, go back to step 1
24
+
25
+ ### Convergence Tracking
26
+
27
+ Track failures each round. Example: 5→3→3→3→3 = plateau at round 3, stop at round 5 (3/3).
28
+
29
+ **Key rule**: If failures decrease (even by 1), the plateau counter resets to 0.
30
+
31
+ ### Escalation — Single Agent
32
+
33
+ When the recovery loop exits with remaining failures:
34
+ - Document all remaining failures in Implementation Log with root cause analysis
35
+ - Record PARTIAL status with known failure list
36
+ - **Do NOT block commit** — unresolved test failures are deferred to next session
37
+
38
+ ### Context-Aware Optimization
39
+
40
+ **Skip redundant re-runs**: If Implementation Log already confirms "all tests passing", skip full suite re-run.
41
+
42
+ ### Failure Capture Rules
43
+
44
+ If tests remain broken after recovery:
45
+
46
+ ```
47
+ ## Test Failures Encountered
48
+
49
+ - **Test**: [test name/path]
50
+ - Root Cause: [explanation]
51
+ - Category: [pre-existing baseline | new regression | brittle test | environment]
52
+ - Rounds Attempted: [N rounds, plateau at round M]
53
+ - Status: [still failing | requires next session | known limitation]
54
+
55
+ - **Impact on Feature**: [can AC be verified despite failure | blocks AC verification]
56
+ ```
57
+
58
+ **Rule**: If any AC cannot be verified due to test failure, the feature is incomplete. Document in failure-log.md for next session.