claude-flow-novice 2.14.8 → 2.14.10
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.claude/commands/cfn-loop-cli.md +1 -1
- package/.claude/skills/cfn-agent-selector/SKILL.md +2 -2
- package/.claude/skills/cfn-agent-selector/SKILL.md.backup_before_replace +91 -0
- package/.claude/skills/cfn-loop-orchestration/orchestrate.sh +72 -5
- package/README.md +4 -4
- package/README.md.backup_before_replace +781 -0
- package/claude-assets/agents/AGENT_LIFECYCLE.md +3 -3
- package/claude-assets/agents/AGENT_LIFECYCLE.md.backup_before_replace +530 -0
- package/claude-assets/agents/README-AGENT_LIFECYCLE.md +3 -3
- package/claude-assets/agents/README-AGENT_LIFECYCLE.md.backup_before_replace +522 -0
- package/claude-assets/agents/cfn-dev-team/CLAUDE.md +3 -3
- package/claude-assets/agents/cfn-dev-team/CLAUDE.md.backup_before_replace +1086 -0
- package/claude-assets/agents/cfn-dev-team/README.md +1 -1
- package/claude-assets/agents/cfn-dev-team/README.md.backup_before_replace +116 -0
- package/claude-assets/agents/cfn-dev-team/coordinators/cfn-v3-coordinator.md +2 -2
- package/claude-assets/agents/cfn-dev-team/coordinators/cfn-v3-coordinator.md.backup_before_replace +451 -0
- package/claude-assets/agents/cfn-dev-team/developers/README.md +3 -3
- package/claude-assets/agents/cfn-dev-team/developers/README.md.backup_before_replace +69 -0
- package/claude-assets/agents/cfn-dev-team/documentation/agent-type-guidelines.md +1 -1
- package/claude-assets/agents/cfn-dev-team/documentation/agent-type-guidelines.md.backup_before_replace +465 -0
- package/claude-assets/agents/cfn-dev-team/test-agent.md +2 -2
- package/claude-assets/agents/cfn-dev-team/test-agent.md.backup_before_replace +141 -0
- package/claude-assets/commands/cfn-loop-cli.md +1 -1
- package/claude-assets/skills/cfn-agent-selector/SKILL.md +2 -2
- package/claude-assets/skills/cfn-agent-selector/SKILL.md.backup_before_replace +91 -0
- package/claude-assets/skills/cfn-cli-setup/validate-cli-environment.sh +192 -0
- package/claude-assets/skills/cfn-deliverable-validation/confidence-calculator.sh +262 -0
- package/claude-assets/skills/cfn-loop-orchestration/orchestrate.sh +72 -5
- package/claude-assets/skills/cfn-mcp-container-selector/SKILL.md +555 -0
- package/claude-assets/skills/cfn-memory-monitoring/SKILL.md +531 -0
- package/claude-assets/skills/cfn-redis-cleanup/cleanup-redis.sh +130 -0
- package/claude-assets/skills/cfn-task-decomposition/task-decomposer.sh +279 -0
- package/dist/agents/agent-loader.js +165 -146
- package/dist/cli/cli-agent-context.js +6 -0
- package/dist/cli/cli-agent-context.js.map +1 -1
- package/dist/cli/config-manager.js +109 -91
- package/dist/cli/config-manager.js.map +1 -1
- package/dist/types/index.js +11 -0
- package/dist/types/index.js.map +1 -0
- package/dist/types/user.js +22 -0
- package/dist/types/user.js.map +1 -0
- package/package.json +1 -1
- package/readme/README.md +1 -1
- package/scripts/docker-playwright-fix.sh +312 -0
- package/scripts/zone-d-type-fixes.sh +333 -0
|
@@ -96,7 +96,7 @@ This document clarifies the complete lifecycle of agents in the CFN Loop system,
|
|
|
96
96
|
|
|
97
97
|
## CFN Loop Protocol (Complete)
|
|
98
98
|
|
|
99
|
-
### For Loop 3 Implementers (coder, backend-
|
|
99
|
+
### For Loop 3 Implementers (coder, backend-developer, etc.)
|
|
100
100
|
|
|
101
101
|
```markdown
|
|
102
102
|
## CFN Loop Redis Completion Protocol
|
|
@@ -298,7 +298,7 @@ CONFIDENCE=$(redis-cli get "swarm:${TASK_ID}:${AGENT_ID}:confidence")
|
|
|
298
298
|
**Key Point:** Each iteration spawns **fresh agents**, enabling adaptive specialization:
|
|
299
299
|
- Iteration 1: coder
|
|
300
300
|
- Iteration 2: rust-developer (if feedback mentions Rust)
|
|
301
|
-
- Iteration 3: backend-
|
|
301
|
+
- Iteration 3: backend-developer (if feedback mentions API)
|
|
302
302
|
|
|
303
303
|
---
|
|
304
304
|
|
|
@@ -418,7 +418,7 @@ fi
|
|
|
418
418
|
|
|
419
419
|
### Agent-Level Timeouts
|
|
420
420
|
Agents have role-based timeouts:
|
|
421
|
-
- **Implementers:** 60 minutes (coder, backend-
|
|
421
|
+
- **Implementers:** 60 minutes (coder, backend-developer)
|
|
422
422
|
- **Validators:** 30 minutes (reviewer, tester)
|
|
423
423
|
- **Product Owner:** 15 minutes (strategic decision)
|
|
424
424
|
- **Researchers:** 120 minutes (deep analysis)
|
|
@@ -0,0 +1,530 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: agent-lifecycle-documentation
|
|
3
|
+
description: Documentation for agent lifecycle management and waiting mode protocols
|
|
4
|
+
model: claude-sonnet-4
|
|
5
|
+
tools: [Read]
|
|
6
|
+
type: documentation
|
|
7
|
+
---
|
|
8
|
+
|
|
9
|
+
# Agent Lifecycle Documentation
|
|
10
|
+
|
|
11
|
+
**Version:** 2.0 (Post-Waiting Mode Removal)
|
|
12
|
+
**Last Updated:** 2025-10-21
|
|
13
|
+
**Status:** Current Standard
|
|
14
|
+
|
|
15
|
+
---
|
|
16
|
+
|
|
17
|
+
## Overview
|
|
18
|
+
|
|
19
|
+
This document clarifies the complete lifecycle of agents in the CFN Loop system, removing ambiguity about exit vs. waiting patterns.
|
|
20
|
+
|
|
21
|
+
**Core Principle:** Agents are **stateless, single-execution workers** that exit cleanly after completing their work and reporting results.
|
|
22
|
+
|
|
23
|
+
---
|
|
24
|
+
|
|
25
|
+
## Lifecycle States
|
|
26
|
+
|
|
27
|
+
### State 1: Spawned
|
|
28
|
+
**Duration:** Instantaneous
|
|
29
|
+
**Who:** Orchestrator via CLI (`npx cfn-spawn agent <type>`)
|
|
30
|
+
**Agent State:** Process starting, loading context
|
|
31
|
+
|
|
32
|
+
**Actions:**
|
|
33
|
+
- Agent process created
|
|
34
|
+
- Context injected via CLI parameters
|
|
35
|
+
- Tools initialized
|
|
36
|
+
- Task description received
|
|
37
|
+
|
|
38
|
+
### State 2: Executing
|
|
39
|
+
**Duration:** Variable (15 seconds - 60 minutes depending on agent type)
|
|
40
|
+
**Who:** Agent (autonomous)
|
|
41
|
+
**Agent State:** Working on assigned task
|
|
42
|
+
|
|
43
|
+
**Actions:**
|
|
44
|
+
- Read task specifications
|
|
45
|
+
- Execute work (code, review, validation, decision)
|
|
46
|
+
- Use tools (Read, Write, Edit, Bash, etc.)
|
|
47
|
+
- Build results
|
|
48
|
+
|
|
49
|
+
### State 3: Reporting
|
|
50
|
+
**Duration:** 1-5 seconds
|
|
51
|
+
**Who:** Agent (mandatory protocol)
|
|
52
|
+
**Agent State:** Completing execution
|
|
53
|
+
|
|
54
|
+
**Actions (in order):**
|
|
55
|
+
1. **Signal completion:**
|
|
56
|
+
```bash
|
|
57
|
+
redis-cli lpush "swarm:${TASK_ID}:${AGENT_ID}:done" "complete"
|
|
58
|
+
```
|
|
59
|
+
|
|
60
|
+
2. **Report confidence:**
|
|
61
|
+
```bash
|
|
62
|
+
./.claude/skills/redis-coordination/invoke-waiting-mode.sh report \
|
|
63
|
+
|
|
64
|
+
**After reporting, exit cleanly. Do NOT enter waiting mode.**
|
|
65
|
+
|
|
66
|
+
**Why This Matters:**
|
|
67
|
+
- Orchestrator collects confidence/consensus scores from Redis
|
|
68
|
+
- Enables adaptive agent specialization for next iteration
|
|
69
|
+
- Prevents orchestrator blocking on wait $PID
|
|
70
|
+
- Coordinator spawns appropriate specialist based on feedback type
|
|
71
|
+
|
|
72
|
+
--task-id "$TASK_ID" \
|
|
73
|
+
--agent-id "$AGENT_ID" \
|
|
74
|
+
--confidence [0.0-1.0] \
|
|
75
|
+
--iteration $ITERATION
|
|
76
|
+
```
|
|
77
|
+
|
|
78
|
+
3. **Store results (if applicable):**
|
|
79
|
+
```bash
|
|
80
|
+
redis-cli setex "swarm:${TASK_ID}:${AGENT_ID}:result" 86400 "$RESULT_JSON"
|
|
81
|
+
```
|
|
82
|
+
|
|
83
|
+
### State 4: Exiting
|
|
84
|
+
**Duration:** Instantaneous
|
|
85
|
+
**Who:** Agent (natural process termination)
|
|
86
|
+
**Agent State:** Process terminating
|
|
87
|
+
|
|
88
|
+
**Actions:**
|
|
89
|
+
- Clean exit (exit code 0)
|
|
90
|
+
- Process terminates
|
|
91
|
+
- Resources released
|
|
92
|
+
- ~~NO waiting mode~~ ❌ (removed)
|
|
93
|
+
- ~~NO wake signal needed~~ ❌ (removed)
|
|
94
|
+
|
|
95
|
+
---
|
|
96
|
+
|
|
97
|
+
## CFN Loop Protocol (Complete)
|
|
98
|
+
|
|
99
|
+
### For Loop 3 Implementers (coder, backend-dev, etc.)
|
|
100
|
+
|
|
101
|
+
```markdown
|
|
102
|
+
## CFN Loop Redis Completion Protocol
|
|
103
|
+
|
|
104
|
+
When participating in CFN Loop workflows, agents MUST follow this protocol:
|
|
105
|
+
|
|
106
|
+
### Step 1: Complete Work
|
|
107
|
+
Execute assigned task (code implementation, feature development, bug fixing)
|
|
108
|
+
|
|
109
|
+
### Step 2: Signal Completion
|
|
110
|
+
```bash
|
|
111
|
+
redis-cli lpush "swarm:${TASK_ID}:${AGENT_ID}:done" "complete"
|
|
112
|
+
```
|
|
113
|
+
|
|
114
|
+
### Step 3: Report Confidence Score
|
|
115
|
+
```bash
|
|
116
|
+
./.claude/skills/redis-coordination/invoke-waiting-mode.sh report \
|
|
117
|
+
|
|
118
|
+
**After reporting, exit cleanly. Do NOT enter waiting mode.**
|
|
119
|
+
|
|
120
|
+
**Why This Matters:**
|
|
121
|
+
- Orchestrator collects confidence/consensus scores from Redis
|
|
122
|
+
- Enables adaptive agent specialization for next iteration
|
|
123
|
+
- Prevents orchestrator blocking on wait $PID
|
|
124
|
+
- Coordinator spawns appropriate specialist based on feedback type
|
|
125
|
+
|
|
126
|
+
--task-id "$TASK_ID" \
|
|
127
|
+
--agent-id "$AGENT_ID" \
|
|
128
|
+
--confidence [0.0-1.0] \
|
|
129
|
+
--iteration 1
|
|
130
|
+
```
|
|
131
|
+
|
|
132
|
+
Confidence score guidelines:
|
|
133
|
+
- 1.0: Perfect implementation, all requirements met, no issues
|
|
134
|
+
- 0.9-0.99: Excellent, minor refinements possible
|
|
135
|
+
- 0.75-0.89: Good, gate threshold met, ready for validation
|
|
136
|
+
- 0.5-0.74: Below gate, needs iteration
|
|
137
|
+
- 0.0-0.49: Significant issues, requires major rework
|
|
138
|
+
|
|
139
|
+
### Step 4: Exit Cleanly
|
|
140
|
+
Agent work is complete. Exit cleanly to allow orchestrator to proceed.
|
|
141
|
+
|
|
142
|
+
**Note:** If another iteration is needed, orchestrator will spawn a fresh agent
|
|
143
|
+
(possibly a different specialist based on feedback). This enables adaptive
|
|
144
|
+
agent specialization per PATTERN-022.
|
|
145
|
+
```
|
|
146
|
+
|
|
147
|
+
### For Loop 2 Validators (reviewer, tester, security-specialist, etc.)
|
|
148
|
+
|
|
149
|
+
```markdown
|
|
150
|
+
## CFN Loop Redis Completion Protocol
|
|
151
|
+
|
|
152
|
+
### Step 1: Wait for Gate Pass Signal
|
|
153
|
+
```bash
|
|
154
|
+
# Wait for Loop 3 to pass gate threshold
|
|
155
|
+
redis-cli blpop "swarm:${TASK_ID}:gate-passed" 0
|
|
156
|
+
```
|
|
157
|
+
|
|
158
|
+
### Step 2: Retrieve Loop 3 Results
|
|
159
|
+
```bash
|
|
160
|
+
# Get agent outputs and confidence scores from Redis
|
|
161
|
+
redis-cli get "swarm:${TASK_ID}:coder-1:result"
|
|
162
|
+
redis-cli get "swarm:${TASK_ID}:coder-1:confidence"
|
|
163
|
+
```
|
|
164
|
+
|
|
165
|
+
### Step 3: Perform Validation
|
|
166
|
+
Execute validation task (code review, security audit, testing)
|
|
167
|
+
|
|
168
|
+
### Step 4: Signal Completion
|
|
169
|
+
```bash
|
|
170
|
+
redis-cli lpush "swarm:${TASK_ID}:${AGENT_ID}:done" "complete"
|
|
171
|
+
```
|
|
172
|
+
|
|
173
|
+
### Step 5: Report Consensus Score
|
|
174
|
+
```bash
|
|
175
|
+
./.claude/skills/redis-coordination/invoke-waiting-mode.sh report \
|
|
176
|
+
|
|
177
|
+
**After reporting, exit cleanly. Do NOT enter waiting mode.**
|
|
178
|
+
|
|
179
|
+
**Why This Matters:**
|
|
180
|
+
- Orchestrator collects confidence/consensus scores from Redis
|
|
181
|
+
- Enables adaptive agent specialization for next iteration
|
|
182
|
+
- Prevents orchestrator blocking on wait $PID
|
|
183
|
+
- Coordinator spawns appropriate specialist based on feedback type
|
|
184
|
+
|
|
185
|
+
--task-id "$TASK_ID" \
|
|
186
|
+
--agent-id "$AGENT_ID" \
|
|
187
|
+
--confidence [0.0-1.0] \
|
|
188
|
+
--iteration 1
|
|
189
|
+
```
|
|
190
|
+
|
|
191
|
+
Consensus score guidelines:
|
|
192
|
+
- 1.0: Perfect quality, no issues found
|
|
193
|
+
- 0.9-0.99: Excellent, consensus threshold typically met
|
|
194
|
+
- 0.75-0.89: Good, minor issues found
|
|
195
|
+
- 0.5-0.74: Below consensus, needs iteration
|
|
196
|
+
- 0.0-0.49: Significant issues, requires rework
|
|
197
|
+
|
|
198
|
+
### Step 6: Exit Cleanly
|
|
199
|
+
Validation complete. Exit cleanly to allow orchestrator to calculate consensus.
|
|
200
|
+
```
|
|
201
|
+
|
|
202
|
+
### For Product Owner
|
|
203
|
+
|
|
204
|
+
```markdown
|
|
205
|
+
## CFN Loop Product Owner Protocol
|
|
206
|
+
|
|
207
|
+
### Step 1: Wait for Consensus Completion
|
|
208
|
+
```bash
|
|
209
|
+
# Wait for Loop 2 to complete consensus validation
|
|
210
|
+
redis-cli blpop "swarm:${TASK_ID}:consensus-complete" 0
|
|
211
|
+
```
|
|
212
|
+
|
|
213
|
+
### Step 2: Retrieve All Context
|
|
214
|
+
```bash
|
|
215
|
+
# Get Loop 2 consensus, feedback, acceptance criteria
|
|
216
|
+
redis-cli get "swarm:${TASK_ID}:loop2:consensus"
|
|
217
|
+
redis-cli lrange "swarm:${TASK_ID}:loop2:feedback" 0 -1
|
|
218
|
+
redis-cli get "swarm:${TASK_ID}:success-criteria"
|
|
219
|
+
```
|
|
220
|
+
|
|
221
|
+
### Step 3: Make Strategic Decision
|
|
222
|
+
Analyze consensus, feedback, and business requirements.
|
|
223
|
+
|
|
224
|
+
Output one of:
|
|
225
|
+
- **PROCEED:** Task complete, meets acceptance criteria
|
|
226
|
+
- **ITERATE:** Needs another iteration (provide specific feedback)
|
|
227
|
+
- **ABORT:** Out of scope or max iterations reached
|
|
228
|
+
|
|
229
|
+
### Step 4: Report Decision
|
|
230
|
+
```bash
|
|
231
|
+
redis-cli lpush "swarm:${TASK_ID}:product-owner:decision" "$DECISION_JSON"
|
|
232
|
+
```
|
|
233
|
+
|
|
234
|
+
### Step 5: Exit Cleanly
|
|
235
|
+
Decision made. Exit to allow orchestrator to proceed with final actions.
|
|
236
|
+
```
|
|
237
|
+
|
|
238
|
+
---
|
|
239
|
+
|
|
240
|
+
## Orchestrator Responsibilities
|
|
241
|
+
|
|
242
|
+
### Agent Spawning
|
|
243
|
+
```bash
|
|
244
|
+
# Spawn agent via CLI
|
|
245
|
+
npx cfn-spawn agent <agent-type> \
|
|
246
|
+
--task-id "$TASK_ID" \
|
|
247
|
+
--iteration "$ITERATION" \
|
|
248
|
+
--context "$CONTEXT_JSON" &
|
|
249
|
+
|
|
250
|
+
AGENT_PID=$!
|
|
251
|
+
```
|
|
252
|
+
|
|
253
|
+
### Agent Monitoring
|
|
254
|
+
```bash
|
|
255
|
+
# Wait for agent to complete and exit naturally
|
|
256
|
+
wait $AGENT_PID
|
|
257
|
+
EXIT_CODE=$?
|
|
258
|
+
|
|
259
|
+
# Check completion signal
|
|
260
|
+
DONE_SIGNAL=$(redis-cli lpop "swarm:${TASK_ID}:${AGENT_ID}:done")
|
|
261
|
+
|
|
262
|
+
# Retrieve confidence
|
|
263
|
+
CONFIDENCE=$(redis-cli get "swarm:${TASK_ID}:${AGENT_ID}:confidence")
|
|
264
|
+
```
|
|
265
|
+
|
|
266
|
+
### No Wake Calls Needed
|
|
267
|
+
❌ **Removed:** `invoke-waiting-mode.sh wake` calls
|
|
268
|
+
✅ **Current:** Agents exit, orchestrator spawns fresh agents for next iteration
|
|
269
|
+
|
|
270
|
+
---
|
|
271
|
+
|
|
272
|
+
## Iteration Pattern
|
|
273
|
+
|
|
274
|
+
### Single Iteration (Typical)
|
|
275
|
+
```
|
|
276
|
+
1. Orchestrator spawns Loop 3 agents
|
|
277
|
+
2. Loop 3 agents work → report confidence → EXIT
|
|
278
|
+
3. Orchestrator checks gate threshold
|
|
279
|
+
4. If PASS: Orchestrator spawns Loop 2 agents
|
|
280
|
+
5. Loop 2 agents validate → report consensus → EXIT
|
|
281
|
+
6. Orchestrator checks consensus threshold
|
|
282
|
+
7. If PASS: Orchestrator spawns Product Owner
|
|
283
|
+
8. Product Owner decides → EXIT
|
|
284
|
+
9. Task complete
|
|
285
|
+
```
|
|
286
|
+
|
|
287
|
+
### Multi-Iteration (If Gate/Consensus Fails)
|
|
288
|
+
```
|
|
289
|
+
1. Orchestrator spawns Loop 3 agents (iteration 1)
|
|
290
|
+
2. Loop 3 agents work → report confidence → EXIT
|
|
291
|
+
3. Gate check FAILS (confidence < 0.75)
|
|
292
|
+
4. Orchestrator spawns NEW Loop 3 agents (iteration 2) ← Fresh agents!
|
|
293
|
+
5. New agents work → report confidence → EXIT
|
|
294
|
+
6. Gate check PASSES
|
|
295
|
+
7. Continue to Loop 2...
|
|
296
|
+
```
|
|
297
|
+
|
|
298
|
+
**Key Point:** Each iteration spawns **fresh agents**, enabling adaptive specialization:
|
|
299
|
+
- Iteration 1: coder
|
|
300
|
+
- Iteration 2: rust-developer (if feedback mentions Rust)
|
|
301
|
+
- Iteration 3: backend-dev (if feedback mentions API)
|
|
302
|
+
|
|
303
|
+
---
|
|
304
|
+
|
|
305
|
+
## Anti-Patterns (Forbidden)
|
|
306
|
+
|
|
307
|
+
### ❌ Anti-Pattern 1: Waiting Mode
|
|
308
|
+
```bash
|
|
309
|
+
# WRONG - DO NOT USE:
|
|
310
|
+
--task-id "$TASK_ID" \
|
|
311
|
+
--agent-id "$AGENT_ID"
|
|
312
|
+
```
|
|
313
|
+
|
|
314
|
+
**Why forbidden:**
|
|
315
|
+
- Blocks orchestrator indefinitely
|
|
316
|
+
- Creates process zombies
|
|
317
|
+
- Prevents adaptive specialization
|
|
318
|
+
- Requires manual wake calls (complexity)
|
|
319
|
+
|
|
320
|
+
### ❌ Anti-Pattern 2: Fork/Resume Pattern
|
|
321
|
+
```bash
|
|
322
|
+
# WRONG - DO NOT USE:
|
|
323
|
+
redis-cli get "swarm:${TASK_ID}:${AGENT}:fork-id"
|
|
324
|
+
npx cfn-fork resume --fork-id "$FORK_ID"
|
|
325
|
+
```
|
|
326
|
+
|
|
327
|
+
**Why forbidden:**
|
|
328
|
+
- Adds complexity (conversation state management)
|
|
329
|
+
- Not needed (fresh agents work better)
|
|
330
|
+
- Harder to debug (stateful resume)
|
|
331
|
+
|
|
332
|
+
### ❌ Anti-Pattern 3: Manual Agent Spawning
|
|
333
|
+
```bash
|
|
334
|
+
# WRONG - DO NOT USE in CFN Loop:
|
|
335
|
+
Task("coder", "implement feature")
|
|
336
|
+
```
|
|
337
|
+
|
|
338
|
+
**Why forbidden:**
|
|
339
|
+
- Bypasses CFN Loop protocol
|
|
340
|
+
- No confidence reporting
|
|
341
|
+
- No Redis coordination
|
|
342
|
+
- Breaks orchestrator flow
|
|
343
|
+
|
|
344
|
+
---
|
|
345
|
+
|
|
346
|
+
## Correct Patterns (Recommended)
|
|
347
|
+
|
|
348
|
+
### ✅ Pattern 1: Clean Exit After Reporting
|
|
349
|
+
```bash
|
|
350
|
+
# Agent code (end of execution):
|
|
351
|
+
|
|
352
|
+
# Step 1: Signal done
|
|
353
|
+
redis-cli lpush "swarm:${TASK_ID}:${AGENT_ID}:done" "complete"
|
|
354
|
+
|
|
355
|
+
# Step 2: Report confidence
|
|
356
|
+
./.claude/skills/redis-coordination/invoke-waiting-mode.sh report \
|
|
357
|
+
|
|
358
|
+
**After reporting, exit cleanly. Do NOT enter waiting mode.**
|
|
359
|
+
|
|
360
|
+
**Why This Matters:**
|
|
361
|
+
- Orchestrator collects confidence/consensus scores from Redis
|
|
362
|
+
- Enables adaptive agent specialization for next iteration
|
|
363
|
+
- Prevents orchestrator blocking on wait $PID
|
|
364
|
+
- Coordinator spawns appropriate specialist based on feedback type
|
|
365
|
+
|
|
366
|
+
--task-id "$TASK_ID" \
|
|
367
|
+
--agent-id "$AGENT_ID" \
|
|
368
|
+
--confidence 0.95 \
|
|
369
|
+
--iteration 1
|
|
370
|
+
|
|
371
|
+
# Step 3: Exit cleanly
|
|
372
|
+
exit 0
|
|
373
|
+
```
|
|
374
|
+
|
|
375
|
+
### ✅ Pattern 2: Orchestrator Wait Pattern
|
|
376
|
+
```bash
|
|
377
|
+
# Orchestrator code:
|
|
378
|
+
|
|
379
|
+
# Spawn agent in background
|
|
380
|
+
npx cfn-spawn agent coder \
|
|
381
|
+
--task-id "$TASK_ID" \
|
|
382
|
+
--context "$CONTEXT" &
|
|
383
|
+
AGENT_PID=$!
|
|
384
|
+
|
|
385
|
+
# Wait for agent to complete
|
|
386
|
+
wait $AGENT_PID
|
|
387
|
+
EXIT_CODE=$?
|
|
388
|
+
|
|
389
|
+
# Retrieve results from Redis (agent already exited)
|
|
390
|
+
CONFIDENCE=$(redis-cli get "swarm:${TASK_ID}:coder-1:confidence")
|
|
391
|
+
```
|
|
392
|
+
|
|
393
|
+
### ✅ Pattern 3: Adaptive Specialization
|
|
394
|
+
```bash
|
|
395
|
+
# Orchestrator iteration logic:
|
|
396
|
+
|
|
397
|
+
if [ "$GATE_PASSED" = "false" ]; then
|
|
398
|
+
# Analyze feedback to select specialist
|
|
399
|
+
if [[ "$FEEDBACK" =~ "security" ]]; then
|
|
400
|
+
SPECIALIST="security-specialist"
|
|
401
|
+
elif [[ "$FEEDBACK" =~ "performance" ]]; then
|
|
402
|
+
SPECIALIST="perf-analyzer"
|
|
403
|
+
else
|
|
404
|
+
SPECIALIST="$ORIGINAL_AGENT" # Retry with same type
|
|
405
|
+
fi
|
|
406
|
+
|
|
407
|
+
# Spawn fresh specialist (not resume old agent)
|
|
408
|
+
npx cfn-spawn agent "$SPECIALIST" \
|
|
409
|
+
--task-id "$TASK_ID" \
|
|
410
|
+
--iteration $((ITERATION + 1)) \
|
|
411
|
+
--feedback "$FEEDBACK" &
|
|
412
|
+
fi
|
|
413
|
+
```
|
|
414
|
+
|
|
415
|
+
---
|
|
416
|
+
|
|
417
|
+
## Timeout Handling
|
|
418
|
+
|
|
419
|
+
### Agent-Level Timeouts
|
|
420
|
+
Agents have role-based timeouts:
|
|
421
|
+
- **Implementers:** 60 minutes (coder, backend-dev)
|
|
422
|
+
- **Validators:** 30 minutes (reviewer, tester)
|
|
423
|
+
- **Product Owner:** 15 minutes (strategic decision)
|
|
424
|
+
- **Researchers:** 120 minutes (deep analysis)
|
|
425
|
+
|
|
426
|
+
### Timeout Behavior
|
|
427
|
+
```bash
|
|
428
|
+
# If agent times out:
|
|
429
|
+
# 1. Process killed by orchestrator
|
|
430
|
+
# 2. Agent marked as failed
|
|
431
|
+
# 3. No confidence reported (defaults to 0.0)
|
|
432
|
+
# 4. Orchestrator spawns replacement agent
|
|
433
|
+
```
|
|
434
|
+
|
|
435
|
+
---
|
|
436
|
+
|
|
437
|
+
## Error Handling
|
|
438
|
+
|
|
439
|
+
### Agent Failure Scenarios
|
|
440
|
+
|
|
441
|
+
**1. Exit Code Non-Zero:**
|
|
442
|
+
```bash
|
|
443
|
+
wait $AGENT_PID
|
|
444
|
+
EXIT_CODE=$?
|
|
445
|
+
|
|
446
|
+
if [ "$EXIT_CODE" -ne 0 ]; then
|
|
447
|
+
# Agent failed - log error, spawn replacement
|
|
448
|
+
CONFIDENCE=0.0
|
|
449
|
+
fi
|
|
450
|
+
```
|
|
451
|
+
|
|
452
|
+
**2. No Completion Signal:**
|
|
453
|
+
```bash
|
|
454
|
+
DONE_SIGNAL=$(redis-cli lpop "swarm:${TASK_ID}:${AGENT_ID}:done")
|
|
455
|
+
|
|
456
|
+
if [ -z "$DONE_SIGNAL" ]; then
|
|
457
|
+
# Agent didn't signal completion - treat as failure
|
|
458
|
+
CONFIDENCE=0.0
|
|
459
|
+
fi
|
|
460
|
+
```
|
|
461
|
+
|
|
462
|
+
**3. Missing Confidence:**
|
|
463
|
+
```bash
|
|
464
|
+
CONFIDENCE=$(redis-cli get "swarm:${TASK_ID}:${AGENT_ID}:confidence")
|
|
465
|
+
|
|
466
|
+
if [ -z "$CONFIDENCE" ] || [ "$CONFIDENCE" = "(nil)" ]; then
|
|
467
|
+
# No confidence reported - default to 0.0
|
|
468
|
+
CONFIDENCE=0.0
|
|
469
|
+
fi
|
|
470
|
+
```
|
|
471
|
+
|
|
472
|
+
---
|
|
473
|
+
|
|
474
|
+
## Redis Key Conventions
|
|
475
|
+
|
|
476
|
+
### Agent Completion Keys
|
|
477
|
+
```
|
|
478
|
+
swarm:{TASK_ID}:{AGENT_ID}:done → "complete" (signal)
|
|
479
|
+
swarm:{TASK_ID}:{AGENT_ID}:confidence → "0.95" (score)
|
|
480
|
+
swarm:{TASK_ID}:{AGENT_ID}:result → JSON (output)
|
|
481
|
+
```
|
|
482
|
+
|
|
483
|
+
### Coordination Keys
|
|
484
|
+
```
|
|
485
|
+
swarm:{TASK_ID}:gate-passed → "1" (Loop 3 → Loop 2 signal)
|
|
486
|
+
swarm:{TASK_ID}:consensus-complete → "1" (Loop 2 → PO signal)
|
|
487
|
+
swarm:{TASK_ID}:product-owner:decision → JSON (PO decision)
|
|
488
|
+
```
|
|
489
|
+
|
|
490
|
+
### Metrics Keys
|
|
491
|
+
```
|
|
492
|
+
swarm:{TASK_ID}:metrics:loop3_consensus → List of JSON metrics
|
|
493
|
+
swarm:{TASK_ID}:metrics:loop2_consensus → List of JSON metrics
|
|
494
|
+
swarm:{TASK_ID}:metrics:iteration_start → List of timestamps
|
|
495
|
+
```
|
|
496
|
+
|
|
497
|
+
---
|
|
498
|
+
|
|
499
|
+
## Summary
|
|
500
|
+
|
|
501
|
+
**Agent Lifecycle (4 States):**
|
|
502
|
+
1. **Spawned** - Process starts, context loaded
|
|
503
|
+
2. **Executing** - Agent works autonomously
|
|
504
|
+
3. **Reporting** - Signal completion, report confidence
|
|
505
|
+
4. **Exiting** - Clean exit (exit code 0)
|
|
506
|
+
|
|
507
|
+
**Key Changes from v1.0:**
|
|
508
|
+
- ❌ Removed: Waiting mode (Step 4)
|
|
509
|
+
- ❌ Removed: Wake calls from orchestrator
|
|
510
|
+
- ❌ Removed: Fork/resume pattern
|
|
511
|
+
- ✅ Added: Clean exit after reporting
|
|
512
|
+
- ✅ Added: Adaptive agent specialization
|
|
513
|
+
- ✅ Added: Fresh agents per iteration
|
|
514
|
+
|
|
515
|
+
**Benefits:**
|
|
516
|
+
- Simpler orchestrator (no wake logic)
|
|
517
|
+
- Stateless agents (easier debugging)
|
|
518
|
+
- Adaptive specialization (better results)
|
|
519
|
+
- No process zombies (clean resource management)
|
|
520
|
+
|
|
521
|
+
**Next Steps:**
|
|
522
|
+
- See P4: Product Owner structured JSON output
|
|
523
|
+
- See P5: Coordinator simplification (780 → 200 lines)
|
|
524
|
+
- See P6: Unified agent spawning patterns
|
|
525
|
+
|
|
526
|
+
---
|
|
527
|
+
|
|
528
|
+
**Version History:**
|
|
529
|
+
- v1.0: Original with waiting mode
|
|
530
|
+
- v2.0 (2025-10-21): Waiting mode removed, PATTERN-022 compliant
|
|
@@ -88,7 +88,7 @@ This document clarifies the complete lifecycle of agents in the CFN Loop system,
|
|
|
88
88
|
|
|
89
89
|
## CFN Loop Protocol (Complete)
|
|
90
90
|
|
|
91
|
-
### For Loop 3 Implementers (coder, backend-
|
|
91
|
+
### For Loop 3 Implementers (coder, backend-developer, etc.)
|
|
92
92
|
|
|
93
93
|
```markdown
|
|
94
94
|
## CFN Loop Redis Completion Protocol
|
|
@@ -290,7 +290,7 @@ CONFIDENCE=$(redis-cli get "swarm:${TASK_ID}:${AGENT_ID}:confidence")
|
|
|
290
290
|
**Key Point:** Each iteration spawns **fresh agents**, enabling adaptive specialization:
|
|
291
291
|
- Iteration 1: coder
|
|
292
292
|
- Iteration 2: rust-developer (if feedback mentions Rust)
|
|
293
|
-
- Iteration 3: backend-
|
|
293
|
+
- Iteration 3: backend-developer (if feedback mentions API)
|
|
294
294
|
|
|
295
295
|
---
|
|
296
296
|
|
|
@@ -410,7 +410,7 @@ fi
|
|
|
410
410
|
|
|
411
411
|
### Agent-Level Timeouts
|
|
412
412
|
Agents have role-based timeouts:
|
|
413
|
-
- **Implementers:** 60 minutes (coder, backend-
|
|
413
|
+
- **Implementers:** 60 minutes (coder, backend-developer)
|
|
414
414
|
- **Validators:** 30 minutes (reviewer, tester)
|
|
415
415
|
- **Product Owner:** 15 minutes (strategic decision)
|
|
416
416
|
- **Researchers:** 120 minutes (deep analysis)
|