@thierrynakoa/fire-flow 10.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (215) hide show
  1. package/.claude-plugin/plugin.json +64 -0
  2. package/ARCHITECTURE-DIAGRAM.md +440 -0
  3. package/COMMAND-REFERENCE.md +172 -0
  4. package/DOMINION-FLOW-OVERVIEW.md +421 -0
  5. package/LICENSE +21 -0
  6. package/QUICK-START.md +351 -0
  7. package/README.md +398 -0
  8. package/TROUBLESHOOTING.md +264 -0
  9. package/agents/fire-codebase-mapper.md +484 -0
  10. package/agents/fire-debugger.md +535 -0
  11. package/agents/fire-executor.md +949 -0
  12. package/agents/fire-fact-checker.md +276 -0
  13. package/agents/fire-learncoding-explainer.md +237 -0
  14. package/agents/fire-learncoding-walker.md +147 -0
  15. package/agents/fire-planner.md +675 -0
  16. package/agents/fire-project-researcher.md +155 -0
  17. package/agents/fire-research-synthesizer.md +166 -0
  18. package/agents/fire-researcher.md +723 -0
  19. package/agents/fire-reviewer.md +499 -0
  20. package/agents/fire-roadmapper.md +203 -0
  21. package/agents/fire-verifier.md +880 -0
  22. package/bin/cli.js +208 -0
  23. package/commands/fire-0-orient.md +476 -0
  24. package/commands/fire-1-new.md +281 -0
  25. package/commands/fire-1a-discuss.md +455 -0
  26. package/commands/fire-2-plan.md +527 -0
  27. package/commands/fire-3-execute.md +1303 -0
  28. package/commands/fire-4-verify.md +845 -0
  29. package/commands/fire-5-handoff.md +515 -0
  30. package/commands/fire-6-resume.md +501 -0
  31. package/commands/fire-7-review.md +409 -0
  32. package/commands/fire-add-new-skill.md +598 -0
  33. package/commands/fire-analytics.md +499 -0
  34. package/commands/fire-assumptions.md +78 -0
  35. package/commands/fire-autonomous.md +528 -0
  36. package/commands/fire-brainstorm.md +413 -0
  37. package/commands/fire-complete-milestone.md +270 -0
  38. package/commands/fire-dashboard.md +375 -0
  39. package/commands/fire-debug.md +663 -0
  40. package/commands/fire-discover.md +616 -0
  41. package/commands/fire-double-check.md +460 -0
  42. package/commands/fire-execute-plan.md +182 -0
  43. package/commands/fire-learncoding.md +242 -0
  44. package/commands/fire-loop-resume.md +272 -0
  45. package/commands/fire-loop-stop.md +198 -0
  46. package/commands/fire-loop.md +1168 -0
  47. package/commands/fire-map-codebase.md +313 -0
  48. package/commands/fire-new-milestone.md +356 -0
  49. package/commands/fire-reflect.md +235 -0
  50. package/commands/fire-research.md +246 -0
  51. package/commands/fire-search.md +330 -0
  52. package/commands/fire-security-audit-repo.md +293 -0
  53. package/commands/fire-security-scan.md +484 -0
  54. package/commands/fire-session-summary.md +252 -0
  55. package/commands/fire-skills-diff.md +506 -0
  56. package/commands/fire-skills-history.md +388 -0
  57. package/commands/fire-skills-rollback.md +408 -0
  58. package/commands/fire-skills-sync.md +470 -0
  59. package/commands/fire-test.md +520 -0
  60. package/commands/fire-todos.md +335 -0
  61. package/commands/fire-transition.md +186 -0
  62. package/commands/fire-update.md +312 -0
  63. package/commands/fire-verify-uat.md +146 -0
  64. package/commands/fire-vuln-scan.md +493 -0
  65. package/hooks/hooks.json +16 -0
  66. package/hooks/run-hook.cmd +69 -0
  67. package/hooks/run-hook.sh +8 -0
  68. package/hooks/run-session-end.cmd +49 -0
  69. package/hooks/run-session-end.sh +7 -0
  70. package/hooks/session-end.sh +90 -0
  71. package/hooks/session-start.sh +111 -0
  72. package/package.json +52 -0
  73. package/plugin.json +7 -0
  74. package/references/auto-skill-extraction.md +136 -0
  75. package/references/behavioral-directives.md +365 -0
  76. package/references/blocker-tracking.md +155 -0
  77. package/references/checkpoints.md +165 -0
  78. package/references/circuit-breaker.md +410 -0
  79. package/references/context-engineering.md +587 -0
  80. package/references/decision-time-guidance.md +289 -0
  81. package/references/error-classification.md +326 -0
  82. package/references/execution-mode-intelligence.md +242 -0
  83. package/references/git-integration.md +217 -0
  84. package/references/honesty-protocols.md +304 -0
  85. package/references/integration-architecture.md +470 -0
  86. package/references/issue-to-pr-pipeline.md +150 -0
  87. package/references/metrics-and-trends.md +234 -0
  88. package/references/playwright-e2e-testing.md +326 -0
  89. package/references/questioning.md +125 -0
  90. package/references/research-improvements.md +110 -0
  91. package/references/skills-usage-guide.md +429 -0
  92. package/references/tdd.md +131 -0
  93. package/references/testing-enforcement.md +192 -0
  94. package/references/ui-brand.md +383 -0
  95. package/references/validation-checklist.md +456 -0
  96. package/references/verification-patterns.md +187 -0
  97. package/references/warrior-principles.md +173 -0
  98. package/skills-library/SKILLS-INDEX.md +588 -0
  99. package/skills-library/_general/frontend/html-visual-reports.md +292 -0
  100. package/skills-library/_general/methodology/debug-swarm-researcher-escape-hatch.md +240 -0
  101. package/skills-library/_general/methodology/learncoding-agentic-pattern.md +114 -0
  102. package/skills-library/_general/methodology/shell-autonomous-loop-fixplan.md +238 -0
  103. package/skills-library/basics/api-rest-basics.md +162 -0
  104. package/skills-library/basics/env-variables.md +96 -0
  105. package/skills-library/basics/error-handling-basics.md +125 -0
  106. package/skills-library/basics/git-commit-conventions.md +106 -0
  107. package/skills-library/basics/readme-template.md +108 -0
  108. package/skills-library/common-tasks/async-await-patterns.md +157 -0
  109. package/skills-library/common-tasks/auth-jwt-basics.md +164 -0
  110. package/skills-library/common-tasks/database-schema-design.md +166 -0
  111. package/skills-library/common-tasks/file-upload-basics.md +166 -0
  112. package/skills-library/common-tasks/form-validation.md +159 -0
  113. package/skills-library/debugging/FAILURE_TAXONOMY_CLASSIFICATION.md +117 -0
  114. package/skills-library/debugging/THREE_AGENT_HYPOTHESIS_DEBUGGING.md +86 -0
  115. package/skills-library/methodology/BREATH_BASED_PARALLEL_EXECUTION.md +678 -0
  116. package/skills-library/methodology/CONFIDENCE_GATED_EXECUTION.md +243 -0
  117. package/skills-library/methodology/EVIDENCE_BASED_VALIDATION.md +308 -0
  118. package/skills-library/methodology/MULTI_PERSPECTIVE_CODE_REVIEW.md +330 -0
  119. package/skills-library/methodology/PATH_VERIFICATION_GATE.md +211 -0
  120. package/skills-library/methodology/REFLEXION_MEMORY_PATTERN.md +183 -0
  121. package/skills-library/methodology/RESEARCH_BACKED_WORKFLOW_UPGRADE.md +263 -0
  122. package/skills-library/methodology/SABBATH_REST_PATTERN.md +267 -0
  123. package/skills-library/methodology/STONE_AND_SCAFFOLD.md +220 -0
  124. package/skills-library/performance/cache-augmented-generation.md +172 -0
  125. package/skills-library/quality-safety/debugging-steps.md +147 -0
  126. package/skills-library/quality-safety/deployment-checklist.md +155 -0
  127. package/skills-library/quality-safety/security-checklist.md +204 -0
  128. package/skills-library/quality-safety/testing-basics.md +180 -0
  129. package/skills-library/security/agent-security-scanner.md +445 -0
  130. package/skills-library/specialists/api-architecture/api-designer.md +49 -0
  131. package/skills-library/specialists/api-architecture/graphql-architect.md +49 -0
  132. package/skills-library/specialists/api-architecture/mcp-developer.md +51 -0
  133. package/skills-library/specialists/api-architecture/microservices-architect.md +50 -0
  134. package/skills-library/specialists/api-architecture/websocket-engineer.md +48 -0
  135. package/skills-library/specialists/backend/django-expert.md +52 -0
  136. package/skills-library/specialists/backend/fastapi-expert.md +52 -0
  137. package/skills-library/specialists/backend/laravel-specialist.md +52 -0
  138. package/skills-library/specialists/backend/nestjs-expert.md +51 -0
  139. package/skills-library/specialists/backend/rails-expert.md +53 -0
  140. package/skills-library/specialists/backend/spring-boot-engineer.md +56 -0
  141. package/skills-library/specialists/data-ml/fine-tuning-expert.md +48 -0
  142. package/skills-library/specialists/data-ml/ml-pipeline.md +47 -0
  143. package/skills-library/specialists/data-ml/pandas-pro.md +47 -0
  144. package/skills-library/specialists/data-ml/rag-architect.md +51 -0
  145. package/skills-library/specialists/data-ml/spark-engineer.md +47 -0
  146. package/skills-library/specialists/frontend/angular-architect.md +52 -0
  147. package/skills-library/specialists/frontend/flutter-expert.md +51 -0
  148. package/skills-library/specialists/frontend/nextjs-developer.md +54 -0
  149. package/skills-library/specialists/frontend/react-native-expert.md +50 -0
  150. package/skills-library/specialists/frontend/vue-expert.md +51 -0
  151. package/skills-library/specialists/infrastructure/chaos-engineer.md +74 -0
  152. package/skills-library/specialists/infrastructure/cloud-architect.md +70 -0
  153. package/skills-library/specialists/infrastructure/database-optimizer.md +64 -0
  154. package/skills-library/specialists/infrastructure/devops-engineer.md +70 -0
  155. package/skills-library/specialists/infrastructure/kubernetes-specialist.md +52 -0
  156. package/skills-library/specialists/infrastructure/monitoring-expert.md +70 -0
  157. package/skills-library/specialists/infrastructure/sre-engineer.md +70 -0
  158. package/skills-library/specialists/infrastructure/terraform-engineer.md +51 -0
  159. package/skills-library/specialists/languages/cpp-pro.md +74 -0
  160. package/skills-library/specialists/languages/csharp-developer.md +69 -0
  161. package/skills-library/specialists/languages/dotnet-core-expert.md +54 -0
  162. package/skills-library/specialists/languages/golang-pro.md +51 -0
  163. package/skills-library/specialists/languages/java-architect.md +49 -0
  164. package/skills-library/specialists/languages/javascript-pro.md +68 -0
  165. package/skills-library/specialists/languages/kotlin-specialist.md +68 -0
  166. package/skills-library/specialists/languages/php-pro.md +49 -0
  167. package/skills-library/specialists/languages/python-pro.md +52 -0
  168. package/skills-library/specialists/languages/react-expert.md +51 -0
  169. package/skills-library/specialists/languages/rust-engineer.md +50 -0
  170. package/skills-library/specialists/languages/sql-pro.md +56 -0
  171. package/skills-library/specialists/languages/swift-expert.md +69 -0
  172. package/skills-library/specialists/languages/typescript-pro.md +51 -0
  173. package/skills-library/specialists/platform/atlassian-mcp.md +52 -0
  174. package/skills-library/specialists/platform/embedded-systems.md +53 -0
  175. package/skills-library/specialists/platform/game-developer.md +53 -0
  176. package/skills-library/specialists/platform/salesforce-developer.md +53 -0
  177. package/skills-library/specialists/platform/shopify-expert.md +49 -0
  178. package/skills-library/specialists/platform/wordpress-pro.md +49 -0
  179. package/skills-library/specialists/quality/code-documenter.md +51 -0
  180. package/skills-library/specialists/quality/code-reviewer.md +67 -0
  181. package/skills-library/specialists/quality/debugging-wizard.md +51 -0
  182. package/skills-library/specialists/quality/fullstack-guardian.md +51 -0
  183. package/skills-library/specialists/quality/legacy-modernizer.md +50 -0
  184. package/skills-library/specialists/quality/playwright-expert.md +65 -0
  185. package/skills-library/specialists/quality/spec-miner.md +56 -0
  186. package/skills-library/specialists/quality/test-master.md +65 -0
  187. package/skills-library/specialists/security/secure-code-guardian.md +55 -0
  188. package/skills-library/specialists/security/security-reviewer.md +53 -0
  189. package/skills-library/specialists/workflow/architecture-designer.md +53 -0
  190. package/skills-library/specialists/workflow/cli-developer.md +70 -0
  191. package/skills-library/specialists/workflow/feature-forge.md +65 -0
  192. package/skills-library/specialists/workflow/prompt-engineer.md +54 -0
  193. package/skills-library/specialists/workflow/the-fool.md +62 -0
  194. package/templates/ASSUMPTIONS.md +125 -0
  195. package/templates/BLOCKERS.md +73 -0
  196. package/templates/DECISION_LOG.md +116 -0
  197. package/templates/UAT.md +96 -0
  198. package/templates/blueprint.md +94 -0
  199. package/templates/brainstorm.md +185 -0
  200. package/templates/conscience.md +92 -0
  201. package/templates/fire-handoff.md +159 -0
  202. package/templates/metrics.md +67 -0
  203. package/templates/phase-prompt.md +142 -0
  204. package/templates/record.md +131 -0
  205. package/templates/review-report.md +117 -0
  206. package/templates/skills-index.md +157 -0
  207. package/templates/verification.md +149 -0
  208. package/templates/vision.md +79 -0
  209. package/validation-config.yml +793 -0
  210. package/version.json +7 -0
  211. package/workflows/execute-phase.md +732 -0
  212. package/workflows/handoff-session.md +678 -0
  213. package/workflows/new-project.md +578 -0
  214. package/workflows/plan-phase.md +592 -0
  215. package/workflows/verify-phase.md +874 -0
@@ -0,0 +1,1168 @@
1
+ ---
2
+ description: Start self-iterating loop until completion with circuit breaker, error classification, context engineering, and skills integration
3
+ argument-hint: "PROMPT [--max-iterations N] [--completion-promise TEXT]"
4
+ ---
5
+
6
+ # /fire-loop
7
+
8
+ > Self-iterating autonomous loop with quantitative convergence detection, approach rotation, and context-aware execution
9
+
10
+ ---
11
+
12
+ ## Purpose
13
+
14
+ Start a self-iterating loop that persists until task completion. Integrates Dominion Flow's full v3 intelligence stack:
15
+
16
+ - **Circuit Breaker** — Hard numerical thresholds that detect stalling, spinning, and degradation
17
+ - **Error Classification** — PROGRESS/STALLED/SPINNING/DEGRADED/BLOCKED state machine driving different responses
18
+ - **Context Engineering** — Recitation pattern keeps plan in attention window; .powerignore excludes noise
19
+ - **Decision-Time Guidance** — Skills library micro-instructions injected at error/decision points
20
+ - **Sabbath Rest** — Context rot detection with state persistence for clean resume
21
+
22
+ **Key difference from `/fire-loop`:** Power Loop is self-aware. It measures its own health, rotates approaches when stuck, and stops before wasting iterations on unsolvable problems.
23
+
24
+ ---
25
+
26
+ ## Arguments
27
+
28
+ ```yaml
29
+ arguments:
30
+ prompt:
31
+ required: true
32
+ type: string
33
+ description: "Task description with clear completion criteria"
34
+ example: '/fire-loop "Fix login bug. Tests must pass. Output DONE when fixed."'
35
+
36
+ options:
37
+ --max-iterations:
38
+ type: number
39
+ default: 50
40
+ description: "Safety limit — stop after N iterations"
41
+
42
+ --completion-promise:
43
+ type: string
44
+ default: "DONE"
45
+ description: "Exact text that signals successful completion"
46
+
47
+ --checkpoint-interval:
48
+ type: number
49
+ default: 5
50
+ description: "Save checkpoint every N iterations"
51
+
52
+ --apply-skills:
53
+ type: boolean
54
+ default: true
55
+ description: "Search and apply relevant skills from library"
56
+
57
+ --discover:
58
+ type: boolean
59
+ default: false
60
+ description: "Run /fire-discover at start to find relevant patterns"
61
+
62
+ --no-circuit-breaker:
63
+ type: boolean
64
+ default: false
65
+ description: "Disable circuit breaker (not recommended)"
66
+
67
+ --aggressive:
68
+ type: boolean
69
+ default: false
70
+ description: "Tighter thresholds: stall=2, spin=3, decline=40%"
71
+
72
+ --autonomous:
73
+ type: boolean
74
+ default: false
75
+ description: "Auto-route review gate verdicts without human checkpoints (used by /fire-autonomous)"
76
+ ```
77
+
78
+ ---
79
+
80
+ ## Process
81
+
82
+ ### Step 0.5: Path Verification Gate (v5.0 — MANDATORY)
83
+
84
+ Before creating any files or executing any work, verify working directory:
85
+
86
+ ```
87
+ expected_project = extract from CONSCIENCE.md or user context
88
+ actual_cwd = pwd
89
+
90
+ IF actual_cwd does NOT contain expected project path:
91
+ → HARD STOP: "Wrong directory. Expected {expected}, got {actual_cwd}."
92
+ → Do NOT create loop files in wrong project.
93
+
94
+ IF .planning/ directory does not exist:
95
+ → WARN: "No .planning/ directory. Is this the right project?"
96
+ → Ask user to confirm before proceeding.
97
+ ```
98
+
99
+ ### Step 1: Initialize Loop State
100
+
101
+ Create loop tracking file with v3 enhanced fields:
102
+
103
+ ```bash
104
+ mkdir -p .planning/loops
105
+ LOOP_ID=$(date +%Y%m%d-%H%M%S)
106
+ LOOP_FILE=".planning/loops/fire-loop-${LOOP_ID}.md"
107
+ ```
108
+
109
+ Write initial state:
110
+
111
+ ```markdown
112
+ ---
113
+ id: ${LOOP_ID}
114
+ status: active
115
+ prompt: |
116
+ [user's prompt]
117
+ completion_promise: [promise text]
118
+ max_iterations: [N]
119
+ current_iteration: 0
120
+ started: [timestamp]
121
+ last_checkpoint: null
122
+ skills_applied: []
123
+ context_warnings: 0
124
+
125
+ # v3 Circuit Breaker State
126
+ circuit_breaker:
127
+ state: HEALTHY
128
+ stall_counter: 0
129
+ error_hashes: {}
130
+ output_baseline: null
131
+ output_history: []
132
+ approaches_tried: []
133
+
134
+ # v3 Error Classification
135
+ health_state: PROGRESS
136
+ health_history: []
137
+ ---
138
+
139
+ ## Loop Progress
140
+
141
+ | Iter | Timestamp | Files Changed | Error Hash | Output Lines | Health | Action |
142
+ |------|-----------|--------------|------------|-------------|--------|--------|
143
+
144
+ ## Circuit Breaker State
145
+
146
+ | Iter | Stall Count | Spin Count | Output % | State |
147
+ |------|-------------|------------|----------|-------|
148
+
149
+ ## Approaches Tried
150
+
151
+ ## Checkpoints
152
+
153
+ ## Sabbath Rest Snapshots
154
+
155
+ ## Final Result
156
+ ```
157
+
158
+ ### Step 2: Context Engineering Setup
159
+
160
+ ```
161
+ 1. Load .powerignore if present in project root
162
+ 2. Establish context layout:
163
+ - STABLE: System prompt + project context + skills (loaded once)
164
+ - SEMI-STABLE: Plan context + DTG instructions
165
+ - DYNAMIC: Recitation block + iteration output
166
+ 3. Set recitation template for this task
167
+ ```
168
+
169
+ ### Step 3: Run /fire-discover (if --discover)
170
+
171
+ Before starting, discover relevant patterns:
172
+
173
+ ```
174
+ /fire-discover "[task keywords from prompt]"
175
+ ```
176
+
177
+ Cache discovered skills — don't re-search each iteration.
178
+
179
+ ### Step 4: Skills Library Search (if --apply-skills)
180
+
181
+ Search for relevant skills based on task keywords:
182
+
183
+ ```
184
+ Search skills library for patterns matching:
185
+ - Error patterns mentioned in prompt
186
+ - Technology/framework keywords
187
+ - Problem domain (auth, api, database, etc.)
188
+ ```
189
+
190
+ Load applicable skills into context (max 3 skills, micro-instruction format):
191
+
192
+ ```markdown
193
+ ## Skills Loaded (cached for session)
194
+
195
+ ### [Skill 1]: {name}
196
+ - Pattern: {key pattern}
197
+ - Pitfalls: {common pitfalls}
198
+
199
+ ### [Skill 2]: {name}
200
+ - Pattern: {key pattern}
201
+ - Pitfalls: {common pitfalls}
202
+ ```
203
+
204
+ ### Step 5: Update CONSCIENCE.md
205
+
206
+ Add loop tracking to project state:
207
+
208
+ ```markdown
209
+ ## Active Power Loop
210
+
211
+ - **ID:** ${LOOP_ID}
212
+ - **Started:** [timestamp]
213
+ - **Iteration:** 0 / [max]
214
+ - **Status:** Running
215
+ - **Promise:** "[completion_promise]"
216
+ - **Health:** PROGRESS
217
+ - **Circuit Breaker:** HEALTHY
218
+
219
+ To cancel: `/fire-loop-stop`
220
+ ```
221
+
222
+ ### Step 6: Display Start Banner
223
+
224
+ ```
225
+ +------------------------------------------------------------------------------+
226
+ | POWER LOOP v3 STARTED |
227
+ +------------------------------------------------------------------------------+
228
+ | |
229
+ | Loop ID: ${LOOP_ID} |
230
+ | Max Iterations: [N] |
231
+ | Completion Promise: "[promise]" |
232
+ | |
233
+ | Intelligence Stack: |
234
+ | Circuit Breaker: [ON | OFF] |
235
+ | Error Classification: ON |
236
+ | Context Engineering: ON |
237
+ | Decision-Time Guidance: [ON | OFF] |
238
+ | Sabbath Rest: ON |
239
+ | |
240
+ | Skills Applied: [count] |
241
+ | - [skill 1] |
242
+ | - [skill 2] |
243
+ | |
244
+ | Context Exclusions: [.powerignore loaded | none] |
245
+ | |
246
+ +------------------------------------------------------------------------------+
247
+ | ITERATION 1 |
248
+ +------------------------------------------------------------------------------+
249
+ ```
250
+
251
+ ---
252
+
253
+ ## ITERATION LOOP (Steps 6.5-11)
254
+
255
+ ### Step 6.5: Difficulty Classification (v7.0)
256
+
257
+ > **Research basis:** Difficulty-Aware Agent Orchestration (Sep 2025) — +11.21% accuracy at 64% cost
258
+ > by routing tasks through different pipeline depths based on complexity.
259
+
260
+ Classify current task before entering the iteration pipeline:
261
+
262
+ ```
263
+ SIMPLE (fast path — skip Steps 7.1, 8.5, 8.8):
264
+ - Single file change
265
+ - Known pattern (exact skill match found)
266
+ - Config/typo/rename tasks
267
+ - Estimated < 5 minutes
268
+
269
+ MODERATE (standard path — all steps active):
270
+ - 2-5 files affected
271
+ - Requires some investigation
272
+ - Partial skill match or unfamiliar combination
273
+
274
+ COMPLEX (enhanced path — all steps + extra validation):
275
+ - 6+ files affected or cross-cutting concern
276
+ - No skill match, unfamiliar framework
277
+ - Architecture or security implications
278
+ - Add: double-check step before commit, mandatory episodic injection
279
+
280
+ Store classification in recitation block: "Difficulty: {SIMPLE|MODERATE|COMPLEX}"
281
+
282
+ For SIMPLE tasks: skip Step 7.1 (episodic injection), Step 8.5 (directive check),
283
+ Step 8.8 (reward scoring). Go directly from Step 7 → Step 8 → Step 9.
284
+
285
+ ### Parallelizability Axis (v10.0)
286
+
287
+ > **Research basis (v10.0):** Google/MIT "Scaling Laws for Agent Systems" (Dec 2025) —
288
+ > multi-agent parallel execution improves parallelizable tasks by 80.9% but DEGRADES
289
+ > sequential reasoning by 39-70%. The difficulty axis alone is insufficient — a COMPLEX
290
+ > task that is inherently sequential gets WORSE with parallel agents.
291
+
292
+ After difficulty classification, add a second axis: PARALLEL vs SEQUENTIAL:
293
+
294
+ ```
295
+ PARALLEL (can split into independent sub-tasks):
296
+ Signals:
297
+ - Different files with no shared state
298
+ - Independent API endpoints
299
+ - UI components with no prop dependencies
300
+ - Test suites for different modules
301
+ → SWARM/SUBAGENT mode beneficial
302
+ → Agent count scales well
303
+
304
+ SEQUENTIAL (steps depend on previous results):
305
+ Signals:
306
+ - Migration chains (step N depends on step N-1)
307
+ - Auth flow (login → token → protected route)
308
+ - Data pipeline (extract → transform → load)
309
+ - Debugging (hypothesis → test → narrow → fix)
310
+ → SEQUENTIAL mode MANDATORY
311
+ → Multiple agents DEGRADE performance
312
+ → Single agent with full context is optimal
313
+
314
+ MIXED (some steps parallel, some sequential):
315
+ → Break into sequential phases, parallelize within each phase
316
+ → Example: "Build API + UI" = parallel, then "Wire API→UI" = sequential
317
+ ```
318
+
319
+ **Combined routing matrix:**
320
+
321
+ | Difficulty | Parallelizability | Mode | Agents |
322
+ |-----------|-------------------|------|--------|
323
+ | SIMPLE | any | SEQUENTIAL | 1 (Haiku) |
324
+ | MODERATE | PARALLEL | SUBAGENT | 2-3 |
325
+ | MODERATE | SEQUENTIAL | SEQUENTIAL | 1 |
326
+ | COMPLEX | PARALLEL | SWARM | 3-5 |
327
+ | COMPLEX | SEQUENTIAL | SEQUENTIAL | 1 (Opus) |
328
+ | COMPLEX | MIXED | HYBRID | sequential phases, parallel within |
329
+
330
+ Store in recitation: "Difficulty: {X} | Parallelizability: {PARALLEL|SEQUENTIAL|MIXED}"
331
+ ```
332
+
333
+ ### Agent Profile Selection (ATLAS v9.1)
334
+
335
+ > **Research basis:** ATLAS (2025) — Adaptive Task-Level Agent Selection.
336
+ > Dynamically choosing agent capability per task improves efficiency without sacrificing quality.
337
+
338
+ After classifying difficulty, select the agent profile:
339
+
340
+ ```
341
+ SIMPLE → agent_profile: "lightweight"
342
+ - Skip episodic injection, behavioral directives, reward scoring
343
+ - Single agent, sequential execution
344
+ - No specialist context needed
345
+
346
+ MODERATE → agent_profile: "standard"
347
+ - All steps active
348
+ - fire-executor with full skill context
349
+ - SUBAGENT or SEQUENTIAL based on file overlap
350
+
351
+ COMPLEX → agent_profile: "specialist"
352
+ - All steps + mandatory double-check before commit
353
+ - Select specialist based on file patterns:
354
+ * 60%+ backend files (routes/, models/, middleware/) → backend-specialist
355
+ * 60%+ frontend files (components/, pages/, hooks/) → frontend-specialist
356
+ * 60%+ test files (*.test.*, *.spec.*) → test-specialist
357
+ * Mixed or infrastructure files → full fire-executor
358
+ - SWARM mode preferred for cross-cutting changes
359
+ - Extended thinking enabled for architecture decisions
360
+ ```
361
+
362
+ **Specialist context injection (COMPLEX only):**
363
+
364
+ When agent_profile is "specialist", prepend to executor prompt:
365
+ ```
366
+ <specialist_focus>
367
+ You are operating as a {domain}-specialist. Prioritize:
368
+ - backend-specialist: API contracts, DB queries, middleware chain, error handling
369
+ - frontend-specialist: Component composition, state management, UX flows, accessibility
370
+ - test-specialist: Coverage gaps, edge cases, integration boundaries, mock accuracy
371
+ </specialist_focus>
372
+ ```
373
+
374
+ Store in recitation block: "Agent Profile: {lightweight|standard|specialist}"
375
+
376
+ ---
377
+
378
+ ### Step 7: Compose Recitation Block
379
+
380
+ Before each iteration, recite current state (max 30 lines):
381
+
382
+ ```markdown
383
+ ---
384
+ DOMINION FLOW RECITATION — Iteration {N} of {MAX}
385
+ ---
386
+
387
+ ## Task
388
+ {original prompt — unchanged}
389
+
390
+ ## Progress
391
+ - Iterations completed: {N-1}
392
+ - Files changed total: {count}
393
+ - Last action: {what happened last iteration}
394
+ - Current approach: {active approach description}
395
+
396
+ ## Health
397
+ - State: {PROGRESS | STALLED | SPINNING | DEGRADED | BLOCKED}
398
+ - Circuit Breaker: {HEALTHY | WARNING | TRIPPED}
399
+ - Stall counter: {N} / {threshold}
400
+ - Spin counter: {N} / {threshold}
401
+ - Output trend: {stable | declining N%}
402
+ - Confidence: {HIGH >80 | MEDIUM 50-80 | LOW <50}
403
+
404
+ ## Approaches Tried
405
+ {numbered list of approaches, most recent first}
406
+
407
+ ## Key Finding
408
+ {most important thing learned so far}
409
+
410
+ ## Task Checklist (v10.0)
411
+ <!-- Read todos.md if present in .planning/ or project root -->
412
+ <!-- Surface unchecked items relevant to current iteration -->
413
+ {IF .planning/todos.md exists:}
414
+ - [ ] {relevant unchecked item 1}
415
+ - [ ] {relevant unchecked item 2}
416
+ {ELSE: omit this section}
417
+
418
+ ## Confidence Check (v5.0)
419
+ - Score: {0-100} — {HIGH/MEDIUM/LOW}
420
+ - Signals: {what raised or lowered confidence}
421
+ - Action: {proceed / extra-validation / escalate}
422
+ ---
423
+ ```
424
+
425
+ **Confidence Gate (v5.0):** Before executing, estimate confidence for this iteration:
426
+
427
+ ```
428
+ confidence = 50 (baseline)
429
+ + skill_match? +20 (found matching skill in library)
430
+ + reflection_match? +15 (found matching reflection)
431
+ + tests_available? +25 (can verify changes)
432
+ + familiar_tech? +15 (worked with this before)
433
+ - unfamiliar? -20 (new framework/library)
434
+ - no_tests? -15 (can't verify)
435
+ - ambiguous? -20 (unclear what to do)
436
+
437
+ IF confidence < 50:
438
+ → Search reflections and skills before proceeding
439
+ → If still LOW: ask user for guidance
440
+ → Create checkpoint before attempting
441
+ ```
442
+
443
+ **Confidence Propagation (v7.0 — AUQ):**
444
+
445
+ > **Research basis:** AUQ (Jan 2026) — System 1/System 2 uncertainty split; AgentPRM
446
+ > (Feb 2025) — process reward hacking detection. Metacognition limits paper (Sep 2025)
447
+ > warns: don't trust self-reported confidence alone.
448
+
449
+ ```
450
+ ## System 1 (UAM — Uncertainty-Aware Memory)
451
+ # Propagate uncertainty from previous iterations:
452
+ propagated_uncertainty = 0
453
+ FOR each prev_iteration in last 3 iterations:
454
+ IF prev_iteration.confidence < 50:
455
+ propagated_uncertainty += (50 - prev_iteration.confidence) * 0.3
456
+ # Uncertainty decays: recent iterations weigh more
457
+
458
+ adjusted_confidence = raw_confidence - propagated_uncertainty
459
+ # A string of low-confidence iterations compounds the penalty
460
+
461
+ ## System 2 (UAR — Triggered Deep Reflection)
462
+ # Only fires when System 1 flags a concern:
463
+ IF adjusted_confidence < 40 OR propagated_uncertainty > 30:
464
+ → Trigger deep reflection: review last 3 iterations' outcomes
465
+ → Search vector memory for similar situations
466
+ → If reflection finds pattern: adjust approach
467
+ → If no pattern: escalate to user
468
+
469
+ ## Confidence-Outcome Divergence Detector (v7.0 — AgentPRM)
470
+ # Process reward hacking: confidence rises while outcomes degrade
471
+ IF iteration >= 3:
472
+ confidence_trend = linear_slope(last 3 confidence scores)
473
+ reward_trend = linear_slope(last 3 turn_rewards from Step 8.8)
474
+
475
+ IF confidence_trend > 0 AND reward_trend < 0:
476
+ → FLAG: "Confidence rising but outcomes declining — possible reward hacking"
477
+ → Trigger early circuit breaker WARNING
478
+ → Force external verification (run tests, check git diff)
479
+ ```
480
+
481
+ ### Step 7.1: Per-Turn Episodic Auto-Injection (v6.0)
482
+
483
+ > **Research basis:** CoALA (Berkeley 2024) — Cognitive architecture requires automatic
484
+ > episodic injection every decision cycle, not just on stall or low confidence.
485
+ > "Every action cycle should: retrieve relevant episodic memory → inject into working
486
+ > context → decide → store outcome."
487
+
488
+ Before each task execution, automatically recall relevant episodic memory:
489
+
490
+ ```
491
+ # 1. Extract keywords from current task
492
+ task_keywords = extract_keywords(current_task_description)
493
+
494
+ # 2. Search vector memory (use two-phase retrieval from Breath 2)
495
+ cd ~/.claude/memory
496
+ results = npm run search -- "{task_keywords}" --limit 3 --two-phase
497
+
498
+ # 3. Inject if relevant results found
499
+ IF results exist AND top_result.score > 0.7:
500
+ Inject into working context:
501
+
502
+ <episodic_context>
503
+ <!-- Auto-injected by CoALA episodic recall (v6.0 Step 7.1) -->
504
+ <!-- These are past experiences relevant to this task -->
505
+
506
+ {For each result with score > 0.7:}
507
+ **[{result.sourceType}] {result.title}** (score: {result.score})
508
+ {result.text (first 300 chars)}
509
+ Source: {result.sourceFile} | Date: {result.date}
510
+
511
+ </episodic_context>
512
+
513
+ ELSE:
514
+ # No relevant memories — proceed without injection
515
+ # This is normal for novel tasks
516
+ ```
517
+
518
+ **Cost control:** This adds ~500 tokens per iteration when memories are found.
519
+ Skip injection if iteration count > 5 (agent should be deep enough by then).
520
+
521
+ **Graceful Qdrant Degradation (v9.0):**
522
+
523
+ If Qdrant is unreachable (connection refused on port 6335), log WARNING and fall back to file-based memory search: grep across `~/.claude/warrior-handoffs/` and `~/.claude/reflections/` for keyword matches. This is slower but functional. Do NOT silently skip memory retrieval. The fallback ensures that even without the vector database, the agent still benefits from past session context. Log the degradation:
524
+
525
+ ```
526
+ WARNING: Qdrant unreachable on port 6335. Falling back to file-based memory search.
527
+ Searched: ~/.claude/warrior-handoffs/ ({N} files)
528
+ Searched: ~/.claude/reflections/ ({N} files)
529
+ Results: {N} keyword matches found
530
+ ```
531
+
532
+ ---
533
+
534
+ ### Step 8: Execute Task
535
+
536
+ Work on the task described in the prompt.
537
+
538
+ **CRITICAL RULES:**
539
+
540
+ 1. **Completion Promise Integrity:** Only output the completion promise when the task is GENUINELY complete. Do not fake completion to escape the loop.
541
+
542
+ 2. **Check Previous Work:** At each iteration, check:
543
+ - Files modified in previous iterations
544
+ - Git history for recent changes
545
+ - Test results from previous runs
546
+ - Loop file for iteration history
547
+
548
+ 3. **Incremental Progress:** Each iteration should make measurable progress. If stuck:
549
+ - Check recitation block for approaches already tried
550
+ - Run Decision-Time Guidance search for the current error
551
+ - Document what was attempted
552
+ - Try a fundamentally different approach
553
+
554
+ 4. **Context Hygiene:**
555
+ - Don't re-read files already in context
556
+ - Use .powerignore exclusions
557
+ - Summarize large file reads (extract relevant section only)
558
+ - Keep iteration output focused and concise
559
+
560
+ ### Step 8.5: Behavioral Directive Check + HAC Enforcement (v6.0 + v7.0)
561
+
562
+ > **Research basis:** CoALA procedural memory + SICA self-modifying agent (ICLR 2025)
563
+ > v7.0 addition: MPR (Sep 2025) — Predicate-form rules with Hard Admissibility Checks
564
+
565
+ **(Skip if difficulty = SIMPLE — see Step 6.5)**
566
+
567
+ **Part A — HAC Pre-Execution Check (v7.0):**
568
+
569
+ ```
570
+ BEFORE executing the next action, scan behavioral-directives.md:
571
+
572
+ For each Active Rule where IF condition matches current context:
573
+ IF rule is positive (THEN) → inject action into working instructions
574
+ IF rule is anti-pattern (DONT) → inject explicit warning
575
+
576
+ HAC (Hard Admissibility Check):
577
+ IF an Active Rule OR Anti-Pattern with confidence 5/5
578
+ explicitly prohibits the planned action:
579
+ → BLOCK execution
580
+ → Display: "HAC BLOCK: {rule/anti-pattern statement}"
581
+ → Require explicit user override to proceed
582
+ ```
583
+
584
+ **Part B — Directive Discovery (v6.0, unchanged):**
585
+
586
+ ```
587
+ IF task resolution revealed a reusable pattern or anti-pattern:
588
+ 1. Read references/behavioral-directives.md
589
+ 2. Check: does similar directive already exist?
590
+ ├── In Active Rules → Skip (already known)
591
+ ├── In Proposed Rules → Increment confidence
592
+ │ └── If confidence reaches 3/5 → Promote to Active Rules
593
+ └── Not found → Add to Proposed Rules with confidence 1/5
594
+
595
+ New rules use predicate format (v7.0):
596
+ ### Rule {N}
597
+ - **IF:** {condition}
598
+ - **THEN:** {action} (or **DONT:** {anti-action})
599
+ - **BECAUSE:** {justification}
600
+ - **Source:** {current session} | **Confidence:** 1/5 | **First proposed:** {date}
601
+
602
+ SKIP this step if:
603
+ - Task was trivial (single-line fix)
604
+ - No novel insight emerged
605
+ - The insight is project-specific, not reusable
606
+ ```
607
+
608
+ ### Step 8.7: Iteration Checkpoint (v6.0 — GCC)
609
+
610
+ > **Research basis:** GCC (Jul 2025) — Git-style checkpoints enable structured rollback.
611
+
612
+ After each iteration that made file changes:
613
+
614
+ ```
615
+ IF git_diff_stat(HEAD) shows changes:
616
+ git add {files changed this iteration}
617
+ git commit -m "loop-checkpoint: iteration {i} — {task summary (50 chars max)}"
618
+ checkpoint = git rev-parse HEAD
619
+
620
+ # Record in dominion-flow.local.md
621
+ Append:
622
+ checkpoint_hash: {checkpoint:7}
623
+ iteration: {i}
624
+ files_changed: {count}
625
+ task: "{task summary}"
626
+
627
+ # On resume: can restore to any checkpoint
628
+ ```
629
+
630
+ **Skip checkpoint if:** No files changed this iteration (research-only or read-only work).
631
+
632
+ ### Step 8.8: Turn-Level Reward Scoring (v6.0 — AgentPRM)
633
+
634
+ > **Research basis:** AgentPRM (Feb 2025) — Process reward models that score each turn
635
+ > in a multi-turn interaction enable fine-grained learning signals. Binary success/fail
636
+ > is like grading pass/fail — you can't improve. Per-turn rewards enable identifying
637
+ > which task types the agent handles well vs poorly.
638
+
639
+ After each iteration, compute turn-level reward:
640
+
641
+ ```
642
+ # Score this iteration (each 0-5)
643
+ task_completion = IF task_complete THEN 5 ELSE (progress_percentage / 20)
644
+ approach_quality = 5 - min(4, retries_needed) # 5=first try, 1=4+ retries
645
+ context_efficiency = 5 - min(4, floor(tokens_used / 20000)) # 5=<20k, 1=>80k tokens
646
+
647
+ # Weighted turn reward
648
+ turn_reward = (0.5 * task_completion) + (0.3 * approach_quality) + (0.2 * context_efficiency)
649
+
650
+ # Store in dominion-flow.local.md
651
+ Append to iteration_rewards:
652
+ - iteration: {i}
653
+ reward: {turn_reward, 1 decimal}
654
+ task: "{task description (50 chars)}"
655
+ completion: {task_completion}
656
+ quality: {approach_quality}
657
+ efficiency: {context_efficiency}
658
+ ```
659
+
660
+ **Use accumulated rewards to:**
661
+ 1. Identify which task types score low → pre-load relevant skills next time
662
+ 2. Detect declining reward trend → trigger approach rotation earlier
663
+ 3. Compute session average reward → include in WARRIOR handoff for trend tracking
664
+
665
+ ---
666
+
667
+ ### Step 9: Measure and Classify
668
+
669
+ After each iteration, collect measurements:
670
+
671
+ ```
672
+ measurements = {
673
+ files_changed: git diff --stat HEAD~1 | count,
674
+ error_output: last error message if any,
675
+ error_hash: hash(normalize(error_output)),
676
+ output_lines: count_lines(iteration_output),
677
+ test_results: {passed: N, failed: N, total: N}
678
+ }
679
+ ```
680
+
681
+ **Error Classification** (see `@references/error-classification.md`):
682
+
683
+ ```
684
+ health = classify_health(measurements)
685
+
686
+ SWITCH health:
687
+ PROGRESS:
688
+ → Continue normally
689
+ → Record in loop file
690
+
691
+ STALLED:
692
+ → Inject urgency: "No file changes in {N} iterations. Make a change."
693
+ → Search skills library for alternative approaches
694
+ → Search reflections: /fire-remember "{current error/goal}" --type reflection
695
+ → If 3+ iterations stalled → escalate check
696
+ → If 3+ iterations stalled → Auto-generate reflection (v5.0):
697
+ Save to ~/.claude/reflections/{date}_loop-stalled-{task-slug}.md
698
+ trigger: "stalled-loop"
699
+ Include: what was attempted, measurements, why no progress
700
+
701
+ SPINNING:
702
+ → FORCE approach rotation
703
+ → Display: "Error seen {N} times. Previous approaches: {list}. Try different."
704
+ → Inject anti-patterns: "DO NOT: {failed approaches}"
705
+ → Auto-generate reflection (v5.0):
706
+ Save to ~/.claude/reflections/{date}_loop-spinning-{task-slug}.md
707
+ trigger: "approach-rotation"
708
+ Include: each failed approach with error hash, what was rotated to
709
+
710
+ DEGRADED:
711
+ → Trigger Sabbath Rest warning
712
+ → Save state for resume
713
+
714
+ BLOCKED:
715
+ → Stop immediately
716
+ → Create blocker in BLOCKERS.md
717
+ → Save state, display recovery options
718
+ ```
719
+
720
+ **Semantic Progress Metric (v9.0):**
721
+
722
+ Augment output volume with semantic progress signals to reduce false positives from verbose error output:
723
+
724
+ ```
725
+ semantic_progress = {
726
+ checklist_completion: count completed tasks / total tasks,
727
+ test_pass_delta: (tests_passing_now - tests_passing_last_iter),
728
+ git_diff_ratio: actual_diff_size / expected_diff_size,
729
+ meaningful_change: any new file created OR test status changed OR API endpoint added
730
+ }
731
+
732
+ # Output volume alone is noisy — verbose errors have high volume but zero progress.
733
+ # Combine: effective_progress = 0.4 * output_metric + 0.6 * semantic_progress
734
+ # Use effective_progress instead of raw output volume for circuit breaker thresholds.
735
+ ```
736
+
737
+ **Circuit Breaker Check** (see `@references/circuit-breaker.md`):
738
+
739
+ ```
740
+ cb_state = circuit_breaker.check(
741
+ stall_counter,
742
+ error_hash_counts,
743
+ output_volume_vs_baseline,
744
+ semantic_progress # v9.0: augmented signal
745
+ )
746
+
747
+ IF cb_state == WARNING:
748
+ → Display warning banner
749
+ → Apply approach rotation
750
+ → Continue with new approach
751
+
752
+ IF cb_state == TRIPPED:
753
+ → Display break banner
754
+ → Save complete state
755
+ → Trigger Sabbath Rest or stop
756
+ ```
757
+
758
+ ### Step 10: Update Loop File
759
+
760
+ Record iteration in tracking table:
761
+
762
+ ```markdown
763
+ | {N} | {timestamp} | {files_changed} | {error_hash} | {output_lines} | {health} | {action_taken} |
764
+ ```
765
+
766
+ Update circuit breaker state table:
767
+
768
+ ```markdown
769
+ | {N} | {stall_count} | {spin_count} | {output_pct}% | {cb_state} |
770
+ ```
771
+
772
+ ### Step 11: Checkpoint (if interval reached)
773
+
774
+ If iteration % checkpoint_interval == 0:
775
+
776
+ ```
777
+ 1. Write detailed checkpoint to loop file
778
+ 2. Update CONSCIENCE.md with current progress
779
+ 3. Commit checkpoint: git commit -m "checkpoint: fire-loop iteration {N}"
780
+ 4. Update active-loop.json with current counters
781
+ ```
782
+
783
+ ### Step 12: Continuation Decision
784
+
785
+ ```
786
+ IF completion_promise found in output:
787
+ → COMPLETE: Go to Step 12.5 (review gate)
788
+
789
+ IF iteration >= max_iterations:
790
+ → MAX REACHED: Go to Step 13
791
+
792
+ IF circuit_breaker == TRIPPED:
793
+ → CIRCUIT BREAK: Save state, go to Step 13
794
+
795
+ IF health == BLOCKED:
796
+ → BLOCKED: Save state, go to Step 13
797
+
798
+ IF health == DEGRADED AND output_decline >= 70%:
799
+ → SABBATH REST: Save state, go to Step 13
800
+
801
+ ELSE:
802
+ → INCREMENT iteration
803
+ → GO TO Step 7 (compose new recitation block)
804
+ ```
805
+
806
+ ### Step 12.5: Post-Loop Review Gate (v8.0)
807
+
808
+ When loop claims completion, run shallow review before presenting to human.
809
+
810
+ **Autonomous Mode Routing (v9.0):**
811
+
812
+ ```
813
+ IF --autonomous flag is set:
814
+
815
+ IF review.verdict == "BLOCK":
816
+ Log to autonomous-log: "Review gate: BLOCK (auto-routing to fix iteration)"
817
+ → Increment iteration, back to Step 7 (no display)
818
+
819
+ IF review.verdict == "APPROVE WITH FIXES":
820
+ Log to autonomous-log: "Review gate: APPROVE WITH FIXES (auto-proceeding)"
821
+ → Proceed to Step 13 (no display)
822
+
823
+ IF review.verdict == "APPROVE":
824
+ → Proceed to Step 13
825
+
826
+ // Non-autonomous mode: fall through to standard display below
827
+ ```
828
+
829
+ **Standard (non-autonomous) behavior:**
830
+
831
+ ```
832
+ IF completion_promise found AND files_changed > 0:
833
+
834
+ files_changed = git diff --name-only {first_checkpoint}..HEAD
835
+
836
+ Task(subagent_type="fire-reviewer", prompt="""
837
+ Loop: {LOOP_ID}
838
+ Task: {original prompt}
839
+ Review Depth: shallow (5 personas: Simplicity + Security + Perf + Test + Pattern)
840
+ Files: {files_changed}
841
+ <simplicity_mandate>STRICT</simplicity_mandate>
842
+ Output to: .planning/loops/review-{LOOP_ID}.md
843
+ """)
844
+
845
+ IF review.verdict == "BLOCK":
846
+ Display:
847
+ "+--------------------------------------------------------------+"
848
+ "| REVIEW GATE — BLOCK |"
849
+ "+--------------------------------------------------------------+"
850
+ "| |"
851
+ "| Loop completed task but review found critical issues: |"
852
+ "| {list of CRITICAL/HIGH findings} |"
853
+ "| |"
854
+ "| Loop continues to fix review findings. |"
855
+ "| Incrementing iteration, back to Step 7. |"
856
+ "+--------------------------------------------------------------+"
857
+ → Do NOT declare complete. Increment iteration, back to Step 7.
858
+ → Inject review findings into recitation block as "must fix" items.
859
+
860
+ ELIF review.verdict == "APPROVE WITH FIXES":
861
+ Display:
862
+ "+--------------------------------------------------------------+"
863
+ "| REVIEW GATE — APPROVE WITH NOTES |"
864
+ "+--------------------------------------------------------------+"
865
+ "| |"
866
+ "| {N} non-critical findings noted in review. |"
867
+ "| Proceeding to completion. |"
868
+ "+--------------------------------------------------------------+"
869
+ → Proceed to Step 13 (completion) with findings in banner.
870
+
871
+ ELSE:
872
+ → Clean pass. Proceed to Step 13.
873
+
874
+ ELSE IF files_changed == 0:
875
+ → No files changed, skip review. Proceed to Step 13.
876
+ ```
877
+
878
+ This means the loop literally cannot declare "DONE" if the reviewer finds
879
+ critical issues or accumulated over-engineering. It must fix them first.
880
+
881
+ **VERSION PERFORMANCE TRACKING:**
882
+
883
+ ```
884
+ After review gate verdict:
885
+ Record to .planning/version-performance.md:
886
+ | {date} | v8.0 | loop-gate | {verdict} | {overridden?} | pending | Loop {LOOP_ID} |
887
+
888
+ If loop was forced past a BLOCK (user said "FORCE CONTINUE"):
889
+ override = yes → contributes to degradation signal tracking
890
+ See: references/behavioral-directives.md § Version Performance Registry
891
+ ```
892
+
893
+ ---
894
+
895
+ ## SABBATH REST — Context Rot Recovery
896
+
897
+ ### Warning Triggers
898
+
899
+ 1. **Output decline ≥ 50%** from baseline (first 3 iterations average)
900
+ 2. **Repetitive behavior** — same action 3+ times without progress
901
+ 3. **Instruction amnesia** — re-asking questions already answered
902
+ 4. **Iteration count ≥ 15** — mandatory health check
903
+ 5. **Circuit Breaker WARNING** on output_decline threshold
904
+
905
+ ### Sabbath Rest Snapshot
906
+
907
+ When warning triggers, automatically save:
908
+
909
+ ```markdown
910
+ ## .planning/loops/sabbath-${LOOP_ID}-iter${N}.md
911
+
912
+ ---
913
+ loop_id: ${LOOP_ID}
914
+ iteration: [N]
915
+ timestamp: [ISO]
916
+ reason: [context_rot | circuit_breaker | manual]
917
+ health_state: [current state]
918
+ circuit_breaker_state: [current CB state]
919
+ ---
920
+
921
+ ## State at Sabbath Rest
922
+
923
+ ### Progress Summary
924
+ - Iterations completed: [N]
925
+ - Last successful action: [description]
926
+ - Current blocker: [if any]
927
+ - Health trajectory: [improving | stable | declining]
928
+
929
+ ### Circuit Breaker Readings
930
+ - Stall counter: [N] / [threshold]
931
+ - Spin counter: [N] / [threshold]
932
+ - Output decline: [N]%
933
+
934
+ ### Files Modified This Session
935
+ - [file]: [change summary]
936
+
937
+ ### Approaches Tried (CRITICAL — don't repeat these)
938
+ 1. [approach]: [result]
939
+ 2. [approach]: [result]
940
+ 3. [approach]: [result]
941
+
942
+ ### Error History
943
+ - [error hash]: seen [N] times
944
+ - [error hash]: seen [N] times
945
+
946
+ ### Next Steps (for resumed session)
947
+ 1. [immediate next action — must be DIFFERENT from tried approaches]
948
+ 2. [follow-up action]
949
+
950
+ ### Skills Applied
951
+ - [skill]: [how it helped]
952
+
953
+ ### Key Context to Restore
954
+ [Critical information the next session needs to know]
955
+
956
+ ### Preserved Stop Signals (v6.0 — JetBrains Compaction Safety)
957
+ <!-- NEVER summarize these — they must survive compaction verbatim -->
958
+ - ERRORS: [exact error messages in code blocks]
959
+ - BLOCKED: [blocking reason if any]
960
+ - FAILED ATTEMPTS: [count] — [list of approaches tried]
961
+ - CIRCUIT BREAKER: [current state]
962
+ - TRIED AND FAILED: [approach 1: result], [approach 2: result]
963
+ ```
964
+
965
+ **Compaction Protocol (v6.0):**
966
+
967
+ > **Research basis:** JetBrains "Cutting Through the Noise" (Dec 2025) — LLM summarization hides stop signals, extending runs ~15% past useful points.
968
+
969
+ ```
970
+ WHEN context approaches limit and compaction triggers:
971
+
972
+ BEFORE compaction:
973
+ 1. Extract from current context:
974
+ - All error messages verbatim (in code blocks)
975
+ - All BLOCKED/STUCK indicators
976
+ - Failed attempt count and approach list
977
+ - Circuit breaker state
978
+ - Explicit "should stop" signals
979
+ 2. Write to Sabbath Rest snapshot under "Preserved Stop Signals"
980
+
981
+ AFTER compaction:
982
+ 3. Verify preserved signals exist in compacted context
983
+ 4. If signals were lost → Re-inject preservation block
984
+ 5. Preservation block goes AFTER summary, not inside it
985
+
986
+ RULE: The "Tried and Failed" list is the most critical signal.
987
+ Without it, the resumed agent will retry the same failed approaches.
988
+ ```
989
+
990
+ ### Sabbath Rest Display
991
+
992
+ ```
993
+ +------------------------------------------------------------------------------+
994
+ | SABBATH REST — CONTEXT REFRESH NEEDED |
995
+ +------------------------------------------------------------------------------+
996
+ | |
997
+ | Context health declining at iteration [N]. |
998
+ | |
999
+ | Health: [DEGRADED] |
1000
+ | Circuit Breaker: [WARNING / TRIPPED] |
1001
+ | Output Decline: [N]% |
1002
+ | |
1003
+ | Progress saved to: |
1004
+ | Loop file: .planning/loops/fire-loop-${LOOP_ID}.md |
1005
+ | Sabbath: .planning/loops/sabbath-${LOOP_ID}-iter${N}.md |
1006
+ | |
1007
+ | TO CONTINUE (fresh context): |
1008
+ | 1. Run /clear or start new session |
1009
+ | 2. Run /fire-loop-resume ${LOOP_ID} |
1010
+ | |
1011
+ | Or force continue (NOT recommended): |
1012
+ | Reply "FORCE CONTINUE" |
1013
+ | |
1014
+ +------------------------------------------------------------------------------+
1015
+ ```
1016
+
1017
+ ---
1018
+
1019
+ ## Step 13: Completion
1020
+
1021
+ When loop ends, update loop file with final result:
1022
+
1023
+ ```markdown
1024
+ ## Final Result
1025
+
1026
+ - **Status:** [completed | max_iterations | circuit_break | blocked | sabbath_rest]
1027
+ - **Total Iterations:** [N]
1028
+ - **Duration:** [time]
1029
+ - **Completion Promise Found:** [yes/no]
1030
+
1031
+ ### Health Summary
1032
+ - Time in PROGRESS: [N] iterations
1033
+ - Time in STALLED: [N] iterations
1034
+ - Time in SPINNING: [N] iterations
1035
+ - Sabbath Rest Warnings: [count]
1036
+ - Circuit Breaker Trips: [count]
1037
+ - Approach Rotations: [count]
1038
+
1039
+ ### Approaches Tried
1040
+ 1. [approach]: [outcome]
1041
+ 2. [approach]: [outcome]
1042
+
1043
+ ### Files Changed
1044
+ - [file list with changes]
1045
+
1046
+ ### Patterns Discovered
1047
+ [New patterns learned — consider /fire-add-new-skill]
1048
+
1049
+ ### Lessons Learned
1050
+ [What worked, what didn't, what to do differently next time]
1051
+ ```
1052
+
1053
+ Display completion banner:
1054
+
1055
+ ```
1056
+ +------------------------------------------------------------------------------+
1057
+ | POWER LOOP COMPLETE |
1058
+ +------------------------------------------------------------------------------+
1059
+ | |
1060
+ | Loop ID: ${LOOP_ID} |
1061
+ | Status: [Completed | Max Iterations | Circuit Break | Blocked] |
1062
+ | Iterations: [N] / [MAX] |
1063
+ | Duration: [time] |
1064
+ | |
1065
+ | Health Profile: |
1066
+ | PROGRESS: [N] iters | STALLED: [N] | SPINNING: [N] |
1067
+ | Approach Rotations: [N] |
1068
+ | Circuit Breaker Trips: [N] |
1069
+ | |
1070
+ | Files Changed: [count] |
1071
+ | Skills Applied: [count] |
1072
+ | |
1073
+ | New patterns discovered? Run: |
1074
+ | /fire-add-new-skill |
1075
+ | |
1076
+ +------------------------------------------------------------------------------+
1077
+ ```
1078
+
1079
+ ---
1080
+
1081
+ ## Examples
1082
+
1083
+ ### Debug Until Tests Pass
1084
+
1085
+ ```bash
1086
+ /fire-loop "Fix the authentication bug in src/auth/login.ts. Run 'npm test' after each change. Output DONE when all tests pass." --max-iterations 30
1087
+ ```
1088
+
1089
+ ### With Pattern Discovery
1090
+
1091
+ ```bash
1092
+ /fire-loop "Implement pagination for /api/users endpoint. Follow existing patterns. Tests must pass. Output COMPLETE when done." --discover --completion-promise "COMPLETE"
1093
+ ```
1094
+
1095
+ ### Aggressive Mode (tighter thresholds)
1096
+
1097
+ ```bash
1098
+ /fire-loop "Fix CSS layout bug on mobile. Output DONE when responsive." --aggressive --max-iterations 20
1099
+ ```
1100
+
1101
+ ### Without Circuit Breaker (manual control)
1102
+
1103
+ ```bash
1104
+ /fire-loop "Exploratory refactoring of auth module. Output DONE when clean." --no-circuit-breaker --max-iterations 40
1105
+ ```
1106
+
1107
+ ---
1108
+
1109
+ ## Best Practices
1110
+
1111
+ ### 1. Clear Completion Criteria
1112
+
1113
+ ```markdown
1114
+ Bad: "Fix the bug"
1115
+ Good: "Fix the login bug. Tests in auth.test.ts must pass. Output FIXED."
1116
+ ```
1117
+
1118
+ ### 2. Use --discover for Unfamiliar Tasks
1119
+
1120
+ ```bash
1121
+ /fire-loop "..." --discover
1122
+ ```
1123
+
1124
+ ### 3. Honor Circuit Breaker Warnings
1125
+
1126
+ When the circuit breaker fires, it's telling you the current approach isn't working. Forcing through wastes iterations and degrades context.
1127
+
1128
+ ### 4. Trust Approach Rotation
1129
+
1130
+ When SPINNING is detected, the system forces a different approach. Trust this — repeating the same failed approach will never produce a different result.
1131
+
1132
+ ### 5. Sabbath Rest Is a Feature, Not a Failure
1133
+
1134
+ Taking a fresh context restart after 15-20 iterations is normal and healthy. The state is preserved — you lose nothing.
1135
+
1136
+ ---
1137
+
1138
+ ## Success Criteria
1139
+
1140
+ - [ ] Loop state file created with v3 fields
1141
+ - [ ] Context engineering setup (recitation template, .powerignore)
1142
+ - [ ] Skills library searched and cached
1143
+ - [ ] CONSCIENCE.md updated with active loop
1144
+ - [ ] Each iteration measured (files, errors, output)
1145
+ - [ ] Error classification applied each iteration
1146
+ - [ ] Circuit breaker monitoring active
1147
+ - [ ] Approach rotation applied when SPINNING
1148
+ - [ ] Recitation block composed each iteration
1149
+ - [ ] Checkpoints saved at interval
1150
+ - [ ] Sabbath Rest triggered when DEGRADED
1151
+ - [ ] Completion promise respected (no false escapes)
1152
+ - [ ] Post-loop review gate applied before declaring complete (v8.0)
1153
+ - [ ] Final summary with health profile written
1154
+
1155
+ ---
1156
+
1157
+ ## References
1158
+
1159
+ - **Circuit Breaker:** `@references/circuit-breaker.md` — quantitative thresholds
1160
+ - **Error Classification:** `@references/error-classification.md` — health state machine
1161
+ - **Context Engineering:** `@references/context-engineering.md` — recitation + cache + exclusion
1162
+ - **Decision-Time Guidance:** `@references/decision-time-guidance.md` — skills injection
1163
+ - **Original:** Ralph Loop by Geoffrey Huntley (https://ghuntley.com/ralph/)
1164
+ - **Related:** `/fire-loop-stop` — Cancel active loop
1165
+ - **Related:** `/fire-loop-resume` — Resume from Sabbath Rest
1166
+ - **Related:** `/fire-discover` — Pattern discovery
1167
+ - **Related:** `/fire-debug` — Structured debugging (non-loop)
1168
+ - **Skills:** `@skills-library/methodology/SABBATH_REST_PATTERN.md`