claude-flow-novice 2.14.3 → 2.14.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (162) hide show
  1. package/.claude/commands/CFN_LOOP_TASK_MODE.md +4 -47
  2. package/.claude/skills/cfn-redis-coordination/demos/test-cancel-swarm.sh +0 -276
  3. package/claude-assets/commands/CFN_LOOP_TASK_MODE.md +4 -47
  4. package/claude-assets/skills/cfn-redis-coordination/demos/test-cancel-swarm.sh +0 -276
  5. package/dist/agents/agent-loader.js +165 -146
  6. package/dist/agents/agent-loader.js.map +1 -1
  7. package/dist/cli/agent-prompt-builder.js +25 -0
  8. package/dist/cli/agent-prompt-builder.js.map +1 -1
  9. package/dist/cli/config-manager.js +91 -109
  10. package/package.json +1 -1
  11. package/.claude/skills/cfn-redis-coordination/HEARTBEAT.md +0 -57
  12. package/.claude/skills/cfn-redis-coordination/HEARTBEAT_MONITORING.md +0 -267
  13. package/.claude/skills/cfn-redis-coordination/LOGGING.md +0 -260
  14. package/.claude/skills/cfn-redis-coordination/README.md +0 -65
  15. package/.claude/skills/cfn-redis-coordination/SECURITY_REVIEW.md +0 -25
  16. package/.claude/skills/cfn-redis-coordination/SHUTDOWN_HANDLING.md +0 -164
  17. package/.claude/skills/cfn-redis-coordination/SKILL.md +0 -720
  18. package/.claude/skills/cfn-redis-coordination/demos/test-dlq.sh +0 -129
  19. package/.claude/skills/cfn-redis-coordination/demos/test-iteration-feedback.sh +0 -320
  20. package/.claude/skills/cfn-redis-coordination/demos/test-orchestrator.sh +0 -249
  21. package/.claude/skills/cfn-redis-coordination/demos/test-priority-wake-phase4-unix.sh +0 -148
  22. package/.claude/skills/cfn-redis-coordination/demos/test-priority-wake-phase4.sh +0 -163
  23. package/.claude/skills/cfn-redis-coordination/demos/test-priority-wake.sh +0 -138
  24. package/.claude/skills/cfn-redis-coordination/demos/test-quick-fix.sh +0 -81
  25. package/.claude/skills/cfn-redis-coordination/demos/test-quorum-absolute.sh +0 -45
  26. package/.claude/skills/cfn-redis-coordination/demos/test-quorum-fallback.sh +0 -68
  27. package/.claude/skills/cfn-redis-coordination/demos/test-quorum-percentage.sh +0 -56
  28. package/.claude/skills/cfn-redis-coordination/demos/test-quorum-with-retry.sh +0 -81
  29. package/.claude/skills/cfn-redis-coordination/demos/test-quorum.sh +0 -57
  30. package/.claude/skills/cfn-redis-coordination/demos/test-shutdown-handling.sh +0 -187
  31. package/.claude/skills/cfn-redis-coordination/demos/test-shutdown.sh +0 -160
  32. package/.claude/skills/cfn-redis-coordination/demos/test-utils-unix.sh +0 -97
  33. package/.claude/skills/cfn-redis-coordination/demos/test-utils.sh +0 -97
  34. package/.claude/skills/cfn-redis-coordination/demos/test-waiting-mode.sh +0 -59
  35. package/.claude/skills/cfn-redis-coordination/examples/README.md +0 -73
  36. package/.claude/skills/cfn-redis-coordination/examples/grafana-dashboard.json +0 -352
  37. package/.claude/skills/cfn-redis-coordination/examples/hierarchical-pattern.sh +0 -127
  38. package/.claude/skills/cfn-redis-coordination/examples/mesh-pattern.sh +0 -171
  39. package/.claude/skills/cfn-redis-coordination/examples/timeout-handling.sh +0 -227
  40. package/.claude/skills/cfn-redis-coordination/examples/waiting-mode-pattern.sh +0 -239
  41. package/.claude/skills/cfn-redis-coordination/execute-product-owner-decision.sh +0 -258
  42. package/.claude/skills/cfn-redis-coordination/get-agent-timeout.sh +0 -177
  43. package/.claude/skills/cfn-redis-coordination/heartbeat-functions.sh +0 -137
  44. package/.claude/skills/cfn-redis-coordination/heartbeat-protocol.md +0 -106
  45. package/.claude/skills/cfn-redis-coordination/heartbeat.sh +0 -126
  46. package/.claude/skills/cfn-redis-coordination/init-swarm.sh +0 -148
  47. package/.claude/skills/cfn-redis-coordination/invoke-redis-pattern.sh +0 -220
  48. package/.claude/skills/cfn-redis-coordination/invoke-waiting-mode.sh +0 -283
  49. package/.claude/skills/cfn-redis-coordination/list-active-swarms.sh +0 -147
  50. package/.claude/skills/cfn-redis-coordination/log-event.sh +0 -109
  51. package/.claude/skills/cfn-redis-coordination/metrics-export.sh +0 -674
  52. package/.claude/skills/cfn-redis-coordination/metrics-schema.json +0 -66
  53. package/.claude/skills/cfn-redis-coordination/metrics-storage.md +0 -31
  54. package/.claude/skills/cfn-redis-coordination/monitor-cfn-violations.sh +0 -391
  55. package/.claude/skills/cfn-redis-coordination/monitor-heartbeats.sh +0 -101
  56. package/.claude/skills/cfn-redis-coordination/orchestrate-cfn-loop-v3.sh +0 -141
  57. package/.claude/skills/cfn-redis-coordination/orchestrate-cfn-loop.sh +0 -31
  58. package/.claude/skills/cfn-redis-coordination/orchestrate-cfn-loop.sh.bak +0 -0
  59. package/.claude/skills/cfn-redis-coordination/priority-wake-mechanism.md +0 -75
  60. package/.claude/skills/cfn-redis-coordination/priority_wake.py +0 -134
  61. package/.claude/skills/cfn-redis-coordination/query-dlq.sh +0 -162
  62. package/.claude/skills/cfn-redis-coordination/query-logs.sh +0 -103
  63. package/.claude/skills/cfn-redis-coordination/redis-pattern.sh +0 -619
  64. package/.claude/skills/cfn-redis-coordination/retrieve-context.sh +0 -58
  65. package/.claude/skills/cfn-redis-coordination/select-specialist-agent.sh +0 -371
  66. package/.claude/skills/cfn-redis-coordination/semantic-match-tfidf.py +0 -252
  67. package/.claude/skills/cfn-redis-coordination/send-heartbeat.sh +0 -165
  68. package/.claude/skills/cfn-redis-coordination/signal.sh +0 -38
  69. package/.claude/skills/cfn-redis-coordination/store-context.sh +0 -86
  70. package/.claude/skills/cfn-redis-coordination/store-epic-context.sh +0 -123
  71. package/.claude/skills/cfn-redis-coordination/test-context-injection.sh +0 -354
  72. package/.claude/skills/cfn-redis-coordination/test-timeout-enforcement.sh +0 -513
  73. package/.claude/skills/cfn-redis-coordination/tests/convert-line-endings.sh +0 -15
  74. package/.claude/skills/cfn-redis-coordination/tests/dlq-functionality-test.sh +0 -102
  75. package/.claude/skills/cfn-redis-coordination/tests/edge-cases-test.sh +0 -99
  76. package/.claude/skills/cfn-redis-coordination/tests/integration-test.sh +0 -170
  77. package/.claude/skills/cfn-redis-coordination/tests/retry-mechanism-test.sh +0 -82
  78. package/.claude/skills/cfn-redis-coordination/tests/run-test-suite.sh +0 -92
  79. package/.claude/skills/cfn-redis-coordination/tests/run-tests.sh +0 -4
  80. package/.claude/skills/cfn-redis-coordination/tests/test-heartbeat-monitoring.sh +0 -418
  81. package/.claude/skills/cfn-redis-coordination/tests/test-heartbeat-simple.sh +0 -124
  82. package/.claude/skills/cfn-redis-coordination/tests/test-primitives.sh +0 -166
  83. package/.claude/skills/cfn-redis-coordination/tests/test-utils.sh +0 -54
  84. package/.claude/skills/cfn-redis-coordination/tests/test_utils.sh +0 -49
  85. package/.claude/skills/cfn-redis-coordination/v2_modularization/core_orchestration.sh +0 -76
  86. package/.claude/skills/cfn-redis-coordination/validate-parameters.sh +0 -492
  87. package/claude-assets/skills/cfn-redis-coordination/HEARTBEAT.md +0 -57
  88. package/claude-assets/skills/cfn-redis-coordination/HEARTBEAT_MONITORING.md +0 -267
  89. package/claude-assets/skills/cfn-redis-coordination/LOGGING.md +0 -260
  90. package/claude-assets/skills/cfn-redis-coordination/README.md +0 -65
  91. package/claude-assets/skills/cfn-redis-coordination/SECURITY_REVIEW.md +0 -25
  92. package/claude-assets/skills/cfn-redis-coordination/SHUTDOWN_HANDLING.md +0 -164
  93. package/claude-assets/skills/cfn-redis-coordination/SKILL.md +0 -720
  94. package/claude-assets/skills/cfn-redis-coordination/demos/test-dlq.sh +0 -129
  95. package/claude-assets/skills/cfn-redis-coordination/demos/test-iteration-feedback.sh +0 -320
  96. package/claude-assets/skills/cfn-redis-coordination/demos/test-orchestrator.sh +0 -249
  97. package/claude-assets/skills/cfn-redis-coordination/demos/test-priority-wake-phase4-unix.sh +0 -148
  98. package/claude-assets/skills/cfn-redis-coordination/demos/test-priority-wake-phase4.sh +0 -163
  99. package/claude-assets/skills/cfn-redis-coordination/demos/test-priority-wake.sh +0 -138
  100. package/claude-assets/skills/cfn-redis-coordination/demos/test-quick-fix.sh +0 -81
  101. package/claude-assets/skills/cfn-redis-coordination/demos/test-quorum-absolute.sh +0 -45
  102. package/claude-assets/skills/cfn-redis-coordination/demos/test-quorum-fallback.sh +0 -68
  103. package/claude-assets/skills/cfn-redis-coordination/demos/test-quorum-percentage.sh +0 -56
  104. package/claude-assets/skills/cfn-redis-coordination/demos/test-quorum-with-retry.sh +0 -81
  105. package/claude-assets/skills/cfn-redis-coordination/demos/test-quorum.sh +0 -57
  106. package/claude-assets/skills/cfn-redis-coordination/demos/test-shutdown-handling.sh +0 -187
  107. package/claude-assets/skills/cfn-redis-coordination/demos/test-shutdown.sh +0 -160
  108. package/claude-assets/skills/cfn-redis-coordination/demos/test-utils-unix.sh +0 -97
  109. package/claude-assets/skills/cfn-redis-coordination/demos/test-utils.sh +0 -97
  110. package/claude-assets/skills/cfn-redis-coordination/demos/test-waiting-mode.sh +0 -59
  111. package/claude-assets/skills/cfn-redis-coordination/examples/README.md +0 -73
  112. package/claude-assets/skills/cfn-redis-coordination/examples/grafana-dashboard.json +0 -352
  113. package/claude-assets/skills/cfn-redis-coordination/examples/hierarchical-pattern.sh +0 -127
  114. package/claude-assets/skills/cfn-redis-coordination/examples/mesh-pattern.sh +0 -171
  115. package/claude-assets/skills/cfn-redis-coordination/examples/timeout-handling.sh +0 -227
  116. package/claude-assets/skills/cfn-redis-coordination/examples/waiting-mode-pattern.sh +0 -239
  117. package/claude-assets/skills/cfn-redis-coordination/execute-product-owner-decision.sh +0 -258
  118. package/claude-assets/skills/cfn-redis-coordination/get-agent-timeout.sh +0 -177
  119. package/claude-assets/skills/cfn-redis-coordination/heartbeat-functions.sh +0 -137
  120. package/claude-assets/skills/cfn-redis-coordination/heartbeat-protocol.md +0 -106
  121. package/claude-assets/skills/cfn-redis-coordination/heartbeat.sh +0 -126
  122. package/claude-assets/skills/cfn-redis-coordination/init-swarm.sh +0 -148
  123. package/claude-assets/skills/cfn-redis-coordination/invoke-redis-pattern.sh +0 -220
  124. package/claude-assets/skills/cfn-redis-coordination/invoke-waiting-mode.sh +0 -283
  125. package/claude-assets/skills/cfn-redis-coordination/list-active-swarms.sh +0 -147
  126. package/claude-assets/skills/cfn-redis-coordination/log-event.sh +0 -109
  127. package/claude-assets/skills/cfn-redis-coordination/metrics-export.sh +0 -674
  128. package/claude-assets/skills/cfn-redis-coordination/metrics-schema.json +0 -66
  129. package/claude-assets/skills/cfn-redis-coordination/metrics-storage.md +0 -31
  130. package/claude-assets/skills/cfn-redis-coordination/monitor-cfn-violations.sh +0 -391
  131. package/claude-assets/skills/cfn-redis-coordination/monitor-heartbeats.sh +0 -101
  132. package/claude-assets/skills/cfn-redis-coordination/orchestrate-cfn-loop-v3.sh +0 -141
  133. package/claude-assets/skills/cfn-redis-coordination/orchestrate-cfn-loop.sh +0 -31
  134. package/claude-assets/skills/cfn-redis-coordination/orchestrate-cfn-loop.sh.bak +0 -0
  135. package/claude-assets/skills/cfn-redis-coordination/priority-wake-mechanism.md +0 -75
  136. package/claude-assets/skills/cfn-redis-coordination/priority_wake.py +0 -134
  137. package/claude-assets/skills/cfn-redis-coordination/query-dlq.sh +0 -162
  138. package/claude-assets/skills/cfn-redis-coordination/query-logs.sh +0 -103
  139. package/claude-assets/skills/cfn-redis-coordination/redis-pattern.sh +0 -619
  140. package/claude-assets/skills/cfn-redis-coordination/retrieve-context.sh +0 -58
  141. package/claude-assets/skills/cfn-redis-coordination/select-specialist-agent.sh +0 -371
  142. package/claude-assets/skills/cfn-redis-coordination/semantic-match-tfidf.py +0 -252
  143. package/claude-assets/skills/cfn-redis-coordination/send-heartbeat.sh +0 -165
  144. package/claude-assets/skills/cfn-redis-coordination/signal.sh +0 -38
  145. package/claude-assets/skills/cfn-redis-coordination/store-context.sh +0 -86
  146. package/claude-assets/skills/cfn-redis-coordination/store-epic-context.sh +0 -123
  147. package/claude-assets/skills/cfn-redis-coordination/test-context-injection.sh +0 -354
  148. package/claude-assets/skills/cfn-redis-coordination/test-timeout-enforcement.sh +0 -513
  149. package/claude-assets/skills/cfn-redis-coordination/tests/convert-line-endings.sh +0 -15
  150. package/claude-assets/skills/cfn-redis-coordination/tests/dlq-functionality-test.sh +0 -102
  151. package/claude-assets/skills/cfn-redis-coordination/tests/edge-cases-test.sh +0 -99
  152. package/claude-assets/skills/cfn-redis-coordination/tests/integration-test.sh +0 -170
  153. package/claude-assets/skills/cfn-redis-coordination/tests/retry-mechanism-test.sh +0 -82
  154. package/claude-assets/skills/cfn-redis-coordination/tests/run-test-suite.sh +0 -92
  155. package/claude-assets/skills/cfn-redis-coordination/tests/run-tests.sh +0 -4
  156. package/claude-assets/skills/cfn-redis-coordination/tests/test-heartbeat-monitoring.sh +0 -418
  157. package/claude-assets/skills/cfn-redis-coordination/tests/test-heartbeat-simple.sh +0 -124
  158. package/claude-assets/skills/cfn-redis-coordination/tests/test-primitives.sh +0 -166
  159. package/claude-assets/skills/cfn-redis-coordination/tests/test-utils.sh +0 -54
  160. package/claude-assets/skills/cfn-redis-coordination/tests/test_utils.sh +0 -49
  161. package/claude-assets/skills/cfn-redis-coordination/v2_modularization/core_orchestration.sh +0 -76
  162. package/claude-assets/skills/cfn-redis-coordination/validate-parameters.sh +0 -492
@@ -1,127 +0,0 @@
1
- #!/bin/bash
2
- # Hierarchical Pattern: 1:Many Broadcast Coordination
3
- # Use Case: One agent's output feeds multiple downstream agents
4
- # Pattern: Coordinator receives result and broadcasts to multiple agent inboxes
5
-
6
- set -e
7
-
8
- TASK_ID="demo:hierarchical"
9
- TIMEOUT=300 # 5 minutes
10
-
11
- echo "=== Hierarchical Pattern Demo (1:Many Broadcast) ==="
12
- echo "Scenario: Researcher → [Analyzer, Architect, Coder]"
13
- echo ""
14
-
15
- # Cleanup previous demo data
16
- echo "Cleaning up previous demo data..."
17
- redis-cli del "${TASK_ID}:researcher:done" > /dev/null 2>&1 || true
18
- redis-cli del "${TASK_ID}:analyzer:inbox" > /dev/null 2>&1 || true
19
- redis-cli del "${TASK_ID}:architect:inbox" > /dev/null 2>&1 || true
20
- redis-cli del "${TASK_ID}:coder:inbox" > /dev/null 2>&1 || true
21
- redis-cli del "${TASK_ID}:coordinator:status" > /dev/null 2>&1 || true
22
-
23
- # Simulate Researcher Agent (runs in background)
24
- (
25
- echo "[Researcher] Starting research..."
26
- sleep 2
27
-
28
- FINDINGS='{
29
- "agent": "researcher",
30
- "confidence": 0.85,
31
- "findings": "JWT-based authentication recommended",
32
- "patterns": ["OAuth2", "JWT", "Session-based"],
33
- "recommendation": "Use JWT with refresh tokens"
34
- }'
35
-
36
- redis-cli lpush "${TASK_ID}:researcher:done" "$FINDINGS" > /dev/null
37
- echo "[Researcher] Research complete, published to ${TASK_ID}:researcher:done"
38
- ) &
39
-
40
- # Coordinator: Wait for researcher, then broadcast to multiple agents
41
- echo "[Coordinator] Waiting for researcher to complete..."
42
- RESEARCH_DATA=$(timeout $TIMEOUT redis-cli --csv blpop "${TASK_ID}:researcher:done" 0 2>/dev/null || echo "")
43
-
44
- if [ -z "$RESEARCH_DATA" ]; then
45
- echo "[Coordinator] ERROR: Researcher timeout after ${TIMEOUT}s"
46
- redis-cli lpush "${TASK_ID}:coordinator:status" '{"status":"error","error":"researcher_timeout"}' > /dev/null
47
- exit 1
48
- fi
49
-
50
- echo "[Coordinator] Received research data, broadcasting to 3 agents..."
51
-
52
- # Broadcast to multiple agents (separate inboxes)
53
- redis-cli lpush "${TASK_ID}:analyzer:inbox" "$RESEARCH_DATA" > /dev/null
54
- redis-cli lpush "${TASK_ID}:architect:inbox" "$RESEARCH_DATA" > /dev/null
55
- redis-cli lpush "${TASK_ID}:coder:inbox" "$RESEARCH_DATA" > /dev/null
56
-
57
- echo "[Coordinator] Broadcast complete to: analyzer, architect, coder"
58
-
59
- # Simulate Analyzer Agent
60
- (
61
- echo "[Analyzer] Waiting for research data in inbox..."
62
- DATA=$(timeout $TIMEOUT redis-cli --csv blpop "${TASK_ID}:analyzer:inbox" 0 2>/dev/null || echo "")
63
-
64
- if [ -z "$DATA" ]; then
65
- echo "[Analyzer] ERROR: Timeout waiting for data"
66
- exit 1
67
- fi
68
-
69
- echo "[Analyzer] Received data: ${DATA:0:50}..."
70
- echo "[Analyzer] Analyzing security implications..."
71
- sleep 1
72
- echo "[Analyzer] Analysis complete (confidence: 0.90)"
73
- ) &
74
-
75
- # Simulate Architect Agent
76
- (
77
- echo "[Architect] Waiting for research data in inbox..."
78
- DATA=$(timeout $TIMEOUT redis-cli --csv blpop "${TASK_ID}:architect:inbox" 0 2>/dev/null || echo "")
79
-
80
- if [ -z "$DATA" ]; then
81
- echo "[Architect] ERROR: Timeout waiting for data"
82
- exit 1
83
- fi
84
-
85
- echo "[Architect] Received data: ${DATA:0:50}..."
86
- echo "[Architect] Designing authentication architecture..."
87
- sleep 1
88
- echo "[Architect] Architecture designed (confidence: 0.88)"
89
- ) &
90
-
91
- # Simulate Coder Agent
92
- (
93
- echo "[Coder] Waiting for research data in inbox..."
94
- DATA=$(timeout $TIMEOUT redis-cli --csv blpop "${TASK_ID}:coder:inbox" 0 2>/dev/null || echo "")
95
-
96
- if [ -z "$DATA" ]; then
97
- echo "[Coder] ERROR: Timeout waiting for data"
98
- exit 1
99
- fi
100
-
101
- echo "[Coder] Received data: ${DATA:0:50}..."
102
- echo "[Coder] Implementing JWT authentication..."
103
- sleep 1
104
- echo "[Coder] Implementation complete (confidence: 0.86)"
105
- ) &
106
-
107
- # Wait for all background jobs to complete
108
- wait
109
-
110
- echo ""
111
- echo "=== Hierarchical Pattern Complete ==="
112
- echo "✅ Coordinator successfully broadcast researcher data to 3 agents"
113
- echo "✅ All agents received data in parallel from dedicated inboxes"
114
- echo "✅ No message loss (BLPOP destructive limitation solved)"
115
- echo ""
116
- echo "Key Pattern:"
117
- echo " 1. Researcher → coordinator (LPUSH/BLPOP)"
118
- echo " 2. Coordinator → 3 separate agent inboxes (LPUSH x3)"
119
- echo " 3. Each agent reads from dedicated inbox (BLPOP)"
120
- echo ""
121
-
122
- # Cleanup
123
- redis-cli del "${TASK_ID}:researcher:done" > /dev/null 2>&1 || true
124
- redis-cli del "${TASK_ID}:analyzer:inbox" > /dev/null 2>&1 || true
125
- redis-cli del "${TASK_ID}:architect:inbox" > /dev/null 2>&1 || true
126
- redis-cli del "${TASK_ID}:coder:inbox" > /dev/null 2>&1 || true
127
- redis-cli del "${TASK_ID}:coordinator:status" > /dev/null 2>&1 || true
@@ -1,171 +0,0 @@
1
- #!/bin/bash
2
- # Mesh Pattern: Many:1 Aggregation Coordination
3
- # Use Case: Multiple agents complete independently, one agent waits for ALL
4
- # Pattern: Hybrid LPUSH (first waiter) + SET (additional readers)
5
-
6
- set -e
7
-
8
- TASK_ID="demo:mesh"
9
- TIMEOUT=300 # 5 minutes
10
-
11
- echo "=== Mesh Pattern Demo (Many:1 Aggregation) ==="
12
- echo "Scenario: [Coder, Tester, Reviewer] → Validator"
13
- echo ""
14
-
15
- # Cleanup previous demo data
16
- echo "Cleaning up previous demo data..."
17
- redis-cli del "${TASK_ID}:coder:done" > /dev/null 2>&1 || true
18
- redis-cli del "${TASK_ID}:coder:result" > /dev/null 2>&1 || true
19
- redis-cli del "${TASK_ID}:tester:done" > /dev/null 2>&1 || true
20
- redis-cli del "${TASK_ID}:tester:result" > /dev/null 2>&1 || true
21
- redis-cli del "${TASK_ID}:reviewer:done" > /dev/null 2>&1 || true
22
- redis-cli del "${TASK_ID}:reviewer:result" > /dev/null 2>&1 || true
23
- redis-cli del "${TASK_ID}:validator:result" > /dev/null 2>&1 || true
24
-
25
- # Simulate Coder Agent (runs in background)
26
- (
27
- echo "[Coder] Implementing authentication feature..."
28
- sleep 2
29
-
30
- RESULT='{
31
- "agent": "coder",
32
- "confidence": 0.86,
33
- "filesModified": ["auth.js", "auth.test.js"],
34
- "linesAdded": 245,
35
- "status": "complete"
36
- }'
37
-
38
- # Hybrid pattern: LPUSH for first waiter, SET for additional readers
39
- redis-cli lpush "${TASK_ID}:coder:done" "$RESULT" > /dev/null
40
- redis-cli set "${TASK_ID}:coder:result" "$RESULT" > /dev/null
41
- redis-cli expire "${TASK_ID}:coder:result" 3600 > /dev/null # 1 hour TTL
42
-
43
- echo "[Coder] Implementation complete, published results"
44
- ) &
45
-
46
- # Simulate Tester Agent (runs in background)
47
- (
48
- echo "[Tester] Running test suite..."
49
- sleep 3
50
-
51
- RESULT='{
52
- "agent": "tester",
53
- "confidence": 0.92,
54
- "testsRun": 45,
55
- "testsPassed": 45,
56
- "coverage": 0.94,
57
- "status": "complete"
58
- }'
59
-
60
- # Hybrid pattern: LPUSH + SET
61
- redis-cli lpush "${TASK_ID}:tester:done" "$RESULT" > /dev/null
62
- redis-cli set "${TASK_ID}:tester:result" "$RESULT" > /dev/null
63
- redis-cli expire "${TASK_ID}:tester:result" 3600 > /dev/null
64
-
65
- echo "[Tester] Tests complete (45/45 passed, 94% coverage)"
66
- ) &
67
-
68
- # Simulate Reviewer Agent (runs in background)
69
- (
70
- echo "[Reviewer] Reviewing code quality..."
71
- sleep 2.5
72
-
73
- RESULT='{
74
- "agent": "reviewer",
75
- "confidence": 0.88,
76
- "issuesFound": 2,
77
- "severity": "low",
78
- "recommendations": ["Add input validation", "Improve error messages"],
79
- "status": "complete"
80
- }'
81
-
82
- # Hybrid pattern: LPUSH + SET
83
- redis-cli lpush "${TASK_ID}:reviewer:done" "$RESULT" > /dev/null
84
- redis-cli set "${TASK_ID}:reviewer:result" "$RESULT" > /dev/null
85
- redis-cli expire "${TASK_ID}:reviewer:result" 3600 > /dev/null
86
-
87
- echo "[Reviewer] Review complete (2 low-severity issues)"
88
- ) &
89
-
90
- # Validator: Wait for ALL three agents (first uses BLPOP, rest use GET)
91
- echo "[Validator] Waiting for coder, tester, and reviewer to complete..."
92
-
93
- # First agent: Use BLPOP (blocking wait)
94
- CODER_DATA=$(timeout $TIMEOUT redis-cli --csv blpop "${TASK_ID}:coder:done" 0 2>/dev/null || echo "")
95
- if [ -z "$CODER_DATA" ]; then
96
- echo "[Validator] ERROR: Coder timeout after ${TIMEOUT}s"
97
- exit 1
98
- fi
99
- echo "[Validator] ✓ Coder complete"
100
-
101
- # Second agent: Use GET (non-blocking, from persistent SET)
102
- TESTER_DATA=""
103
- for i in {1..60}; do
104
- TESTER_DATA=$(redis-cli get "${TASK_ID}:tester:result" 2>/dev/null || echo "")
105
- if [ -n "$TESTER_DATA" ]; then
106
- break
107
- fi
108
- sleep 1
109
- done
110
-
111
- if [ -z "$TESTER_DATA" ]; then
112
- echo "[Validator] ERROR: Tester timeout after 60s"
113
- exit 1
114
- fi
115
- echo "[Validator] ✓ Tester complete"
116
-
117
- # Third agent: Use GET (non-blocking, from persistent SET)
118
- REVIEWER_DATA=""
119
- for i in {1..60}; do
120
- REVIEWER_DATA=$(redis-cli get "${TASK_ID}:reviewer:result" 2>/dev/null || echo "")
121
- if [ -n "$REVIEWER_DATA" ]; then
122
- break
123
- fi
124
- sleep 1
125
- done
126
-
127
- if [ -z "$REVIEWER_DATA" ]; then
128
- echo "[Validator] ERROR: Reviewer timeout after 60s"
129
- exit 1
130
- fi
131
- echo "[Validator] ✓ Reviewer complete"
132
-
133
- # Wait for all background jobs to complete
134
- wait
135
-
136
- echo ""
137
- echo "[Validator] All agents complete, aggregating results..."
138
-
139
- # Calculate aggregate confidence (simple average)
140
- echo "[Validator] Aggregate confidence: ~0.89 (coder: 0.86, tester: 0.92, reviewer: 0.88)"
141
-
142
- VALIDATION_RESULT='{
143
- "agent": "validator",
144
- "status": "validated",
145
- "aggregateConfidence": 0.89,
146
- "summary": "All components validated successfully"
147
- }'
148
-
149
- redis-cli set "${TASK_ID}:validator:result" "$VALIDATION_RESULT" > /dev/null
150
- redis-cli expire "${TASK_ID}:validator:result" 3600 > /dev/null
151
-
152
- echo ""
153
- echo "=== Mesh Pattern Complete ==="
154
- echo "✅ Three agents completed independently in parallel"
155
- echo "✅ Validator successfully aggregated all results"
156
- echo "✅ Hybrid LPUSH+SET pattern prevented BLPOP message loss"
157
- echo ""
158
- echo "Key Pattern:"
159
- echo " 1. Each agent: LPUSH (for first waiter) + SET (for additional readers)"
160
- echo " 2. Validator: BLPOP for first agent, GET for remaining agents"
161
- echo " 3. SET keys have 1-hour expiry for cleanup"
162
- echo ""
163
-
164
- # Cleanup
165
- redis-cli del "${TASK_ID}:coder:done" > /dev/null 2>&1 || true
166
- redis-cli del "${TASK_ID}:coder:result" > /dev/null 2>&1 || true
167
- redis-cli del "${TASK_ID}:tester:done" > /dev/null 2>&1 || true
168
- redis-cli del "${TASK_ID}:tester:result" > /dev/null 2>&1 || true
169
- redis-cli del "${TASK_ID}:reviewer:done" > /dev/null 2>&1 || true
170
- redis-cli del "${TASK_ID}:reviewer:result" > /dev/null 2>&1 || true
171
- redis-cli del "${TASK_ID}:validator:result" > /dev/null 2>&1 || true
@@ -1,227 +0,0 @@
1
- #!/bin/bash
2
- # Timeout Handling: Comprehensive timeout patterns for Redis coordination
3
- # Demonstrates proper timeout handling, error reporting, and recovery strategies
4
-
5
- set -e
6
-
7
- TASK_ID="demo:timeout"
8
- SHORT_TIMEOUT=5 # 5 seconds (for demo of timeout failure)
9
- NORMAL_TIMEOUT=300 # 5 minutes (production default)
10
-
11
- echo "=== Timeout Handling Demo ==="
12
- echo ""
13
-
14
- # Cleanup previous demo data
15
- echo "Cleaning up previous demo data..."
16
- redis-cli del "${TASK_ID}:slow-agent:done" > /dev/null 2>&1 || true
17
- redis-cli del "${TASK_ID}:fast-agent:done" > /dev/null 2>&1 || true
18
- redis-cli del "${TASK_ID}:coordinator:error" > /dev/null 2>&1 || true
19
- redis-cli del "${TASK_ID}:coordinator:status" > /dev/null 2>&1 || true
20
-
21
- echo "--- Scenario 1: Timeout Failure (Agent Too Slow) ---"
22
- echo ""
23
-
24
- # Simulate slow agent that exceeds timeout (runs in background)
25
- (
26
- echo "[Slow Agent] Starting work..."
27
- sleep 10 # Takes 10s but timeout is 5s
28
-
29
- RESULT='{"agent":"slow-agent","confidence":0.85,"status":"complete"}'
30
- redis-cli lpush "${TASK_ID}:slow-agent:done" "$RESULT" > /dev/null
31
- echo "[Slow Agent] Work complete (but too late...)"
32
- ) &
33
-
34
- SLOW_AGENT_PID=$!
35
-
36
- # Coordinator waits with short timeout
37
- echo "[Coordinator] Waiting for slow-agent with ${SHORT_TIMEOUT}s timeout..."
38
- RESULT=$(timeout $SHORT_TIMEOUT redis-cli --csv blpop "${TASK_ID}:slow-agent:done" 0 2>/dev/null || echo "")
39
- EXIT_CODE=$?
40
-
41
- if [ $EXIT_CODE -eq 124 ]; then
42
- echo "[Coordinator] ❌ ERROR: Slow agent timeout after ${SHORT_TIMEOUT}s"
43
-
44
- # Report error to coordinator error channel
45
- ERROR_REPORT='{
46
- "agent": "slow-agent",
47
- "error": "timeout",
48
- "timeout": '${SHORT_TIMEOUT}',
49
- "timestamp": "'$(date -u +"%Y-%m-%dT%H:%M:%SZ")'"
50
- }'
51
-
52
- redis-cli lpush "${TASK_ID}:coordinator:error" "$ERROR_REPORT" > /dev/null
53
- echo "[Coordinator] Error reported to ${TASK_ID}:coordinator:error"
54
-
55
- # Kill slow agent background process
56
- kill $SLOW_AGENT_PID 2>/dev/null || true
57
-
58
- echo "[Coordinator] Decision: Terminate slow agent and retry with different agent"
59
- else
60
- echo "[Coordinator] ✓ Slow agent completed within timeout"
61
- fi
62
-
63
- echo ""
64
- echo "--- Scenario 2: Timeout Success (Agent Fast Enough) ---"
65
- echo ""
66
-
67
- # Simulate fast agent that completes within timeout (runs in background)
68
- (
69
- echo "[Fast Agent] Starting work..."
70
- sleep 2 # Takes 2s, well within 5s timeout
71
-
72
- RESULT='{"agent":"fast-agent","confidence":0.90,"status":"complete"}'
73
- redis-cli lpush "${TASK_ID}:fast-agent:done" "$RESULT" > /dev/null
74
- echo "[Fast Agent] Work complete"
75
- ) &
76
-
77
- # Coordinator waits with short timeout
78
- echo "[Coordinator] Waiting for fast-agent with ${SHORT_TIMEOUT}s timeout..."
79
- RESULT=$(timeout $SHORT_TIMEOUT redis-cli --csv blpop "${TASK_ID}:fast-agent:done" 0 2>/dev/null || echo "")
80
- EXIT_CODE=$?
81
-
82
- if [ $EXIT_CODE -eq 124 ]; then
83
- echo "[Coordinator] ❌ ERROR: Fast agent timeout after ${SHORT_TIMEOUT}s"
84
- else
85
- echo "[Coordinator] ✓ Fast agent completed within timeout"
86
- echo "[Coordinator] Result: ${RESULT:0:80}..."
87
- fi
88
-
89
- wait
90
-
91
- echo ""
92
- echo "--- Scenario 3: Multi-Agent Timeout with Recovery ---"
93
- echo ""
94
-
95
- # Cleanup
96
- redis-cli del "${TASK_ID}:agent-1:done" > /dev/null 2>&1 || true
97
- redis-cli del "${TASK_ID}:agent-2:done" > /dev/null 2>&1 || true
98
- redis-cli del "${TASK_ID}:agent-3:done" > /dev/null 2>&1 || true
99
-
100
- # Simulate 3 agents with varying completion times
101
- (
102
- sleep 1
103
- redis-cli lpush "${TASK_ID}:agent-1:done" '{"agent":"agent-1","confidence":0.85}' > /dev/null
104
- echo "[Agent 1] Complete (1s)"
105
- ) &
106
-
107
- (
108
- sleep 2
109
- redis-cli lpush "${TASK_ID}:agent-2:done" '{"agent":"agent-2","confidence":0.90}' > /dev/null
110
- echo "[Agent 2] Complete (2s)"
111
- ) &
112
-
113
- (
114
- sleep 15 # Too slow - exceeds 5s timeout
115
- redis-cli lpush "${TASK_ID}:agent-3:done" '{"agent":"agent-3","confidence":0.88}' > /dev/null
116
- echo "[Agent 3] Complete (15s - too late)"
117
- ) &
118
-
119
- AGENT_3_PID=$!
120
-
121
- echo "[Coordinator] Waiting for 3 agents with ${SHORT_TIMEOUT}s timeout each..."
122
-
123
- # Wait for agent 1
124
- RESULT_1=$(timeout $SHORT_TIMEOUT redis-cli --csv blpop "${TASK_ID}:agent-1:done" 0 2>/dev/null || echo "")
125
- if [ -z "$RESULT_1" ]; then
126
- echo "[Coordinator] ❌ Agent 1 timeout"
127
- AGENT_1_FAILED=1
128
- else
129
- echo "[Coordinator] ✓ Agent 1 complete"
130
- AGENT_1_FAILED=0
131
- fi
132
-
133
- # Wait for agent 2
134
- RESULT_2=$(timeout $SHORT_TIMEOUT redis-cli --csv blpop "${TASK_ID}:agent-2:done" 0 2>/dev/null || echo "")
135
- if [ -z "$RESULT_2" ]; then
136
- echo "[Coordinator] ❌ Agent 2 timeout"
137
- AGENT_2_FAILED=1
138
- else
139
- echo "[Coordinator] ✓ Agent 2 complete"
140
- AGENT_2_FAILED=0
141
- fi
142
-
143
- # Wait for agent 3
144
- RESULT_3=$(timeout $SHORT_TIMEOUT redis-cli --csv blpop "${TASK_ID}:agent-3:done" 0 2>/dev/null || echo "")
145
- if [ -z "$RESULT_3" ]; then
146
- echo "[Coordinator] ❌ Agent 3 timeout"
147
- AGENT_3_FAILED=1
148
-
149
- # Kill agent 3 background process
150
- kill $AGENT_3_PID 2>/dev/null || true
151
- else
152
- echo "[Coordinator] ✓ Agent 3 complete"
153
- AGENT_3_FAILED=0
154
- fi
155
-
156
- # Calculate success rate
157
- FAILED_COUNT=$((AGENT_1_FAILED + AGENT_2_FAILED + AGENT_3_FAILED))
158
- SUCCESS_COUNT=$((3 - FAILED_COUNT))
159
-
160
- echo ""
161
- echo "[Coordinator] Results: $SUCCESS_COUNT/3 agents completed within timeout"
162
-
163
- if [ $SUCCESS_COUNT -ge 2 ]; then
164
- echo "[Coordinator] Decision: PROCEED with partial results (2/3 quorum met)"
165
-
166
- STATUS='{"status":"partial_success","completed":'$SUCCESS_COUNT',"failed":'$FAILED_COUNT',"decision":"proceed"}'
167
- redis-cli set "${TASK_ID}:coordinator:status" "$STATUS" > /dev/null
168
- else
169
- echo "[Coordinator] Decision: RETRY all agents (quorum not met)"
170
-
171
- STATUS='{"status":"insufficient_quorum","completed":'$SUCCESS_COUNT',"failed":'$FAILED_COUNT',"decision":"retry"}'
172
- redis-cli set "${TASK_ID}:coordinator:status" "$STATUS" > /dev/null
173
- fi
174
-
175
- wait
176
-
177
- echo ""
178
- echo "--- Scenario 4: Timeout Best Practices ---"
179
- echo ""
180
-
181
- echo "✓ Timeout Guidelines:"
182
- echo " - Normal operations: 300s (5 minutes)"
183
- echo " - Research tasks: 600s (10 minutes)"
184
- echo " - Complex builds: 900s (15 minutes)"
185
- echo " - Testing: 600s (10 minutes)"
186
- echo ""
187
-
188
- echo "✓ Timeout Handling Pattern:"
189
- echo ' result=$(timeout 300 redis-cli --csv blpop "channel" 0 2>/dev/null || echo "")'
190
- echo ' if [ $? -eq 124 ]; then'
191
- echo ' echo "TIMEOUT"'
192
- echo ' redis-cli lpush "coordinator:error" '"'"'{"error":"timeout"}'"'"
193
- echo ' fi'
194
- echo ""
195
-
196
- echo "✓ Error Reporting:"
197
- echo " - Always report timeout to coordinator:error channel"
198
- echo " - Include agent ID, timeout duration, timestamp"
199
- echo " - Coordinator decides: retry, skip, or escalate"
200
- echo ""
201
-
202
- echo "✓ Recovery Strategies:"
203
- echo " - Single agent timeout: Retry once with extended timeout"
204
- echo " - Multiple agent timeout: Check quorum (2/3 pass = proceed)"
205
- echo " - Critical agent timeout: Escalate to main chat"
206
- echo " - Repeated timeouts: Switch to different agent type"
207
- echo ""
208
-
209
- echo "=== Timeout Handling Demo Complete ==="
210
- echo ""
211
- echo "Key Takeaways:"
212
- echo " 1. ALWAYS use timeout command with BLPOP"
213
- echo " 2. Check exit code 124 for timeout detection"
214
- echo " 3. Report timeouts to coordinator:error channel"
215
- echo " 4. Implement recovery strategies (retry/skip/escalate)"
216
- echo " 5. Use appropriate timeout values for task type"
217
- echo " 6. Kill/cleanup timed-out background processes"
218
- echo ""
219
-
220
- # Cleanup
221
- redis-cli del "${TASK_ID}:slow-agent:done" > /dev/null 2>&1 || true
222
- redis-cli del "${TASK_ID}:fast-agent:done" > /dev/null 2>&1 || true
223
- redis-cli del "${TASK_ID}:agent-1:done" > /dev/null 2>&1 || true
224
- redis-cli del "${TASK_ID}:agent-2:done" > /dev/null 2>&1 || true
225
- redis-cli del "${TASK_ID}:agent-3:done" > /dev/null 2>&1 || true
226
- redis-cli del "${TASK_ID}:coordinator:error" > /dev/null 2>&1 || true
227
- redis-cli del "${TASK_ID}:coordinator:status" > /dev/null 2>&1 || true