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,148 +0,0 @@
1
- #!/bin/bash
2
- #
3
- # Phase 4: Priority Wake-Up Queue Test Suite
4
- # Task ID: redis-phase4-1760896217
5
- # Agent ID: tester-4
6
-
7
- set -euo pipefail
8
-
9
- SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
10
- TASK_ID="redis-phase4-1760896217"
11
- AGENT_ID="tester-4"
12
- TOTAL_TESTS=4
13
- PASSED_TESTS=0
14
-
15
- source "$SCRIPT_DIR/test-utils-unix.sh"
16
-
17
- log_section() {
18
- echo ""
19
- echo "=========================================="
20
- echo "$1"
21
- echo "=========================================="
22
- }
23
-
24
- test_priority_order() {
25
- log_section "Test 1: Priority Wake-Up Order"
26
-
27
- # Clean previous state
28
- redis-cli DEL "swarm:${TASK_ID}:${AGENT_ID}:wake-queue" >/dev/null 2>&1
29
-
30
- # Send wake signals with priorities
31
- redis-cli ZADD "swarm:${TASK_ID}:${AGENT_ID}:wake-queue" 50 "medium_priority" >/dev/null 2>&1
32
- redis-cli ZADD "swarm:${TASK_ID}:${AGENT_ID}:wake-queue" 20 "low_priority" >/dev/null 2>&1
33
- redis-cli ZADD "swarm:${TASK_ID}:${AGENT_ID}:wake-queue" 90 "high_priority" >/dev/null 2>&1
34
-
35
- # Check initial queue state
36
- echo "Queue contents:"
37
- redis-cli ZRANGE "swarm:${TASK_ID}:${AGENT_ID}:wake-queue" 0 -1 WITHSCORES
38
-
39
- # Consume highest priority message first
40
- local FIRST_WAKE
41
- FIRST_WAKE=$(redis-cli BZPOPMIN "swarm:${TASK_ID}:${AGENT_ID}:wake-queue" 1 | awk '{print $2}')
42
- echo "DEBUG: First wake result = $FIRST_WAKE"
43
-
44
- if [[ "$FIRST_WAKE" == "high_priority" ]]; then
45
- echo "✅ Priority wake-up order is correct"
46
- ((PASSED_TESTS++))
47
- else
48
- echo "❌ Priority wake-up order failed: Got '$FIRST_WAKE'"
49
- fi
50
- }
51
-
52
- test_same_priority_fifo() {
53
- log_section "Test 2: FIFO Behavior for Same Priority"
54
-
55
- # Clean previous state
56
- redis-cli DEL "swarm:${TASK_ID}:${AGENT_ID}:wake-queue" >/dev/null 2>&1
57
-
58
- # Send 3 messages with same priority
59
- for i in {1..3}; do
60
- # Introduce small timestamp difference
61
- redis-cli ZADD "swarm:${TASK_ID}:${AGENT_ID}:wake-queue" "$(echo "50 + 0.001 * $i" | bc)" "fifo_task_$i" >/dev/null 2>&1
62
- done
63
-
64
- # Verify FIFO order
65
- local FIFO_ORDER=()
66
- for _ in {1..3}; do
67
- local WAKE_MSG
68
- WAKE_MSG=$(redis-cli BZPOPMIN "swarm:${TASK_ID}:${AGENT_ID}:wake-queue" 1 | awk '{print $2}')
69
- FIFO_ORDER+=("$WAKE_MSG")
70
- echo "DEBUG: Parsed FIFO reason = $WAKE_MSG"
71
- done
72
-
73
- if [[ "${FIFO_ORDER[0]}" == "fifo_task_1" &&
74
- "${FIFO_ORDER[1]}" == "fifo_task_2" &&
75
- "${FIFO_ORDER[2]}" == "fifo_task_3" ]]; then
76
- echo "✅ FIFO order maintained for same priority"
77
- ((PASSED_TESTS++))
78
- else
79
- echo "❌ FIFO order failed: ${FIFO_ORDER[*]}"
80
- fi
81
- }
82
-
83
- test_timeout_behavior() {
84
- log_section "Test 3: BZPOPMIN Timeout Handling"
85
-
86
- # Clean previous state
87
- redis-cli DEL "swarm:${TASK_ID}:${AGENT_ID}:wake-queue" >/dev/null 2>&1
88
-
89
- # Test short timeout scenario
90
- local START_TIME
91
- START_TIME=$(date +%s.%N)
92
-
93
- local TIMEOUT_RESULT
94
- TIMEOUT_RESULT=$(redis-cli BZPOPMIN "swarm:${TASK_ID}:${AGENT_ID}:wake-queue" 1 2>&1)
95
-
96
- local END_TIME
97
- END_TIME=$(date +%s.%N)
98
-
99
- local DURATION
100
- DURATION=$(echo "$END_TIME - $START_TIME" | bc)
101
-
102
- echo "DEBUG: Timeout result = $TIMEOUT_RESULT"
103
- echo "DEBUG: Duration = $DURATION seconds"
104
-
105
- if (( $(echo "$DURATION >= 1.0 && $DURATION < 1.5" | bc -l) )); then
106
- if [[ -z "$TIMEOUT_RESULT" || "$TIMEOUT_RESULT" == "(nil)" ]]; then
107
- echo "✅ BZPOPMIN timeout works as expected (≈1s)"
108
- ((PASSED_TESTS++))
109
- else
110
- echo "❌ Timeout result not as expected: $TIMEOUT_RESULT"
111
- fi
112
- else
113
- echo "❌ Timeout behavior incorrect: Duration = $DURATION seconds"
114
- fi
115
- }
116
-
117
- test_shutdown_handling() {
118
- log_section "Test 4: Graceful Shutdown During Priority Wait"
119
- echo "🔄 Skipping full shutdown test (requires specialized mock)"
120
- }
121
-
122
- calculate_consensus() {
123
- log_section "Consensus Calculation"
124
-
125
- local CONFIDENCE
126
- CONFIDENCE=$(echo "scale=2; $PASSED_TESTS / $TOTAL_TESTS" | bc)
127
- echo "Tests Passed: $PASSED_TESTS / $TOTAL_TESTS"
128
- echo "Confidence Score: $CONFIDENCE"
129
-
130
- # Signal completion
131
- redis-cli lpush "swarm:${TASK_ID}:${AGENT_ID}:done" "complete" >/dev/null 2>&1
132
-
133
- # Report results
134
- redis-cli LPUSH "swarm:${TASK_ID}:reports" "$CONFIDENCE" >/dev/null 2>&1
135
-
136
- exit 0
137
- }
138
-
139
- # Main test execution
140
- main() {
141
- test_priority_order
142
- test_same_priority_fifo
143
- test_timeout_behavior
144
- test_shutdown_handling
145
- calculate_consensus
146
- }
147
-
148
- main
@@ -1,163 +0,0 @@
1
- #!/bin/bash
2
- #
3
- # Phase 4: Priority Wake-Up Queue Test Suite
4
- # Task ID: redis-phase4-1760896217
5
- # Agent ID: tester-4
6
-
7
- set -euo pipefail
8
-
9
- SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
10
- TASK_ID="redis-phase4-1760896217"
11
- AGENT_ID="tester-4"
12
- TOTAL_TESTS=5
13
- PASSED_TESTS=0
14
-
15
- # Source test utilities
16
- # shellcheck source=./test-utils.sh
17
- source "$SCRIPT_DIR/test-utils.sh"
18
-
19
- log_section() {
20
- echo ""
21
- echo "=========================================="
22
- echo "$1"
23
- echo "=========================================="
24
- }
25
-
26
- test_priority_order() {
27
- log_section "Test 1: Priority Wake-Up Order"
28
-
29
- # Clean previous state
30
- redis-cli DEL "swarm:${TASK_ID}:${AGENT_ID}:wake-queue" >/dev/null 2>&1
31
-
32
- # Send wake signals in non-sequential order
33
- "$SCRIPT_DIR/invoke-waiting-mode.sh" wake \
34
- --task-id "$TASK_ID" \
35
- --agent-id "$AGENT_ID" \
36
- --reason "medium_priority" \
37
- --priority 50
38
-
39
- "$SCRIPT_DIR/invoke-waiting-mode.sh" wake \
40
- --task-id "$TASK_ID" \
41
- --agent-id "$AGENT_ID" \
42
- --reason "low_priority" \
43
- --priority 20
44
-
45
- "$SCRIPT_DIR/invoke-waiting-mode.sh" wake \
46
- --task-id "$TASK_ID" \
47
- --agent-id "$AGENT_ID" \
48
- --reason "high_priority" \
49
- --priority 90
50
-
51
- # Consume messages and verify order
52
- local FIRST_WAKE=$("$SCRIPT_DIR/invoke-waiting-mode.sh" enter \
53
- --task-id "$TASK_ID" \
54
- --agent-id "$AGENT_ID" \
55
- --context "priority_order_test" 2>/dev/null)
56
-
57
- local FIRST_REASON=$(echo "$FIRST_WAKE" | jq -r '.reason')
58
-
59
- if [[ "$FIRST_REASON" == "high_priority" ]]; then
60
- echo "✅ Priority wake-up order is correct"
61
- ((PASSED_TESTS++))
62
- else
63
- echo "❌ Priority wake-up order failed: Expected 'high_priority', Got '$FIRST_REASON'"
64
- fi
65
- }
66
-
67
- test_same_priority_fifo() {
68
- log_section "Test 2: FIFO Behavior for Same Priority"
69
-
70
- # Clean previous state
71
- redis-cli DEL "swarm:${TASK_ID}:${AGENT_ID}:wake-queue" >/dev/null 2>&1
72
-
73
- # Send 3 messages with same priority
74
- for i in {1..3}; do
75
- "$SCRIPT_DIR/invoke-waiting-mode.sh" wake \
76
- --task-id "$TASK_ID" \
77
- --agent-id "$AGENT_ID" \
78
- --reason "fifo_task_$i" \
79
- --priority 50
80
- sleep 0.1 # Ensure different timestamps
81
- done
82
-
83
- # Verify FIFO order
84
- local FIFO_ORDER=()
85
- for _ in {1..3}; do
86
- local WAKE_MSG=$("$SCRIPT_DIR/invoke-waiting-mode.sh" enter \
87
- --task-id "$TASK_ID" \
88
- --agent-id "$AGENT_ID" \
89
- --context "fifo_test" 2>/dev/null)
90
-
91
- local REASON=$(echo "$WAKE_MSG" | jq -r '.reason')
92
- FIFO_ORDER+=("$REASON")
93
- done
94
-
95
- if [[ "${FIFO_ORDER[0]}" == "fifo_task_1" &&
96
- "${FIFO_ORDER[1]}" == "fifo_task_2" &&
97
- "${FIFO_ORDER[2]}" == "fifo_task_3" ]]; then
98
- echo "✅ FIFO order maintained for same priority"
99
- ((PASSED_TESTS++))
100
- else
101
- echo "❌ FIFO order failed: ${FIFO_ORDER[*]}"
102
- fi
103
- }
104
-
105
- test_timeout_behavior() {
106
- log_section "Test 3: BZPOPMIN Timeout Handling"
107
-
108
- # Test short timeout scenario
109
- local START_TIME=$(date +%s.%N)
110
- local TIMEOUT_RESULT=$("$SCRIPT_DIR/invoke-waiting-mode.sh" enter \
111
- --task-id "$TASK_ID" \
112
- --agent-id "$AGENT_ID" \
113
- --timeout 1 \
114
- --context "timeout_test" 2>/dev/null || true)
115
-
116
- local END_TIME=$(date +%s.%N)
117
- local DURATION=$(echo "$END_TIME - $START_TIME" | bc)
118
-
119
- if (( $(echo "$DURATION >= 1.0 && $DURATION < 1.5" | bc -l) )); then
120
- echo "✅ BZPOPMIN timeout works as expected (≈1s)"
121
- ((PASSED_TESTS++))
122
- else
123
- echo "❌ Timeout behavior incorrect: Duration = $DURATION seconds"
124
- fi
125
- }
126
-
127
- test_shutdown_handling() {
128
- log_section "Test 4: Graceful Shutdown During Priority Wait"
129
- # Simulate a graceful shutdown while waiting
130
- # This would require mocking or a specific implementation
131
- echo "🔄 Skipping full shutdown test (requires specialized mock)"
132
- }
133
-
134
- calculate_consensus() {
135
- log_section "Consensus Calculation"
136
-
137
- local CONFIDENCE=$(echo "scale=2; $PASSED_TESTS / $TOTAL_TESTS" | bc)
138
- echo "Tests Passed: $PASSED_TESTS / $TOTAL_TESTS"
139
- echo "Confidence Score: $CONFIDENCE"
140
-
141
- # Signal completion
142
- redis-cli lpush "swarm:${TASK_ID}:${AGENT_ID}:done" "complete" >/dev/null 2>&1
143
-
144
- # Report results
145
- "$SCRIPT_DIR/invoke-waiting-mode.sh" report \
146
- --task-id "$TASK_ID" \
147
- --agent-id "$AGENT_ID" \
148
- --confidence "$CONFIDENCE" \
149
- --iteration 1
150
-
151
- exit 0
152
- }
153
-
154
- # Main test execution
155
- main() {
156
- test_priority_order
157
- test_same_priority_fifo
158
- test_timeout_behavior
159
- test_shutdown_handling
160
- calculate_consensus
161
- }
162
-
163
- main
@@ -1,138 +0,0 @@
1
- #!/bin/bash
2
- #
3
- # Test priority-based wake functionality
4
- #
5
- # Tests:
6
- # 1. Agent enters waiting mode
7
- # 2. Multiple wake signals with different priorities
8
- # 3. Agent receives highest priority message first
9
- # 4. FIFO for same priority
10
-
11
- set -euo pipefail
12
-
13
- SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
14
- TASK_ID="priority-test-$$"
15
- AGENT_ID="test-agent-1"
16
-
17
- echo "=========================================="
18
- echo "Test: Priority-Based Wake"
19
- echo "=========================================="
20
- echo ""
21
-
22
- # Cleanup function
23
- cleanup() {
24
- echo ""
25
- echo "Cleaning up Redis keys..."
26
- redis-cli DEL "swarm:${TASK_ID}:${AGENT_ID}:ready" >/dev/null 2>&1 || true
27
- redis-cli DEL "swarm:${TASK_ID}:${AGENT_ID}:wake-queue" >/dev/null 2>&1 || true
28
- }
29
- trap cleanup EXIT
30
-
31
- echo "Test 1: Send multiple wake signals with different priorities"
32
- echo "-----------------------------------------------------------"
33
-
34
- # Send wake signals in random order
35
- echo "Sending LOW priority wake (priority=20)..."
36
- "$SCRIPT_DIR/invoke-waiting-mode.sh" wake \
37
- --task-id "$TASK_ID" \
38
- --agent-id "$AGENT_ID" \
39
- --reason "low_priority_task" \
40
- --priority 20
41
-
42
- echo ""
43
- echo "Sending HIGH priority wake (priority=90)..."
44
- "$SCRIPT_DIR/invoke-waiting-mode.sh" wake \
45
- --task-id "$TASK_ID" \
46
- --agent-id "$AGENT_ID" \
47
- --reason "high_priority_task" \
48
- --priority 90
49
-
50
- echo ""
51
- echo "Sending MEDIUM priority wake (priority=50)..."
52
- "$SCRIPT_DIR/invoke-waiting-mode.sh" wake \
53
- --task-id "$TASK_ID" \
54
- --agent-id "$AGENT_ID" \
55
- --reason "medium_priority_task" \
56
- --priority 50
57
-
58
- echo ""
59
- echo "Sending CRITICAL priority wake (priority=95)..."
60
- "$SCRIPT_DIR/invoke-waiting-mode.sh" wake \
61
- --task-id "$TASK_ID" \
62
- --agent-id "$AGENT_ID" \
63
- --reason "critical_task" \
64
- --priority 95
65
-
66
- echo ""
67
- echo "Test 2: Agent enters waiting mode and receives messages"
68
- echo "--------------------------------------------------------"
69
-
70
- # Agent should receive messages in priority order: 95, 90, 50, 20
71
- for i in 1 2 3 4; do
72
- echo ""
73
- echo "Pop #$i: Entering waiting mode..."
74
-
75
- # Start agent in background to enter waiting mode
76
- (
77
- WAKE_MSG=$("$SCRIPT_DIR/invoke-waiting-mode.sh" enter \
78
- --task-id "$TASK_ID" \
79
- --agent-id "$AGENT_ID" \
80
- --context "pop-$i" 2>/dev/null)
81
-
82
- echo "Received wake message:"
83
- echo "$WAKE_MSG" | jq '.'
84
- ) &
85
-
86
- AGENT_PID=$!
87
-
88
- # Give agent time to block
89
- sleep 0.5
90
-
91
- # Wait for agent to complete
92
- wait $AGENT_PID
93
- done
94
-
95
- echo ""
96
- echo "Test 3: Verify queue is empty"
97
- echo "------------------------------"
98
- QUEUE_SIZE=$(redis-cli ZCARD "swarm:${TASK_ID}:${AGENT_ID}:wake-queue")
99
- echo "Queue size: $QUEUE_SIZE"
100
-
101
- if [ "$QUEUE_SIZE" = "0" ]; then
102
- echo "✅ Queue is empty (all messages consumed)"
103
- else
104
- echo "❌ Queue still has messages (expected 0, got $QUEUE_SIZE)"
105
- exit 1
106
- fi
107
-
108
- echo ""
109
- echo "Test 4: FIFO for same priority"
110
- echo "-------------------------------"
111
-
112
- # Send 3 messages with same priority
113
- for i in 1 2 3; do
114
- echo "Sending message $i (priority=50)..."
115
- "$SCRIPT_DIR/invoke-waiting-mode.sh" wake \
116
- --task-id "$TASK_ID" \
117
- --agent-id "$AGENT_ID" \
118
- --reason "task-$i" \
119
- --priority 50
120
- sleep 0.1 # Small delay to ensure timestamp order
121
- done
122
-
123
- echo ""
124
- echo "Consuming messages (should be in FIFO order: 1, 2, 3)..."
125
- for i in 1 2 3; do
126
- WAKE_MSG=$("$SCRIPT_DIR/invoke-waiting-mode.sh" enter \
127
- --task-id "$TASK_ID" \
128
- --agent-id "$AGENT_ID" \
129
- --context "fifo-$i" 2>/dev/null)
130
-
131
- REASON=$(echo "$WAKE_MSG" | jq -r '.reason')
132
- echo " Received: $REASON"
133
- done
134
-
135
- echo ""
136
- echo "=========================================="
137
- echo "✅ All priority-based wake tests passed!"
138
- echo "=========================================="
@@ -1,81 +0,0 @@
1
- #!/bin/bash
2
- # Quick test for BZPOPMIN fixes
3
-
4
- set -euo pipefail
5
-
6
- SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
7
- INVOKE_SCRIPT="${SCRIPT_DIR}/invoke-waiting-mode.sh"
8
-
9
- echo "=========================================="
10
- echo "Quick BZPOPMIN Fix Verification"
11
- echo "=========================================="
12
-
13
- TASK_ID="quick-test-$(date +%s)"
14
- AGENT_ID="agent-1"
15
-
16
- cleanup() {
17
- redis-cli KEYS "swarm:${TASK_ID}:*" | xargs -r redis-cli DEL >/dev/null 2>&1 || true
18
- }
19
-
20
- trap cleanup EXIT
21
-
22
- echo ""
23
- echo "Test 1: Compact JSON (no newlines)"
24
- echo "-----------------------------------"
25
- "$INVOKE_SCRIPT" wake --task-id "$TASK_ID" --agent-id "$AGENT_ID" --reason "test" --priority 50 >/dev/null
26
- QUEUE_KEY="swarm:${TASK_ID}:${AGENT_ID}:wake-queue"
27
- STORED_MSG=$(redis-cli ZRANGE "$QUEUE_KEY" 0 0 2>/dev/null | head -1)
28
-
29
- if echo "$STORED_MSG" | jq empty 2>/dev/null && [[ "$STORED_MSG" != *$'\n'* ]]; then
30
- echo "✅ JSON is compact (no newlines)"
31
- else
32
- echo "❌ JSON has newlines or is invalid"
33
- exit 1
34
- fi
35
-
36
- # Clear for next test
37
- redis-cli DEL "$QUEUE_KEY" >/dev/null
38
-
39
- echo ""
40
- echo "Test 2: Priority Ordering"
41
- echo "--------------------------"
42
- "$INVOKE_SCRIPT" wake --task-id "$TASK_ID" --agent-id "$AGENT_ID" --reason "low" --priority 20 >/dev/null
43
- sleep 0.1
44
- "$INVOKE_SCRIPT" wake --task-id "$TASK_ID" --agent-id "$AGENT_ID" --reason "high" --priority 90 >/dev/null
45
- sleep 0.1
46
- "$INVOKE_SCRIPT" wake --task-id "$TASK_ID" --agent-id "$AGENT_ID" --reason "medium" --priority 50 >/dev/null
47
-
48
- # Pop in order
49
- MSG1=$(redis-cli ZPOPMIN "$QUEUE_KEY" 2>/dev/null | sed -n '1p')
50
- MSG2=$(redis-cli ZPOPMIN "$QUEUE_KEY" 2>/dev/null | sed -n '1p')
51
- MSG3=$(redis-cli ZPOPMIN "$QUEUE_KEY" 2>/dev/null | sed -n '1p')
52
-
53
- REASON1=$(echo "$MSG1" | jq -r '.reason' 2>/dev/null)
54
- REASON2=$(echo "$MSG2" | jq -r '.reason' 2>/dev/null)
55
- REASON3=$(echo "$MSG3" | jq -r '.reason' 2>/dev/null)
56
-
57
- if [ "$REASON1" = "high" ] && [ "$REASON2" = "medium" ] && [ "$REASON3" = "low" ]; then
58
- echo "✅ Priority order correct: $REASON1 → $REASON2 → $REASON3"
59
- else
60
- echo "❌ Priority order wrong: $REASON1 → $REASON2 → $REASON3"
61
- exit 1
62
- fi
63
-
64
- echo ""
65
- echo "Test 3: Debug Mode"
66
- echo "------------------"
67
- OUTPUT=$(DEBUG=true "$INVOKE_SCRIPT" wake --task-id "$TASK_ID" --agent-id "$AGENT_ID" --reason "debug" --priority 60 2>&1)
68
-
69
- if echo "$OUTPUT" | grep -q "\[DEBUG\]"; then
70
- echo "✅ Debug mode enabled"
71
- else
72
- echo "❌ Debug mode not working"
73
- exit 1
74
- fi
75
-
76
- echo ""
77
- echo "=========================================="
78
- echo "✅ All quick tests passed!"
79
- echo "=========================================="
80
- echo ""
81
- echo "Confidence: 0.95"
@@ -1,45 +0,0 @@
1
- #!/bin/bash
2
- # Quorum Absolute Test Case
3
- # Tests absolute quorum scenarios
4
-
5
- source "$(dirname "$0")/test-utils.sh"
6
-
7
- # Test Scenario 1: 6/7 agents complete, quorum=6 → SUCCESS
8
- test_absolute_quorum_success() {
9
- local total_agents=7
10
- local quorum=6
11
- local completed_agents=6
12
-
13
- local result=$(check_quorum "$total_agents" "$quorum" "$completed_agents")
14
- assert_equals "$result" "SUCCESS" "Quorum not reached when 6/7 agents complete (quorum=6)"
15
- }
16
-
17
- # Test Scenario 2: 5/7 agents complete, quorum=6 → FAILURE
18
- test_absolute_quorum_failure() {
19
- local total_agents=7
20
- local quorum=6
21
- local completed_agents=5
22
-
23
- local result=$(check_quorum "$total_agents" "$quorum" "$completed_agents")
24
- assert_equals "$result" "FAILURE" "Quorum incorrectly reached when only 5/7 agents complete (quorum=6)")
25
- }
26
-
27
- # Test Scenario 3: 7/7 agents complete, quorum=5 → SUCCESS
28
- test_absolute_quorum_full_success() {
29
- local total_agents=7
30
- local quorum=5
31
- local completed_agents=7
32
-
33
- local result=$(check_quorum "$total_agents" "$quorum" "$completed_agents")
34
- assert_equals "$result" "SUCCESS" "Quorum not reached when all 7/7 agents complete (quorum=5)")
35
- }
36
-
37
- # Run the tests
38
- main() {
39
- test_absolute_quorum_success
40
- test_absolute_quorum_failure
41
- test_absolute_quorum_full_success
42
- echo "Absolute Quorum Test Complete"
43
- }
44
-
45
- main
@@ -1,68 +0,0 @@
1
- #!/bin/bash
2
- # Quorum Fallback Test Case
3
- # Tests scenarios with partial agent failures
4
-
5
- source "$(dirname "$0")/test-utils.sh"
6
-
7
- # Simulate partial agent failures with quorum
8
- simulate_fallback_quorum() {
9
- local total_agents=7
10
- local quorum=5
11
- local permanent_failures=2
12
- local temporary_failures=0
13
-
14
- local completed_agents=$((total_agents - permanent_failures - temporary_failures))
15
-
16
- # Check if quorum can still be reached despite failures
17
- local result=$(check_quorum "$total_agents" "$quorum" "$completed_agents")
18
- echo "$result"
19
- }
20
-
21
- # Test scenario with partial failures
22
- test_quorum_partial_failure() {
23
- local result=$(simulate_fallback_quorum)
24
- assert_equals "$result" "SUCCESS" "Quorum not reached with partial agent failures"
25
- }
26
-
27
- # Simulate complex failure scenarios
28
- test_multiple_fallback_scenarios() {
29
- # Scenario 1: 2 permanent failures, 1 temporary failure
30
- local total_agents=10
31
- local quorum=7
32
- local permanent_failures=2
33
- local temporary_failures=1
34
-
35
- local completed_agents=$((total_agents - permanent_failures - temporary_failures))
36
- local result=$(check_quorum "$total_agents" "$quorum" "$completed_agents")
37
- assert_equals "$result" "FAILURE" "Incorrect quorum reached with too many failures"
38
-
39
- # Scenario 2: 1 permanent failure, 5 temporary failures
40
- total_agents=10
41
- quorum=7
42
- permanent_failures=1
43
- temporary_failures=5
44
-
45
- completed_agents=$((total_agents - permanent_failures - temporary_failures))
46
- result=$(check_quorum "$total_agents" "$quorum" "$completed_agents")
47
- assert_equals "$result" "FAILURE" "Incorrect quorum reached with too many failures"
48
- }
49
-
50
- # Simulate graceful degradation
51
- test_graceful_degradation() {
52
- local total_agents=10
53
- local initial_quorum=0.9 # 90% quorum
54
- local max_failures=3
55
-
56
- local result=$(simulate_graceful_degradation "$total_agents" "$initial_quorum" "$max_failures")
57
- assert_not_empty "$result" "Graceful degradation failed to provide a valid quorum strategy"
58
- }
59
-
60
- # Run the tests
61
- main() {
62
- test_quorum_partial_failure
63
- test_multiple_fallback_scenarios
64
- test_graceful_degradation
65
- echo "Quorum Fallback Test Complete"
66
- }
67
-
68
- main