@thierrynakoa/fire-flow 10.0.0 → 12.2.1

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 (94) hide show
  1. package/.claude-plugin/plugin.json +8 -8
  2. package/ARCHITECTURE-DIAGRAM.md +7 -4
  3. package/COMMAND-REFERENCE.md +33 -13
  4. package/DOMINION-FLOW-OVERVIEW.md +581 -421
  5. package/QUICK-START.md +3 -3
  6. package/README.md +101 -44
  7. package/TROUBLESHOOTING.md +264 -264
  8. package/agents/fire-executor.md +200 -116
  9. package/agents/fire-fact-checker.md +276 -276
  10. package/agents/fire-phoenix-analyst.md +394 -0
  11. package/agents/fire-planner.md +145 -53
  12. package/agents/fire-project-researcher.md +155 -155
  13. package/agents/fire-research-synthesizer.md +166 -166
  14. package/agents/fire-researcher.md +144 -59
  15. package/agents/fire-roadmapper.md +215 -203
  16. package/agents/fire-verifier.md +247 -65
  17. package/agents/fire-vision-architect.md +381 -0
  18. package/commands/fire-0-orient.md +476 -476
  19. package/commands/fire-1a-new.md +216 -0
  20. package/commands/fire-1b-research.md +210 -0
  21. package/commands/fire-1c-setup.md +254 -0
  22. package/commands/{fire-1a-discuss.md → fire-1d-discuss.md} +35 -7
  23. package/commands/fire-3-execute.md +55 -2
  24. package/commands/fire-4-verify.md +61 -0
  25. package/commands/fire-5-handoff.md +2 -2
  26. package/commands/fire-6-resume.md +37 -2
  27. package/commands/fire-add-new-skill.md +2 -2
  28. package/commands/fire-autonomous.md +20 -3
  29. package/commands/fire-brainstorm.md +1 -1
  30. package/commands/fire-complete-milestone.md +2 -2
  31. package/commands/fire-cost.md +183 -0
  32. package/commands/fire-dashboard.md +2 -2
  33. package/commands/fire-debug.md +663 -663
  34. package/commands/fire-loop-resume.md +2 -2
  35. package/commands/fire-loop-stop.md +1 -1
  36. package/commands/fire-loop.md +1168 -1168
  37. package/commands/fire-map-codebase.md +3 -3
  38. package/commands/fire-new-milestone.md +356 -356
  39. package/commands/fire-phoenix.md +603 -0
  40. package/commands/fire-reflect.md +235 -235
  41. package/commands/fire-research.md +246 -246
  42. package/commands/fire-search.md +1 -1
  43. package/commands/fire-skills-diff.md +3 -3
  44. package/commands/fire-skills-history.md +3 -3
  45. package/commands/fire-skills-rollback.md +7 -7
  46. package/commands/fire-skills-sync.md +5 -5
  47. package/commands/fire-test.md +9 -9
  48. package/commands/fire-todos.md +1 -1
  49. package/commands/fire-update.md +5 -5
  50. package/hooks/hooks.json +16 -16
  51. package/hooks/run-hook.sh +8 -8
  52. package/hooks/run-session-end.sh +7 -7
  53. package/hooks/session-end.sh +90 -90
  54. package/hooks/session-start.sh +1 -1
  55. package/package.json +4 -2
  56. package/plugin.json +7 -7
  57. package/references/metrics-and-trends.md +1 -1
  58. package/skills-library/SKILLS-INDEX.md +588 -588
  59. package/skills-library/_general/methodology/AUTONOMOUS_ORCHESTRATION.md +182 -0
  60. package/skills-library/_general/methodology/BACKWARD_PLANNING_INTERVIEW.md +307 -0
  61. package/skills-library/_general/methodology/CIRCUIT_BREAKER_INTELLIGENCE.md +163 -0
  62. package/skills-library/_general/methodology/CONTEXT_ROTATION.md +151 -0
  63. package/skills-library/_general/methodology/DEAD_ENDS_SHELF.md +188 -0
  64. package/skills-library/_general/methodology/DESIGN_PHILOSOPHY_ENFORCEMENT.md +152 -0
  65. package/skills-library/_general/methodology/INTERNAL_CONSISTENCY_AUDIT.md +212 -0
  66. package/skills-library/_general/methodology/LIVE_BREADCRUMB_PROTOCOL.md +242 -0
  67. package/skills-library/_general/methodology/PHOENIX_REBUILD_METHODOLOGY.md +251 -0
  68. package/skills-library/_general/methodology/QUALITY_GATES_AND_VERIFICATION.md +157 -0
  69. package/skills-library/_general/methodology/RELIABILITY_PREDICTION.md +104 -0
  70. package/skills-library/_general/methodology/REQUIREMENTS_DECOMPOSITION.md +155 -0
  71. package/skills-library/_general/methodology/SELF_TESTING_FEEDBACK_LOOP.md +143 -0
  72. package/skills-library/_general/methodology/STACK_COMPATIBILITY_MATRIX.md +178 -0
  73. package/skills-library/_general/methodology/TIERED_CONTEXT_ARCHITECTURE.md +118 -0
  74. package/skills-library/_general/methodology/ZERO_FRICTION_CLI_SETUP.md +312 -0
  75. package/skills-library/_general/methodology/autonomous-multi-phase-build.md +133 -0
  76. package/skills-library/_general/methodology/claude-md-archival.md +280 -0
  77. package/skills-library/_general/methodology/debug-swarm-researcher-escape-hatch.md +240 -240
  78. package/skills-library/_general/methodology/git-worktrees-parallel.md +232 -0
  79. package/skills-library/_general/methodology/llm-judge-memory-crud.md +241 -0
  80. package/skills-library/_general/methodology/multi-project-autonomous-build.md +360 -0
  81. package/skills-library/_general/methodology/shell-autonomous-loop-fixplan.md +238 -238
  82. package/skills-library/_general/patterns-standards/GOF_DESIGN_PATTERNS_FOR_AI_AGENTS.md +358 -0
  83. package/skills-library/methodology/BREATH_BASED_PARALLEL_EXECUTION.md +1 -1
  84. package/skills-library/methodology/RESEARCH_BACKED_WORKFLOW_UPGRADE.md +1 -1
  85. package/skills-library/methodology/SABBATH_REST_PATTERN.md +1 -1
  86. package/templates/ASSUMPTIONS.md +1 -1
  87. package/templates/BLOCKERS.md +1 -1
  88. package/templates/DECISION_LOG.md +1 -1
  89. package/templates/phase-prompt.md +1 -1
  90. package/templates/phoenix-comparison.md +80 -0
  91. package/version.json +2 -2
  92. package/workflows/handoff-session.md +1 -1
  93. package/workflows/new-project.md +2 -2
  94. package/commands/fire-1-new.md +0 -281
@@ -1,240 +1,240 @@
1
- ---
2
- name: debug-swarm-researcher-escape-hatch
3
- category: methodology
4
- version: 1.0.0
5
- contributed: 2026-03-04
6
- contributor: dominion-flow-v2
7
- last_updated: 2026-03-04
8
- tags: [debugging, swarm, multi-agent, escape-hatch, researcher, blocked, orchestration, autonomous-loop]
9
- difficulty: hard
10
- usage_count: 0
11
- success_rate: 100
12
- ---
13
-
14
- # Debug Swarm Researcher Escape Hatch
15
-
16
- ## Problem
17
-
18
- Multi-agent debug swarms run parallel agents attacking the same bug from different hypotheses. When every hypothesis fails — every agent returns BLOCKED — the orchestrator is stuck. Spinning up identical agents produces identical failures. Halting loses all session context.
19
-
20
- **Symptoms:**
21
- - All swarm agents return `{status:"BLOCKED", issue, attempts_made[], error_context}` after N iterations
22
- - No remaining hypotheses to test
23
- - Loop stagnation: circuit breaker fires (`CB_STAGNATION >= limit`)
24
- - Problem requires external knowledge: prior art, community solution, docs deep-dive
25
-
26
- **The core trap:** You can't debug your way out of a knowledge gap. The swarm needs new information before it can make progress.
27
-
28
- ## Solution Pattern
29
-
30
- When the swarm hits a collective wall, **escape the debug loop entirely** and spawn a dedicated researcher agent. The researcher searches external sources (skills library, MCP servers, WebSearch, GitHub) and writes structured findings to a persistent file. The findings file is then injected into the next swarm iteration as first-class context.
31
-
32
- ### The Three-Layer Escape
33
-
34
- ```
35
- Layer 1: SWARM AGENTS (parallel per hypothesis)
36
- ↓ All return BLOCKED
37
- Layer 2: ESCAPE TRIGGER (orchestrator detects collective BLOCKED)
38
- ↓ Spawns fire-researcher instead of re-trying swarm
39
- Layer 3: RESEARCHER (skills lib + MCP + WebSearch + GitHub)
40
- ↓ Writes .planning/research/YYYY-MM-DD-{slug}.md
41
- ↓ Returns research summary to orchestrator
42
- Layer 1 again: NEW SWARM AGENTS (with research injected as context)
43
- ↓ Fresh hypotheses informed by external knowledge
44
- ```
45
-
46
- **Key insight:** The escape does NOT count as a swarm iteration. The loop counter
47
- stays constant. The researcher is outside the iteration budget.
48
-
49
- ### BLOCKED Agent Response Contract
50
-
51
- Swarm agents signal a wall using a structured response:
52
-
53
- ```json
54
- {
55
- "status": "BLOCKED",
56
- "issue": "Cannot determine why X fails — tried Y and Z",
57
- "attempts_made": [
58
- "Checked env variable binding — correct",
59
- "Added console.log to line 47 — never fires",
60
- "Tried disabling auth middleware — same result"
61
- ],
62
- "error_context": {
63
- "error": "Cannot read properties of undefined (reading 'id')",
64
- "file": "src/auth/middleware.ts",
65
- "line": 23,
66
- "stack": "..."
67
- },
68
- "files_checked": ["src/auth/middleware.ts", "src/routes/users.ts"]
69
- }
70
- ```
71
-
72
- The orchestrator collects all BLOCKED responses and synthesizes a research brief.
73
-
74
- ### Orchestrator Escape Logic
75
-
76
- ```python
77
- def check_escape_condition(swarm_results):
78
- blocked_count = sum(1 for r in swarm_results if r["status"] == "BLOCKED")
79
- if blocked_count == len(swarm_results):
80
- # All agents blocked — trigger escape hatch
81
- return True
82
- return False
83
-
84
- def build_research_brief(blocked_responses):
85
- # Synthesize what the swarm tried and where it's stuck
86
- all_attempts = [a for r in blocked_responses for a in r["attempts_made"]]
87
- error_patterns = [r["error_context"] for r in blocked_responses]
88
- return {
89
- "problem_summary": "...",
90
- "attempted_approaches": all_attempts,
91
- "error_signatures": error_patterns,
92
- "research_queries": [
93
- "Cannot read properties undefined middleware chain express",
94
- "JWT auth middleware undefined user id request context"
95
- ]
96
- }
97
- ```
98
-
99
- ### Researcher Sources (priority order)
100
-
101
- ```
102
- 1. Skills library search — Has this been solved before in our patterns?
103
- 2. context7 MCP server — Framework/library official docs
104
- 3. WebSearch — Community solutions, Stack Overflow, GitHub Issues
105
- 4. GitHub code search — Real-world implementations of the pattern
106
- 5. Episodic memory search — Did WE solve a similar issue in a past session?
107
- ```
108
-
109
- ### Research Output Format
110
-
111
- Researcher writes to `.planning/research/YYYY-MM-DD-{slug}.md`:
112
-
113
- ```markdown
114
- # Research: {problem title}
115
- **Date:** YYYY-MM-DD
116
- **Trigger:** Debug swarm collective BLOCKED — N agents, N attempts
117
-
118
- ## Root Cause Hypothesis (from research)
119
- [What the researcher found that the swarm was missing]
120
-
121
- ## Solution Approach
122
- [Concrete steps to fix based on external sources]
123
-
124
- ## Code Reference
125
- ```[language]
126
- // From: [source URL or skill name]
127
- [relevant code snippet]
128
- ```
129
-
130
- ## Sources
131
- - [Source 1 with URL]
132
- - [Source 2 with URL]
133
-
134
- ## Re-injection Prompt
135
- [Ready-to-use context block for injecting into next swarm iteration]
136
- ```
137
-
138
- ### Re-injection Into Next Swarm Iteration
139
-
140
- After researcher completes, the orchestrator spawns a fresh swarm with the research pre-loaded:
141
-
142
- ```
143
- CONTEXT FROM PREVIOUS SWARM + RESEARCHER:
144
-
145
- The debug swarm tried N approaches and was blocked. A researcher agent
146
- investigated and found:
147
-
148
- [Research summary — from .planning/research/YYYY-MM-DD-{slug}.md]
149
-
150
- Known dead ends (do NOT retry):
151
- - [attempt 1]
152
- - [attempt 2]
153
-
154
- New hypotheses to test based on research:
155
- - [fresh hypothesis 1 from external sources]
156
- - [fresh hypothesis 2]
157
- ```
158
-
159
- ## Code Example
160
-
161
- ```markdown
162
- # fire-debug.md — Swarm Orchestrator (key escape section)
163
-
164
- ## Swarm Mode Orchestrator
165
-
166
- ```pseudocode
167
- results = await Promise.all(swarm_agents.map(agent => agent.run()))
168
-
169
- if results.every(r => r.status === "BLOCKED"):
170
- # Escape hatch: all agents blocked
171
- brief = build_research_brief(results)
172
-
173
- research = await spawn_agent(
174
- "fire-researcher",
175
- {
176
- query: brief.problem_summary,
177
- search_sources: ["skills-library", "context7-mcp", "web-search", "github"],
178
- write_to: f".planning/research/{today}-{slug}.md"
179
- }
180
- )
181
-
182
- # Re-spawn swarm with research context (doesn't count as iteration)
183
- new_swarm = spawn_swarm(hypotheses=research.new_hypotheses, context=research)
184
- results = await new_swarm.run()
185
- ```
186
- ```
187
-
188
- ## Implementation Steps
189
-
190
- 1. Define BLOCKED response contract in swarm agent instructions (the JSON shape above)
191
- 2. Implement `check_escape_condition()` in orchestrator — triggers when ALL agents blocked
192
- 3. Implement `build_research_brief()` — synthesizes blocked responses into research queries
193
- 4. Spawn `fire-researcher` (or equivalent) with the brief + write path
194
- 5. Researcher writes structured `.planning/research/YYYY-MM-DD-{slug}.md`
195
- 6. Orchestrator reads research, builds re-injection context block
196
- 7. Spawn fresh swarm iteration with research pre-loaded as context
197
-
198
- ## When to Use
199
-
200
- - Multi-agent debug swarm where ALL agents return BLOCKED simultaneously
201
- - Problem requires external knowledge (docs, prior art, community solutions)
202
- - Stagnation circuit breaker has fired due to repeated identical failures
203
- - The error pattern is unfamiliar — novel framework, obscure edge case, known bug in dependency
204
- - You want to preserve research findings across sessions (write to disk, not just memory)
205
-
206
- ## When NOT to Use
207
-
208
- - Single-agent debugging (use systematic-debugging skill instead)
209
- - Only 1-2 agents blocked (not all) — remaining agents may still find a path
210
- - Problem is clearly a typo or obvious logic error (don't need external research)
211
- - Swarm has only run 1 iteration (premature escape — try more hypotheses first)
212
- - Time-critical hotfix where research delay is unacceptable
213
-
214
- ## Common Mistakes
215
-
216
- - **Counting escape as an iteration** — the researcher escape is outside the iteration budget; resetting the loop counter erases progress tracking
217
- - **Vague research brief** — synthesize specific error signatures and exact code context, not just "it doesn't work". The researcher is only as good as the brief
218
- - **Not writing research to disk** — if findings stay in memory only, they're lost on session compaction. Always write `.planning/research/*.md`
219
- - **Re-injecting all research** — only inject the relevant new hypotheses, not the full research doc. Context window is precious
220
- - **Escaping too early** — require collective BLOCKED (all agents, not just some). Partial blocking means other hypotheses are still viable
221
-
222
- ## Exit Codes (when used in shell loop)
223
-
224
- | Code | Meaning | Action |
225
- |------|---------|--------|
226
- | 0 | Bug fixed after research re-injection | Proceed to verify |
227
- | 2 | Escape triggered, researcher found nothing | Human investigation required |
228
- | 3 | Research found solution, fix not implemented | Apply research manually |
229
-
230
- ## Related Skills
231
-
232
- - [shell-autonomous-loop-fixplan](_general/methodology/shell-autonomous-loop-fixplan.md) — shell-level loop with BLOCKED signal (exit code 2)
233
- - [autonomous-multi-phase-build](_general/methodology/autonomous-multi-phase-build.md) — phase-level orchestration
234
- - [systematic-debugging] — single-agent debugging pattern
235
-
236
- ## References
237
-
238
- - Implemented in: `dominion-flow-v2/commands/fire-debug.md` (--swarm mode section)
239
- - Inspired by: RLHF researcher escalation patterns + bmalph/Ralph BLOCKED exit
240
- - Contributed from: dominion-flow-v2 build session 2026-03-04
1
+ ---
2
+ name: debug-swarm-researcher-escape-hatch
3
+ category: methodology
4
+ version: 1.0.0
5
+ contributed: 2026-03-04
6
+ contributor: dominion-flow-v2
7
+ last_updated: 2026-03-04
8
+ tags: [debugging, swarm, multi-agent, escape-hatch, researcher, blocked, orchestration, autonomous-loop]
9
+ difficulty: hard
10
+ usage_count: 0
11
+ success_rate: 100
12
+ ---
13
+
14
+ # Debug Swarm Researcher Escape Hatch
15
+
16
+ ## Problem
17
+
18
+ Multi-agent debug swarms run parallel agents attacking the same bug from different hypotheses. When every hypothesis fails — every agent returns BLOCKED — the orchestrator is stuck. Spinning up identical agents produces identical failures. Halting loses all session context.
19
+
20
+ **Symptoms:**
21
+ - All swarm agents return `{status:"BLOCKED", issue, attempts_made[], error_context}` after N iterations
22
+ - No remaining hypotheses to test
23
+ - Loop stagnation: circuit breaker fires (`CB_STAGNATION >= limit`)
24
+ - Problem requires external knowledge: prior art, community solution, docs deep-dive
25
+
26
+ **The core trap:** You can't debug your way out of a knowledge gap. The swarm needs new information before it can make progress.
27
+
28
+ ## Solution Pattern
29
+
30
+ When the swarm hits a collective wall, **escape the debug loop entirely** and spawn a dedicated researcher agent. The researcher searches external sources (skills library, MCP servers, WebSearch, GitHub) and writes structured findings to a persistent file. The findings file is then injected into the next swarm iteration as first-class context.
31
+
32
+ ### The Three-Layer Escape
33
+
34
+ ```
35
+ Layer 1: SWARM AGENTS (parallel per hypothesis)
36
+ ↓ All return BLOCKED
37
+ Layer 2: ESCAPE TRIGGER (orchestrator detects collective BLOCKED)
38
+ ↓ Spawns fire-researcher instead of re-trying swarm
39
+ Layer 3: RESEARCHER (skills lib + MCP + WebSearch + GitHub)
40
+ ↓ Writes .planning/research/YYYY-MM-DD-{slug}.md
41
+ ↓ Returns research summary to orchestrator
42
+ Layer 1 again: NEW SWARM AGENTS (with research injected as context)
43
+ ↓ Fresh hypotheses informed by external knowledge
44
+ ```
45
+
46
+ **Key insight:** The escape does NOT count as a swarm iteration. The loop counter
47
+ stays constant. The researcher is outside the iteration budget.
48
+
49
+ ### BLOCKED Agent Response Contract
50
+
51
+ Swarm agents signal a wall using a structured response:
52
+
53
+ ```json
54
+ {
55
+ "status": "BLOCKED",
56
+ "issue": "Cannot determine why X fails — tried Y and Z",
57
+ "attempts_made": [
58
+ "Checked env variable binding — correct",
59
+ "Added console.log to line 47 — never fires",
60
+ "Tried disabling auth middleware — same result"
61
+ ],
62
+ "error_context": {
63
+ "error": "Cannot read properties of undefined (reading 'id')",
64
+ "file": "src/auth/middleware.ts",
65
+ "line": 23,
66
+ "stack": "..."
67
+ },
68
+ "files_checked": ["src/auth/middleware.ts", "src/routes/users.ts"]
69
+ }
70
+ ```
71
+
72
+ The orchestrator collects all BLOCKED responses and synthesizes a research brief.
73
+
74
+ ### Orchestrator Escape Logic
75
+
76
+ ```python
77
+ def check_escape_condition(swarm_results):
78
+ blocked_count = sum(1 for r in swarm_results if r["status"] == "BLOCKED")
79
+ if blocked_count == len(swarm_results):
80
+ # All agents blocked — trigger escape hatch
81
+ return True
82
+ return False
83
+
84
+ def build_research_brief(blocked_responses):
85
+ # Synthesize what the swarm tried and where it's stuck
86
+ all_attempts = [a for r in blocked_responses for a in r["attempts_made"]]
87
+ error_patterns = [r["error_context"] for r in blocked_responses]
88
+ return {
89
+ "problem_summary": "...",
90
+ "attempted_approaches": all_attempts,
91
+ "error_signatures": error_patterns,
92
+ "research_queries": [
93
+ "Cannot read properties undefined middleware chain express",
94
+ "JWT auth middleware undefined user id request context"
95
+ ]
96
+ }
97
+ ```
98
+
99
+ ### Researcher Sources (priority order)
100
+
101
+ ```
102
+ 1. Skills library search — Has this been solved before in our patterns?
103
+ 2. context7 MCP server — Framework/library official docs
104
+ 3. WebSearch — Community solutions, Stack Overflow, GitHub Issues
105
+ 4. GitHub code search — Real-world implementations of the pattern
106
+ 5. Episodic memory search — Did WE solve a similar issue in a past session?
107
+ ```
108
+
109
+ ### Research Output Format
110
+
111
+ Researcher writes to `.planning/research/YYYY-MM-DD-{slug}.md`:
112
+
113
+ ```markdown
114
+ # Research: {problem title}
115
+ **Date:** YYYY-MM-DD
116
+ **Trigger:** Debug swarm collective BLOCKED — N agents, N attempts
117
+
118
+ ## Root Cause Hypothesis (from research)
119
+ [What the researcher found that the swarm was missing]
120
+
121
+ ## Solution Approach
122
+ [Concrete steps to fix based on external sources]
123
+
124
+ ## Code Reference
125
+ ```[language]
126
+ // From: [source URL or skill name]
127
+ [relevant code snippet]
128
+ ```
129
+
130
+ ## Sources
131
+ - [Source 1 with URL]
132
+ - [Source 2 with URL]
133
+
134
+ ## Re-injection Prompt
135
+ [Ready-to-use context block for injecting into next swarm iteration]
136
+ ```
137
+
138
+ ### Re-injection Into Next Swarm Iteration
139
+
140
+ After researcher completes, the orchestrator spawns a fresh swarm with the research pre-loaded:
141
+
142
+ ```
143
+ CONTEXT FROM PREVIOUS SWARM + RESEARCHER:
144
+
145
+ The debug swarm tried N approaches and was blocked. A researcher agent
146
+ investigated and found:
147
+
148
+ [Research summary — from .planning/research/YYYY-MM-DD-{slug}.md]
149
+
150
+ Known dead ends (do NOT retry):
151
+ - [attempt 1]
152
+ - [attempt 2]
153
+
154
+ New hypotheses to test based on research:
155
+ - [fresh hypothesis 1 from external sources]
156
+ - [fresh hypothesis 2]
157
+ ```
158
+
159
+ ## Code Example
160
+
161
+ ```markdown
162
+ # fire-debug.md — Swarm Orchestrator (key escape section)
163
+
164
+ ## Swarm Mode Orchestrator
165
+
166
+ ```pseudocode
167
+ results = await Promise.all(swarm_agents.map(agent => agent.run()))
168
+
169
+ if results.every(r => r.status === "BLOCKED"):
170
+ # Escape hatch: all agents blocked
171
+ brief = build_research_brief(results)
172
+
173
+ research = await spawn_agent(
174
+ "fire-researcher",
175
+ {
176
+ query: brief.problem_summary,
177
+ search_sources: ["skills-library", "context7-mcp", "web-search", "github"],
178
+ write_to: f".planning/research/{today}-{slug}.md"
179
+ }
180
+ )
181
+
182
+ # Re-spawn swarm with research context (doesn't count as iteration)
183
+ new_swarm = spawn_swarm(hypotheses=research.new_hypotheses, context=research)
184
+ results = await new_swarm.run()
185
+ ```
186
+ ```
187
+
188
+ ## Implementation Steps
189
+
190
+ 1. Define BLOCKED response contract in swarm agent instructions (the JSON shape above)
191
+ 2. Implement `check_escape_condition()` in orchestrator — triggers when ALL agents blocked
192
+ 3. Implement `build_research_brief()` — synthesizes blocked responses into research queries
193
+ 4. Spawn `fire-researcher` (or equivalent) with the brief + write path
194
+ 5. Researcher writes structured `.planning/research/YYYY-MM-DD-{slug}.md`
195
+ 6. Orchestrator reads research, builds re-injection context block
196
+ 7. Spawn fresh swarm iteration with research pre-loaded as context
197
+
198
+ ## When to Use
199
+
200
+ - Multi-agent debug swarm where ALL agents return BLOCKED simultaneously
201
+ - Problem requires external knowledge (docs, prior art, community solutions)
202
+ - Stagnation circuit breaker has fired due to repeated identical failures
203
+ - The error pattern is unfamiliar — novel framework, obscure edge case, known bug in dependency
204
+ - You want to preserve research findings across sessions (write to disk, not just memory)
205
+
206
+ ## When NOT to Use
207
+
208
+ - Single-agent debugging (use systematic-debugging skill instead)
209
+ - Only 1-2 agents blocked (not all) — remaining agents may still find a path
210
+ - Problem is clearly a typo or obvious logic error (don't need external research)
211
+ - Swarm has only run 1 iteration (premature escape — try more hypotheses first)
212
+ - Time-critical hotfix where research delay is unacceptable
213
+
214
+ ## Common Mistakes
215
+
216
+ - **Counting escape as an iteration** — the researcher escape is outside the iteration budget; resetting the loop counter erases progress tracking
217
+ - **Vague research brief** — synthesize specific error signatures and exact code context, not just "it doesn't work". The researcher is only as good as the brief
218
+ - **Not writing research to disk** — if findings stay in memory only, they're lost on session compaction. Always write `.planning/research/*.md`
219
+ - **Re-injecting all research** — only inject the relevant new hypotheses, not the full research doc. Context window is precious
220
+ - **Escaping too early** — require collective BLOCKED (all agents, not just some). Partial blocking means other hypotheses are still viable
221
+
222
+ ## Exit Codes (when used in shell loop)
223
+
224
+ | Code | Meaning | Action |
225
+ |------|---------|--------|
226
+ | 0 | Bug fixed after research re-injection | Proceed to verify |
227
+ | 2 | Escape triggered, researcher found nothing | Human investigation required |
228
+ | 3 | Research found solution, fix not implemented | Apply research manually |
229
+
230
+ ## Related Skills
231
+
232
+ - [shell-autonomous-loop-fixplan](_general/methodology/shell-autonomous-loop-fixplan.md) — shell-level loop with BLOCKED signal (exit code 2)
233
+ - [autonomous-multi-phase-build](_general/methodology/autonomous-multi-phase-build.md) — phase-level orchestration
234
+ - [systematic-debugging] — single-agent debugging pattern
235
+
236
+ ## References
237
+
238
+ - Implemented in: `fire-flow/commands/fire-debug.md` (--swarm mode section)
239
+ - Inspired by: RLHF researcher escalation patterns + bmalph/Ralph BLOCKED exit
240
+ - Contributed from: dominion-flow-v2 build session 2026-03-04