claude-flow-novice 2.14.14 → 2.14.15
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 +45 -122
- package/claude-assets/commands/cfn-loop-cli.md +45 -122
- package/claude-assets/skills/cfn-multi-coordinator-planning/map-dependencies-conflicts.sh +375 -375
- package/claude-assets/skills/cfn-multi-coordinator-planning/plan-coordinator-resources.sh +257 -257
- package/claude-assets/skills/cfn-multi-coordinator-planning/plan-multi-coordinator-work.sh +266 -266
- package/claude-assets/skills/cfn-multi-coordinator-planning/plan-risk-rollout.sh +349 -349
- package/claude-assets/skills/cfn-multi-coordinator-planning/test-multi-coordinator-planning.sh +337 -337
- package/claude-assets/skills/cfn-multi-coordinator-planning/validate-task-planning.sh +188 -188
- package/package.json +1 -1
|
@@ -1,376 +1,376 @@
|
|
|
1
|
-
#!/bin/bash
|
|
2
|
-
|
|
3
|
-
set -euo pipefail
|
|
4
|
-
|
|
5
|
-
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
|
6
|
-
|
|
7
|
-
# Configuration
|
|
8
|
-
SHARED_RESOURCES=("redis" "file_system" "network_ports" "memory" "cpu")
|
|
9
|
-
CONFLICT_RESOLUTION_STRATEGIES=("queue_based_priority" "resource_isolation" "time_sharing" "fail_fast")
|
|
10
|
-
|
|
11
|
-
# Colors
|
|
12
|
-
RED='\033[0;31m'
|
|
13
|
-
GREEN='\033[0;32m'
|
|
14
|
-
YELLOW='\033[1;33m'
|
|
15
|
-
BLUE='\033[0;34m'
|
|
16
|
-
NC='\033[0m'
|
|
17
|
-
|
|
18
|
-
log() {
|
|
19
|
-
echo -e "${GREEN}[$(date '+%Y-%m-%d %H:%M:%S')] $1${NC}"
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
warn() {
|
|
23
|
-
echo -e "${YELLOW}[$(date '+%Y-%m-%d %H:%M:%S')] WARNING: $1${NC}"
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
error() {
|
|
27
|
-
echo -e "${RED}[$(date '+%Y-%m-%d %H:%M:%S')] ERROR: $1${NC}"
|
|
28
|
-
exit 1
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
info() {
|
|
32
|
-
echo -e "${BLUE}[$(date '+%Y-%m-%d %H:%M:%S')] INFO: $1${NC}"
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
identify_shared_resources() {
|
|
36
|
-
local zone_config="$1"
|
|
37
|
-
local shared_resources_analysis="[]"
|
|
38
|
-
|
|
39
|
-
# Analyze each zone for shared resource usage
|
|
40
|
-
local i=0
|
|
41
|
-
while IFS= read -r zone_name; do
|
|
42
|
-
local zone_data
|
|
43
|
-
zone_data=$(echo "$zone_config" | jq ".zones[$i]")
|
|
44
|
-
|
|
45
|
-
local resource_usage="{
|
|
46
|
-
\"zone\": \"$zone_name\",
|
|
47
|
-
\"redis_usage\": \"isolated_namespace\",
|
|
48
|
-
\"file_system_usage\": \"/tmp/zone-${zone_name}-*\",
|
|
49
|
-
\"network_ports\": \"dynamic_allocation\",
|
|
50
|
-
\"memory_requirement\": \"2GB\",
|
|
51
|
-
\"cpu_requirement\": \"2_cores\"
|
|
52
|
-
}"
|
|
53
|
-
|
|
54
|
-
shared_resources_analysis=$(echo "$shared_resources_analysis" | jq ". + [$resource_usage]")
|
|
55
|
-
((i++))
|
|
56
|
-
done < <(echo "$zone_config" | jq -r '.zones[].name')
|
|
57
|
-
|
|
58
|
-
echo "$shared_resources_analysis"
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
detect_potential_conflicts() {
|
|
62
|
-
local shared_resources="$1"
|
|
63
|
-
local conflicts="[]"
|
|
64
|
-
|
|
65
|
-
# Check for Redis key pattern conflicts
|
|
66
|
-
local redis_patterns
|
|
67
|
-
redis_patterns=$(echo "$shared_resources" | jq -r '.[].redis_usage')
|
|
68
|
-
local unique_redis_patterns
|
|
69
|
-
unique_redis_patterns=$(echo "$redis_patterns" | sort -u | wc -l)
|
|
70
|
-
|
|
71
|
-
if [[ $unique_redis_patterns -lt $(echo "$shared_resources" | jq 'length') ]]; then
|
|
72
|
-
local conflict="{
|
|
73
|
-
\"type\": \"redis_namespace_collision\",
|
|
74
|
-
\"severity\": \"high\",
|
|
75
|
-
\"description\": \"Multiple zones may use overlapping Redis namespaces\",
|
|
76
|
-
\"affected_zones\": $(echo "$shared_resources" | jq 'map(.zone)'),
|
|
77
|
-
\"resolution_strategy\": \"namespace_isolation\"
|
|
78
|
-
}"
|
|
79
|
-
conflicts=$(echo "$conflicts" | jq ". + [$conflict]")
|
|
80
|
-
fi
|
|
81
|
-
|
|
82
|
-
# Check for file system path conflicts
|
|
83
|
-
local file_patterns
|
|
84
|
-
file_patterns=$(echo "$shared_resources" | jq -r '.[].file_system_usage')
|
|
85
|
-
|
|
86
|
-
# Look for potential conflicts in temporary directories
|
|
87
|
-
if echo "$file_patterns" | grep -q "/tmp/"; then
|
|
88
|
-
local conflict="{
|
|
89
|
-
\"type\": \"temporary_directory_conflict\",
|
|
90
|
-
\"severity\": \"medium\",
|
|
91
|
-
\"description\": \"Multiple zones using /tmp directory may conflict\",
|
|
92
|
-
\"affected_zones\": $(echo "$shared_resources" | jq 'map(.zone)'),
|
|
93
|
-
\"resolution_strategy\": \"zone_specific_subdirectories\"
|
|
94
|
-
}"
|
|
95
|
-
conflicts=$(echo "$conflicts" | jq ". + [$conflict]")
|
|
96
|
-
fi
|
|
97
|
-
|
|
98
|
-
# Check for network port conflicts
|
|
99
|
-
local network_usage
|
|
100
|
-
network_usage=$(echo "$shared_resources" | jq -r '.[].network_ports')
|
|
101
|
-
|
|
102
|
-
if echo "$network_usage" | grep -q "dynamic"; then
|
|
103
|
-
local conflict="{
|
|
104
|
-
\"type\": \"dynamic_port_allocation_conflict\",
|
|
105
|
-
\"severity\": \"low\",
|
|
106
|
-
\"description\": \"Dynamic port allocation may cause conflicts\",
|
|
107
|
-
\"affected_zones\": $(echo "$shared_resources" | jq 'map(.zone)'),
|
|
108
|
-
\"resolution_strategy\": \"port_range_reservation\"
|
|
109
|
-
}"
|
|
110
|
-
conflicts=$(echo "$conflicts" | jq ". + [$conflict]")
|
|
111
|
-
fi
|
|
112
|
-
|
|
113
|
-
echo "$conflicts"
|
|
114
|
-
}
|
|
115
|
-
|
|
116
|
-
analyze_dependencies() {
|
|
117
|
-
local zone_config="$1"
|
|
118
|
-
local dependencies="[]"
|
|
119
|
-
|
|
120
|
-
# Check for cross-zone dependencies in task descriptions
|
|
121
|
-
local i=0
|
|
122
|
-
while IFS= read -r zone_name; do
|
|
123
|
-
local zone_data
|
|
124
|
-
zone_data=$(echo "$zone_config" | jq ".zones[$i]")
|
|
125
|
-
local task_description
|
|
126
|
-
task_description=$(echo "$zone_data" | jq -r '.task_description // ""')
|
|
127
|
-
|
|
128
|
-
# Look for dependency keywords
|
|
129
|
-
local dependency_patterns=("depends on" "requires" "after" "waits for" "needs")
|
|
130
|
-
local found_dependencies="[]"
|
|
131
|
-
|
|
132
|
-
for pattern in "${dependency_patterns[@]}"; do
|
|
133
|
-
if [[ "$task_description" =~ $pattern ]]; then
|
|
134
|
-
# Extract potential dependency target
|
|
135
|
-
local dependency_target
|
|
136
|
-
dependency_target=$(echo "$task_description" | grep -o "$pattern [^.]*" | sed "s/$pattern //" | xargs)
|
|
137
|
-
|
|
138
|
-
if [[ -n "$dependency_target" ]]; then
|
|
139
|
-
found_dependencies=$(echo "$found_dependencies" | jq ". + [\"$dependency_target\"]")
|
|
140
|
-
fi
|
|
141
|
-
fi
|
|
142
|
-
done
|
|
143
|
-
|
|
144
|
-
if [[ "$(echo "$found_dependencies" | jq 'length')" -gt 0 ]]; then
|
|
145
|
-
local dependency_entry="{
|
|
146
|
-
\"zone\": \"$zone_name\",
|
|
147
|
-
\"dependencies\": $found_dependencies,
|
|
148
|
-
\"dependency_type\": \"explicit_text\"
|
|
149
|
-
}"
|
|
150
|
-
dependencies=$(echo "$dependencies" | jq ". + [$dependency_entry]")
|
|
151
|
-
fi
|
|
152
|
-
|
|
153
|
-
((i++))
|
|
154
|
-
done < <(echo "$zone_config" | jq -r '.zones[].name')
|
|
155
|
-
|
|
156
|
-
echo "$dependencies"
|
|
157
|
-
}
|
|
158
|
-
|
|
159
|
-
create_resolution_strategies() {
|
|
160
|
-
local conflicts="$1"
|
|
161
|
-
local strategies="{}"
|
|
162
|
-
|
|
163
|
-
local conflict_count
|
|
164
|
-
conflict_count=$(echo "$conflicts" | jq 'length')
|
|
165
|
-
|
|
166
|
-
for ((i=0; i<conflict_count; i++)); do
|
|
167
|
-
local conflict
|
|
168
|
-
conflict=$(echo "$conflicts" | jq ".[$i]")
|
|
169
|
-
local conflict_type
|
|
170
|
-
conflict_type=$(echo "$conflict" | jq -r '.type')
|
|
171
|
-
local resolution_strategy
|
|
172
|
-
resolution_strategy=$(echo "$conflict" | jq -r '.resolution_strategy')
|
|
173
|
-
|
|
174
|
-
case "$conflict_type" in
|
|
175
|
-
"redis_namespace_collision")
|
|
176
|
-
local strategy="{
|
|
177
|
-
\"approach\": \"namespace_isolation\",
|
|
178
|
-
\"implementation\": \"zone_specific_redis_databases\",
|
|
179
|
-
\"priority\": \"high\",
|
|
180
|
-
\"estimated_effort\": \"low\",
|
|
181
|
-
\"success_probability\": 0.95
|
|
182
|
-
}"
|
|
183
|
-
;;
|
|
184
|
-
"temporary_directory_conflict")
|
|
185
|
-
local strategy="{
|
|
186
|
-
\"approach\": \"zone_specific_subdirectories\",
|
|
187
|
-
\"implementation\": \"timestamped_zone_directories\",
|
|
188
|
-
\"priority\": \"medium\",
|
|
189
|
-
\"estimated_effort\": \"low\",
|
|
190
|
-
\"success_probability\": 0.90
|
|
191
|
-
}"
|
|
192
|
-
;;
|
|
193
|
-
"dynamic_port_allocation_conflict")
|
|
194
|
-
local strategy="{
|
|
195
|
-
\"approach\": \"port_range_reservation\",
|
|
196
|
-
\"implementation\": \"pre_allocated_port_ranges_per_zone\",
|
|
197
|
-
\"priority\": \"low\",
|
|
198
|
-
\"estimated_effort\": \"medium\",
|
|
199
|
-
\"success_probability\": 0.85
|
|
200
|
-
}"
|
|
201
|
-
;;
|
|
202
|
-
*)
|
|
203
|
-
local strategy="{
|
|
204
|
-
\"approach\": \"monitor_and_remediate\",
|
|
205
|
-
\"implementation\": \"runtime_detection_and_correction\",
|
|
206
|
-
\"priority\": \"medium\",
|
|
207
|
-
\"estimated_effort\": \"high\",
|
|
208
|
-
\"success_probability\": 0.70
|
|
209
|
-
}"
|
|
210
|
-
;;
|
|
211
|
-
esac
|
|
212
|
-
|
|
213
|
-
strategies=$(echo "$strategies" | jq ".[\"$conflict_type\"] = $strategy")
|
|
214
|
-
done
|
|
215
|
-
|
|
216
|
-
echo "$strategies"
|
|
217
|
-
}
|
|
218
|
-
|
|
219
|
-
create_completion_pathways() {
|
|
220
|
-
local zone_config="$1"
|
|
221
|
-
local pathways="[]"
|
|
222
|
-
|
|
223
|
-
local i=0
|
|
224
|
-
while IFS= read -r zone_name; do
|
|
225
|
-
local zone_data
|
|
226
|
-
zone_data=$(echo "$zone_config" | jq ".zones[$i]")
|
|
227
|
-
|
|
228
|
-
local pathway="{
|
|
229
|
-
\"zone\": \"$zone_name\",
|
|
230
|
-
\"normal_flow\": [
|
|
231
|
-
\"agent_completion\",
|
|
232
|
-
\"coordinator_processing\",
|
|
233
|
-
\"main_chat_notification\"
|
|
234
|
-
],
|
|
235
|
-
\"failure_flows\": {
|
|
236
|
-
\"agent_timeout\": [
|
|
237
|
-
\"timeout_detection\",
|
|
238
|
-
\"agent_cleanup\",
|
|
239
|
-
\"coordinator_restart_or_abort\"
|
|
240
|
-
],
|
|
241
|
-
\"coordinator_failure\": [
|
|
242
|
-
\"failure_detection\",
|
|
243
|
-
\"context_preservation\",
|
|
244
|
-
\"coordinator_restart\",
|
|
245
|
-
\"work_resumption\"
|
|
246
|
-
],
|
|
247
|
-
\"namespace_corruption\": [
|
|
248
|
-
\"corruption_detection\",
|
|
249
|
-
\"emergency_stop\",
|
|
250
|
-
\"context_recovery\",
|
|
251
|
-
\"coordinator_restart\"
|
|
252
|
-
]
|
|
253
|
-
},
|
|
254
|
-
\"escalation_triggers\": [
|
|
255
|
-
\"multiple_agent_failures\",
|
|
256
|
-
\"repeated_timeout_cycles\",
|
|
257
|
-
\"resource_exhaustion\"
|
|
258
|
-
]
|
|
259
|
-
}"
|
|
260
|
-
|
|
261
|
-
pathways=$(echo "$pathways" | jq ". + [$pathway]")
|
|
262
|
-
((i++))
|
|
263
|
-
done < <(echo "$zone_config" | jq -r '.zones[].name')
|
|
264
|
-
|
|
265
|
-
echo "$pathways"
|
|
266
|
-
}
|
|
267
|
-
|
|
268
|
-
generate_dependency_conflict_plan() {
|
|
269
|
-
local zone_config="$1"
|
|
270
|
-
|
|
271
|
-
info "Analyzing dependencies and conflicts for multi-coordinator execution"
|
|
272
|
-
|
|
273
|
-
# Identify shared resources
|
|
274
|
-
local shared_resources
|
|
275
|
-
shared_resources=$(identify_shared_resources "$zone_config")
|
|
276
|
-
|
|
277
|
-
# Detect potential conflicts
|
|
278
|
-
local conflicts
|
|
279
|
-
conflicts=$(detect_potential_conflicts "$shared_resources")
|
|
280
|
-
|
|
281
|
-
# Analyze dependencies
|
|
282
|
-
local dependencies
|
|
283
|
-
dependencies=$(analyze_dependencies "$zone_config")
|
|
284
|
-
|
|
285
|
-
# Create resolution strategies
|
|
286
|
-
local resolution_strategies
|
|
287
|
-
resolution_strategies=$(create_resolution_strategies "$conflicts")
|
|
288
|
-
|
|
289
|
-
# Create completion pathways
|
|
290
|
-
local completion_pathways
|
|
291
|
-
completion_pathways=$(create_completion_pathways "$zone_config")
|
|
292
|
-
|
|
293
|
-
# Generate complete analysis plan
|
|
294
|
-
local analysis_plan="{
|
|
295
|
-
\"timestamp\": $(date '+%s'),
|
|
296
|
-
\"zone_count\": $(echo "$zone_config" | jq '.zones | length'),
|
|
297
|
-
\"shared_resources_analysis\": $shared_resources,
|
|
298
|
-
\"detected_conflicts\": $conflicts,
|
|
299
|
-
\"dependency_analysis\": $dependencies,
|
|
300
|
-
\"resolution_strategies\": $resolution_strategies,
|
|
301
|
-
\"completion_pathways\": $completion_pathways,
|
|
302
|
-
\"recommendations\": {
|
|
303
|
-
\"isolation_level\": \"zone_based\",
|
|
304
|
-
\"monitoring_priority\": \"high\",
|
|
305
|
-
\"auto_recovery_enabled\": true,
|
|
306
|
-
\"manual_intervention_points\": [\"critical_conflicts\", \"escalation_triggers\"]
|
|
307
|
-
}
|
|
308
|
-
}"
|
|
309
|
-
|
|
310
|
-
echo "$analysis_plan"
|
|
311
|
-
}
|
|
312
|
-
|
|
313
|
-
display_analysis_summary() {
|
|
314
|
-
local analysis_plan="$1"
|
|
315
|
-
|
|
316
|
-
echo
|
|
317
|
-
info "=== Dependencies & Conflicts Analysis ==="
|
|
318
|
-
echo "Zones analyzed: $(echo "$analysis_plan" | jq -r '.zone_count')"
|
|
319
|
-
echo "Shared resources identified: $(echo "$analysis_plan" | jq -r '.shared_resources_analysis | length')"
|
|
320
|
-
echo "Potential conflicts detected: $(echo "$analysis_plan" | jq -r '.detected_conflicts | length')"
|
|
321
|
-
echo "Dependencies found: $(echo "$analysis_plan" | jq -r '.dependency_analysis | length')"
|
|
322
|
-
echo
|
|
323
|
-
|
|
324
|
-
if [[ "$(echo "$analysis_plan" | jq -r '.detected_conflicts | length')" -gt 0 ]]; then
|
|
325
|
-
echo "Conflict Summary:"
|
|
326
|
-
echo "$analysis_plan" | jq -r '.detected_conflicts[] | " - \(.type): \(.description) (severity: \(.severity))"'
|
|
327
|
-
echo
|
|
328
|
-
fi
|
|
329
|
-
|
|
330
|
-
echo "Resolution Strategies:"
|
|
331
|
-
echo "$analysis_plan" | jq -r '.resolution_strategies | to_entries[] | " - \(.key): \(.value.approach) (\(.value.success_probability * 100)% success)"'
|
|
332
|
-
echo
|
|
333
|
-
|
|
334
|
-
echo "Recommendations:"
|
|
335
|
-
echo " - Isolation level: $(echo "$analysis_plan" | jq -r '.recommendations.isolation_level')"
|
|
336
|
-
echo " - Monitoring priority: $(echo "$analysis_plan" | jq -r '.recommendations.monitoring_priority')"
|
|
337
|
-
echo " - Auto recovery: $(echo "$analysis_plan" | jq -r '.recommendations.auto_recovery_enabled')"
|
|
338
|
-
echo
|
|
339
|
-
}
|
|
340
|
-
|
|
341
|
-
main() {
|
|
342
|
-
local config_file="$1"
|
|
343
|
-
|
|
344
|
-
if [[ -z "$config_file" ]]; then
|
|
345
|
-
error "Usage: $0 <zone-config-file>"
|
|
346
|
-
fi
|
|
347
|
-
|
|
348
|
-
if [[ ! -f "$config_file" ]]; then
|
|
349
|
-
error "Configuration file not found: $config_file"
|
|
350
|
-
fi
|
|
351
|
-
|
|
352
|
-
log "Starting dependency and conflict analysis for: $config_file"
|
|
353
|
-
|
|
354
|
-
# Read configuration
|
|
355
|
-
local zone_config
|
|
356
|
-
if ! zone_config=$(jq . "$config_file" 2>/dev/null); then
|
|
357
|
-
error "Invalid JSON in configuration file: $config_file"
|
|
358
|
-
fi
|
|
359
|
-
|
|
360
|
-
# Generate analysis plan
|
|
361
|
-
local analysis_plan
|
|
362
|
-
analysis_plan=$(generate_dependency_conflict_plan "$zone_config")
|
|
363
|
-
|
|
364
|
-
# Save analysis plan
|
|
365
|
-
local output_file="/tmp/dependency-conflict-analysis-$(date '+%s').json"
|
|
366
|
-
echo "$analysis_plan" > "$output_file"
|
|
367
|
-
|
|
368
|
-
log "✅ Dependency and conflict analysis completed"
|
|
369
|
-
log "Analysis plan saved to: $output_file"
|
|
370
|
-
|
|
371
|
-
# Display summary
|
|
372
|
-
display_analysis_summary "$analysis_plan"
|
|
373
|
-
}
|
|
374
|
-
|
|
375
|
-
# Execute main function with all arguments
|
|
1
|
+
#!/bin/bash
|
|
2
|
+
|
|
3
|
+
set -euo pipefail
|
|
4
|
+
|
|
5
|
+
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
|
6
|
+
|
|
7
|
+
# Configuration
|
|
8
|
+
SHARED_RESOURCES=("redis" "file_system" "network_ports" "memory" "cpu")
|
|
9
|
+
CONFLICT_RESOLUTION_STRATEGIES=("queue_based_priority" "resource_isolation" "time_sharing" "fail_fast")
|
|
10
|
+
|
|
11
|
+
# Colors
|
|
12
|
+
RED='\033[0;31m'
|
|
13
|
+
GREEN='\033[0;32m'
|
|
14
|
+
YELLOW='\033[1;33m'
|
|
15
|
+
BLUE='\033[0;34m'
|
|
16
|
+
NC='\033[0m'
|
|
17
|
+
|
|
18
|
+
log() {
|
|
19
|
+
echo -e "${GREEN}[$(date '+%Y-%m-%d %H:%M:%S')] $1${NC}"
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
warn() {
|
|
23
|
+
echo -e "${YELLOW}[$(date '+%Y-%m-%d %H:%M:%S')] WARNING: $1${NC}"
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
error() {
|
|
27
|
+
echo -e "${RED}[$(date '+%Y-%m-%d %H:%M:%S')] ERROR: $1${NC}"
|
|
28
|
+
exit 1
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
info() {
|
|
32
|
+
echo -e "${BLUE}[$(date '+%Y-%m-%d %H:%M:%S')] INFO: $1${NC}"
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
identify_shared_resources() {
|
|
36
|
+
local zone_config="$1"
|
|
37
|
+
local shared_resources_analysis="[]"
|
|
38
|
+
|
|
39
|
+
# Analyze each zone for shared resource usage
|
|
40
|
+
local i=0
|
|
41
|
+
while IFS= read -r zone_name; do
|
|
42
|
+
local zone_data
|
|
43
|
+
zone_data=$(echo "$zone_config" | jq ".zones[$i]")
|
|
44
|
+
|
|
45
|
+
local resource_usage="{
|
|
46
|
+
\"zone\": \"$zone_name\",
|
|
47
|
+
\"redis_usage\": \"isolated_namespace\",
|
|
48
|
+
\"file_system_usage\": \"/tmp/zone-${zone_name}-*\",
|
|
49
|
+
\"network_ports\": \"dynamic_allocation\",
|
|
50
|
+
\"memory_requirement\": \"2GB\",
|
|
51
|
+
\"cpu_requirement\": \"2_cores\"
|
|
52
|
+
}"
|
|
53
|
+
|
|
54
|
+
shared_resources_analysis=$(echo "$shared_resources_analysis" | jq ". + [$resource_usage]")
|
|
55
|
+
((i++))
|
|
56
|
+
done < <(echo "$zone_config" | jq -r '.zones[].name')
|
|
57
|
+
|
|
58
|
+
echo "$shared_resources_analysis"
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
detect_potential_conflicts() {
|
|
62
|
+
local shared_resources="$1"
|
|
63
|
+
local conflicts="[]"
|
|
64
|
+
|
|
65
|
+
# Check for Redis key pattern conflicts
|
|
66
|
+
local redis_patterns
|
|
67
|
+
redis_patterns=$(echo "$shared_resources" | jq -r '.[].redis_usage')
|
|
68
|
+
local unique_redis_patterns
|
|
69
|
+
unique_redis_patterns=$(echo "$redis_patterns" | sort -u | wc -l)
|
|
70
|
+
|
|
71
|
+
if [[ $unique_redis_patterns -lt $(echo "$shared_resources" | jq 'length') ]]; then
|
|
72
|
+
local conflict="{
|
|
73
|
+
\"type\": \"redis_namespace_collision\",
|
|
74
|
+
\"severity\": \"high\",
|
|
75
|
+
\"description\": \"Multiple zones may use overlapping Redis namespaces\",
|
|
76
|
+
\"affected_zones\": $(echo "$shared_resources" | jq 'map(.zone)'),
|
|
77
|
+
\"resolution_strategy\": \"namespace_isolation\"
|
|
78
|
+
}"
|
|
79
|
+
conflicts=$(echo "$conflicts" | jq ". + [$conflict]")
|
|
80
|
+
fi
|
|
81
|
+
|
|
82
|
+
# Check for file system path conflicts
|
|
83
|
+
local file_patterns
|
|
84
|
+
file_patterns=$(echo "$shared_resources" | jq -r '.[].file_system_usage')
|
|
85
|
+
|
|
86
|
+
# Look for potential conflicts in temporary directories
|
|
87
|
+
if echo "$file_patterns" | grep -q "/tmp/"; then
|
|
88
|
+
local conflict="{
|
|
89
|
+
\"type\": \"temporary_directory_conflict\",
|
|
90
|
+
\"severity\": \"medium\",
|
|
91
|
+
\"description\": \"Multiple zones using /tmp directory may conflict\",
|
|
92
|
+
\"affected_zones\": $(echo "$shared_resources" | jq 'map(.zone)'),
|
|
93
|
+
\"resolution_strategy\": \"zone_specific_subdirectories\"
|
|
94
|
+
}"
|
|
95
|
+
conflicts=$(echo "$conflicts" | jq ". + [$conflict]")
|
|
96
|
+
fi
|
|
97
|
+
|
|
98
|
+
# Check for network port conflicts
|
|
99
|
+
local network_usage
|
|
100
|
+
network_usage=$(echo "$shared_resources" | jq -r '.[].network_ports')
|
|
101
|
+
|
|
102
|
+
if echo "$network_usage" | grep -q "dynamic"; then
|
|
103
|
+
local conflict="{
|
|
104
|
+
\"type\": \"dynamic_port_allocation_conflict\",
|
|
105
|
+
\"severity\": \"low\",
|
|
106
|
+
\"description\": \"Dynamic port allocation may cause conflicts\",
|
|
107
|
+
\"affected_zones\": $(echo "$shared_resources" | jq 'map(.zone)'),
|
|
108
|
+
\"resolution_strategy\": \"port_range_reservation\"
|
|
109
|
+
}"
|
|
110
|
+
conflicts=$(echo "$conflicts" | jq ". + [$conflict]")
|
|
111
|
+
fi
|
|
112
|
+
|
|
113
|
+
echo "$conflicts"
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
analyze_dependencies() {
|
|
117
|
+
local zone_config="$1"
|
|
118
|
+
local dependencies="[]"
|
|
119
|
+
|
|
120
|
+
# Check for cross-zone dependencies in task descriptions
|
|
121
|
+
local i=0
|
|
122
|
+
while IFS= read -r zone_name; do
|
|
123
|
+
local zone_data
|
|
124
|
+
zone_data=$(echo "$zone_config" | jq ".zones[$i]")
|
|
125
|
+
local task_description
|
|
126
|
+
task_description=$(echo "$zone_data" | jq -r '.task_description // ""')
|
|
127
|
+
|
|
128
|
+
# Look for dependency keywords
|
|
129
|
+
local dependency_patterns=("depends on" "requires" "after" "waits for" "needs")
|
|
130
|
+
local found_dependencies="[]"
|
|
131
|
+
|
|
132
|
+
for pattern in "${dependency_patterns[@]}"; do
|
|
133
|
+
if [[ "$task_description" =~ $pattern ]]; then
|
|
134
|
+
# Extract potential dependency target
|
|
135
|
+
local dependency_target
|
|
136
|
+
dependency_target=$(echo "$task_description" | grep -o "$pattern [^.]*" | sed "s/$pattern //" | xargs)
|
|
137
|
+
|
|
138
|
+
if [[ -n "$dependency_target" ]]; then
|
|
139
|
+
found_dependencies=$(echo "$found_dependencies" | jq ". + [\"$dependency_target\"]")
|
|
140
|
+
fi
|
|
141
|
+
fi
|
|
142
|
+
done
|
|
143
|
+
|
|
144
|
+
if [[ "$(echo "$found_dependencies" | jq 'length')" -gt 0 ]]; then
|
|
145
|
+
local dependency_entry="{
|
|
146
|
+
\"zone\": \"$zone_name\",
|
|
147
|
+
\"dependencies\": $found_dependencies,
|
|
148
|
+
\"dependency_type\": \"explicit_text\"
|
|
149
|
+
}"
|
|
150
|
+
dependencies=$(echo "$dependencies" | jq ". + [$dependency_entry]")
|
|
151
|
+
fi
|
|
152
|
+
|
|
153
|
+
((i++))
|
|
154
|
+
done < <(echo "$zone_config" | jq -r '.zones[].name')
|
|
155
|
+
|
|
156
|
+
echo "$dependencies"
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
create_resolution_strategies() {
|
|
160
|
+
local conflicts="$1"
|
|
161
|
+
local strategies="{}"
|
|
162
|
+
|
|
163
|
+
local conflict_count
|
|
164
|
+
conflict_count=$(echo "$conflicts" | jq 'length')
|
|
165
|
+
|
|
166
|
+
for ((i=0; i<conflict_count; i++)); do
|
|
167
|
+
local conflict
|
|
168
|
+
conflict=$(echo "$conflicts" | jq ".[$i]")
|
|
169
|
+
local conflict_type
|
|
170
|
+
conflict_type=$(echo "$conflict" | jq -r '.type')
|
|
171
|
+
local resolution_strategy
|
|
172
|
+
resolution_strategy=$(echo "$conflict" | jq -r '.resolution_strategy')
|
|
173
|
+
|
|
174
|
+
case "$conflict_type" in
|
|
175
|
+
"redis_namespace_collision")
|
|
176
|
+
local strategy="{
|
|
177
|
+
\"approach\": \"namespace_isolation\",
|
|
178
|
+
\"implementation\": \"zone_specific_redis_databases\",
|
|
179
|
+
\"priority\": \"high\",
|
|
180
|
+
\"estimated_effort\": \"low\",
|
|
181
|
+
\"success_probability\": 0.95
|
|
182
|
+
}"
|
|
183
|
+
;;
|
|
184
|
+
"temporary_directory_conflict")
|
|
185
|
+
local strategy="{
|
|
186
|
+
\"approach\": \"zone_specific_subdirectories\",
|
|
187
|
+
\"implementation\": \"timestamped_zone_directories\",
|
|
188
|
+
\"priority\": \"medium\",
|
|
189
|
+
\"estimated_effort\": \"low\",
|
|
190
|
+
\"success_probability\": 0.90
|
|
191
|
+
}"
|
|
192
|
+
;;
|
|
193
|
+
"dynamic_port_allocation_conflict")
|
|
194
|
+
local strategy="{
|
|
195
|
+
\"approach\": \"port_range_reservation\",
|
|
196
|
+
\"implementation\": \"pre_allocated_port_ranges_per_zone\",
|
|
197
|
+
\"priority\": \"low\",
|
|
198
|
+
\"estimated_effort\": \"medium\",
|
|
199
|
+
\"success_probability\": 0.85
|
|
200
|
+
}"
|
|
201
|
+
;;
|
|
202
|
+
*)
|
|
203
|
+
local strategy="{
|
|
204
|
+
\"approach\": \"monitor_and_remediate\",
|
|
205
|
+
\"implementation\": \"runtime_detection_and_correction\",
|
|
206
|
+
\"priority\": \"medium\",
|
|
207
|
+
\"estimated_effort\": \"high\",
|
|
208
|
+
\"success_probability\": 0.70
|
|
209
|
+
}"
|
|
210
|
+
;;
|
|
211
|
+
esac
|
|
212
|
+
|
|
213
|
+
strategies=$(echo "$strategies" | jq ".[\"$conflict_type\"] = $strategy")
|
|
214
|
+
done
|
|
215
|
+
|
|
216
|
+
echo "$strategies"
|
|
217
|
+
}
|
|
218
|
+
|
|
219
|
+
create_completion_pathways() {
|
|
220
|
+
local zone_config="$1"
|
|
221
|
+
local pathways="[]"
|
|
222
|
+
|
|
223
|
+
local i=0
|
|
224
|
+
while IFS= read -r zone_name; do
|
|
225
|
+
local zone_data
|
|
226
|
+
zone_data=$(echo "$zone_config" | jq ".zones[$i]")
|
|
227
|
+
|
|
228
|
+
local pathway="{
|
|
229
|
+
\"zone\": \"$zone_name\",
|
|
230
|
+
\"normal_flow\": [
|
|
231
|
+
\"agent_completion\",
|
|
232
|
+
\"coordinator_processing\",
|
|
233
|
+
\"main_chat_notification\"
|
|
234
|
+
],
|
|
235
|
+
\"failure_flows\": {
|
|
236
|
+
\"agent_timeout\": [
|
|
237
|
+
\"timeout_detection\",
|
|
238
|
+
\"agent_cleanup\",
|
|
239
|
+
\"coordinator_restart_or_abort\"
|
|
240
|
+
],
|
|
241
|
+
\"coordinator_failure\": [
|
|
242
|
+
\"failure_detection\",
|
|
243
|
+
\"context_preservation\",
|
|
244
|
+
\"coordinator_restart\",
|
|
245
|
+
\"work_resumption\"
|
|
246
|
+
],
|
|
247
|
+
\"namespace_corruption\": [
|
|
248
|
+
\"corruption_detection\",
|
|
249
|
+
\"emergency_stop\",
|
|
250
|
+
\"context_recovery\",
|
|
251
|
+
\"coordinator_restart\"
|
|
252
|
+
]
|
|
253
|
+
},
|
|
254
|
+
\"escalation_triggers\": [
|
|
255
|
+
\"multiple_agent_failures\",
|
|
256
|
+
\"repeated_timeout_cycles\",
|
|
257
|
+
\"resource_exhaustion\"
|
|
258
|
+
]
|
|
259
|
+
}"
|
|
260
|
+
|
|
261
|
+
pathways=$(echo "$pathways" | jq ". + [$pathway]")
|
|
262
|
+
((i++))
|
|
263
|
+
done < <(echo "$zone_config" | jq -r '.zones[].name')
|
|
264
|
+
|
|
265
|
+
echo "$pathways"
|
|
266
|
+
}
|
|
267
|
+
|
|
268
|
+
generate_dependency_conflict_plan() {
|
|
269
|
+
local zone_config="$1"
|
|
270
|
+
|
|
271
|
+
info "Analyzing dependencies and conflicts for multi-coordinator execution"
|
|
272
|
+
|
|
273
|
+
# Identify shared resources
|
|
274
|
+
local shared_resources
|
|
275
|
+
shared_resources=$(identify_shared_resources "$zone_config")
|
|
276
|
+
|
|
277
|
+
# Detect potential conflicts
|
|
278
|
+
local conflicts
|
|
279
|
+
conflicts=$(detect_potential_conflicts "$shared_resources")
|
|
280
|
+
|
|
281
|
+
# Analyze dependencies
|
|
282
|
+
local dependencies
|
|
283
|
+
dependencies=$(analyze_dependencies "$zone_config")
|
|
284
|
+
|
|
285
|
+
# Create resolution strategies
|
|
286
|
+
local resolution_strategies
|
|
287
|
+
resolution_strategies=$(create_resolution_strategies "$conflicts")
|
|
288
|
+
|
|
289
|
+
# Create completion pathways
|
|
290
|
+
local completion_pathways
|
|
291
|
+
completion_pathways=$(create_completion_pathways "$zone_config")
|
|
292
|
+
|
|
293
|
+
# Generate complete analysis plan
|
|
294
|
+
local analysis_plan="{
|
|
295
|
+
\"timestamp\": $(date '+%s'),
|
|
296
|
+
\"zone_count\": $(echo "$zone_config" | jq '.zones | length'),
|
|
297
|
+
\"shared_resources_analysis\": $shared_resources,
|
|
298
|
+
\"detected_conflicts\": $conflicts,
|
|
299
|
+
\"dependency_analysis\": $dependencies,
|
|
300
|
+
\"resolution_strategies\": $resolution_strategies,
|
|
301
|
+
\"completion_pathways\": $completion_pathways,
|
|
302
|
+
\"recommendations\": {
|
|
303
|
+
\"isolation_level\": \"zone_based\",
|
|
304
|
+
\"monitoring_priority\": \"high\",
|
|
305
|
+
\"auto_recovery_enabled\": true,
|
|
306
|
+
\"manual_intervention_points\": [\"critical_conflicts\", \"escalation_triggers\"]
|
|
307
|
+
}
|
|
308
|
+
}"
|
|
309
|
+
|
|
310
|
+
echo "$analysis_plan"
|
|
311
|
+
}
|
|
312
|
+
|
|
313
|
+
display_analysis_summary() {
|
|
314
|
+
local analysis_plan="$1"
|
|
315
|
+
|
|
316
|
+
echo
|
|
317
|
+
info "=== Dependencies & Conflicts Analysis ==="
|
|
318
|
+
echo "Zones analyzed: $(echo "$analysis_plan" | jq -r '.zone_count')"
|
|
319
|
+
echo "Shared resources identified: $(echo "$analysis_plan" | jq -r '.shared_resources_analysis | length')"
|
|
320
|
+
echo "Potential conflicts detected: $(echo "$analysis_plan" | jq -r '.detected_conflicts | length')"
|
|
321
|
+
echo "Dependencies found: $(echo "$analysis_plan" | jq -r '.dependency_analysis | length')"
|
|
322
|
+
echo
|
|
323
|
+
|
|
324
|
+
if [[ "$(echo "$analysis_plan" | jq -r '.detected_conflicts | length')" -gt 0 ]]; then
|
|
325
|
+
echo "Conflict Summary:"
|
|
326
|
+
echo "$analysis_plan" | jq -r '.detected_conflicts[] | " - \(.type): \(.description) (severity: \(.severity))"'
|
|
327
|
+
echo
|
|
328
|
+
fi
|
|
329
|
+
|
|
330
|
+
echo "Resolution Strategies:"
|
|
331
|
+
echo "$analysis_plan" | jq -r '.resolution_strategies | to_entries[] | " - \(.key): \(.value.approach) (\(.value.success_probability * 100)% success)"'
|
|
332
|
+
echo
|
|
333
|
+
|
|
334
|
+
echo "Recommendations:"
|
|
335
|
+
echo " - Isolation level: $(echo "$analysis_plan" | jq -r '.recommendations.isolation_level')"
|
|
336
|
+
echo " - Monitoring priority: $(echo "$analysis_plan" | jq -r '.recommendations.monitoring_priority')"
|
|
337
|
+
echo " - Auto recovery: $(echo "$analysis_plan" | jq -r '.recommendations.auto_recovery_enabled')"
|
|
338
|
+
echo
|
|
339
|
+
}
|
|
340
|
+
|
|
341
|
+
main() {
|
|
342
|
+
local config_file="$1"
|
|
343
|
+
|
|
344
|
+
if [[ -z "$config_file" ]]; then
|
|
345
|
+
error "Usage: $0 <zone-config-file>"
|
|
346
|
+
fi
|
|
347
|
+
|
|
348
|
+
if [[ ! -f "$config_file" ]]; then
|
|
349
|
+
error "Configuration file not found: $config_file"
|
|
350
|
+
fi
|
|
351
|
+
|
|
352
|
+
log "Starting dependency and conflict analysis for: $config_file"
|
|
353
|
+
|
|
354
|
+
# Read configuration
|
|
355
|
+
local zone_config
|
|
356
|
+
if ! zone_config=$(jq . "$config_file" 2>/dev/null); then
|
|
357
|
+
error "Invalid JSON in configuration file: $config_file"
|
|
358
|
+
fi
|
|
359
|
+
|
|
360
|
+
# Generate analysis plan
|
|
361
|
+
local analysis_plan
|
|
362
|
+
analysis_plan=$(generate_dependency_conflict_plan "$zone_config")
|
|
363
|
+
|
|
364
|
+
# Save analysis plan
|
|
365
|
+
local output_file="/tmp/dependency-conflict-analysis-$(date '+%s').json"
|
|
366
|
+
echo "$analysis_plan" > "$output_file"
|
|
367
|
+
|
|
368
|
+
log "✅ Dependency and conflict analysis completed"
|
|
369
|
+
log "Analysis plan saved to: $output_file"
|
|
370
|
+
|
|
371
|
+
# Display summary
|
|
372
|
+
display_analysis_summary "$analysis_plan"
|
|
373
|
+
}
|
|
374
|
+
|
|
375
|
+
# Execute main function with all arguments
|
|
376
376
|
main "$@"
|