claude-flow-novice 2.14.13 → 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_TASK_MODE.md +7 -51
- package/.claude/commands/cfn-loop-cli.md +50 -125
- package/.claude/skills/cfn-agent-selector/SKILL.md +2 -2
- package/.claude/skills/cfn-agent-selector/select-agents.sh +0 -45
- package/.claude/skills/cfn-loop-orchestration/helpers/context-injection.sh +6 -69
- package/.claude/skills/cfn-loop-orchestration/orchestrate.sh +0 -17
- package/README.md +2 -2
- package/claude-assets/agents/cfn-dev-team/CLAUDE.md +3 -3
- package/claude-assets/agents/cfn-dev-team/README.md +1 -1
- package/claude-assets/agents/cfn-dev-team/coordinators/cfn-v3-coordinator.md +2 -2
- package/claude-assets/agents/cfn-dev-team/developers/README.md +3 -3
- package/claude-assets/agents/cfn-dev-team/documentation/agent-type-guidelines.md +1 -1
- package/claude-assets/agents/cfn-dev-team/test-agent.md +2 -2
- package/claude-assets/commands/CFN_LOOP_TASK_MODE.md +7 -51
- package/claude-assets/commands/cfn-loop-cli.md +50 -125
- package/claude-assets/skills/cfn-agent-selector/SKILL.md +2 -2
- package/claude-assets/skills/cfn-agent-selector/select-agents.sh +0 -45
- package/claude-assets/skills/cfn-loop-orchestration/helpers/context-injection.sh +6 -69
- package/claude-assets/skills/cfn-loop-orchestration/orchestrate.sh +0 -17
- package/claude-assets/skills/cfn-multi-coordinator-planning/README.md +256 -0
- package/claude-assets/skills/cfn-multi-coordinator-planning/SKILL.md +62 -0
- package/claude-assets/skills/cfn-multi-coordinator-planning/map-dependencies-conflicts.sh +376 -0
- package/claude-assets/skills/cfn-multi-coordinator-planning/plan-coordinator-resources.sh +258 -0
- package/claude-assets/skills/cfn-multi-coordinator-planning/plan-multi-coordinator-work.sh +267 -0
- package/claude-assets/skills/cfn-multi-coordinator-planning/plan-risk-rollout.sh +350 -0
- package/claude-assets/skills/cfn-multi-coordinator-planning/test-multi-coordinator-planning.sh +338 -0
- package/claude-assets/skills/cfn-multi-coordinator-planning/validate-task-planning.sh +189 -0
- package/dist/agents/agent-loader.js +165 -146
- package/dist/agents/agent-loader.js.map +1 -1
- package/package.json +1 -1
- package/.claude/skills/cfn-agent-selector/SKILL.md.backup_before_replace +0 -91
- package/.claude/skills/cfn-loop-orchestration/helpers/validate-task-context.sh +0 -241
- package/.claude/skills/pre-edit-backup/backup.sh +0 -130
- package/.claude/skills/pre-edit-backup/cleanup.sh +0 -155
- package/.claude/skills/pre-edit-backup/restore.sh +0 -128
- package/.claude/skills/pre-edit-backup/revert-file.sh +0 -168
- package/claude-assets/agents/cfn-dev-team/CLAUDE.md.backup_before_replace +0 -1086
- package/claude-assets/agents/cfn-dev-team/README.md.backup_before_replace +0 -116
- package/claude-assets/agents/cfn-dev-team/coordinators/cfn-v3-coordinator.md.backup_before_replace +0 -451
- package/claude-assets/agents/cfn-dev-team/developers/README.md.backup_before_replace +0 -69
- package/claude-assets/agents/cfn-dev-team/documentation/agent-type-guidelines.md.backup_before_replace +0 -465
- package/claude-assets/agents/cfn-dev-team/test-agent.md.backup_before_replace +0 -141
- package/claude-assets/skills/CFN-LOOP-VALIDATION.md +0 -202
- package/claude-assets/skills/REDIS-COORDINATION.md +0 -187
- package/claude-assets/skills/SKILL.md +0 -229
- package/claude-assets/skills/agent-discovery/agents-registry.json +0 -484
- package/claude-assets/skills/agent-name-validation/README.md +0 -28
- package/claude-assets/skills/agent-name-validation/SKILL.md +0 -168
- package/claude-assets/skills/agent-name-validation/validate-agent-names.sh +0 -47
- package/claude-assets/skills/cfn-agent-selector/SKILL.md.backup_before_replace +0 -91
- package/claude-assets/skills/cfn-loop-orchestration/helpers/validate-task-context.sh +0 -241
- package/claude-assets/skills/consensus-calculator.js +0 -45
- package/claude-assets/skills/evidence-chain.sql +0 -66
- package/claude-assets/skills/hook-pipeline/bash-dependency-checker.sh +0 -89
- package/claude-assets/skills/hook-pipeline/bash-pipe-safety.sh +0 -69
- package/claude-assets/skills/hook-pipeline/enforce-lf.sh +0 -36
- package/claude-assets/skills/hook-pipeline/js-promise-safety.sh +0 -110
- package/claude-assets/skills/hook-pipeline/python-async-safety.py +0 -124
- package/claude-assets/skills/hook-pipeline/python-import-checker.py +0 -114
- package/claude-assets/skills/hook-pipeline/python-subprocess-safety.py +0 -77
- package/claude-assets/skills/hook-pipeline/rust-command-safety.sh +0 -38
- package/claude-assets/skills/hook-pipeline/rust-dependency-checker.sh +0 -50
- package/claude-assets/skills/hook-pipeline/rust-future-safety.sh +0 -50
- package/claude-assets/skills/pre-edit-backup/backup.sh +0 -130
- package/claude-assets/skills/pre-edit-backup/cleanup.sh +0 -155
- package/claude-assets/skills/pre-edit-backup/restore.sh +0 -128
- package/claude-assets/skills/pre-edit-backup/revert-file.sh +0 -168
- package/claude-assets/skills/run-all-skill-tests.sh +0 -124
- package/claude-assets/skills/seo-orchestration/SKILL.md +0 -292
- package/claude-assets/skills/seo-orchestration/orchestrate-seo.sh +0 -566
- package/claude-assets/skills/seo-orchestration/orchestrate-seo.sh.backup +0 -755
- package/claude-assets/skills/seo-orchestration/validate-consensus.sh +0 -270
- package/claude-assets/skills/team-provider-routing/execute-agent.sh +0 -76
- package/claude-assets/skills/test-execution-coordinator-pattern.md +0 -228
|
@@ -0,0 +1,256 @@
|
|
|
1
|
+
# Multi-Coordinator Planning Skill
|
|
2
|
+
|
|
3
|
+
**Purpose:** Systematic planning and validation for parallel multi-coordinator execution workflows, designed to prevent Zone B-style execution failures.
|
|
4
|
+
|
|
5
|
+
## Overview
|
|
6
|
+
|
|
7
|
+
This skill provides comprehensive pre-flight planning for multi-coordinator execution, addressing the critical failures identified in the Zone B analysis:
|
|
8
|
+
- Redis namespace collision (Echo zone)
|
|
9
|
+
- Protocol compliance breakdown (Alpha/Charlie zones)
|
|
10
|
+
- Orchestration gaps (Delta zone)
|
|
11
|
+
- Consensus on vapor anti-patterns (Bravo zone)
|
|
12
|
+
|
|
13
|
+
## Quick Start
|
|
14
|
+
|
|
15
|
+
```bash
|
|
16
|
+
# Create zone configuration
|
|
17
|
+
cat > zone-config.json << 'EOF'
|
|
18
|
+
{
|
|
19
|
+
"zones": [
|
|
20
|
+
{
|
|
21
|
+
"name": "zone-alpha",
|
|
22
|
+
"task_description": "Implement React authentication component with TypeScript interfaces",
|
|
23
|
+
"deliverables": [
|
|
24
|
+
"src/components/AuthForm.tsx",
|
|
25
|
+
"src/types/auth.ts",
|
|
26
|
+
"src/hooks/useAuth.ts",
|
|
27
|
+
"tests/auth.test.ts"
|
|
28
|
+
],
|
|
29
|
+
"agent_types": ["react-frontend-engineer", "reviewer", "tester"],
|
|
30
|
+
"acceptance_criteria": [
|
|
31
|
+
"Form validates user input",
|
|
32
|
+
"Authentication state managed globally",
|
|
33
|
+
"Component tested with >80% coverage"
|
|
34
|
+
],
|
|
35
|
+
"in_scope": ["React components", "TypeScript interfaces"],
|
|
36
|
+
"out_of_scope": ["Backend authentication"],
|
|
37
|
+
"directory": "src/auth"
|
|
38
|
+
}
|
|
39
|
+
]
|
|
40
|
+
}
|
|
41
|
+
EOF
|
|
42
|
+
|
|
43
|
+
# Execute planning
|
|
44
|
+
./.claude/skills/cfn-multi-coordinator-planning/plan-multi-coordinator-work.sh zone-config.json
|
|
45
|
+
```
|
|
46
|
+
|
|
47
|
+
## Components
|
|
48
|
+
|
|
49
|
+
### 1. Main Planning Script
|
|
50
|
+
- **`plan-multi-coordinator-work.sh`** - Orchestrates all planning phases
|
|
51
|
+
|
|
52
|
+
### 2. Planning Phase Scripts
|
|
53
|
+
- **`validate-task-planning.sh`** - Task configuration validation
|
|
54
|
+
- **`plan-coordinator-resources.sh`** - Resource allocation and namespace planning
|
|
55
|
+
- **`map-dependencies-conflicts.sh`** - Dependency analysis and conflict resolution
|
|
56
|
+
- **`plan-risk-rollout.sh`** - Risk-based rollout strategy
|
|
57
|
+
|
|
58
|
+
### 3. Testing
|
|
59
|
+
- **`test-multi-coordinator-planning.sh`** - Comprehensive test suite
|
|
60
|
+
|
|
61
|
+
## Configuration Format
|
|
62
|
+
|
|
63
|
+
### Zone Configuration Structure
|
|
64
|
+
```json
|
|
65
|
+
{
|
|
66
|
+
"zones": [
|
|
67
|
+
{
|
|
68
|
+
"name": "zone-identifier",
|
|
69
|
+
"task_description": "Specific implementation task with clear deliverables",
|
|
70
|
+
"deliverables": [
|
|
71
|
+
"file/path/to/deliverable.ext"
|
|
72
|
+
],
|
|
73
|
+
"agent_types": ["required-agent-types"],
|
|
74
|
+
"acceptance_criteria": [
|
|
75
|
+
"Measurable acceptance criteria"
|
|
76
|
+
],
|
|
77
|
+
"in_scope": ["items in scope"],
|
|
78
|
+
"out_of_scope": ["items out of scope"],
|
|
79
|
+
"directory": "working/directory",
|
|
80
|
+
"risk_factors": ["optional-risk-factors"]
|
|
81
|
+
}
|
|
82
|
+
]
|
|
83
|
+
}
|
|
84
|
+
```
|
|
85
|
+
|
|
86
|
+
### Validation Requirements
|
|
87
|
+
- **Minimum 3 deliverables** for software tasks
|
|
88
|
+
- **Minimum 2 agent types** (prevents single-agent anti-patterns)
|
|
89
|
+
- **Specific task descriptions** (no generic "implementation" tasks)
|
|
90
|
+
- **Acceptance criteria** required
|
|
91
|
+
- **In-scope/out-of-scope boundaries** required
|
|
92
|
+
|
|
93
|
+
## Usage Examples
|
|
94
|
+
|
|
95
|
+
### Basic Planning
|
|
96
|
+
```bash
|
|
97
|
+
./plan-multi-coordinator-work.sh zone-config.json
|
|
98
|
+
```
|
|
99
|
+
|
|
100
|
+
### Advanced Planning with Custom Parameters
|
|
101
|
+
```bash
|
|
102
|
+
./plan-multi-coordinator-work.sh zone-config.json \
|
|
103
|
+
--max-zones-per-phase 3 \
|
|
104
|
+
--output-dir ./plans \
|
|
105
|
+
--dry-run
|
|
106
|
+
```
|
|
107
|
+
|
|
108
|
+
### Skip Validation (Not Recommended)
|
|
109
|
+
```bash
|
|
110
|
+
./plan-multi-coordinator-work.sh zone-config.json --skip-validation
|
|
111
|
+
```
|
|
112
|
+
|
|
113
|
+
## Planning Phases
|
|
114
|
+
|
|
115
|
+
### Phase 1: Task Validation
|
|
116
|
+
- Deliverable specificity verification
|
|
117
|
+
- Agent type diversity requirements
|
|
118
|
+
- Context completeness scoring
|
|
119
|
+
- Anti-pattern detection
|
|
120
|
+
|
|
121
|
+
### Phase 2: Resource Allocation
|
|
122
|
+
- Redis namespace reservation and isolation
|
|
123
|
+
- Memory/CPU capacity planning
|
|
124
|
+
- Coordinator limit calculations
|
|
125
|
+
- Working directory allocation
|
|
126
|
+
|
|
127
|
+
### Phase 3: Dependency Analysis
|
|
128
|
+
- Cross-zone dependency identification
|
|
129
|
+
- Shared resource conflict detection
|
|
130
|
+
- Completion pathway validation
|
|
131
|
+
- Resolution strategy creation
|
|
132
|
+
|
|
133
|
+
### Phase 4: Risk-Based Rollout
|
|
134
|
+
- Zone complexity ranking
|
|
135
|
+
- Graduated phase rollout
|
|
136
|
+
- Success gate definition
|
|
137
|
+
- Rollback trigger configuration
|
|
138
|
+
|
|
139
|
+
## Output Files
|
|
140
|
+
|
|
141
|
+
### Generated Plans
|
|
142
|
+
- `coordinator-resource-plan-*.json` - Resource allocation mapping
|
|
143
|
+
- `dependency-conflict-analysis-*.json` - Dependencies and conflicts analysis
|
|
144
|
+
- `rollout-plan-*.json` - Risk-based rollout strategy
|
|
145
|
+
- `multi-coordinator-planning-summary-*.json` - Execution summary
|
|
146
|
+
|
|
147
|
+
### Structure
|
|
148
|
+
```json
|
|
149
|
+
{
|
|
150
|
+
"timestamp": 1699123456,
|
|
151
|
+
"zone_count": 2,
|
|
152
|
+
"system_resources": {...},
|
|
153
|
+
"resource_plans": [...],
|
|
154
|
+
"phases": [...],
|
|
155
|
+
"success_criteria": [...],
|
|
156
|
+
"rollback_triggers": [...]
|
|
157
|
+
}
|
|
158
|
+
```
|
|
159
|
+
|
|
160
|
+
## Risk Mitigation
|
|
161
|
+
|
|
162
|
+
### Prevents Zone B Failures
|
|
163
|
+
1. **Namespace Collision Prevention** - Redis DB allocation per zone
|
|
164
|
+
2. **Protocol Compliance** - Agent completion pathway validation
|
|
165
|
+
3. **Orchestration Gaps** - Coordinator lifecycle management
|
|
166
|
+
4. **Anti-Pattern Detection** - Consensus on vapor prevention
|
|
167
|
+
|
|
168
|
+
### Rollback Strategies
|
|
169
|
+
- Immediate rollback on critical failures
|
|
170
|
+
- Phase-specific rollback triggers
|
|
171
|
+
- Context preservation and recovery
|
|
172
|
+
- Emergency stop and cleanup procedures
|
|
173
|
+
|
|
174
|
+
## Testing
|
|
175
|
+
|
|
176
|
+
```bash
|
|
177
|
+
# Run comprehensive test suite
|
|
178
|
+
./test-multi-coordinator-planning.sh
|
|
179
|
+
|
|
180
|
+
# Test individual components
|
|
181
|
+
./validate-task-planning.sh test-config.json
|
|
182
|
+
./plan-coordinator-resources.sh test-config.json
|
|
183
|
+
./map-dependencies-conflicts.sh test-config.json
|
|
184
|
+
./plan-risk-rollout.sh test-config.json
|
|
185
|
+
```
|
|
186
|
+
|
|
187
|
+
## Integration with CFN Loop
|
|
188
|
+
|
|
189
|
+
This skill integrates with the existing CFN Loop ecosystem:
|
|
190
|
+
|
|
191
|
+
### Pre-Flight Validation
|
|
192
|
+
- Use before `/cfn-loop-cli` multi-coordinator execution
|
|
193
|
+
- Validates coordinator readiness and resource availability
|
|
194
|
+
- Prevents execution failures through comprehensive planning
|
|
195
|
+
|
|
196
|
+
### CLI Spawning Support
|
|
197
|
+
- Generates CLI-compatible coordinator configurations
|
|
198
|
+
- Supports the recommendation to spawn coordinators via CLI
|
|
199
|
+
- Enables Main Chat monitoring and interjection capabilities
|
|
200
|
+
|
|
201
|
+
### Redis Coordination
|
|
202
|
+
- Uses existing Redis coordination patterns
|
|
203
|
+
- Integrates with `cfn-redis-coordination` skill
|
|
204
|
+
- Maintains namespace isolation standards
|
|
205
|
+
|
|
206
|
+
## Best Practices
|
|
207
|
+
|
|
208
|
+
### Planning Phase
|
|
209
|
+
1. **Always validate configurations** before execution
|
|
210
|
+
2. **Use graduated rollout** for complex multi-zone scenarios
|
|
211
|
+
3. **Monitor resource utilization** during planning
|
|
212
|
+
4. **Test rollback procedures** before production execution
|
|
213
|
+
|
|
214
|
+
### Configuration
|
|
215
|
+
1. **Be specific** about deliverables and acceptance criteria
|
|
216
|
+
2. **Include risk factors** for accurate complexity assessment
|
|
217
|
+
3. **Define clear scope boundaries** to prevent scope creep
|
|
218
|
+
4. **Use appropriate agent types** for task complexity
|
|
219
|
+
|
|
220
|
+
### Execution
|
|
221
|
+
1. **Follow the rollout sequence** generated by the planner
|
|
222
|
+
2. **Monitor each phase** before proceeding to the next
|
|
223
|
+
3. **Be prepared to rollback** on trigger activation
|
|
224
|
+
4. **Document lessons learned** for future planning
|
|
225
|
+
|
|
226
|
+
## Troubleshooting
|
|
227
|
+
|
|
228
|
+
### Common Issues
|
|
229
|
+
- **Redis connection failures** - Check Redis service status
|
|
230
|
+
- **Resource exhaustion** - Reduce concurrent zones or increase resources
|
|
231
|
+
- **Validation failures** - Review configuration against requirements
|
|
232
|
+
- **Namespace conflicts** - Ensure unique zone names and task IDs
|
|
233
|
+
|
|
234
|
+
### Debug Mode
|
|
235
|
+
```bash
|
|
236
|
+
# Enable verbose output
|
|
237
|
+
set -x
|
|
238
|
+
./plan-multi-coordinator-work.sh zone-config.json
|
|
239
|
+
set +x
|
|
240
|
+
```
|
|
241
|
+
|
|
242
|
+
## Dependencies
|
|
243
|
+
|
|
244
|
+
- **jq** - JSON processing
|
|
245
|
+
- **redis-cli** - Redis connectivity and namespace planning
|
|
246
|
+
- **bc** - Mathematical calculations
|
|
247
|
+
- **Redis server** - Namespace reservation and coordination
|
|
248
|
+
|
|
249
|
+
## Maintenance
|
|
250
|
+
|
|
251
|
+
- Regular testing of all planning phases
|
|
252
|
+
- Update validation rules based on new failure patterns
|
|
253
|
+
- Enhance resource planning algorithms
|
|
254
|
+
- Extend rollback trigger configurations
|
|
255
|
+
|
|
256
|
+
---
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
# Multi-Coordinator Planning Skill
|
|
2
|
+
|
|
3
|
+
**Purpose:** Systematic planning and validation for parallel multi-coordinator execution workflows.
|
|
4
|
+
|
|
5
|
+
**Usage:**
|
|
6
|
+
```bash
|
|
7
|
+
./.claude/skills/cfn-multi-coordinator-planning/plan-multi-coordinator-work.sh [zone-config-file]
|
|
8
|
+
```
|
|
9
|
+
|
|
10
|
+
## Overview
|
|
11
|
+
|
|
12
|
+
Prevents Zone B-style execution failures through comprehensive pre-flight planning, resource allocation, and risk-based rollout validation.
|
|
13
|
+
|
|
14
|
+
## Core Functions
|
|
15
|
+
|
|
16
|
+
### 1. Task Configuration Validation
|
|
17
|
+
- Deliverable specificity verification
|
|
18
|
+
- Agent type diversity requirements
|
|
19
|
+
- Context completeness scoring
|
|
20
|
+
- Anti-pattern detection (consensus on vapor)
|
|
21
|
+
|
|
22
|
+
### 2. Resource Allocation Planning
|
|
23
|
+
- Redis namespace reservation and isolation
|
|
24
|
+
- Memory/CPU capacity planning per coordinator
|
|
25
|
+
- Coordinator limit calculations
|
|
26
|
+
- Monitoring overhead allocation
|
|
27
|
+
|
|
28
|
+
### 3. Dependency & Conflict Mapping
|
|
29
|
+
- Cross-zone dependency identification
|
|
30
|
+
- Shared resource conflict resolution
|
|
31
|
+
- Completion pathway validation
|
|
32
|
+
- Failure escalation planning
|
|
33
|
+
|
|
34
|
+
### 4. Risk-Based Rollout Strategy
|
|
35
|
+
- Zone complexity ranking
|
|
36
|
+
- Graduated phase rollout
|
|
37
|
+
- Success gate validation
|
|
38
|
+
- Rollback trigger definition
|
|
39
|
+
|
|
40
|
+
## Inputs
|
|
41
|
+
|
|
42
|
+
- Zone configuration file (JSON format)
|
|
43
|
+
- Task definitions per zone
|
|
44
|
+
- Resource availability parameters
|
|
45
|
+
- Risk tolerance settings
|
|
46
|
+
|
|
47
|
+
## Outputs
|
|
48
|
+
|
|
49
|
+
- Validated execution plan
|
|
50
|
+
- Resource allocation mapping
|
|
51
|
+
- Rollout sequence with success gates
|
|
52
|
+
- Risk assessment and mitigation strategies
|
|
53
|
+
|
|
54
|
+
## Validation
|
|
55
|
+
|
|
56
|
+
Comprehensive test suite covering:
|
|
57
|
+
- Namespace collision detection
|
|
58
|
+
- Resource capacity validation
|
|
59
|
+
- Dependency conflict resolution
|
|
60
|
+
- Rollout scenario testing
|
|
61
|
+
|
|
62
|
+
---
|
|
@@ -0,0 +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
|
|
376
|
+
main "$@"
|