claude-flow-novice 2.15.9 → 2.15.10

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (39) hide show
  1. package/.claude/skills/cfn-loop-orchestration/IMPLEMENTATION_SUMMARY.md +519 -0
  2. package/.claude/skills/cfn-loop-orchestration/ORCHESTRATOR_IMPLEMENTATION.md +493 -0
  3. package/.claude/skills/cfn-loop-orchestration/ORCHESTRATOR_QUICK_START.md +499 -0
  4. package/.claude/skills/cfn-loop-orchestration/helpers/orchestrate-ts.sh +104 -0
  5. package/.claude/skills/cfn-loop-orchestration/orchestrate.sh +2 -2
  6. package/.claude/skills/cfn-loop-orchestration/src/orchestrate.ts +648 -0
  7. package/.claude/skills/cfn-loop-orchestration/tests/orchestrate.test.ts +836 -0
  8. package/README.md +205 -10
  9. package/claude-assets/agents/cfn-dev-team/coordinators/cfn-v3-coordinator.md +180 -229
  10. package/claude-assets/agents/cfn-dev-team/dev-ops/docker-specialist.md +2 -0
  11. package/claude-assets/agents/cfn-dev-team/dev-ops/kubernetes-specialist.md +2 -0
  12. package/claude-assets/agents/cfn-dev-team/developers/api-gateway-specialist.md +2 -1
  13. package/claude-assets/agents/cfn-dev-team/developers/database/database-architect.md +3 -0
  14. package/claude-assets/agents/cfn-dev-team/developers/frontend/mobile-dev.md +4 -1
  15. package/claude-assets/agents/cfn-dev-team/developers/frontend/react-frontend-engineer.md +4 -1
  16. package/claude-assets/agents/cfn-dev-team/developers/frontend/typescript-specialist.md +4 -1
  17. package/claude-assets/agents/cfn-dev-team/developers/frontend/ui-designer.md +5 -0
  18. package/claude-assets/agents/cfn-dev-team/developers/graphql-specialist.md +2 -1
  19. package/claude-assets/agents/cfn-dev-team/developers/rust-developer.md +2 -1
  20. package/claude-assets/agents/cfn-dev-team/documentation/pseudocode.md +2 -7
  21. package/claude-assets/agents/cfn-dev-team/utility/epic-creator.md +16 -9
  22. package/claude-assets/agents/cfn-dev-team/utility/memory-leak-specialist.md +16 -9
  23. package/claude-assets/agents/cfn-dev-team/utility/z-ai-specialist.md +16 -9
  24. package/claude-assets/skills/cfn-loop-orchestration/IMPLEMENTATION_SUMMARY.md +519 -0
  25. package/claude-assets/skills/cfn-loop-orchestration/ORCHESTRATOR_IMPLEMENTATION.md +493 -0
  26. package/claude-assets/skills/cfn-loop-orchestration/ORCHESTRATOR_QUICK_START.md +499 -0
  27. package/claude-assets/skills/cfn-loop-orchestration/helpers/orchestrate-ts.sh +104 -0
  28. package/claude-assets/skills/cfn-loop-orchestration/orchestrate.sh +2 -2
  29. package/claude-assets/skills/cfn-loop-orchestration/src/orchestrate.ts +648 -0
  30. package/claude-assets/skills/cfn-loop-orchestration/tests/orchestrate.test.ts +836 -0
  31. package/dist/cli/config-manager.js +91 -109
  32. package/dist/cli/config-manager.js.map +1 -1
  33. package/dist/coordination/coordinate.js +369 -0
  34. package/dist/coordination/coordinate.js.map +1 -0
  35. package/dist/coordination/spawn-agent.js +364 -0
  36. package/dist/coordination/spawn-agent.js.map +1 -0
  37. package/dist/coordination/types-export.js +38 -0
  38. package/dist/coordination/types-export.js.map +1 -0
  39. package/package.json +1 -1
package/README.md CHANGED
@@ -4,7 +4,7 @@
4
4
  [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)
5
5
  [![Node.js Version](https://img.shields.io/badge/node-%3E%3D18.0.0-brightgreen)](https://nodejs.org/)
6
6
  [![CI Pipeline](https://github.com/yourusername/claude-flow-novice/actions/workflows/ci.yml/badge.svg)](https://github.com/yourusername/claude-flow-novice/actions/workflows/ci.yml)
7
- [![Coverage Report](https://img.shields.io/badge/coverage-dynamic-blue)](docs/CI_CD_PIPELINE.md)
7
+ [![Coverage Report](https://img.shields.io/badge/coverage-dynamic-blue)](.github/workflows)
8
8
 
9
9
  Autonomous self-correcting AI agent orchestration with multi-domain support and intelligent learning capabilities.
10
10
 
@@ -437,25 +437,220 @@ See `readme/logs-tools.md` for complete documentation.
437
437
 
438
438
  ## Testing
439
439
 
440
+ Claude Flow Novice includes comprehensive test suites across multiple execution modes and test types. Choose the appropriate test runner based on your development context.
441
+
442
+ ### Quick Start
443
+
444
+ ```bash
445
+ # Run all npm-based tests (unit, integration, e2e)
446
+ npm test
447
+
448
+ # Run CLI mode test suite (test-driven validation)
449
+ ./tests/cli-mode/run-all-tests.sh
450
+
451
+ # Run Docker mode test suite (45 production tests)
452
+ ./tests/docker-mode/run-all-implementations.sh
453
+ ```
454
+
455
+ ### Test Execution Modes
456
+
457
+ #### CLI Mode Tests (Production)
458
+ Run the CLI mode test suite to validate end-to-end coordination, quality gates, and agent spawning:
459
+
460
+ ```bash
461
+ # Full test suite with all assertions
462
+ ./tests/cli-mode/run-all-tests.sh
463
+
464
+ # Expected runtime: ~5-10 minutes
465
+ # Tests: 8 suites, 159 total assertions
466
+ # Coverage: Redis coordination, threshold enforcement, agent spawning, path resolution
467
+ ```
468
+
469
+ **Validates:**
470
+ - `/cfn-loop-cli` slash command workflow
471
+ - Coordinator spawning and orchestration
472
+ - Loop 3 → Loop 2 → Product Owner progression
473
+ - Quality gate enforcement (MVP/Standard/Enterprise modes)
474
+ - Redis coordination layer
475
+ - Agent tool access and permissions
476
+
477
+ **Prerequisites:**
478
+ - Redis running (`redis-server`)
479
+ - Project built (`npm run build`)
480
+ - Z.ai API key configured (`.env`) for integration tests
481
+
482
+ **Documentation:** See `tests/cli-mode/README.md` for detailed test descriptions and results.
483
+
484
+ #### Docker Mode Tests (Integration)
485
+ Run the Docker mode test suite to validate real container-based orchestration:
486
+
487
+ ```bash
488
+ # Run all 45 Docker test implementations
489
+ ./tests/docker-mode/run-all-implementations.sh
490
+
491
+ # Expected runtime: ~3-5 minutes
492
+ # Tests: 45 production tests across 3 suites
493
+ # Coverage: Coordinator spawning, orchestrator workflow, TDD compliance
494
+ ```
495
+
496
+ **Test Suites:**
497
+ - Coordinator Spawning (13 tests): Container cleanup, exit codes, service discovery
498
+ - Orchestrator Workflow (13 tests): Iteration management, monitoring, recovery
499
+ - TDD Compliance (19 tests): Test-driven validation, metrics collection, parallel execution
500
+
501
+ **Prerequisites:**
502
+ - Docker daemon running (`docker ps`)
503
+ - No port conflicts (Docker networks auto-created)
504
+ - ~2GB available memory for container execution
505
+
506
+ **Documentation:** See `tests/docker-mode/README.md` for test categories and patterns.
507
+
508
+ #### NPM-Based Tests (Development)
509
+ Run standard npm test commands for fast feedback during development:
510
+
440
511
  ```bash
441
512
  # Run all tests
442
513
  npm test
443
514
 
444
515
  # Run specific test suites
445
- npm run test:unit
446
- npm run test:integration
447
- npm run test:e2e
516
+ npm run test:unit # Unit tests only
517
+ npm run test:integration # Integration tests only
518
+ npm run test:e2e # End-to-end tests only
448
519
 
449
- # CFN Loop end-to-end tests
450
- ./tests/cfn-v3/test-e2e-cfn-loop.sh
520
+ # Run with coverage
521
+ npm test -- --coverage
522
+
523
+ # Watch mode (re-run on file changes)
524
+ npm test -- --watch
525
+ ```
526
+
527
+ **Expected runtime:**
528
+ - Unit tests: ~1-2 minutes
529
+ - Integration tests: ~2-3 minutes
530
+ - E2E tests: ~3-5 minutes
531
+
532
+ #### CFN Loop End-to-End Tests
533
+ Run specialized CFN Loop tests for validation and debugging:
534
+
535
+ ```bash
536
+ # Validate CFN Loop coordinator handoffs
451
537
  ./tests/cfn-v3/test-coordinator-handoffs.sh
538
+
539
+ # Full CFN Loop e2e test
540
+ ./tests/cfn-v3/test-e2e-cfn-loop.sh
541
+
542
+ # Enterprise change management tests
543
+ ./tests/enterprise/run-all-enterprise-tests.sh
452
544
  ```
453
545
 
454
- ---
546
+ ### Test Organization
547
+
548
+ ```
549
+ tests/
550
+ ├── cli-mode/ # CLI mode validation (8 tests, 159 assertions)
551
+ │ ├── README.md # CLI test documentation
552
+ │ ├── run-all-tests.sh # Test runner
553
+ │ └── test-*.sh # Individual test suites
554
+ ├── docker-mode/ # Docker integration tests (45 tests)
555
+ │ ├── README.md # Docker test documentation
556
+ │ ├── run-all-implementations.sh # Test runner
557
+ │ └── implementations/
558
+ │ ├── coordinator-spawning-real-tests.sh
559
+ │ ├── orchestrator-workflow-real-tests.sh
560
+ │ └── tdd-compliance-real-tests.sh
561
+ ├── docker/ # Docker-based core tests
562
+ │ ├── coordination/ # Redis coordination tests
563
+ │ ├── lifecycle/ # Container lifecycle tests
564
+ │ └── perf/ # Performance benchmarks
565
+ ├── cfn-v3/ # CFN Loop validation tests
566
+ ├── enterprise/ # Enterprise mode tests
567
+ ├── CLAUDE.md # Test authoring standards
568
+ ├── test-utils.sh # Shared test utilities
569
+ └── README.md # Test suite documentation
570
+ ```
571
+
572
+ ### Test Coverage Matrix
573
+
574
+ | Mode | Type | Tests | Duration | Prerequisites |
575
+ |------|------|-------|----------|---|
576
+ | CLI | Unit + Integration + E2E | 159 assertions | 5-10 min | Redis, npm build |
577
+ | Docker | Production integration | 45 tests | 3-5 min | Docker daemon |
578
+ | NPM | Development | Variable | 1-5 min | Node.js, npm |
579
+ | CFN Loop | Workflow validation | Variable | 5-15 min | Full environment |
580
+
581
+ ### Test Authoring Guidelines
582
+
583
+ For developers writing new tests, see `tests/CLAUDE.md` which documents:
584
+ - Boilerplate template structure
585
+ - GIVEN/WHEN/THEN assertion patterns
586
+ - Production testing requirements (BUG #21)
587
+ - Infrastructure vs integration test patterns
588
+ - Cleanup and resource management
589
+ - Review checklist for test quality
590
+
591
+ Key principles:
592
+ - Infrastructure tests (mocks OK): Docker networking, volumes, Redis connectivity
593
+ - Integration tests (real images/scripts): Agent spawning, CLI execution, production workflows
594
+ - Always use `set -euo pipefail` and `trap cleanup EXIT`
595
+ - Route output through `log_step`, `log_info`, `annotate`, `assert_success` helpers
596
+ - Cite relevant bugs in test comments for future context
597
+
598
+ ### CI/CD Integration
599
+
600
+ Tests run automatically in GitHub Actions on every push and pull request. See [CI/CD Pipeline Documentation](.github/workflows) for:
601
+ - Coverage gates (80%+ lines/statements/functions)
602
+ - Test failure notifications
603
+ - Performance benchmarking
604
+ - Security scanning
605
+ - Deployment workflows
606
+
607
+ ### Troubleshooting
608
+
609
+ **Redis not available:**
610
+ ```bash
611
+ # Start Redis in background
612
+ redis-server --daemonize yes
613
+
614
+ # Or run in Docker
615
+ docker run -d -p 6379:6379 redis:7-alpine
616
+ ```
617
+
618
+ **Docker permission denied:**
619
+ ```bash
620
+ # Add user to docker group
621
+ sudo usermod -aG docker $USER
622
+ newgrp docker
623
+ ```
624
+
625
+ **Port conflicts:**
626
+ ```bash
627
+ # Stop and remove existing containers
628
+ docker stop $(docker ps -aq)
629
+ docker rm $(docker ps -aq)
630
+
631
+ # Clean up Docker networks
632
+ docker network prune -f
633
+ ```
634
+
635
+ **Test failures with unclear messages:**
636
+ ```bash
637
+ # Run with verbose output
638
+ DEBUG=true ./tests/cli-mode/run-all-tests.sh
639
+ DEBUG=true ./tests/docker-mode/run-all-implementations.sh
640
+
641
+ # Check test logs in .artifacts/
642
+ tail -100 .artifacts/logs/test-execution.log
643
+ ```
455
644
 
456
- ## Contributing
645
+ ### Related Documentation
457
646
 
458
- We welcome contributions! See [CONTRIBUTING.md](CONTRIBUTING.md) for guidelines.
647
+ - **Test Suite Overview:** `tests/README.md`
648
+ - **Test Authoring Standards:** `tests/CLAUDE.md`
649
+ - **CLI Mode Details:** `tests/cli-mode/README.md`
650
+ - **Docker Mode Details:** `tests/docker-mode/README.md`
651
+ - **Test Coverage Analysis:** `tests/TEST_COVERAGE_MATRIX.md`
652
+ - **CFN Loop Architecture:** `docs/CFN_LOOP_ARCHITECTURE.md`
653
+ - **CI/CD Pipeline:** `.github/workflows`
459
654
 
460
655
  ### Development Setup
461
656
 
@@ -476,7 +671,7 @@ npm run build
476
671
 
477
672
  ### CI/CD Pipeline
478
673
 
479
- Comprehensive GitHub Actions automation with unit testing, integration testing, coverage gates (80%+ lines/statements/functions), security scanning, and deployment workflows. See [CI/CD Pipeline Documentation](docs/CI_CD_PIPELINE.md) for details.
674
+ Comprehensive GitHub Actions automation with unit testing, integration testing, coverage gates (80%+ lines/statements/functions), security scanning, and deployment workflows. See [CI/CD Pipeline Documentation](.github/workflows) for details.
480
675
 
481
676
  ---
482
677
 
@@ -319,6 +319,184 @@ All generated criteria MUST conform to:
319
319
 
320
320
  Orchestrate CFN Loop v3 execution using Redis coordination for CLI agent spawning, context management, and consensus collection.
321
321
 
322
+ ## COORDINATOR EXECUTION (START HERE - MANDATORY)
323
+
324
+ **Execute ALL 5 actions in THIS bash script below. DO NOT execute actions separately.**
325
+
326
+ **CRITICAL:** This is THE execution path. Execute the complete bash script in ONE call.
327
+
328
+ ### Unified Execution Script (Actions 1-5)
329
+
330
+ ```bash
331
+ #!/bin/bash
332
+ set -euo pipefail
333
+
334
+ # ITERATION GUARD: Prevent infinite loops
335
+ if [[ ${BASH_EXECUTION_COUNT:-0} -gt 1 ]]; then
336
+ echo "❌ FATAL: Multiple executions detected - orchestrator should have been invoked" >&2
337
+ exit 1
338
+ fi
339
+ export BASH_EXECUTION_COUNT=$((${BASH_EXECUTION_COUNT:-0} + 1))
340
+
341
+ # ==============================================================================
342
+ # ACTION 1: Initialize Task Context
343
+ # ==============================================================================
344
+ TASK_ID="${TASK_ID:-$(date +%s)}"
345
+ TASK_DESCRIPTION="${TASK_DESCRIPTION:-Generic CFN Loop task}"
346
+ MODE="${MODE:-standard}"
347
+ MAX_ITERATIONS="${MAX_ITERATIONS:-10}" # Default to 10, can be overridden via context
348
+ PROJECT_ROOT="${PROJECT_ROOT:-.}"
349
+
350
+ echo "📋 COORDINATOR INITIALIZATION (CLI Mode v3.0)"
351
+ echo " TASK_ID: $TASK_ID"
352
+ echo " MODE: $MODE"
353
+ echo " TASK: $TASK_DESCRIPTION"
354
+
355
+ # ==============================================================================
356
+ # ACTION 2: Perform Task Classification
357
+ # ==============================================================================
358
+ TASK_TYPE="software-development" # Default fallback
359
+
360
+ if [[ -f "$PROJECT_ROOT/.claude/skills/task-classifier/classify-task.sh" ]]; then
361
+ CLASSIFIED=$(bash "$PROJECT_ROOT/.claude/skills/task-classifier/classify-task.sh" "$TASK_DESCRIPTION" 2>/dev/null || echo "")
362
+ [[ -n "$CLASSIFIED" ]] && TASK_TYPE="$CLASSIFIED"
363
+ fi
364
+
365
+ # Store in Redis for persistence across Bash tool calls
366
+ redis-cli -h "${REDIS_HOST:-localhost}" -p "${REDIS_PORT:-6379}" \
367
+ HSET "swarm:${TASK_ID}:config" "task_type" "$TASK_TYPE" 2>/dev/null || true
368
+
369
+ echo "✅ ACTION 2 Complete: Task classified as '$TASK_TYPE'"
370
+
371
+ # ==============================================================================
372
+ # ACTION 3: Select Agents Based on Task Type
373
+ # ==============================================================================
374
+ case "$TASK_TYPE" in
375
+ "infrastructure")
376
+ LOOP3_AGENTS="terraform-engineer,devops-engineer,cloud-architect"
377
+ LOOP2_AGENTS="security-auditor,compliance-checker,cost-optimizer"
378
+ PRODUCT_OWNER="infrastructure-product-owner"
379
+ ;;
380
+ "software-development"|*)
381
+ LOOP3_AGENTS="backend-developer,frontend-developer,database-engineer"
382
+ LOOP2_AGENTS="code-reviewer,security-specialist,performance-tester"
383
+ PRODUCT_OWNER="technical-product-owner"
384
+ ;;
385
+ esac
386
+
387
+ # Store in Redis
388
+ redis-cli -h "${REDIS_HOST:-localhost}" -p "${REDIS_PORT:-6379}" \
389
+ HSET "swarm:${TASK_ID}:config" "loop3_agents" "$LOOP3_AGENTS" 2>/dev/null || true
390
+ redis-cli -h "${REDIS_HOST:-localhost}" -p "${REDIS_PORT:-6379}" \
391
+ HSET "swarm:${TASK_ID}:config" "loop2_agents" "$LOOP2_AGENTS" 2>/dev/null || true
392
+
393
+ echo "✅ ACTION 3 Complete: Agents selected"
394
+ echo " Loop 3: $LOOP3_AGENTS"
395
+ echo " Loop 2: $LOOP2_AGENTS"
396
+ echo " Product Owner: $PRODUCT_OWNER"
397
+
398
+ # ==============================================================================
399
+ # ACTION 4: Validate Parameters
400
+ # ==============================================================================
401
+ if [[ -z "$TASK_ID" ]]; then
402
+ echo "❌ FATAL: TASK_ID is required" >&2
403
+ exit 1
404
+ fi
405
+
406
+ if [[ -z "$LOOP3_AGENTS" ]]; then
407
+ echo "❌ FATAL: No Loop 3 agents selected" >&2
408
+ exit 1
409
+ fi
410
+
411
+ if [[ -z "$LOOP2_AGENTS" ]]; then
412
+ echo "❌ FATAL: No Loop 2 agents selected" >&2
413
+ exit 1
414
+ fi
415
+
416
+ echo "✅ ACTION 4 Complete: Parameters validated"
417
+
418
+ # ==============================================================================
419
+ # ACTION 5: INVOKE ORCHESTRATOR - MANDATORY (This is your PRIMARY job)
420
+ # ==============================================================================
421
+ echo ""
422
+ echo "🚀 ACTION 5: INVOKING ORCHESTRATOR (MANDATORY)"
423
+ echo " This is the ONLY action that truly matters for coordinator"
424
+ echo " The orchestrator handles ALL remaining CFN Loop work"
425
+
426
+ ORCHESTRATOR_PATH="$PROJECT_ROOT/.claude/skills/cfn-loop-orchestration/orchestrate-wrapper.sh"
427
+
428
+ if [[ ! -f "$ORCHESTRATOR_PATH" ]]; then
429
+ echo "❌ FATAL: Orchestrator not found at $ORCHESTRATOR_PATH" >&2
430
+ echo " Expected path: $ORCHESTRATOR_PATH"
431
+ exit 1
432
+ fi
433
+
434
+ # Store success criteria in Redis BEFORE invoking orchestrator
435
+ # The orchestrator requires this when --success-criteria flag is set
436
+ CRITERIA_JSON='{
437
+ "test_suites": [
438
+ {
439
+ "name": "Unit Tests",
440
+ "command": "echo \"Simulated test execution\"",
441
+ "required": true,
442
+ "pass_threshold": 0.70
443
+ }
444
+ ],
445
+ "gate_mode": "test-driven",
446
+ "metadata": {
447
+ "created_by": "cfn-v3-coordinator",
448
+ "task_type": "general",
449
+ "mode": "'$MODE'"
450
+ }
451
+ }'
452
+
453
+ # Store in Redis
454
+ echo "$CRITERIA_JSON" | redis-cli -h "${REDIS_HOST:-localhost}" -p "${REDIS_PORT:-6379}" \
455
+ -x HSET "cfn_loop:task:${TASK_ID}:context" "success-criteria" >/dev/null 2>&1 || true
456
+
457
+ echo " ✅ Success criteria stored in Redis"
458
+
459
+ # Invoke orchestrator with validated parameters
460
+ # The orchestrator handles ALL remaining work:
461
+ # - Loop 3 agent spawning and execution
462
+ # - Test execution and gate validation
463
+ # - Loop 2 validator spawning and consensus
464
+ # - Product Owner decision (PROCEED/ITERATE/ABORT)
465
+ # - Git commits and result reporting
466
+ echo " Executing: $ORCHESTRATOR_PATH"
467
+ bash "$ORCHESTRATOR_PATH" \
468
+ --task-id "$TASK_ID" \
469
+ --mode "$MODE" \
470
+ --loop3-agents "$LOOP3_AGENTS" \
471
+ --loop2-agents "$LOOP2_AGENTS" \
472
+ --product-owner "$PRODUCT_OWNER" \
473
+ --max-iterations "$MAX_ITERATIONS" \
474
+ --success-criteria "enabled" 2>&1
475
+
476
+ ORCHESTRATOR_EXIT_CODE=$?
477
+
478
+ if [[ $ORCHESTRATOR_EXIT_CODE -eq 0 ]]; then
479
+ echo "✅ ORCHESTRATOR COMPLETED SUCCESSFULLY"
480
+ else
481
+ echo "❌ ORCHESTRATOR FAILED (exit code: $ORCHESTRATOR_EXIT_CODE)"
482
+ exit $ORCHESTRATOR_EXIT_CODE
483
+ fi
484
+ ```
485
+
486
+ **What happens next:**
487
+ 1. Orchestrator spawns Loop 3 agents (implementers)
488
+ 2. Loop 3 agents complete work and execute tests
489
+ 3. Orchestrator validates test pass rates against gate threshold
490
+ 4. If gate passes, orchestrator spawns Loop 2 agents (validators)
491
+ 5. Loop 2 validators review work and report consensus
492
+ 6. Orchestrator spawns Product Owner for final decision
493
+ 7. Product Owner decides: PROCEED / ITERATE / ABORT
494
+ 8. Orchestrator creates git commit (if PROCEED) or starts next iteration (if ITERATE)
495
+
496
+ **Coordinator's job is now DONE.** The orchestrator handles everything else.
497
+
498
+
499
+
322
500
  ## CLI Mode Execution (Coordinator is ALWAYS CLI Mode)
323
501
 
324
502
  **IMPORTANT:** This coordinator agent is **ALWAYS CLI mode**. Task mode coordination happens directly in Main Chat, not via coordinator agents.
@@ -748,234 +926,6 @@ Extract deliverables from task description:
748
926
  - Estimate iteration count
749
927
  - Provide reasoning for choices
750
928
 
751
- ## Execution Steps (CLI Mode Only)
752
-
753
- **CRITICAL:** This coordinator is ALWAYS CLI mode. There is no Task Mode execution path.
754
-
755
- ### Step 1: Task Classification (REQUIRED)
756
- ```bash
757
- # BUG #23 FIX: Store task classification in Redis to persist across Bash tool calls
758
- # Each Bash tool call creates a new shell, so environment variables don't persist
759
- # Redis provides persistence across iterations
760
-
761
- # Classify task type (use hardcoded defaults if script fails)
762
- TASK_TYPE="infrastructure" # Default fallback
763
- if [[ -f ".claude/skills/task-classifier/classify-task.sh" ]]; then
764
- CLASSIFIED_TYPE=$(bash .claude/skills/task-classifier/classify-task.sh "$TASK_DESCRIPTION" 2>/dev/null || echo "")
765
- [[ -n "$CLASSIFIED_TYPE" ]] && TASK_TYPE="$CLASSIFIED_TYPE"
766
- fi
767
-
768
- # Store task type in Redis for persistence across Bash tool calls
769
- echo "✅ Task type '$TASK_TYPE' stored in Redis: swarm:${TASK_ID}:config"
770
- ```
771
-
772
- ### Step 2: Agent Selection with Fallback (REQUIRED)
773
- ```bash
774
- # BUG #23 FIX: Store agent selections in Redis to persist across Bash tool calls
775
- # Environment variables are lost between Bash tool executions
776
- # Redis ensures parameters persist through validation and orchestrator invocation
777
-
778
- # Select agents with hardcoded fallbacks (never fail)
779
- LOOP3_AGENTS="terraform-engineer,devops-engineer" # Infrastructure default
780
- LOOP2_AGENTS="security-auditor,compliance-checker,cost-optimizer" # Validation default
781
- PRODUCT_OWNER="product-owner"
782
-
783
- # Try dynamic selection but fall back to defaults
784
- if [[ -f ".claude/skills/cfn-agent-selector/select-agents.sh" ]]; then
785
- SELECTED_AGENTS=$(bash .claude/skills/cfn-agent-selector/select-agents.sh --task-type "$TASK_TYPE" --description "$TASK_DESCRIPTION" 2>/dev/null || echo "")
786
- if [[ -n "$SELECTED_AGENTS" ]]; then
787
- PARSED_AGENTS=$(echo "$SELECTED_AGENTS" | jq -r '.loop3 // empty | join(",")')
788
- [[ -n "$PARSED_AGENTS" ]] && LOOP3_AGENTS="$PARSED_AGENTS"
789
-
790
- PARSED_AGENTS=$(echo "$SELECTED_AGENTS" | jq -r '.loop2 // empty | join(",")')
791
- [[ -n "$PARSED_AGENTS" ]] && LOOP2_AGENTS="$PARSED_AGENTS"
792
- fi
793
- fi
794
-
795
- # Store agent selections in Redis for persistence
796
-
797
- echo "✅ Agent selections stored in Redis:"
798
- echo " loop3_agents: $LOOP3_AGENTS"
799
- echo " loop2_agents: $LOOP2_AGENTS"
800
- echo " product_owner: $PRODUCT_OWNER"
801
- ```
802
-
803
- ### Step 2.5: MANDATORY Parameter Initialization (BUG #22 & BUG #23 FIX)
804
-
805
- **CRITICAL: Execute this BEFORE orchestrator invocation to prevent empty parameter errors.**
806
-
807
- This step implements defense-in-depth fixes for both BUG #22 and BUG #23:
808
- - BUG #22: Empty parameter validation with hardcoded fallbacks
809
- - BUG #23: Redis-first parameter retrieval to handle Bash tool session loss
810
-
811
- ```bash
812
- # BUG #23 FIX: Read parameters from Redis with fallbacks
813
- # Bash tool creates new shell each call, so variables set in Step 2 may be lost
814
- # Redis provides persistent storage across all Bash tool executions
815
- LOOP3_AGENTS=$(redis-cli HGET "swarm:${TASK_ID}:config" "loop3_agents" 2>/dev/null || echo "")
816
- LOOP2_AGENTS=$(redis-cli HGET "swarm:${TASK_ID}:config" "loop2_agents" 2>/dev/null || echo "")
817
- PRODUCT_OWNER=$(redis-cli HGET "swarm:${TASK_ID}:config" "product_owner" 2>/dev/null || echo "")
818
-
819
- echo "🔄 Parameters retrieved from Redis (BUG #23 fix)"
820
- echo " LOOP3_AGENTS='$LOOP3_AGENTS'"
821
- echo " LOOP2_AGENTS='$LOOP2_AGENTS'"
822
- echo " PRODUCT_OWNER='$PRODUCT_OWNER'"
823
-
824
- # BUG #22 FIX: Apply fallbacks if Redis returns empty (defense-in-depth)
825
- # Even if Redis succeeded, re-validate and apply defaults if empty
826
- LOOP3_AGENTS="${LOOP3_AGENTS:-backend-developer,frontend-developer}"
827
- LOOP2_AGENTS="${LOOP2_AGENTS:-code-reviewer,tester,security-specialist}"
828
- PRODUCT_OWNER="${PRODUCT_OWNER:-product-owner}"
829
-
830
- echo "🔒 Fallback parameters initialized (BUG #22 prevention)"
831
- echo " LOOP3_AGENTS='$LOOP3_AGENTS'"
832
- echo " LOOP2_AGENTS='$LOOP2_AGENTS'"
833
- echo " PRODUCT_OWNER='$PRODUCT_OWNER'"
834
-
835
- # MANDATORY: Validate before orchestrator invocation
836
- if [[ -z "$LOOP3_AGENTS" ]] || [[ -z "$LOOP2_AGENTS" ]] || [[ -z "$PRODUCT_OWNER" ]]; then
837
- echo "❌ FATAL: Agent parameters cannot be empty after Redis retrieval + fallback initialization" >&2
838
- echo " This indicates a critical logic error in parameter handling (BUG #22 & #23)" >&2
839
- echo " LOOP3_AGENTS='$LOOP3_AGENTS'" >&2
840
- echo " LOOP2_AGENTS='$LOOP2_AGENTS'" >&2
841
- echo " PRODUCT_OWNER='$PRODUCT_OWNER'" >&2
842
- exit 1
843
- fi
844
-
845
- echo "✅ All parameters validated non-empty before orchestrator invocation (BUG #22 & #23 fixes applied)"
846
- ```
847
-
848
- **Why This Matters:**
849
-
850
- 1. **BUG #23 Fix - Redis Persistence**: Each Bash tool call creates a new shell
851
- - Environment variables set in iteration N are lost in iteration N+1
852
- - Redis provides persistent storage across all Bash tool executions
853
- - Parameters stored in Step 2 are reliably retrieved in Step 2.5
854
- - Prevents coordinator from being stuck in validation loop
855
-
856
- 2. **BUG #22 Fix - Defense-in-Depth**: Multiple layers of protection against empty parameters
857
- - Step 2 provides hardcoded defaults AND stores in Redis
858
- - Step 2.5 reads from Redis then applies fallbacks if Redis fails
859
- - Explicit validation catches any logic errors before orchestrator call
860
-
861
- 3. **Clear Error Messages**: If validation fails, provides:
862
- - Exact parameter values (shows what went wrong)
863
- - Context about where failure occurred (BUG #22 or BUG #23)
864
- - Actionable error message (indicates critical logic error)
865
-
866
- 4. **Fail-Fast Principle**: Better to exit early with clear error than pass empty strings to orchestrator
867
- - Orchestrator would fail with confusing error messages
868
- - Empty parameters cause cascade failures in agent spawning
869
- - Early validation prevents wasted iteration time
870
-
871
- **Testing BUG #22 & BUG #23 Fixes:**
872
-
873
- ```bash
874
- # Test BUG #23 fix (Redis persistence across Bash tool calls)
875
- # Simulate multiple Bash tool executions (coordinator iterations)
876
- npx claude-flow-novice agent-spawn cfn-v3-coordinator \
877
- --task-id test-bug23 \
878
- --env TASK_DESCRIPTION="Test Redis parameter persistence"
879
-
880
- # Expected output in Step 2:
881
- # ✅ Agent selections stored in Redis:
882
- # loop3_agents: backend-developer,frontend-developer
883
- # loop2_agents: code-reviewer,tester,security-specialist
884
- # product_owner: product-owner
885
-
886
- # Expected output in Step 2.5 (even in NEW Bash shell):
887
- # 🔄 Parameters retrieved from Redis (BUG #23 fix)
888
- # LOOP3_AGENTS='backend-developer,frontend-developer'
889
- # LOOP2_AGENTS='code-reviewer,tester,security-specialist'
890
- # PRODUCT_OWNER='product-owner'
891
- # ✅ All parameters validated non-empty before orchestrator invocation (BUG #22 & #23 fixes applied)
892
-
893
- # Test BUG #22 fix (fallbacks when Redis fails)
894
- # Simulate Redis failure
895
- redis-cli SHUTDOWN NOSAVE
896
-
897
- # Run coordinator - should fall back to defaults
898
- npx claude-flow-novice agent-spawn cfn-v3-coordinator \
899
- --task-id test-bug22 \
900
- --env TASK_DESCRIPTION="Test fallback parameters"
901
-
902
- # Expected output:
903
- # 🔄 Parameters retrieved from Redis (BUG #23 fix)
904
- # LOOP3_AGENTS='' (Redis down)
905
- # 🔒 Fallback parameters initialized (BUG #22 prevention)
906
- # LOOP3_AGENTS='backend-developer,frontend-developer'
907
- # ✅ All parameters validated non-empty before orchestrator invocation (BUG #22 & #23 fixes applied)
908
- ```
909
-
910
- ### Step 3: INVOKE ORCHESTRATOR (MANDATORY - NOT OPTIONAL)
911
-
912
- **CRITICAL:** You MUST invoke orchestrator by iteration 3. DO NOT complete tasks directly.
913
-
914
- ```bash
915
- # BUG #23 FIX: Read parameters from Redis before invoking orchestrator
916
- # This ensures we use the SAME parameters that were validated in Step 2.5
917
- # Even if this is executed in a NEW Bash shell (which it likely is)
918
- LOOP3_AGENTS=$(redis-cli HGET "swarm:${TASK_ID}:config" "loop3_agents" 2>/dev/null || echo "backend-developer,frontend-developer")
919
- LOOP2_AGENTS=$(redis-cli HGET "swarm:${TASK_ID}:config" "loop2_agents" 2>/dev/null || echo "code-reviewer,tester,security-specialist")
920
- PRODUCT_OWNER=$(redis-cli HGET "swarm:${TASK_ID}:config" "product_owner" 2>/dev/null || echo "product-owner")
921
-
922
- # Apply final fallbacks if Redis returns empty (defense-in-depth)
923
- LOOP3_AGENTS="${LOOP3_AGENTS:-backend-developer,frontend-developer}"
924
- LOOP2_AGENTS="${LOOP2_AGENTS:-code-reviewer,tester,security-specialist}"
925
- PRODUCT_OWNER="${PRODUCT_OWNER:-product-owner}"
926
-
927
- echo "🔄 Orchestrator parameters loaded from Redis (BUG #23 fix):"
928
- echo " LOOP3_AGENTS='$LOOP3_AGENTS'"
929
- echo " LOOP2_AGENTS='$LOOP2_AGENTS'"
930
- echo " PRODUCT_OWNER='$PRODUCT_OWNER'"
931
-
932
- # ALWAYS invoke orchestrator - this is your ONLY responsibility
933
-
934
- # Store success criteria in Redis BEFORE spawning orchestrator
935
- REDIS_KEY="swarm:${TASK_ID}:context"
936
- cat <<'CRITERIA_EOF' | redis-cli -h "${REDIS_HOST:-localhost}" -p "${REDIS_PORT:-6379}" -x HSET "$REDIS_KEY" "success-criteria"
937
- {
938
- "deliverables": [],
939
- "acceptanceCriteria": ["Implementation complete"],
940
- "test_suites": []
941
- }
942
- CRITERIA_EOF
943
-
944
- # Set TTL on context hash (24 hours)
945
- redis-cli -h "${REDIS_HOST:-localhost}" -p "${REDIS_PORT:-6379}" EXPIRE "$REDIS_KEY" 86400
946
-
947
- echo "✅ Success criteria stored in Redis: $REDIS_KEY"
948
-
949
- # BUG #22 & BUG #23 FIX: Use orchestrate-wrapper.sh with Redis-backed parameters
950
- # BUG #22: Wrapper provides additional validation and error handling
951
- # BUG #23: Parameters are read from Redis to survive Bash tool session boundaries
952
- ./.claude/skills/cfn-loop-orchestration/orchestrate-wrapper.sh \
953
- --task-id "$TASK_ID" \
954
- --mode "standard" \
955
- --loop3-agents "$LOOP3_AGENTS" \
956
- --loop2-agents "$LOOP2_AGENTS" \
957
- --product-owner "$PRODUCT_OWNER" \
958
- --max-iterations 10 \
959
- --success-criteria "enabled"
960
-
961
- # The orchestrator handles ALL CFN Loop execution including:
962
- # - Loop 3 agent spawning and iteration
963
- # - Loop 2 validator spawning and consensus
964
- # - Product Owner decision (PROCEED/ITERATE/ABORT)
965
- # - Git commit and push (on PROCEED)
966
- # - Sprint summary generation
967
-
968
- # Your job is complete after invoking this command - DO NOT wait for results
969
- ```
970
-
971
- **EXECUTION GUARANTEE:**
972
- - If steps 1-2 fail, use hardcoded defaults and proceed to step 3
973
- - **Step 2 stores parameters in Redis** (BUG #23 fix - persistence)
974
- - **Step 2.5 validates parameters from Redis** (BUG #22 + BUG #23 fix - retrieval + fallbacks)
975
- - **Step 3 reads parameters from Redis** (BUG #23 fix - fresh shell reads from persistent storage)
976
- - **Never exit without invoking orchestrator**
977
- - **Orchestrator invocation MUST happen by iteration 3**
978
- - This coordinator's ONLY job is to configure and invoke the orchestrator
979
929
 
980
930
 
981
931
  ## Multi-Worktree Coordination
@@ -1022,4 +972,5 @@ npx claude-flow-novice agent-spawn backend-developer \
1022
972
  - Validation criteria cover all critical requirements
1023
973
  - Deliverable list is comprehensive
1024
974
  - Confidence score ≥ 0.85 in analysis quality
1025
- - **CRITICAL: Orchestrator invoked successfully**
975
+ - **CRITICAL: Orchestrator invoked successfully**
976
+
@@ -58,6 +58,8 @@ fi
58
58
 
59
59
  **Old (Deprecated):**
60
60
  ```bash
61
+ # Not shown - deprecated pattern
62
+ ```
61
63
 
62
64
  **New (Required):**
63
65
  ```bash
@@ -59,6 +59,8 @@ fi
59
59
 
60
60
  **Old (Deprecated):**
61
61
  ```bash
62
+ # Not shown - deprecated pattern
63
+ ```
62
64
 
63
65
  **New (Required):**
64
66
  ```bash