claude-flow-novice 2.15.11 → 2.16.0
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/cfn-extras/agents/cfn-v3-coordinator.md +517 -0
- package/.claude/commands/cfn-loop-cli.md +158 -464
- package/.claude/commands/cfn-loop-trigger.md +114 -0
- package/.claude/hooks/cfn-invoke-post-edit-ts.sh +100 -0
- package/.claude/hooks/cfn-invoke-post-edit-ts.sh.backup +78 -0
- package/.claude/hooks/cfn-invoke-post-edit.sh +22 -0
- package/.claude/hooks/cfn-invoke-post-edit.sh.backup +87 -0
- package/.claude/hooks/cfn-invoke-pre-edit-ts.sh +116 -0
- package/.claude/hooks/cfn-invoke-pre-edit-ts.sh.backup +94 -0
- package/.claude/hooks/cfn-invoke-pre-edit.sh +22 -0
- package/.claude/hooks/cfn-invoke-pre-edit.sh.backup +88 -0
- package/.claude/skills/cfn-agent-spawning/SKILL.md +48 -1
- package/.claude/skills/cfn-agent-spawning/SKILL.md.backup +135 -0
- package/.claude/skills/cfn-agent-spawning/TYPESCRIPT_MIGRATION.md +567 -0
- package/.claude/skills/cfn-agent-spawning/check-dependencies.sh +22 -0
- package/.claude/skills/{cfn-redis-coordination/check-dependencies.sh → cfn-agent-spawning/check-dependencies.sh.backup} +3 -5
- package/.claude/skills/cfn-agent-spawning/get-agent-provider-env.sh +22 -0
- package/.claude/skills/cfn-agent-spawning/get-agent-provider-env.sh.backup +127 -0
- package/.claude/skills/cfn-agent-spawning/parse-agent-provider.sh +22 -0
- package/.claude/skills/cfn-agent-spawning/parse-agent-provider.sh.backup +59 -0
- package/.claude/skills/cfn-agent-spawning/spawn-agent-wrapper.sh +63 -0
- package/.claude/skills/cfn-agent-spawning/spawn-agent-wrapper.sh.backup +41 -0
- package/.claude/skills/cfn-agent-spawning/spawn-agent.sh +26 -1
- package/.claude/skills/cfn-agent-spawning/spawn-templates.sh +22 -0
- package/.claude/skills/cfn-agent-spawning/spawn-templates.sh.backup +613 -0
- package/.claude/skills/cfn-agent-spawning/spawn-worker.sh +22 -0
- package/.claude/skills/cfn-agent-spawning/spawn-worker.sh.backup +176 -0
- package/.claude/skills/cfn-loop-orchestration/.backups/unknown/1763619700_33aff4a69b99159e4e849107ebc4d09f/metadata.json +8 -0
- package/.claude/skills/cfn-loop-orchestration/.backups/unknown/1763619700_33aff4a69b99159e4e849107ebc4d09f/original +271 -0
- package/.claude/skills/cfn-loop-orchestration/.backups/unknown/1763619700_33aff4a69b99159e4e849107ebc4d09f/revert.sh +7 -0
- package/.claude/skills/cfn-loop-orchestration/.backups/unknown/1763671642_06496e8c399a79db08167cc00ed4b31e/metadata.json +8 -0
- package/.claude/skills/cfn-loop-orchestration/.backups/unknown/1763671642_06496e8c399a79db08167cc00ed4b31e/original +325 -0
- package/.claude/skills/cfn-loop-orchestration/.backups/unknown/1763671642_06496e8c399a79db08167cc00ed4b31e/revert.sh +7 -0
- package/.claude/skills/cfn-loop-orchestration/CLI_IMPLEMENTATION_SUMMARY.md +330 -0
- package/.claude/skills/cfn-loop-orchestration/CONFIGURATION_IMPROVEMENTS.md +318 -0
- package/.claude/skills/cfn-loop-orchestration/CONTEXT_LOOKUP_MIGRATION.md +308 -0
- package/.claude/skills/cfn-loop-orchestration/CONTEXT_LOOKUP_QUICK_START.md +378 -0
- package/.claude/skills/cfn-loop-orchestration/E2E_VALIDATION_REPORT.md +262 -0
- package/.claude/skills/cfn-loop-orchestration/IMPLEMENTATION_SUMMARY.md +319 -519
- package/.claude/skills/cfn-loop-orchestration/NORTH_STAR_E2E_REPORT.md +299 -0
- package/.claude/skills/cfn-loop-orchestration/NORTH_STAR_EXECUTION_SUMMARY.md +403 -0
- package/.claude/skills/cfn-loop-orchestration/NORTH_STAR_INDEX.md +323 -0
- package/.claude/skills/cfn-loop-orchestration/SKILL.md +159 -48
- package/.claude/skills/cfn-loop-orchestration/SPAWN_AGENTS_IMPLEMENTATION.md +188 -0
- package/.claude/skills/cfn-loop-orchestration/TEST_COVERAGE_REPORT.md +335 -0
- package/.claude/skills/cfn-loop-orchestration/TEST_COVERAGE_SUMMARY.md +456 -0
- package/.claude/skills/cfn-loop-orchestration/TYPESCRIPT_INTEGRATION_REPORT.md +709 -0
- package/.claude/skills/cfn-loop-orchestration/TYPESCRIPT_INTEGRATION_SUMMARY.md +257 -0
- package/.claude/skills/cfn-loop-orchestration/VALIDATION_REPORT.md +572 -0
- package/.claude/skills/cfn-loop-orchestration/VALIDATION_SUMMARY.txt +196 -0
- package/.claude/skills/cfn-loop-orchestration/VALIDATOR_MODULE_GUIDE.md +526 -0
- package/.claude/skills/cfn-loop-orchestration/archive/legacy-bash/README.md +167 -0
- package/.claude/skills/cfn-loop-orchestration/archive/legacy-bash/orchestrate-enhanced.sh +548 -0
- package/{claude-assets/skills/cfn-loop-orchestration → .claude/skills/cfn-loop-orchestration/archive/legacy-bash}/orchestrate-wrapper.sh +11 -1
- package/.claude/skills/cfn-loop-orchestration/archive/legacy-bash/orchestrate.sh +182 -0
- package/.claude/skills/cfn-loop-orchestration/e2e-validation-fixed.js +240 -0
- package/.claude/skills/cfn-loop-orchestration/e2e-validation.js +213 -0
- package/.claude/skills/cfn-loop-orchestration/package-lock.json +3 -0
- package/.claude/skills/cfn-loop-orchestration/package.json +4 -0
- package/.claude/skills/cfn-loop-orchestration/run-north-star-e2e.ts +210 -0
- package/.claude/skills/cfn-loop-orchestration/src/cli/orchestrator-cli.ts +396 -0
- package/.claude/skills/cfn-loop-orchestration/src/helpers/CONFIDENCE_AGGREGATOR.md +564 -0
- package/.claude/skills/cfn-loop-orchestration/src/helpers/CONFIDENCE_AGGREGATOR_QUICK_REF.md +241 -0
- package/.claude/skills/cfn-loop-orchestration/src/helpers/CONTEXT_INJECTOR_IMPLEMENTATION.md +375 -0
- package/.claude/skills/cfn-loop-orchestration/src/helpers/CONTEXT_INJECTOR_QUICK_REFERENCE.md +362 -0
- package/.claude/skills/cfn-loop-orchestration/src/helpers/CONTEXT_INJECTOR_README.md +307 -0
- package/.claude/skills/cfn-loop-orchestration/src/helpers/CONTEXT_INJECTOR_USAGE_GUIDE.md +508 -0
- package/.claude/skills/cfn-loop-orchestration/src/helpers/confidence-aggregator.ts +473 -0
- package/.claude/skills/cfn-loop-orchestration/src/helpers/consensus.ts +1 -1
- package/.claude/skills/cfn-loop-orchestration/src/helpers/context-injector.ts +349 -0
- package/.claude/skills/cfn-loop-orchestration/src/helpers/context-lookup.ts +486 -0
- package/.claude/skills/cfn-loop-orchestration/src/helpers/deliverable-verifier.ts +6 -2
- package/.claude/skills/cfn-loop-orchestration/src/helpers/gate-check.ts +1 -1
- package/.claude/skills/cfn-loop-orchestration/src/helpers/product-owner-decision.ts +316 -0
- package/.claude/skills/cfn-loop-orchestration/src/helpers/spawn-agents.ts +357 -0
- package/.claude/skills/cfn-loop-orchestration/src/helpers/validator.ts +276 -0
- package/.claude/skills/cfn-loop-orchestration/src/index.ts +2 -0
- package/.claude/skills/cfn-loop-orchestration/src/orchestrate.ts +743 -2
- package/.claude/skills/cfn-loop-orchestration/src/types.ts +56 -0
- package/.claude/skills/cfn-loop-orchestration/test-cli.sh +92 -0
- package/.claude/skills/cfn-loop-orchestration/test-typescript-integration.sh +442 -0
- package/.claude/skills/cfn-loop-orchestration/tests/agent-spawner.test.ts +124 -0
- package/.claude/skills/cfn-loop-orchestration/tests/confidence-aggregator.test.ts +604 -0
- package/.claude/skills/cfn-loop-orchestration/tests/context-injector.test.ts +561 -0
- package/.claude/skills/cfn-loop-orchestration/tests/context-lookup.test.ts +661 -0
- package/.claude/skills/cfn-loop-orchestration/tests/deliverable-verifier.test.ts +2 -2
- package/.claude/skills/cfn-loop-orchestration/tests/gate-check-edge-cases.test.ts +422 -0
- package/.claude/skills/cfn-loop-orchestration/tests/gate-checker.test.ts +276 -0
- package/.claude/skills/cfn-loop-orchestration/tests/logger.test.ts +291 -0
- package/.claude/skills/cfn-loop-orchestration/tests/north-star-e2e.test.ts +334 -0
- package/.claude/skills/cfn-loop-orchestration/tests/redis-coordinator.test.ts +321 -0
- package/.claude/skills/cfn-loop-orchestration/tests/spawn-agents.test.ts +284 -0
- package/.claude/skills/cfn-loop-orchestration/tests/validator.test.ts +643 -0
- package/.claude/skills/cfn-loop-validation/IMPLEMENTATION_SUMMARY.md +672 -0
- package/.claude/skills/cfn-loop-validation/INDEX.md +531 -0
- package/.claude/skills/cfn-loop-validation/README_TYPESCRIPT.md +454 -0
- package/.claude/skills/cfn-loop-validation/SKILL.md +48 -1
- package/.claude/skills/cfn-loop-validation/SKILL.md.backup +353 -0
- package/.claude/skills/cfn-loop-validation/SKILL_TYPESCRIPT.md +782 -0
- package/.claude/skills/cfn-loop-validation/VAPOR_DETECTION_EXAMPLES.md +598 -0
- package/.claude/skills/cfn-loop-validation/check-dependencies.sh +22 -0
- package/{claude-assets/skills/cfn-redis-coordination/check-dependencies.sh → .claude/skills/cfn-loop-validation/check-dependencies.sh.backup} +4 -5
- package/.claude/skills/cfn-loop-validation/detect-vapor.sh +59 -0
- package/.claude/skills/cfn-loop-validation/detect-vapor.sh.backup +37 -0
- package/.claude/skills/cfn-loop-validation/dist/.tsbuildinfo +1 -0
- package/.claude/skills/cfn-loop-validation/dist/cli/detect-vapor.d.ts +14 -0
- package/.claude/skills/cfn-loop-validation/dist/cli/detect-vapor.d.ts.map +1 -0
- package/.claude/skills/cfn-loop-validation/dist/cli/detect-vapor.js +185 -0
- package/.claude/skills/cfn-loop-validation/dist/cli/detect-vapor.js.map +1 -0
- package/.claude/skills/cfn-loop-validation/dist/cli/validate-deliverables.d.ts +14 -0
- package/.claude/skills/cfn-loop-validation/dist/cli/validate-deliverables.d.ts.map +1 -0
- package/.claude/skills/cfn-loop-validation/dist/cli/validate-deliverables.js +176 -0
- package/.claude/skills/cfn-loop-validation/dist/cli/validate-deliverables.js.map +1 -0
- package/.claude/skills/cfn-loop-validation/dist/cli/validate-gate.d.ts +19 -0
- package/.claude/skills/cfn-loop-validation/dist/cli/validate-gate.d.ts.map +1 -0
- package/.claude/skills/cfn-loop-validation/dist/cli/validate-gate.js +123 -0
- package/.claude/skills/cfn-loop-validation/dist/cli/validate-gate.js.map +1 -0
- package/.claude/skills/cfn-loop-validation/dist/types.d.ts +156 -0
- package/.claude/skills/cfn-loop-validation/dist/types.d.ts.map +1 -0
- package/.claude/skills/cfn-loop-validation/dist/types.js +66 -0
- package/.claude/skills/cfn-loop-validation/dist/types.js.map +1 -0
- package/.claude/skills/cfn-loop-validation/dist/validator.d.ts +85 -0
- package/.claude/skills/cfn-loop-validation/dist/validator.d.ts.map +1 -0
- package/.claude/skills/cfn-loop-validation/dist/validator.js +411 -0
- package/.claude/skills/cfn-loop-validation/dist/validator.js.map +1 -0
- package/.claude/skills/cfn-loop-validation/orchestrate-cfn-loop.sh +22 -0
- package/.claude/skills/cfn-loop-validation/orchestrate-cfn-loop.sh.backup +252 -0
- package/.claude/skills/cfn-loop-validation/package.json +93 -0
- package/.claude/skills/cfn-loop-validation/src/cli/detect-vapor.ts +177 -0
- package/.claude/skills/cfn-loop-validation/src/cli/validate-deliverables.ts +161 -0
- package/.claude/skills/cfn-loop-validation/src/cli/validate-gate.ts +139 -0
- package/.claude/skills/cfn-loop-validation/src/types.ts +215 -0
- package/.claude/skills/cfn-loop-validation/src/validator.ts +503 -0
- package/.claude/skills/cfn-loop-validation/tests/validator.test.ts +537 -0
- package/.claude/skills/{cfn-redis-coordination → cfn-loop-validation}/tsconfig.json +34 -31
- package/.claude/skills/cfn-loop-validation/validate-deliverables.sh +59 -0
- package/.claude/skills/cfn-loop-validation/validate-deliverables.sh.backup +37 -0
- package/.claude/skills/cfn-loop-validation/validate-gate.sh +63 -0
- package/.claude/skills/cfn-loop-validation/validate-gate.sh.backup +41 -0
- package/.claude/skills/cfn-loop-validation/validate-iteration.sh +22 -0
- package/.claude/skills/cfn-loop-validation/validate-iteration.sh.backup +134 -0
- package/.claude/skills/cfn-product-owner-decision/SKILL.md +479 -147
- package/.claude/skills/cfn-product-owner-decision/TYPESCRIPT_IMPLEMENTATION.md +653 -0
- package/{claude-assets/skills/cfn-product-owner-decision → .claude/skills/cfn-product-owner-decision/archive/legacy-bash}/execute-decision.sh +24 -2
- package/.claude/skills/pre-edit-backup/SKILL.md +324 -0
- package/.claude/skills/pre-edit-backup/SKILL.md.backup +277 -0
- package/.claude/skills/pre-edit-backup/backup.sh +22 -0
- package/.claude/skills/pre-edit-backup/backup.sh.backup +107 -0
- package/claude-assets/agents/cfn-dev-team/coordinators/cfn-frontend-coordinator.md +1 -0
- package/claude-assets/agents/cfn-dev-team/coordinators/consensus-builder.md +1 -0
- package/claude-assets/agents/cfn-dev-team/coordinators/handoff-coordinator.md +1 -0
- package/claude-assets/agents/cfn-dev-team/coordinators/multi-sprint-coordinator.md +1 -0
- package/claude-assets/agents/cfn-dev-team/dev-ops/devops-engineer.md +10 -0
- package/claude-assets/agents/cfn-dev-team/dev-ops/docker-specialist.md +56 -33
- package/claude-assets/agents/cfn-dev-team/dev-ops/kubernetes-specialist.md +46 -36
- package/claude-assets/agents/cfn-dev-team/dev-ops/monitoring-specialist.md +9 -0
- package/claude-assets/agents/cfn-dev-team/developers/api-gateway-specialist.md +17 -17
- package/claude-assets/agents/cfn-dev-team/developers/backend-developer.md +40 -58
- package/claude-assets/agents/cfn-dev-team/developers/data/data-engineer.md +18 -20
- package/claude-assets/agents/cfn-dev-team/developers/database/database-architect.md +19 -28
- package/claude-assets/agents/cfn-dev-team/developers/frontend/mobile-dev.md +15 -19
- package/claude-assets/agents/cfn-dev-team/developers/frontend/react-frontend-engineer.md +15 -10
- package/claude-assets/agents/cfn-dev-team/developers/frontend/typescript-specialist.md +15 -10
- package/claude-assets/agents/cfn-dev-team/developers/frontend/ui-designer.md +15 -25
- package/claude-assets/agents/cfn-dev-team/developers/graphql-specialist.md +17 -21
- package/claude-assets/agents/cfn-dev-team/developers/rust-developer.md +17 -21
- package/claude-assets/agents/cfn-dev-team/product-owners/product-owner.md +1 -5
- package/claude-assets/agents/cfn-dev-team/reviewers/code-reviewer.md +20 -51
- package/claude-assets/agents/cfn-dev-team/reviewers/quality/code-quality-validator.md +22 -71
- package/claude-assets/agents/cfn-dev-team/reviewers/quality/perf-analyzer.md +21 -64
- package/claude-assets/agents/cfn-dev-team/reviewers/quality/performance-benchmarker.md +22 -67
- package/claude-assets/agents/cfn-dev-team/reviewers/quality/security-specialist.md +23 -67
- package/claude-assets/agents/cfn-dev-team/testers/api-testing-specialist.md +7 -35
- package/claude-assets/agents/cfn-dev-team/testers/chaos-engineering-specialist.md +8 -37
- package/claude-assets/agents/cfn-dev-team/testers/contract-tester.md +16 -54
- package/claude-assets/agents/cfn-dev-team/testers/integration-tester.md +17 -55
- package/claude-assets/agents/cfn-dev-team/testers/interaction-tester.md +9 -37
- package/claude-assets/agents/cfn-dev-team/testers/load-testing-specialist.md +17 -55
- package/claude-assets/agents/cfn-dev-team/testers/mutation-testing-specialist.md +17 -48
- package/claude-assets/agents/cfn-dev-team/testers/playwright-tester.md +8 -37
- package/claude-assets/agents/cfn-dev-team/testers/tester.md +7 -27
- package/claude-assets/agents/cfn-dev-team/utility/analyst.md +12 -28
- package/claude-assets/agents/cfn-dev-team/utility/code-booster.md +13 -13
- package/claude-assets/agents/cfn-dev-team/utility/context-curator.md +7 -2
- package/claude-assets/agents/cfn-dev-team/utility/epic-creator.md +5 -10
- package/claude-assets/agents/cfn-dev-team/utility/memory-leak-specialist.md +120 -714
- package/claude-assets/agents/cfn-dev-team/utility/researcher.md +12 -21
- package/claude-assets/agents/cfn-dev-team/utility/z-ai-specialist.md +146 -572
- package/claude-assets/agents/custom/cfn-docker-expert.md +102 -0
- package/claude-assets/agents/custom/cfn-loops-cli-expert.md +129 -0
- package/claude-assets/cfn-extras/agents/cfn-v3-coordinator.md +517 -0
- package/claude-assets/commands/cfn-loop-cli.md +158 -464
- package/claude-assets/commands/cfn-loop-trigger.md +114 -0
- package/claude-assets/hooks/SKILL.md +518 -0
- package/claude-assets/hooks/SKILL.md.backup +471 -0
- package/claude-assets/hooks/cfn-invoke-post-edit-ts.sh +100 -0
- package/claude-assets/hooks/cfn-invoke-post-edit-ts.sh.backup +78 -0
- package/claude-assets/hooks/cfn-invoke-post-edit.sh +22 -0
- package/claude-assets/hooks/cfn-invoke-post-edit.sh.backup +87 -0
- package/claude-assets/hooks/cfn-invoke-pre-edit-ts.sh +116 -0
- package/claude-assets/hooks/cfn-invoke-pre-edit-ts.sh.backup +94 -0
- package/claude-assets/hooks/cfn-invoke-pre-edit.sh +22 -0
- package/claude-assets/hooks/cfn-invoke-pre-edit.sh.backup +88 -0
- package/claude-assets/skills/cfn-agent-selection-with-fallback/DELIVERABLES.md +409 -0
- package/claude-assets/skills/cfn-agent-selection-with-fallback/IMPLEMENTATION_SUMMARY.md +396 -0
- package/claude-assets/skills/cfn-agent-selection-with-fallback/INTEGRATION_GUIDE.md +308 -0
- package/claude-assets/skills/cfn-agent-selection-with-fallback/QUICK_REFERENCE.md +239 -0
- package/claude-assets/skills/cfn-agent-selection-with-fallback/SKILL.md +107 -1
- package/claude-assets/skills/cfn-agent-selection-with-fallback/SKILL.md.backup +302 -0
- package/claude-assets/skills/cfn-agent-selection-with-fallback/TYPESCRIPT_MIGRATION.md +295 -0
- package/claude-assets/skills/cfn-agent-selection-with-fallback/dist/agent-selector.cjs +297 -0
- package/claude-assets/skills/cfn-agent-selection-with-fallback/dist/agent-selector.js +297 -0
- package/claude-assets/skills/cfn-agent-selection-with-fallback/dist/cli.cjs +96 -0
- package/claude-assets/skills/cfn-agent-selection-with-fallback/dist/cli.js +96 -0
- package/claude-assets/skills/cfn-agent-selection-with-fallback/select-agents-ts.sh +45 -0
- package/claude-assets/skills/cfn-agent-selection-with-fallback/select-agents-ts.sh.backup +23 -0
- package/claude-assets/skills/cfn-agent-selection-with-fallback/select-agents.sh +22 -0
- package/claude-assets/skills/cfn-agent-selection-with-fallback/select-agents.sh.backup +173 -0
- package/claude-assets/skills/cfn-agent-selection-with-fallback/src/agent-selector.test.ts +357 -0
- package/claude-assets/skills/cfn-agent-selection-with-fallback/src/agent-selector.ts +350 -0
- package/claude-assets/skills/cfn-agent-selection-with-fallback/src/cli.ts +74 -0
- package/claude-assets/skills/cfn-agent-selection-with-fallback/task-classifier.sh +22 -0
- package/claude-assets/skills/cfn-agent-selection-with-fallback/task-classifier.sh.backup +71 -0
- package/claude-assets/skills/cfn-agent-selection-with-fallback/tsconfig.json +18 -0
- package/claude-assets/skills/cfn-agent-spawning/SKILL.md +48 -1
- package/claude-assets/skills/cfn-agent-spawning/SKILL.md.backup +135 -0
- package/claude-assets/skills/cfn-agent-spawning/TYPESCRIPT_MIGRATION.md +567 -0
- package/claude-assets/skills/cfn-agent-spawning/check-dependencies.sh +22 -0
- package/claude-assets/skills/cfn-agent-spawning/check-dependencies.sh.backup +30 -0
- package/claude-assets/skills/cfn-agent-spawning/get-agent-provider-env.sh +22 -0
- package/claude-assets/skills/cfn-agent-spawning/get-agent-provider-env.sh.backup +127 -0
- package/claude-assets/skills/cfn-agent-spawning/parse-agent-provider.sh +22 -0
- package/claude-assets/skills/cfn-agent-spawning/parse-agent-provider.sh.backup +59 -0
- package/claude-assets/skills/cfn-agent-spawning/spawn-agent-wrapper.sh +63 -0
- package/claude-assets/skills/cfn-agent-spawning/spawn-agent-wrapper.sh.backup +41 -0
- package/claude-assets/skills/cfn-agent-spawning/spawn-agent.sh +26 -1
- package/claude-assets/skills/cfn-agent-spawning/spawn-templates.sh +22 -0
- package/claude-assets/skills/cfn-agent-spawning/spawn-templates.sh.backup +613 -0
- package/claude-assets/skills/cfn-agent-spawning/spawn-worker.sh +22 -0
- package/claude-assets/skills/cfn-agent-spawning/spawn-worker.sh.backup +176 -0
- package/claude-assets/skills/cfn-coordination/agent-completion.sh.backup +36 -0
- package/claude-assets/skills/cfn-coordination/coordination-signal.sh.backup +36 -0
- package/claude-assets/skills/cfn-coordination/coordination-wait.sh.backup +36 -0
- package/claude-assets/skills/cfn-dependency-ingestion/README.md +101 -0
- package/claude-assets/skills/cfn-dependency-ingestion/SKILL.md +369 -0
- package/claude-assets/skills/cfn-dependency-ingestion/build.sh +23 -0
- package/claude-assets/skills/cfn-dependency-ingestion/dist/ingest-dependencies.js +478 -0
- package/claude-assets/skills/cfn-dependency-ingestion/ingest-dependencies.sh +295 -0
- package/claude-assets/skills/cfn-dependency-ingestion/src/ingest-dependencies.ts +563 -0
- package/claude-assets/skills/cfn-loop-orchestration/.backups/unknown/1763619700_33aff4a69b99159e4e849107ebc4d09f/metadata.json +8 -0
- package/claude-assets/skills/cfn-loop-orchestration/.backups/unknown/1763619700_33aff4a69b99159e4e849107ebc4d09f/original +271 -0
- package/claude-assets/skills/cfn-loop-orchestration/.backups/unknown/1763619700_33aff4a69b99159e4e849107ebc4d09f/revert.sh +7 -0
- package/claude-assets/skills/cfn-loop-orchestration/.backups/unknown/1763671642_06496e8c399a79db08167cc00ed4b31e/metadata.json +8 -0
- package/claude-assets/skills/cfn-loop-orchestration/.backups/unknown/1763671642_06496e8c399a79db08167cc00ed4b31e/original +325 -0
- package/claude-assets/skills/cfn-loop-orchestration/.backups/unknown/1763671642_06496e8c399a79db08167cc00ed4b31e/revert.sh +7 -0
- package/claude-assets/skills/cfn-loop-orchestration/CLI_IMPLEMENTATION_SUMMARY.md +330 -0
- package/claude-assets/skills/cfn-loop-orchestration/CONFIGURATION_IMPROVEMENTS.md +318 -0
- package/claude-assets/skills/cfn-loop-orchestration/CONTEXT_LOOKUP_MIGRATION.md +308 -0
- package/claude-assets/skills/cfn-loop-orchestration/CONTEXT_LOOKUP_QUICK_START.md +378 -0
- package/claude-assets/skills/cfn-loop-orchestration/E2E_VALIDATION_REPORT.md +262 -0
- package/claude-assets/skills/cfn-loop-orchestration/IMPLEMENTATION_SUMMARY.md +319 -519
- package/claude-assets/skills/cfn-loop-orchestration/NORTH_STAR_E2E_REPORT.md +299 -0
- package/claude-assets/skills/cfn-loop-orchestration/NORTH_STAR_EXECUTION_SUMMARY.md +403 -0
- package/claude-assets/skills/cfn-loop-orchestration/NORTH_STAR_INDEX.md +323 -0
- package/claude-assets/skills/cfn-loop-orchestration/SKILL.md +159 -48
- package/claude-assets/skills/cfn-loop-orchestration/SPAWN_AGENTS_IMPLEMENTATION.md +188 -0
- package/claude-assets/skills/cfn-loop-orchestration/TEST_COVERAGE_REPORT.md +335 -0
- package/claude-assets/skills/cfn-loop-orchestration/TEST_COVERAGE_SUMMARY.md +456 -0
- package/claude-assets/skills/cfn-loop-orchestration/TYPESCRIPT_INTEGRATION_REPORT.md +709 -0
- package/claude-assets/skills/cfn-loop-orchestration/TYPESCRIPT_INTEGRATION_SUMMARY.md +257 -0
- package/claude-assets/skills/cfn-loop-orchestration/VALIDATION_REPORT.md +572 -0
- package/claude-assets/skills/cfn-loop-orchestration/VALIDATION_SUMMARY.txt +196 -0
- package/claude-assets/skills/cfn-loop-orchestration/VALIDATOR_MODULE_GUIDE.md +526 -0
- package/claude-assets/skills/cfn-loop-orchestration/archive/legacy-bash/README.md +167 -0
- package/claude-assets/skills/cfn-loop-orchestration/archive/legacy-bash/orchestrate-enhanced.sh +548 -0
- package/{.claude/skills/cfn-loop-orchestration → claude-assets/skills/cfn-loop-orchestration/archive/legacy-bash}/orchestrate-wrapper.sh +11 -1
- package/claude-assets/skills/cfn-loop-orchestration/archive/legacy-bash/orchestrate.sh +182 -0
- package/claude-assets/skills/cfn-loop-orchestration/e2e-validation-fixed.js +240 -0
- package/claude-assets/skills/cfn-loop-orchestration/e2e-validation.js +213 -0
- package/claude-assets/skills/cfn-loop-orchestration/package-lock.json +3 -0
- package/claude-assets/skills/cfn-loop-orchestration/package.json +4 -0
- package/claude-assets/skills/cfn-loop-orchestration/run-north-star-e2e.ts +210 -0
- package/claude-assets/skills/cfn-loop-orchestration/src/cli/orchestrator-cli.ts +396 -0
- package/claude-assets/skills/cfn-loop-orchestration/src/helpers/CONFIDENCE_AGGREGATOR.md +564 -0
- package/claude-assets/skills/cfn-loop-orchestration/src/helpers/CONFIDENCE_AGGREGATOR_QUICK_REF.md +241 -0
- package/claude-assets/skills/cfn-loop-orchestration/src/helpers/CONTEXT_INJECTOR_IMPLEMENTATION.md +375 -0
- package/claude-assets/skills/cfn-loop-orchestration/src/helpers/CONTEXT_INJECTOR_QUICK_REFERENCE.md +362 -0
- package/claude-assets/skills/cfn-loop-orchestration/src/helpers/CONTEXT_INJECTOR_README.md +307 -0
- package/claude-assets/skills/cfn-loop-orchestration/src/helpers/CONTEXT_INJECTOR_USAGE_GUIDE.md +508 -0
- package/claude-assets/skills/cfn-loop-orchestration/src/helpers/confidence-aggregator.ts +473 -0
- package/claude-assets/skills/cfn-loop-orchestration/src/helpers/consensus.ts +1 -1
- package/claude-assets/skills/cfn-loop-orchestration/src/helpers/context-injector.ts +349 -0
- package/claude-assets/skills/cfn-loop-orchestration/src/helpers/context-lookup.ts +486 -0
- package/claude-assets/skills/cfn-loop-orchestration/src/helpers/deliverable-verifier.ts +6 -2
- package/claude-assets/skills/cfn-loop-orchestration/src/helpers/gate-check.ts +1 -1
- package/claude-assets/skills/cfn-loop-orchestration/src/helpers/product-owner-decision.ts +316 -0
- package/claude-assets/skills/cfn-loop-orchestration/src/helpers/spawn-agents.ts +357 -0
- package/claude-assets/skills/cfn-loop-orchestration/src/helpers/validator.ts +276 -0
- package/claude-assets/skills/cfn-loop-orchestration/src/index.ts +2 -0
- package/claude-assets/skills/cfn-loop-orchestration/src/orchestrate.ts +743 -2
- package/claude-assets/skills/cfn-loop-orchestration/src/types.ts +56 -0
- package/claude-assets/skills/cfn-loop-orchestration/test-cli.sh +92 -0
- package/claude-assets/skills/cfn-loop-orchestration/test-typescript-integration.sh +442 -0
- package/claude-assets/skills/cfn-loop-orchestration/tests/agent-spawner.test.ts +124 -0
- package/claude-assets/skills/cfn-loop-orchestration/tests/confidence-aggregator.test.ts +604 -0
- package/claude-assets/skills/cfn-loop-orchestration/tests/context-injector.test.ts +561 -0
- package/claude-assets/skills/cfn-loop-orchestration/tests/context-lookup.test.ts +661 -0
- package/claude-assets/skills/cfn-loop-orchestration/tests/deliverable-verifier.test.ts +2 -2
- package/claude-assets/skills/cfn-loop-orchestration/tests/gate-check-edge-cases.test.ts +422 -0
- package/claude-assets/skills/cfn-loop-orchestration/tests/gate-checker.test.ts +276 -0
- package/claude-assets/skills/cfn-loop-orchestration/tests/logger.test.ts +291 -0
- package/claude-assets/skills/cfn-loop-orchestration/tests/north-star-e2e.test.ts +334 -0
- package/claude-assets/skills/cfn-loop-orchestration/tests/redis-coordinator.test.ts +321 -0
- package/claude-assets/skills/cfn-loop-orchestration/tests/spawn-agents.test.ts +284 -0
- package/claude-assets/skills/cfn-loop-orchestration/tests/validator.test.ts +643 -0
- package/claude-assets/skills/cfn-loop-output-processing/.eslintrc.json +33 -0
- package/claude-assets/skills/cfn-loop-output-processing/DELIVERY_SUMMARY.txt +462 -0
- package/claude-assets/skills/cfn-loop-output-processing/DEPRECATION_NOTICE.md +183 -0
- package/claude-assets/skills/cfn-loop-output-processing/EXAMPLES.md +609 -0
- package/claude-assets/skills/cfn-loop-output-processing/IMPLEMENTATION_SUMMARY.md +418 -0
- package/claude-assets/skills/cfn-loop-output-processing/INDEX.md +531 -0
- package/claude-assets/skills/cfn-loop-output-processing/MIGRATION.md +362 -0
- package/claude-assets/skills/cfn-loop-output-processing/README.md +114 -0
- package/claude-assets/skills/cfn-loop-output-processing/SKILL.md +633 -0
- package/{.claude/skills/cfn-docker-redis-coordination → claude-assets/skills/cfn-loop-output-processing}/jest.config.js +7 -15
- package/claude-assets/skills/cfn-loop-output-processing/package.json +50 -0
- package/claude-assets/skills/cfn-loop-output-processing/src/cli/process-loop2.ts +195 -0
- package/claude-assets/skills/cfn-loop-output-processing/src/cli/process-loop3.ts +157 -0
- package/claude-assets/skills/cfn-loop-output-processing/src/output-processor.ts +632 -0
- package/claude-assets/skills/cfn-loop-output-processing/tests/output-processor.test.ts +617 -0
- package/claude-assets/skills/{cfn-docker-redis-coordination → cfn-loop-output-processing}/tsconfig.json +16 -7
- package/claude-assets/skills/cfn-loop-validation/IMPLEMENTATION_SUMMARY.md +672 -0
- package/claude-assets/skills/cfn-loop-validation/INDEX.md +531 -0
- package/claude-assets/skills/cfn-loop-validation/README_TYPESCRIPT.md +454 -0
- package/claude-assets/skills/cfn-loop-validation/SKILL.md +48 -1
- package/claude-assets/skills/cfn-loop-validation/SKILL.md.backup +353 -0
- package/claude-assets/skills/cfn-loop-validation/SKILL_TYPESCRIPT.md +782 -0
- package/claude-assets/skills/cfn-loop-validation/VAPOR_DETECTION_EXAMPLES.md +598 -0
- package/claude-assets/skills/cfn-loop-validation/check-dependencies.sh +22 -0
- package/claude-assets/skills/cfn-loop-validation/check-dependencies.sh.backup +31 -0
- package/claude-assets/skills/cfn-loop-validation/detect-vapor.sh +59 -0
- package/claude-assets/skills/cfn-loop-validation/detect-vapor.sh.backup +37 -0
- package/claude-assets/skills/cfn-loop-validation/dist/.tsbuildinfo +1 -0
- package/claude-assets/skills/cfn-loop-validation/dist/cli/detect-vapor.d.ts +14 -0
- package/claude-assets/skills/cfn-loop-validation/dist/cli/detect-vapor.d.ts.map +1 -0
- package/claude-assets/skills/cfn-loop-validation/dist/cli/detect-vapor.js +185 -0
- package/claude-assets/skills/cfn-loop-validation/dist/cli/detect-vapor.js.map +1 -0
- package/claude-assets/skills/cfn-loop-validation/dist/cli/validate-deliverables.d.ts +14 -0
- package/claude-assets/skills/cfn-loop-validation/dist/cli/validate-deliverables.d.ts.map +1 -0
- package/claude-assets/skills/cfn-loop-validation/dist/cli/validate-deliverables.js +176 -0
- package/claude-assets/skills/cfn-loop-validation/dist/cli/validate-deliverables.js.map +1 -0
- package/claude-assets/skills/cfn-loop-validation/dist/cli/validate-gate.d.ts +19 -0
- package/claude-assets/skills/cfn-loop-validation/dist/cli/validate-gate.d.ts.map +1 -0
- package/claude-assets/skills/cfn-loop-validation/dist/cli/validate-gate.js +123 -0
- package/claude-assets/skills/cfn-loop-validation/dist/cli/validate-gate.js.map +1 -0
- package/claude-assets/skills/cfn-loop-validation/dist/types.d.ts +156 -0
- package/claude-assets/skills/cfn-loop-validation/dist/types.d.ts.map +1 -0
- package/claude-assets/skills/cfn-loop-validation/dist/types.js +66 -0
- package/claude-assets/skills/cfn-loop-validation/dist/types.js.map +1 -0
- package/claude-assets/skills/cfn-loop-validation/dist/validator.d.ts +85 -0
- package/claude-assets/skills/cfn-loop-validation/dist/validator.d.ts.map +1 -0
- package/claude-assets/skills/cfn-loop-validation/dist/validator.js +411 -0
- package/claude-assets/skills/cfn-loop-validation/dist/validator.js.map +1 -0
- package/claude-assets/skills/cfn-loop-validation/orchestrate-cfn-loop.sh +22 -0
- package/claude-assets/skills/cfn-loop-validation/orchestrate-cfn-loop.sh.backup +252 -0
- package/claude-assets/skills/cfn-loop-validation/package.json +93 -0
- package/claude-assets/skills/cfn-loop-validation/src/cli/detect-vapor.ts +177 -0
- package/claude-assets/skills/cfn-loop-validation/src/cli/validate-deliverables.ts +161 -0
- package/claude-assets/skills/cfn-loop-validation/src/cli/validate-gate.ts +139 -0
- package/claude-assets/skills/cfn-loop-validation/src/types.ts +215 -0
- package/claude-assets/skills/cfn-loop-validation/src/validator.ts +503 -0
- package/claude-assets/skills/cfn-loop-validation/tests/validator.test.ts +537 -0
- package/claude-assets/skills/{cfn-redis-coordination → cfn-loop-validation}/tsconfig.json +34 -31
- package/claude-assets/skills/cfn-loop-validation/validate-deliverables.sh +59 -0
- package/claude-assets/skills/cfn-loop-validation/validate-deliverables.sh.backup +37 -0
- package/claude-assets/skills/cfn-loop-validation/validate-gate.sh +63 -0
- package/claude-assets/skills/cfn-loop-validation/validate-gate.sh.backup +41 -0
- package/claude-assets/skills/cfn-loop-validation/validate-iteration.sh +22 -0
- package/claude-assets/skills/cfn-loop-validation/validate-iteration.sh.backup +134 -0
- package/claude-assets/skills/cfn-product-owner-decision/SKILL.md +479 -147
- package/claude-assets/skills/cfn-product-owner-decision/TYPESCRIPT_IMPLEMENTATION.md +653 -0
- package/{.claude/skills/cfn-product-owner-decision → claude-assets/skills/cfn-product-owner-decision/archive/legacy-bash}/execute-decision.sh +24 -2
- package/claude-assets/skills/cfn-provider-routing/README.md +129 -0
- package/claude-assets/skills/cfn-provider-routing/SKILL.md +192 -0
- package/claude-assets/skills/cfn-provider-routing/resolve-provider-model.ts +223 -0
- package/claude-assets/skills/pre-edit-backup/SKILL.md +324 -0
- package/claude-assets/skills/pre-edit-backup/SKILL.md.backup +277 -0
- package/claude-assets/skills/pre-edit-backup/backup.sh +22 -0
- package/claude-assets/skills/pre-edit-backup/backup.sh.backup +107 -0
- package/dist/agents/agent-loader.js +146 -165
- package/dist/agents/agent-loader.js.map +1 -1
- package/dist/api/auth-endpoints.js +415 -0
- package/dist/api/auth-endpoints.js.map +1 -0
- package/dist/api/task-endpoints.js +562 -0
- package/dist/api/task-endpoints.js.map +1 -0
- package/dist/backend/server.js +418 -0
- package/dist/backend/server.js.map +1 -0
- package/dist/cfn-loop/product-owner/decision-parser.js +356 -0
- package/dist/cfn-loop/product-owner/decision-parser.js.map +1 -0
- package/dist/cfn-loop/product-owner/index.js +1 -0
- package/dist/cfn-loop/product-owner/index.js.map +1 -1
- package/dist/cli/agent-command.js +1 -1
- package/dist/cli/agent-command.js.map +1 -1
- package/dist/cli/agent-completion.js +273 -0
- package/dist/cli/agent-completion.js.map +1 -0
- package/dist/cli/agent-prompt-builder.js +83 -48
- package/dist/cli/agent-prompt-builder.js.map +1 -1
- package/dist/cli/agent-spawner.js +499 -0
- package/dist/cli/agent-spawner.js.map +1 -0
- package/dist/cli/anthropic-client.js +10 -3
- package/dist/cli/anthropic-client.js.map +1 -1
- package/dist/cli/config-manager.js +91 -109
- package/dist/cli/index.js +11 -0
- package/dist/cli/index.js.map +1 -1
- package/dist/cli/parse-decision-cli.js +268 -0
- package/dist/cli/parse-decision-cli.js.map +1 -0
- package/dist/cli/post-edit-hook.js +83 -0
- package/dist/cli/post-edit-hook.js.map +1 -0
- package/dist/cli/pre-edit-hook.js +77 -0
- package/dist/cli/pre-edit-hook.js.map +1 -0
- package/dist/cli/spawn-agent-cli.js +209 -0
- package/dist/cli/spawn-agent-cli.js.map +1 -0
- package/dist/coordination/coordination-wrapper.js +383 -0
- package/dist/coordination/coordination-wrapper.js.map +1 -0
- package/dist/coordination/store-success-criteria.js +68 -0
- package/dist/coordination/store-success-criteria.js.map +1 -0
- package/dist/coordination/store-task-context.js +65 -0
- package/dist/coordination/store-task-context.js.map +1 -0
- package/dist/hooks/backup-manager.js +273 -0
- package/dist/hooks/backup-manager.js.map +1 -0
- package/dist/hooks/post-edit-validator.js +388 -0
- package/dist/hooks/post-edit-validator.js.map +1 -0
- package/dist/integration/index.js +19 -0
- package/dist/integration/index.js.map +1 -0
- package/dist/integration/task-mode-adapter.js +297 -0
- package/dist/integration/task-mode-adapter.js.map +1 -0
- package/dist/integration/trigger-dev-client.js +253 -0
- package/dist/integration/trigger-dev-client.js.map +1 -0
- package/dist/integration/trigger-dev-webhooks.js +362 -0
- package/dist/integration/trigger-dev-webhooks.js.map +1 -0
- package/dist/lib/path-validator.js +14 -5
- package/dist/lib/path-validator.js.map +1 -1
- package/dist/lib/redis-queue-manager.js +5 -1
- package/dist/lib/redis-queue-manager.js.map +1 -1
- package/dist/middleware/authentication.js +317 -0
- package/dist/middleware/authentication.js.map +1 -0
- package/dist/services/authentication.js +669 -0
- package/dist/services/authentication.js.map +1 -0
- package/dist/services/session-management.js +436 -0
- package/dist/services/session-management.js.map +1 -0
- package/dist/services/skill-deployment.js +8 -6
- package/dist/services/skill-deployment.js.map +1 -1
- package/dist/services/user-service.js +710 -0
- package/dist/services/user-service.js.map +1 -0
- package/dist/types/trigger-dev-events.d.js +10 -0
- package/dist/types/trigger-dev-events.d.js.map +1 -0
- package/docs/README.md +240 -0
- package/package.json +13 -4
- package/scripts/compare-workflow-performance.sh +556 -0
- package/scripts/migrate-to-optimized-workflows.sh +438 -0
- package/scripts/organize-docs.sh +338 -0
- package/scripts/trigger-dev-setup.sh +267 -0
- package/.claude/skills/cfn-docker-redis-coordination/MIGRATION_SUMMARY.md +0 -348
- package/.claude/skills/cfn-docker-redis-coordination/README.md +0 -294
- package/.claude/skills/cfn-docker-redis-coordination/SKILL.md +0 -435
- package/.claude/skills/cfn-docker-redis-coordination/coordinate.sh +0 -650
- package/.claude/skills/cfn-docker-redis-coordination/coordinate.sh.backup-1763145142 +0 -641
- package/.claude/skills/cfn-docker-redis-coordination/package-lock.json +0 -5259
- package/.claude/skills/cfn-docker-redis-coordination/package.json +0 -40
- package/.claude/skills/cfn-docker-redis-coordination/src/coordinator.ts +0 -801
- package/.claude/skills/cfn-docker-redis-coordination/src/index.ts +0 -42
- package/.claude/skills/cfn-docker-redis-coordination/src/types.ts +0 -351
- package/.claude/skills/cfn-docker-redis-coordination/tests/coordinator.test.ts +0 -1464
- package/.claude/skills/cfn-docker-redis-coordination/tsconfig.json +0 -30
- package/.claude/skills/cfn-loop-orchestration/helpers/auto-tune-timeouts.sh +0 -228
- package/.claude/skills/cfn-loop-orchestration/helpers/consensus-ts.sh +0 -104
- package/.claude/skills/cfn-loop-orchestration/helpers/consensus.sh +0 -94
- package/.claude/skills/cfn-loop-orchestration/helpers/context-injection.sh +0 -142
- package/.claude/skills/cfn-loop-orchestration/helpers/context-lookup.sh +0 -359
- package/.claude/skills/cfn-loop-orchestration/helpers/deliverable-verifier-ts.sh +0 -123
- package/.claude/skills/cfn-loop-orchestration/helpers/deliverable-verifier.sh +0 -71
- package/.claude/skills/cfn-loop-orchestration/helpers/gate-check.sh +0 -56
- package/.claude/skills/cfn-loop-orchestration/helpers/iteration-manager-ts.sh +0 -89
- package/.claude/skills/cfn-loop-orchestration/helpers/iteration-manager.sh +0 -87
- package/.claude/skills/cfn-loop-orchestration/helpers/orchestrate-ts.sh +0 -104
- package/.claude/skills/cfn-loop-orchestration/helpers/parse-test-results.sh +0 -56
- package/.claude/skills/cfn-loop-orchestration/helpers/spawn-agents.sh +0 -290
- package/.claude/skills/cfn-loop-orchestration/helpers/timeout-calculator-ts.sh +0 -47
- package/.claude/skills/cfn-loop-orchestration/helpers/timeout-calculator.sh +0 -51
- package/.claude/skills/cfn-loop-orchestration/orchestrate.sh +0 -1345
- package/.claude/skills/cfn-redis-coordination/AGENT_LOGGING.md +0 -280
- package/.claude/skills/cfn-redis-coordination/BZPOPMIN_FIX_SUMMARY.md +0 -209
- package/.claude/skills/cfn-redis-coordination/CENTRALIZED_REDIS_WRAPPER.md +0 -319
- package/.claude/skills/cfn-redis-coordination/agent-log.sh.bak +0 -124
- package/.claude/skills/cfn-redis-coordination/config.json +0 -61
- package/.claude/skills/cfn-redis-coordination/demos/phase4-wake-queue-test-report.md +0 -82
- package/.claude/skills/cfn-redis-coordination/demos/test-bzpopmin-fix.sh +0 -274
- package/.claude/skills/cfn-redis-coordination/demos/test-cancel-swarm.sh +0 -0
- package/.claude/skills/cfn-redis-coordination/docs/migration/PHASE_3_REDIS_COORDINATION_COMPLETION_REPORT.md +0 -553
- package/.claude/skills/cfn-redis-coordination/jest.config.js +0 -23
- package/.claude/skills/cfn-redis-coordination/package-lock.json +0 -5272
- package/.claude/skills/cfn-redis-coordination/package.json +0 -45
- package/.claude/skills/cfn-redis-coordination/src/agent-logger.ts +0 -446
- package/.claude/skills/cfn-redis-coordination/src/agent-recovery.ts +0 -454
- package/.claude/skills/cfn-redis-coordination/src/completion-reporter.ts +0 -396
- package/.claude/skills/cfn-redis-coordination/src/context-manager.ts +0 -327
- package/.claude/skills/cfn-redis-coordination/src/index.ts +0 -82
- package/.claude/skills/cfn-redis-coordination/src/mode-detector.ts +0 -155
- package/.claude/skills/cfn-redis-coordination/src/redis/redis-client.ts +0 -305
- package/.claude/skills/cfn-redis-coordination/src/redis/redis-functions.ts +0 -283
- package/.claude/skills/cfn-redis-coordination/src/redis-client.ts +0 -654
- package/.claude/skills/cfn-redis-coordination/src/result-collector.ts +0 -437
- package/.claude/skills/cfn-redis-coordination/src/swarm-manager.ts +0 -494
- package/.claude/skills/cfn-redis-coordination/src/task-analyzer.ts +0 -404
- package/.claude/skills/cfn-redis-coordination/src/task-executor.ts +0 -423
- package/.claude/skills/cfn-redis-coordination/src/types.ts +0 -235
- package/.claude/skills/cfn-redis-coordination/src/waiting-coordinator.ts +0 -587
- package/.claude/skills/cfn-redis-coordination/store-success-criteria.sh +0 -85
- package/.claude/skills/cfn-redis-coordination/test-connection-attempts.js +0 -70
- package/.claude/skills/cfn-redis-coordination/test-mode-simple.js +0 -121
- package/.claude/skills/cfn-redis-coordination/test-redis-check.js +0 -84
- package/.claude/skills/cfn-redis-coordination/test-task-mode-redis.cjs +0 -391
- package/.claude/skills/cfn-redis-coordination/tests/coordination.test.ts +0 -788
- package/.claude/skills/cfn-redis-coordination/update-all-scripts.sh +0 -67
- package/claude-assets/agents/cfn-dev-team/coordinators/cfn-v3-coordinator.md +0 -980
- package/claude-assets/agents/typescript-specialist.md +0 -280
- package/claude-assets/skills/cfn-docker-redis-coordination/MIGRATION_SUMMARY.md +0 -348
- package/claude-assets/skills/cfn-docker-redis-coordination/README.md +0 -294
- package/claude-assets/skills/cfn-docker-redis-coordination/SKILL.md +0 -435
- package/claude-assets/skills/cfn-docker-redis-coordination/coordinate.sh +0 -650
- package/claude-assets/skills/cfn-docker-redis-coordination/coordinate.sh.backup-1763145142 +0 -641
- package/claude-assets/skills/cfn-docker-redis-coordination/jest.config.js +0 -37
- package/claude-assets/skills/cfn-docker-redis-coordination/package-lock.json +0 -5259
- package/claude-assets/skills/cfn-docker-redis-coordination/package.json +0 -40
- package/claude-assets/skills/cfn-docker-redis-coordination/src/coordinator.ts +0 -801
- package/claude-assets/skills/cfn-docker-redis-coordination/src/index.ts +0 -42
- package/claude-assets/skills/cfn-docker-redis-coordination/src/types.ts +0 -351
- package/claude-assets/skills/cfn-docker-redis-coordination/tests/coordinator.test.ts +0 -1464
- package/claude-assets/skills/cfn-loop-orchestration/helpers/auto-tune-timeouts.sh +0 -228
- package/claude-assets/skills/cfn-loop-orchestration/helpers/consensus-ts.sh +0 -104
- package/claude-assets/skills/cfn-loop-orchestration/helpers/consensus.sh +0 -94
- package/claude-assets/skills/cfn-loop-orchestration/helpers/context-injection.sh +0 -142
- package/claude-assets/skills/cfn-loop-orchestration/helpers/context-lookup.sh +0 -359
- package/claude-assets/skills/cfn-loop-orchestration/helpers/deliverable-verifier-ts.sh +0 -123
- package/claude-assets/skills/cfn-loop-orchestration/helpers/deliverable-verifier.sh +0 -71
- package/claude-assets/skills/cfn-loop-orchestration/helpers/gate-check.sh +0 -56
- package/claude-assets/skills/cfn-loop-orchestration/helpers/iteration-manager-ts.sh +0 -89
- package/claude-assets/skills/cfn-loop-orchestration/helpers/iteration-manager.sh +0 -87
- package/claude-assets/skills/cfn-loop-orchestration/helpers/orchestrate-ts.sh +0 -104
- package/claude-assets/skills/cfn-loop-orchestration/helpers/parse-test-results.sh +0 -56
- package/claude-assets/skills/cfn-loop-orchestration/helpers/spawn-agents.sh +0 -290
- package/claude-assets/skills/cfn-loop-orchestration/helpers/timeout-calculator-ts.sh +0 -47
- package/claude-assets/skills/cfn-loop-orchestration/helpers/timeout-calculator.sh +0 -51
- package/claude-assets/skills/cfn-loop-orchestration/orchestrate.sh +0 -1345
- package/claude-assets/skills/cfn-redis-cleanup/cleanup-redis.sh +0 -130
- package/claude-assets/skills/cfn-redis-coordination/AGENT_LOGGING.md +0 -280
- package/claude-assets/skills/cfn-redis-coordination/BZPOPMIN_FIX_SUMMARY.md +0 -209
- package/claude-assets/skills/cfn-redis-coordination/CENTRALIZED_REDIS_WRAPPER.md +0 -319
- package/claude-assets/skills/cfn-redis-coordination/agent-log.sh.bak +0 -124
- package/claude-assets/skills/cfn-redis-coordination/config.json +0 -61
- package/claude-assets/skills/cfn-redis-coordination/demos/phase4-wake-queue-test-report.md +0 -82
- package/claude-assets/skills/cfn-redis-coordination/demos/test-bzpopmin-fix.sh +0 -274
- package/claude-assets/skills/cfn-redis-coordination/demos/test-cancel-swarm.sh +0 -0
- package/claude-assets/skills/cfn-redis-coordination/docs/migration/PHASE_3_REDIS_COORDINATION_COMPLETION_REPORT.md +0 -553
- package/claude-assets/skills/cfn-redis-coordination/jest.config.js +0 -23
- package/claude-assets/skills/cfn-redis-coordination/package-lock.json +0 -5272
- package/claude-assets/skills/cfn-redis-coordination/package.json +0 -45
- package/claude-assets/skills/cfn-redis-coordination/src/agent-logger.ts +0 -446
- package/claude-assets/skills/cfn-redis-coordination/src/agent-recovery.ts +0 -454
- package/claude-assets/skills/cfn-redis-coordination/src/completion-reporter.ts +0 -396
- package/claude-assets/skills/cfn-redis-coordination/src/context-manager.ts +0 -327
- package/claude-assets/skills/cfn-redis-coordination/src/index.ts +0 -82
- package/claude-assets/skills/cfn-redis-coordination/src/mode-detector.ts +0 -155
- package/claude-assets/skills/cfn-redis-coordination/src/redis/redis-client.ts +0 -305
- package/claude-assets/skills/cfn-redis-coordination/src/redis/redis-functions.ts +0 -283
- package/claude-assets/skills/cfn-redis-coordination/src/redis-client.ts +0 -654
- package/claude-assets/skills/cfn-redis-coordination/src/result-collector.ts +0 -437
- package/claude-assets/skills/cfn-redis-coordination/src/swarm-manager.ts +0 -494
- package/claude-assets/skills/cfn-redis-coordination/src/task-analyzer.ts +0 -404
- package/claude-assets/skills/cfn-redis-coordination/src/task-executor.ts +0 -423
- package/claude-assets/skills/cfn-redis-coordination/src/types.ts +0 -235
- package/claude-assets/skills/cfn-redis-coordination/src/waiting-coordinator.ts +0 -587
- package/claude-assets/skills/cfn-redis-coordination/store-success-criteria.sh +0 -85
- package/claude-assets/skills/cfn-redis-coordination/test-connection-attempts.js +0 -70
- package/claude-assets/skills/cfn-redis-coordination/test-mode-simple.js +0 -121
- package/claude-assets/skills/cfn-redis-coordination/test-redis-check.js +0 -84
- package/claude-assets/skills/cfn-redis-coordination/test-task-mode-redis.cjs +0 -391
- package/claude-assets/skills/cfn-redis-coordination/tests/coordination.test.ts +0 -788
- package/claude-assets/skills/cfn-redis-coordination/update-all-scripts.sh +0 -67
- package/claude-assets/skills/cfn-redis-data-extraction/SKILL.md +0 -442
- package/claude-assets/skills/cfn-redis-data-extraction/extract.sh +0 -306
- package/dist/coordination/index.js +0 -25
- package/dist/coordination/index.js.map +0 -1
- package/docs/BUG_19_MEMORY_LEAK_TASK_MODE.md +0 -405
- package/docs/MEMORY_CLEANUP_GUIDE.md +0 -358
- package/docs/MEMORY_LEAK_FIX_SUMMARY.md +0 -322
- package/docs/REDIS_CLEANUP_EXECUTIVE_SUMMARY.md +0 -319
- package/docs/REDIS_CLEANUP_VERIFICATION_REPORT.md +0 -574
- /package/.claude/skills/cfn-loop-orchestration/{inject-loop-context.sh → archive/legacy-bash/inject-loop-context.sh} +0 -0
- /package/.claude/skills/cfn-loop-orchestration/{monitor-execution.sh → archive/legacy-bash/monitor-execution.sh} +0 -0
- /package/.claude/skills/cfn-redis-coordination/{agent-log.sh → agent-log.sh.backup} +0 -0
- /package/.claude/skills/cfn-redis-coordination/{agent-recovery.sh → agent-recovery.sh.backup} +0 -0
- /package/.claude/skills/cfn-redis-coordination/{analyze-task-complexity.sh → analyze-task-complexity.sh.backup} +0 -0
- /package/.claude/skills/cfn-redis-coordination/bash-wrappers/{store-context.sh → store-context.sh.backup} +0 -0
- /package/.claude/skills/cfn-redis-coordination/{cancel-swarm.sh → cancel-swarm.sh.backup} +0 -0
- /package/.claude/skills/cfn-redis-coordination/{cfn-loop-exec.sh → cfn-loop-exec.sh.backup} +0 -0
- /package/.claude/skills/cfn-redis-coordination/{cfn-loop-relaunch.sh → cfn-loop-relaunch.sh.backup} +0 -0
- /package/.claude/skills/cfn-redis-coordination/{collect-confidence-scores.sh → collect-confidence-scores.sh.backup} +0 -0
- /package/.claude/skills/cfn-redis-coordination/{collect-results.sh → collect-results.sh.backup} +0 -0
- /package/.claude/skills/cfn-redis-coordination/{complete-swarm.sh → complete-swarm.sh.backup} +0 -0
- /package/.claude/skills/cfn-redis-coordination/{get-context.sh → get-context.sh.backup} +0 -0
- /package/.claude/skills/cfn-redis-coordination/{get-success-criteria.sh → get-success-criteria.sh.backup} +0 -0
- /package/.claude/skills/cfn-redis-coordination/{invoke-waiting-mode.sh → invoke-waiting-mode.sh.backup} +0 -0
- /package/.claude/skills/cfn-redis-coordination/{redis-cli-wrapper.sh → redis-cli-wrapper.sh.backup} +0 -0
- /package/.claude/skills/cfn-redis-coordination/{redis-functions.sh → redis-functions.sh.backup} +0 -0
- /package/.claude/skills/cfn-redis-coordination/{report-completion.sh → report-completion.sh.backup} +0 -0
- /package/.claude/skills/cfn-redis-coordination/{store-context.sh → store-context.sh.backup} +0 -0
- /package/claude-assets/skills/cfn-loop-orchestration/{inject-loop-context.sh → archive/legacy-bash/inject-loop-context.sh} +0 -0
- /package/claude-assets/skills/cfn-loop-orchestration/{monitor-execution.sh → archive/legacy-bash/monitor-execution.sh} +0 -0
- /package/claude-assets/skills/cfn-redis-coordination/{agent-log.sh → agent-log.sh.backup} +0 -0
- /package/claude-assets/skills/cfn-redis-coordination/{agent-recovery.sh → agent-recovery.sh.backup} +0 -0
- /package/claude-assets/skills/cfn-redis-coordination/{analyze-task-complexity.sh → analyze-task-complexity.sh.backup} +0 -0
- /package/claude-assets/skills/cfn-redis-coordination/bash-wrappers/{store-context.sh → store-context.sh.backup} +0 -0
- /package/claude-assets/skills/cfn-redis-coordination/{cancel-swarm.sh → cancel-swarm.sh.backup} +0 -0
- /package/claude-assets/skills/cfn-redis-coordination/{cfn-loop-exec.sh → cfn-loop-exec.sh.backup} +0 -0
- /package/claude-assets/skills/cfn-redis-coordination/{cfn-loop-relaunch.sh → cfn-loop-relaunch.sh.backup} +0 -0
- /package/claude-assets/skills/cfn-redis-coordination/{collect-confidence-scores.sh → collect-confidence-scores.sh.backup} +0 -0
- /package/claude-assets/skills/cfn-redis-coordination/{collect-results.sh → collect-results.sh.backup} +0 -0
- /package/claude-assets/skills/cfn-redis-coordination/{complete-swarm.sh → complete-swarm.sh.backup} +0 -0
- /package/claude-assets/skills/cfn-redis-coordination/{get-context.sh → get-context.sh.backup} +0 -0
- /package/claude-assets/skills/cfn-redis-coordination/{get-success-criteria.sh → get-success-criteria.sh.backup} +0 -0
- /package/claude-assets/skills/cfn-redis-coordination/{invoke-waiting-mode.sh → invoke-waiting-mode.sh.backup} +0 -0
- /package/claude-assets/skills/cfn-redis-coordination/{redis-cli-wrapper.sh → redis-cli-wrapper.sh.backup} +0 -0
- /package/claude-assets/skills/cfn-redis-coordination/{redis-functions.sh → redis-functions.sh.backup} +0 -0
- /package/claude-assets/skills/cfn-redis-coordination/{report-completion.sh → report-completion.sh.backup} +0 -0
- /package/claude-assets/skills/cfn-redis-coordination/{store-context.sh → store-context.sh.backup} +0 -0
|
@@ -1,1345 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env bash
|
|
2
|
-
|
|
3
|
-
##############################################################################
|
|
4
|
-
# CFN Loop Orchestration - Main Coordinator
|
|
5
|
-
# Version: 1.1.0 (Security Enhanced)
|
|
6
|
-
#
|
|
7
|
-
# Orchestrates the Complete Fail Never (CFN) Loop workflow using modular
|
|
8
|
-
# helper scripts, Redis Coordination primitives, and enhanced security.
|
|
9
|
-
#
|
|
10
|
-
# Usage:
|
|
11
|
-
# ./orchestrate.sh --task-id <id> \
|
|
12
|
-
# --mode <mvp|standard|enterprise> \
|
|
13
|
-
# --loop3-agents <agent1,agent2,...> \
|
|
14
|
-
# --loop2-agents <agent1,agent2,...> \
|
|
15
|
-
# --product-owner <agent-id> \
|
|
16
|
-
# [--max-iterations <n>] \
|
|
17
|
-
# [--epic-context <json>] \
|
|
18
|
-
# [--phase-context <json>] \
|
|
19
|
-
# [--success-criteria <enabled>] # Flag: criteria stored in Redis by coordinator
|
|
20
|
-
##############################################################################
|
|
21
|
-
|
|
22
|
-
set -euo pipefail
|
|
23
|
-
|
|
24
|
-
# Determine PROJECT_ROOT first before any other operations
|
|
25
|
-
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
|
26
|
-
# Fixed path resolution - go up 4 levels from cfn-loop-orchestration to project root (.claude/skills/cfn-loop-orchestration -> .claude/skills -> .claude -> project root)
|
|
27
|
-
PROJECT_ROOT="$(cd "$SCRIPT_DIR/../../.." && pwd)"
|
|
28
|
-
|
|
29
|
-
# ⚠️ ANTI-023 MEMORY LEAK PROTECTION:
|
|
30
|
-
# Task Mode validation moved to after argument parsing at line 276
|
|
31
|
-
# This allows proper CLI argument processing before validation
|
|
32
|
-
|
|
33
|
-
# ⚠️ ANTI-023 MEMORY LEAK PROTECTION: Environment Sanitization
|
|
34
|
-
# Load and apply environment sanitization to prevent memory leaks
|
|
35
|
-
if [[ -f "$PROJECT_ROOT/.claude/skills/cfn-task-mode-sanitize/task-mode-env-sanitizer.sh" ]]; then
|
|
36
|
-
source "$PROJECT_ROOT/.claude/skills/cfn-task-mode-sanitize/task-mode-env-sanitizer.sh"
|
|
37
|
-
sanitize_task_mode_environment "cli"
|
|
38
|
-
echo "✅ Environment sanitization applied" >&2
|
|
39
|
-
else
|
|
40
|
-
echo "⚠️ Environment sanitization not available - proceeding without protection" >&2
|
|
41
|
-
fi
|
|
42
|
-
|
|
43
|
-
# ⚠️ ANTI-023 MEMORY LEAK PROTECTION: Process Instrumentation
|
|
44
|
-
# Load process instrumentation and monitoring for the orchestrator
|
|
45
|
-
if [[ -f "$PROJECT_ROOT/.claude/skills/cfn-validation-runner-instrumentation/wrapped-executor.sh" ]]; then
|
|
46
|
-
source "$PROJECT_ROOT/.claude/skills/cfn-validation-runner-instrumentation/wrapped-executor.sh"
|
|
47
|
-
echo "✅ Orchestrator process instrumentation enabled" >&2
|
|
48
|
-
else
|
|
49
|
-
echo "⚠️ Process instrumentation not available - proceeding without monitoring" >&2
|
|
50
|
-
fi
|
|
51
|
-
|
|
52
|
-
# ⚠️ ANTI-023 MEMORY LEAK PROTECTION: Environment Configuration
|
|
53
|
-
# Set stabilization environment variables with sensible defaults
|
|
54
|
-
export CFN_VALIDATION_TIMEOUT="${CFN_VALIDATION_TIMEOUT:-300}" # 5 minutes
|
|
55
|
-
export CFN_MEMORY_LIMIT="${CFN_MEMORY_LIMIT:-2048}" # 2GB memory limit
|
|
56
|
-
export CFN_CPU_LIMIT="${CFN_CPU_LIMIT:-80}" # 80% CPU limit
|
|
57
|
-
export CFN_TELEMETRY_DIR="${CFN_TELEMETRY_DIR:-$PROJECT_ROOT/.artifacts/telemetry}"
|
|
58
|
-
mkdir -p "$CFN_TELEMETRY_DIR"
|
|
59
|
-
|
|
60
|
-
# Load security utilities
|
|
61
|
-
# shellcheck source=./security_utils.sh
|
|
62
|
-
source "$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)/security_utils.sh"
|
|
63
|
-
|
|
64
|
-
##############################################################################
|
|
65
|
-
# Input Sanitization (Security)
|
|
66
|
-
##############################################################################
|
|
67
|
-
sanitize_input() {
|
|
68
|
-
local input="$1"
|
|
69
|
-
local max_length="${2:-256}" # Default max length 256 chars
|
|
70
|
-
|
|
71
|
-
# Truncate to max length
|
|
72
|
-
input="${input:0:$max_length}"
|
|
73
|
-
|
|
74
|
-
# Remove dangerous characters (only allow alphanumeric, dash, underscore, dot, comma, colon, space, forward slash)
|
|
75
|
-
# This covers task IDs, agent types, file paths, and JSON-like structures
|
|
76
|
-
echo "$input" | sed 's/[^a-zA-Z0-9._:, /-]//g'
|
|
77
|
-
}
|
|
78
|
-
|
|
79
|
-
HELPERS_DIR="$SCRIPT_DIR/helpers"
|
|
80
|
-
REDIS_COORD_SKILL="$PROJECT_ROOT/.claude/skills/cfn-redis-coordination"
|
|
81
|
-
|
|
82
|
-
# Validate Redis connectivity
|
|
83
|
-
REDIS_PORT="${CFN_REDIS_PORT:-6379}"
|
|
84
|
-
REDIS_HOST="${CFN_REDIS_HOST:-localhost}"
|
|
85
|
-
if command -v redis-cli &>/dev/null; then
|
|
86
|
-
if ! redis-cli -h "${REDIS_HOST}" -p "${REDIS_PORT}" ping &>/dev/null; then
|
|
87
|
-
echo "⚠️ Warning: Redis not reachable at ${REDIS_HOST}:${REDIS_PORT}" >&2
|
|
88
|
-
echo " Redis coordination features may not function correctly" >&2
|
|
89
|
-
fi
|
|
90
|
-
fi
|
|
91
|
-
|
|
92
|
-
# Configuration
|
|
93
|
-
TASK_ID=""
|
|
94
|
-
MODE="standard"
|
|
95
|
-
LOOP3_AGENTS=""
|
|
96
|
-
LOOP2_AGENTS=""
|
|
97
|
-
PRODUCT_OWNER=""
|
|
98
|
-
MAX_ITERATIONS=10
|
|
99
|
-
MAX_ALLOWED_ITERATIONS=100 # Security: Prevent resource exhaustion via unbounded iterations
|
|
100
|
-
MIN_QUORUM_LOOP3="0.66"
|
|
101
|
-
MIN_QUORUM_LOOP2="0.66"
|
|
102
|
-
EPIC_CONTEXT=""
|
|
103
|
-
PHASE_CONTEXT=""
|
|
104
|
-
SUCCESS_CRITERIA=""
|
|
105
|
-
EXPECTED_FILES=""
|
|
106
|
-
PHASE_ID=""
|
|
107
|
-
|
|
108
|
-
# Mode-specific thresholds
|
|
109
|
-
declare -A GATE_THRESHOLD=(
|
|
110
|
-
[mvp]=0.70
|
|
111
|
-
[standard]=0.95
|
|
112
|
-
[enterprise]=0.98
|
|
113
|
-
)
|
|
114
|
-
|
|
115
|
-
declare -A CONSENSUS_THRESHOLD=(
|
|
116
|
-
[mvp]=0.80
|
|
117
|
-
[standard]=0.90
|
|
118
|
-
[enterprise]=0.95
|
|
119
|
-
)
|
|
120
|
-
|
|
121
|
-
# Execution tracking
|
|
122
|
-
START_TIME=$(date +%s)
|
|
123
|
-
ITERATIONS_COMPLETED=0
|
|
124
|
-
FINAL_DECISION=""
|
|
125
|
-
LOOP3_FINAL_CONFIDENCE=0.0
|
|
126
|
-
LOOP2_FINAL_CONSENSUS=0.0
|
|
127
|
-
DELIVERABLES_VERIFIED=false
|
|
128
|
-
|
|
129
|
-
##############################################################################
|
|
130
|
-
# Argument Parsing
|
|
131
|
-
##############################################################################
|
|
132
|
-
while [[ $# -gt 0 ]]; do
|
|
133
|
-
case $1 in
|
|
134
|
-
--task-id)
|
|
135
|
-
if [[ $# -lt 2 ]]; then
|
|
136
|
-
echo "Error: --task-id requires a value"
|
|
137
|
-
exit 1
|
|
138
|
-
fi
|
|
139
|
-
TASK_ID=$(sanitize_input "$2") || { echo "Invalid task ID"; exit 1; }
|
|
140
|
-
shift 2
|
|
141
|
-
;;
|
|
142
|
-
--mode)
|
|
143
|
-
if [[ $# -lt 2 ]]; then
|
|
144
|
-
echo "Error: --mode requires a value"
|
|
145
|
-
exit 1
|
|
146
|
-
fi
|
|
147
|
-
MODE="$2"
|
|
148
|
-
# Whitelist allowed modes
|
|
149
|
-
if [[ ! "$MODE" =~ ^(mvp|standard|enterprise)$ ]]; then
|
|
150
|
-
echo "Invalid mode. Must be mvp, standard, or enterprise."
|
|
151
|
-
exit 1
|
|
152
|
-
fi
|
|
153
|
-
shift 2
|
|
154
|
-
;;
|
|
155
|
-
--loop3-agents)
|
|
156
|
-
if [[ $# -lt 2 ]]; then
|
|
157
|
-
echo "Error: --loop3-agents requires a value"
|
|
158
|
-
exit 1
|
|
159
|
-
fi
|
|
160
|
-
if [[ -z "$2" ]]; then
|
|
161
|
-
echo "Error: --loop3-agents value cannot be empty"
|
|
162
|
-
exit 1
|
|
163
|
-
fi
|
|
164
|
-
validate_agent_list "$2" || { echo "Invalid Loop 3 agent list"; exit 1; }
|
|
165
|
-
LOOP3_AGENTS="$2"
|
|
166
|
-
shift 2
|
|
167
|
-
;;
|
|
168
|
-
--loop2-agents)
|
|
169
|
-
if [[ $# -lt 2 ]]; then
|
|
170
|
-
echo "Error: --loop2-agents requires a value"
|
|
171
|
-
exit 1
|
|
172
|
-
fi
|
|
173
|
-
if [[ -z "$2" ]]; then
|
|
174
|
-
echo "Error: --loop2-agents value cannot be empty"
|
|
175
|
-
exit 1
|
|
176
|
-
fi
|
|
177
|
-
validate_agent_list "$2" || { echo "Invalid Loop 2 agent list"; exit 1; }
|
|
178
|
-
LOOP2_AGENTS="$2"
|
|
179
|
-
shift 2
|
|
180
|
-
;;
|
|
181
|
-
--product-owner)
|
|
182
|
-
if [[ $# -lt 2 ]]; then
|
|
183
|
-
echo "Error: --product-owner requires a value"
|
|
184
|
-
exit 1
|
|
185
|
-
fi
|
|
186
|
-
if [[ -z "$2" ]]; then
|
|
187
|
-
echo "Error: --product-owner value cannot be empty"
|
|
188
|
-
exit 1
|
|
189
|
-
fi
|
|
190
|
-
PRODUCT_OWNER=$(sanitize_input "$2") || { echo "Invalid product owner"; exit 1; }
|
|
191
|
-
shift 2
|
|
192
|
-
;;
|
|
193
|
-
--max-iterations)
|
|
194
|
-
if [[ $# -lt 2 ]]; then
|
|
195
|
-
echo "Error: --max-iterations requires a value"
|
|
196
|
-
exit 1
|
|
197
|
-
fi
|
|
198
|
-
# Validate max iterations is a positive integer
|
|
199
|
-
if [[ ! "$2" =~ ^[1-9][0-9]*$ ]]; then
|
|
200
|
-
echo "Max iterations must be a positive integer"
|
|
201
|
-
exit 1
|
|
202
|
-
fi
|
|
203
|
-
# SECURITY FIX: Enforce upper bound to prevent resource exhaustion
|
|
204
|
-
if [[ "$2" -gt "$MAX_ALLOWED_ITERATIONS" ]]; then
|
|
205
|
-
echo "❌ MAX_ITERATIONS=$2 exceeds limit of $MAX_ALLOWED_ITERATIONS" >&2
|
|
206
|
-
echo " (Use --max-iterations <N> where N <= $MAX_ALLOWED_ITERATIONS)" >&2
|
|
207
|
-
exit 1
|
|
208
|
-
fi
|
|
209
|
-
if [[ "$2" -lt 1 ]]; then
|
|
210
|
-
echo "❌ MAX_ITERATIONS must be at least 1" >&2
|
|
211
|
-
exit 1
|
|
212
|
-
fi
|
|
213
|
-
MAX_ITERATIONS="$2"
|
|
214
|
-
shift 2
|
|
215
|
-
;;
|
|
216
|
-
|
|
217
|
-
--min-quorum-loop3)
|
|
218
|
-
if [[ $# -lt 2 ]]; then
|
|
219
|
-
echo "Error: --min-quorum-loop3 requires a value"
|
|
220
|
-
exit 1
|
|
221
|
-
fi
|
|
222
|
-
# Validate quorum is a valid decimal between 0 and 1
|
|
223
|
-
if [[ ! "$2" =~ ^0\.[0-9]+$ ]] || (( $(echo "$2 > 1" | bc -l) )); then
|
|
224
|
-
echo "Invalid Loop 3 quorum. Must be between 0 and 1."
|
|
225
|
-
exit 1
|
|
226
|
-
fi
|
|
227
|
-
MIN_QUORUM_LOOP3="$2"
|
|
228
|
-
shift 2
|
|
229
|
-
;;
|
|
230
|
-
--min-quorum-loop2)
|
|
231
|
-
if [[ $# -lt 2 ]]; then
|
|
232
|
-
echo "Error: --min-quorum-loop2 requires a value"
|
|
233
|
-
exit 1
|
|
234
|
-
fi
|
|
235
|
-
# Validate quorum is a valid decimal between 0 and 1
|
|
236
|
-
if [[ ! "$2" =~ ^0\.[0-9]+$ ]] || (( $(echo "$2 > 1" | bc -l) )); then
|
|
237
|
-
echo "Invalid Loop 2 quorum. Must be between 0 and 1."
|
|
238
|
-
exit 1
|
|
239
|
-
fi
|
|
240
|
-
MIN_QUORUM_LOOP2="$2"
|
|
241
|
-
shift 2
|
|
242
|
-
;;
|
|
243
|
-
--epic-context)
|
|
244
|
-
if [[ $# -lt 2 ]]; then
|
|
245
|
-
echo "Error: --epic-context requires a value"
|
|
246
|
-
exit 1
|
|
247
|
-
fi
|
|
248
|
-
validate_json_context "$2" || { echo "Invalid epic context JSON"; exit 1; }
|
|
249
|
-
EPIC_CONTEXT="$2"
|
|
250
|
-
shift 2
|
|
251
|
-
;;
|
|
252
|
-
--phase-context)
|
|
253
|
-
if [[ $# -lt 2 ]]; then
|
|
254
|
-
echo "Error: --phase-context requires a value"
|
|
255
|
-
exit 1
|
|
256
|
-
fi
|
|
257
|
-
validate_json_context "$2" || { echo "Invalid phase context JSON"; exit 1; }
|
|
258
|
-
PHASE_CONTEXT="$2"
|
|
259
|
-
shift 2
|
|
260
|
-
;;
|
|
261
|
-
--success-criteria)
|
|
262
|
-
if [[ $# -lt 2 ]]; then
|
|
263
|
-
echo "Error: --success-criteria requires a value"
|
|
264
|
-
exit 1
|
|
265
|
-
fi
|
|
266
|
-
# Store flag value - coordinator will write to Redis before spawning orchestrator
|
|
267
|
-
# Orchestrator validates the key exists in Redis during pre-flight
|
|
268
|
-
SUCCESS_CRITERIA="$2"
|
|
269
|
-
shift 2
|
|
270
|
-
;;
|
|
271
|
-
--expected-files)
|
|
272
|
-
if [[ $# -lt 2 ]]; then
|
|
273
|
-
echo "Error: --expected-files requires a value"
|
|
274
|
-
exit 1
|
|
275
|
-
fi
|
|
276
|
-
# Optional: validate each expected file name if not empty
|
|
277
|
-
if [ -n "$2" ]; then
|
|
278
|
-
IFS=',' read -ra FILES <<< "$2"
|
|
279
|
-
for file in "${FILES[@]}"; do
|
|
280
|
-
sanitize_input "$file" 256 || { echo "Invalid expected filename: $file"; exit 1; }
|
|
281
|
-
done
|
|
282
|
-
fi
|
|
283
|
-
EXPECTED_FILES="$2"
|
|
284
|
-
shift 2
|
|
285
|
-
;;
|
|
286
|
-
--phase-id)
|
|
287
|
-
if [[ $# -lt 2 ]]; then
|
|
288
|
-
echo "Error: --phase-id requires a value"
|
|
289
|
-
exit 1
|
|
290
|
-
fi
|
|
291
|
-
PHASE_ID=$(sanitize_input "$2") || { echo "Invalid phase ID"; exit 1; }
|
|
292
|
-
shift 2
|
|
293
|
-
;;
|
|
294
|
-
*)
|
|
295
|
-
echo "Error: Unknown option: '$1'"
|
|
296
|
-
echo ""
|
|
297
|
-
echo "Usage: $0 [OPTIONS]"
|
|
298
|
-
echo ""
|
|
299
|
-
echo "Required options:"
|
|
300
|
-
echo " --task-id <id> Unique task identifier"
|
|
301
|
-
echo " --loop3-agents <agents> Comma-separated list of Loop 3 agents"
|
|
302
|
-
echo " --loop2-agents <agents> Comma-separated list of Loop 2 agents"
|
|
303
|
-
echo " --product-owner <agent> Product owner agent ID"
|
|
304
|
-
echo ""
|
|
305
|
-
echo "Optional options:"
|
|
306
|
-
echo " --mode <mode> CFN mode: mvp, standard, enterprise (default: standard)"
|
|
307
|
-
echo " --max-iterations <n> Maximum iterations (default: 10)"
|
|
308
|
-
echo " --min-quorum-loop3 <n> Loop 3 quorum threshold (default: 0.66)"
|
|
309
|
-
echo " --min-quorum-loop2 <n> Loop 2 quorum threshold (default: 0.66)"
|
|
310
|
-
echo " --epic-context <json> Epic context JSON"
|
|
311
|
-
echo " --phase-context <json> Phase context JSON"
|
|
312
|
-
echo " --success-criteria <value> Flag to enable success criteria (stored in Redis by coordinator)"
|
|
313
|
-
echo " --expected-files <files> Comma-separated expected deliverables"
|
|
314
|
-
echo " --phase-id <id> Phase identifier for timeout calculation"
|
|
315
|
-
exit 1
|
|
316
|
-
;;
|
|
317
|
-
esac
|
|
318
|
-
done
|
|
319
|
-
|
|
320
|
-
# Validation
|
|
321
|
-
if [ -z "$TASK_ID" ] || [ -z "$LOOP3_AGENTS" ] || [ -z "$LOOP2_AGENTS" ] || [ -z "$PRODUCT_OWNER" ]; then
|
|
322
|
-
echo "Error: Required parameters missing"
|
|
323
|
-
echo "Usage: $0 --task-id <id> --mode <mode> --loop3-agents <agents> --loop2-agents <agents> --product-owner <agent>"
|
|
324
|
-
exit 1
|
|
325
|
-
fi
|
|
326
|
-
|
|
327
|
-
# ⚠️ ANTI-023 MEMORY LEAK PROTECTION: Process Instrumentation
|
|
328
|
-
# Load process instrumentation and monitoring for the orchestrator
|
|
329
|
-
# shellcheck source=../cfn-process-instrumentation/instrument-process.sh
|
|
330
|
-
if [[ -f "$PROJECT_ROOT/.claude/skills/cfn-process-instrumentation/instrument-process.sh" ]]; then
|
|
331
|
-
source "$PROJECT_ROOT/.claude/skills/cfn-process-instrumentation/instrument-process.sh"
|
|
332
|
-
echo "✅ Orchestrator process instrumentation enabled" >&2
|
|
333
|
-
else
|
|
334
|
-
echo "⚠️ Process instrumentation not available - proceeding without monitoring" >&2
|
|
335
|
-
fi
|
|
336
|
-
|
|
337
|
-
# Get thresholds for mode
|
|
338
|
-
# Add additional mode validation with safe fallback
|
|
339
|
-
case "$MODE" in
|
|
340
|
-
mvp)
|
|
341
|
-
GATE=${GATE_THRESHOLD[mvp]:-0.70}
|
|
342
|
-
CONSENSUS=${CONSENSUS_THRESHOLD[mvp]:-0.80}
|
|
343
|
-
;;
|
|
344
|
-
standard)
|
|
345
|
-
GATE=${GATE_THRESHOLD[standard]:-0.95}
|
|
346
|
-
CONSENSUS=${CONSENSUS_THRESHOLD[standard]:-0.90}
|
|
347
|
-
;;
|
|
348
|
-
enterprise)
|
|
349
|
-
GATE=${GATE_THRESHOLD[enterprise]:-0.98}
|
|
350
|
-
CONSENSUS=${CONSENSUS_THRESHOLD[enterprise]:-0.95}
|
|
351
|
-
;;
|
|
352
|
-
*)
|
|
353
|
-
echo "Invalid mode: $MODE"
|
|
354
|
-
exit 1
|
|
355
|
-
;;
|
|
356
|
-
esac
|
|
357
|
-
|
|
358
|
-
# Calculate timeout
|
|
359
|
-
TIMEOUT=$("$HELPERS_DIR/timeout-calculator.sh" --phase-id "${PHASE_ID:-unknown}")
|
|
360
|
-
|
|
361
|
-
echo "=============================================="
|
|
362
|
-
echo "CFN Loop Orchestration v1.0.0"
|
|
363
|
-
echo "=============================================="
|
|
364
|
-
echo "Task ID: $TASK_ID"
|
|
365
|
-
echo "Mode: $MODE"
|
|
366
|
-
echo "Gate Threshold: $GATE"
|
|
367
|
-
echo "Consensus Threshold: $CONSENSUS"
|
|
368
|
-
echo "Max Iterations: $MAX_ITERATIONS"
|
|
369
|
-
echo "Timeout: ${TIMEOUT}s"
|
|
370
|
-
echo "=============================================="
|
|
371
|
-
echo ""
|
|
372
|
-
|
|
373
|
-
##############################################################################
|
|
374
|
-
# Pre-Flight Validation
|
|
375
|
-
##############################################################################
|
|
376
|
-
|
|
377
|
-
echo "Running pre-flight checks..."
|
|
378
|
-
|
|
379
|
-
# 1. Validate Success Criteria in Redis (if flag provided)
|
|
380
|
-
if [ -n "$SUCCESS_CRITERIA" ]; then
|
|
381
|
-
CRITERIA_VALUE=$("$REDIS_COORD_SKILL/get-context.sh" \
|
|
382
|
-
--task-id "$TASK_ID" \
|
|
383
|
-
--key "success-criteria" \
|
|
384
|
-
--namespace "cfn_loop:task" 2>/dev/null || echo "")
|
|
385
|
-
|
|
386
|
-
if [ -z "$CRITERIA_VALUE" ]; then
|
|
387
|
-
echo "❌ Pre-flight failed: --success-criteria flag set but not found in Redis" >&2
|
|
388
|
-
echo " Coordinator must store criteria before spawning orchestrator" >&2
|
|
389
|
-
exit 1
|
|
390
|
-
fi
|
|
391
|
-
|
|
392
|
-
# Validate JSON syntax
|
|
393
|
-
if ! echo "$CRITERIA_VALUE" | jq empty 2>/dev/null; then
|
|
394
|
-
echo "❌ Pre-flight failed: Success criteria in Redis contains invalid JSON" >&2
|
|
395
|
-
exit 1
|
|
396
|
-
fi
|
|
397
|
-
|
|
398
|
-
echo "✅ Success criteria validated in Redis"
|
|
399
|
-
fi
|
|
400
|
-
|
|
401
|
-
# 2. Validate Redis Connectivity (required for CLI mode)
|
|
402
|
-
if ! redis-cli -h "${REDIS_HOST:-localhost}" -p "${REDIS_PORT:-6379}" ping &>/dev/null; then
|
|
403
|
-
echo "❌ Pre-flight failed: Redis not available at ${REDIS_HOST:-localhost}:${REDIS_PORT:-6379}" >&2
|
|
404
|
-
echo " CLI mode requires Redis for coordination" >&2
|
|
405
|
-
exit 1
|
|
406
|
-
fi
|
|
407
|
-
echo "✅ Redis connectivity validated"
|
|
408
|
-
|
|
409
|
-
# 3. Validate Agent Types Exist
|
|
410
|
-
MISSING_AGENTS=""
|
|
411
|
-
for agent_type in $(echo "$LOOP3_AGENTS,$LOOP2_AGENTS" | tr ',' '\n' | sort -u); do
|
|
412
|
-
if ! find "$PROJECT_ROOT/.claude/agents" -name "*${agent_type}*.md" 2>/dev/null | grep -q .; then
|
|
413
|
-
MISSING_AGENTS="${MISSING_AGENTS}${agent_type}, "
|
|
414
|
-
fi
|
|
415
|
-
done
|
|
416
|
-
|
|
417
|
-
if [ -n "$MISSING_AGENTS" ]; then
|
|
418
|
-
echo "⚠️ Warning: Agent types not found in .claude/agents/: ${MISSING_AGENTS%, }" >&2
|
|
419
|
-
echo " Continuing anyway (agent-spawn will handle missing agents)" >&2
|
|
420
|
-
fi
|
|
421
|
-
|
|
422
|
-
# 4. Validate Helper Scripts Exist
|
|
423
|
-
REQUIRED_HELPERS=(
|
|
424
|
-
"$HELPERS_DIR/gate-check.sh"
|
|
425
|
-
"$HELPERS_DIR/consensus.sh"
|
|
426
|
-
"$HELPERS_DIR/iteration-manager.sh"
|
|
427
|
-
"$HELPERS_DIR/timeout-calculator.sh"
|
|
428
|
-
)
|
|
429
|
-
|
|
430
|
-
for helper in "${REQUIRED_HELPERS[@]}"; do
|
|
431
|
-
if [ ! -x "$helper" ]; then
|
|
432
|
-
echo "❌ Pre-flight failed: Required helper script missing or not executable: $helper" >&2
|
|
433
|
-
exit 1
|
|
434
|
-
fi
|
|
435
|
-
done
|
|
436
|
-
echo "✅ Helper scripts validated"
|
|
437
|
-
|
|
438
|
-
# 5. Validate Product Owner Decision Skill
|
|
439
|
-
if [ ! -x "$PROJECT_ROOT/.claude/skills/cfn-product-owner-decision/execute-decision.sh" ]; then
|
|
440
|
-
echo "❌ Pre-flight failed: Product owner decision script not found or not executable" >&2
|
|
441
|
-
exit 1
|
|
442
|
-
fi
|
|
443
|
-
echo "✅ Product owner decision script validated"
|
|
444
|
-
|
|
445
|
-
echo "✅ All pre-flight checks passed"
|
|
446
|
-
echo ""
|
|
447
|
-
|
|
448
|
-
##############################################################################
|
|
449
|
-
# Helper Functions
|
|
450
|
-
##############################################################################
|
|
451
|
-
|
|
452
|
-
function store_context() {
|
|
453
|
-
local task_id="$1"
|
|
454
|
-
|
|
455
|
-
# Store epic context if provided using Redis coordination primitive
|
|
456
|
-
if [ -n "$EPIC_CONTEXT" ]; then
|
|
457
|
-
"$REDIS_COORD_SKILL/store-context.sh" \
|
|
458
|
-
--task-id "$task_id" \
|
|
459
|
-
--key "epic-context" \
|
|
460
|
-
--value "$EPIC_CONTEXT" \
|
|
461
|
-
--namespace "swarm" >/dev/null
|
|
462
|
-
echo "Stored epic context"
|
|
463
|
-
fi
|
|
464
|
-
|
|
465
|
-
# Store phase context if provided using Redis coordination primitive
|
|
466
|
-
if [ -n "$PHASE_CONTEXT" ]; then
|
|
467
|
-
"$REDIS_COORD_SKILL/store-context.sh" \
|
|
468
|
-
--task-id "$task_id" \
|
|
469
|
-
--key "phase-context" \
|
|
470
|
-
--value "$PHASE_CONTEXT" \
|
|
471
|
-
--namespace "swarm" >/dev/null
|
|
472
|
-
echo "Stored phase context"
|
|
473
|
-
fi
|
|
474
|
-
|
|
475
|
-
# NOTE: Success criteria is now stored by coordinator BEFORE spawning orchestrator
|
|
476
|
-
# Orchestrator only validates that it exists in Redis during pre-flight
|
|
477
|
-
# This comment explains the flow for future maintainers
|
|
478
|
-
if [ -n "$SUCCESS_CRITERIA" ]; then
|
|
479
|
-
# Verify criteria exists in Redis (should have been stored by coordinator)
|
|
480
|
-
CRITERIA_VALUE=$("$REDIS_COORD_SKILL/get-context.sh" \
|
|
481
|
-
--task-id "$task_id" \
|
|
482
|
-
--key "success-criteria" \
|
|
483
|
-
--namespace "cfn_loop:task" 2>/dev/null || echo "")
|
|
484
|
-
|
|
485
|
-
if [ -n "$CRITERIA_VALUE" ]; then
|
|
486
|
-
echo "✅ Success criteria loaded from Redis (stored by coordinator)"
|
|
487
|
-
else
|
|
488
|
-
echo "⚠️ Success criteria flag set but not found in Redis" >&2
|
|
489
|
-
fi
|
|
490
|
-
fi
|
|
491
|
-
|
|
492
|
-
echo ""
|
|
493
|
-
}
|
|
494
|
-
|
|
495
|
-
build_agent_context() {
|
|
496
|
-
local task_id="$1"
|
|
497
|
-
local iteration="$2"
|
|
498
|
-
local agent_type="$3"
|
|
499
|
-
local feedback="$4"
|
|
500
|
-
local loop_type="${5:-}" # NEW: loop3, loop2, or loop4 (optional)
|
|
501
|
-
|
|
502
|
-
# Initialize context variables
|
|
503
|
-
local task_desc="CFN Loop implementation"
|
|
504
|
-
local deliverables=""
|
|
505
|
-
local acceptance=""
|
|
506
|
-
local epic_context=""
|
|
507
|
-
local phase_context=""
|
|
508
|
-
local target_files=""
|
|
509
|
-
|
|
510
|
-
# Try to retrieve complete context from Redis
|
|
511
|
-
if command -v "$REDIS_COORD_SKILL/get-context.sh" >/dev/null 2>&1; then
|
|
512
|
-
if redis_context=$("$REDIS_COORD_SKILL/get-context.sh" --task-id "$task_id" --namespace "swarm" 2>/dev/null); then
|
|
513
|
-
echo "📥 Retrieved Redis context for task: $task_id" >&2
|
|
514
|
-
|
|
515
|
-
# Extract fields from Redis context
|
|
516
|
-
task_desc=$(echo "$redis_context" | jq -r '.["epic-context"] // .epic_context // "CFN Loop implementation"' 2>/dev/null || echo "CFN Loop implementation")
|
|
517
|
-
deliverables=$(echo "$redis_context" | jq -r '.deliverables // [] | if type == "array" then join(", ") else . end' 2>/dev/null || echo "")
|
|
518
|
-
acceptance=$(echo "$redis_context" | jq -r '.acceptanceCriteria // .["acceptance-criteria"] // [] | if type == "array" then join(", ") else . end' 2>/dev/null || echo "")
|
|
519
|
-
epic_context=$(echo "$redis_context" | jq -r '.["epic-context"] // ""' 2>/dev/null || echo "")
|
|
520
|
-
phase_context=$(echo "$redis_context" | jq -r '.["phase-context"] // ""' 2>/dev/null || echo "")
|
|
521
|
-
target_files=$(echo "$redis_context" | jq -r '.["target-files"] // ""' 2>/dev/null || echo "")
|
|
522
|
-
|
|
523
|
-
echo "📋 Redis context extracted - Task: $task_desc" >&2
|
|
524
|
-
else
|
|
525
|
-
echo "⚠️ Failed to retrieve Redis context, using local SUCCESS_CRITERIA" >&2
|
|
526
|
-
fi
|
|
527
|
-
else
|
|
528
|
-
echo "⚠️ get-context.sh not found, using local SUCCESS_CRITERIA" >&2
|
|
529
|
-
fi
|
|
530
|
-
|
|
531
|
-
# Fallback to local SUCCESS_CRITERIA if Redis retrieval failed or incomplete
|
|
532
|
-
if [ -z "$deliverables" ] && [ -n "$SUCCESS_CRITERIA" ]; then
|
|
533
|
-
deliverables=$(echo "$SUCCESS_CRITERIA" | jq -r '.deliverables // [] | join(", ")' 2>/dev/null || echo "")
|
|
534
|
-
acceptance=$(echo "$SUCCESS_CRITERIA" | jq -r '.acceptanceCriteria // [] | join(", ")' 2>/dev/null || echo "")
|
|
535
|
-
echo "🔄 Using local SUCCESS_CRITERIA as fallback" >&2
|
|
536
|
-
fi
|
|
537
|
-
|
|
538
|
-
# Build comprehensive context string
|
|
539
|
-
local context="Task: $task_desc"
|
|
540
|
-
|
|
541
|
-
if [ -n "$deliverables" ]; then
|
|
542
|
-
context="$context | Deliverables: $deliverables"
|
|
543
|
-
fi
|
|
544
|
-
|
|
545
|
-
if [ -n "$acceptance" ]; then
|
|
546
|
-
context="$context | Acceptance Criteria: $acceptance"
|
|
547
|
-
fi
|
|
548
|
-
|
|
549
|
-
if [ -n "$target_files" ]; then
|
|
550
|
-
context="$context | Target Files: $target_files"
|
|
551
|
-
fi
|
|
552
|
-
|
|
553
|
-
context="$context | Iteration: $iteration"
|
|
554
|
-
|
|
555
|
-
# Check if jq is available before attempting JSON parsing
|
|
556
|
-
if ! command -v jq &>/dev/null; then
|
|
557
|
-
echo "⚠️ Warning: jq not installed. Test context injection will be skipped" >&2
|
|
558
|
-
echo "$context"
|
|
559
|
-
return
|
|
560
|
-
fi
|
|
561
|
-
|
|
562
|
-
# Inject test failure diagnostics from previous iteration
|
|
563
|
-
if [ "$iteration" -gt 1 ]; then
|
|
564
|
-
local iteration_context_file="/tmp/cfn-iteration-context-${task_id}.json"
|
|
565
|
-
|
|
566
|
-
if [ -f "$iteration_context_file" ]; then
|
|
567
|
-
# Extract failed test summary from iteration context
|
|
568
|
-
local failed_summary=""
|
|
569
|
-
failed_summary=$(jq -r '
|
|
570
|
-
if (.pass_rate? != null)
|
|
571
|
-
and .failed_tests
|
|
572
|
-
and (.failed_tests | length > 0)
|
|
573
|
-
then
|
|
574
|
-
"Previous Test Results: Pass Rate " +
|
|
575
|
-
((.pass_rate * 100) | floor | tostring) +
|
|
576
|
-
"% | Failed Tests: " +
|
|
577
|
-
([.failed_tests[].failed_test_names[]? // empty] | join(", "))
|
|
578
|
-
else
|
|
579
|
-
empty
|
|
580
|
-
end
|
|
581
|
-
' "$iteration_context_file" 2>/dev/null || echo "")
|
|
582
|
-
|
|
583
|
-
if [ -n "$failed_summary" ]; then
|
|
584
|
-
context="$context | $failed_summary"
|
|
585
|
-
echo "📊 Injected test diagnostics from previous iteration" >&2
|
|
586
|
-
fi
|
|
587
|
-
fi
|
|
588
|
-
fi
|
|
589
|
-
|
|
590
|
-
if [[ -n "$feedback" ]]; then
|
|
591
|
-
context="$context | Feedback: $feedback"
|
|
592
|
-
fi
|
|
593
|
-
|
|
594
|
-
# Add epic/phase context if available
|
|
595
|
-
if [ -n "$epic_context" ]; then
|
|
596
|
-
context="$context | Epic: $epic_context"
|
|
597
|
-
fi
|
|
598
|
-
|
|
599
|
-
if [ -n "$phase_context" ]; then
|
|
600
|
-
context="$context | Phase: $phase_context"
|
|
601
|
-
fi
|
|
602
|
-
|
|
603
|
-
# Inject CFN Loop context if injection script exists and loop_type provided
|
|
604
|
-
if [[ -n "$loop_type" ]] && [[ -x "$SCRIPT_DIR/inject-loop-context.sh" ]]; then
|
|
605
|
-
context=$("$SCRIPT_DIR/inject-loop-context.sh" "$loop_type" "$context" 2>/dev/null || echo "$context")
|
|
606
|
-
fi
|
|
607
|
-
|
|
608
|
-
echo "$context"
|
|
609
|
-
}
|
|
610
|
-
|
|
611
|
-
function spawn_loop3_agents() {
|
|
612
|
-
local task_id="$1"
|
|
613
|
-
local iteration="$2"
|
|
614
|
-
local agents="$3"
|
|
615
|
-
|
|
616
|
-
echo "[Loop 3] Spawning implementer agents (iteration $iteration)..."
|
|
617
|
-
|
|
618
|
-
# Load success criteria from Redis (if available)
|
|
619
|
-
export AGENT_SUCCESS_CRITERIA=""
|
|
620
|
-
if [[ -n "$task_id" ]] && [[ -x "$SCRIPT_DIR/../cfn-redis-coordination/get-success-criteria.sh" ]]; then
|
|
621
|
-
SUCCESS_CRITERIA=$("$SCRIPT_DIR/../cfn-redis-coordination/get-success-criteria.sh" --task-id "$task_id" 2>/dev/null || echo "")
|
|
622
|
-
|
|
623
|
-
if [[ -n "$SUCCESS_CRITERIA" ]]; then
|
|
624
|
-
# SECURITY FIX: Validate JSON size before parsing (prevent DoS)
|
|
625
|
-
CRITERIA_SIZE=$(echo -n "$SUCCESS_CRITERIA" | wc -c)
|
|
626
|
-
MAX_SIZE=10485760 # 10MB
|
|
627
|
-
|
|
628
|
-
if [[ "$CRITERIA_SIZE" -gt "$MAX_SIZE" ]]; then
|
|
629
|
-
echo " ❌ Success criteria exceeds maximum size (10MB): ${CRITERIA_SIZE} bytes" >&2
|
|
630
|
-
exit 1
|
|
631
|
-
fi
|
|
632
|
-
|
|
633
|
-
# Validate JSON before exporting
|
|
634
|
-
if echo "$SUCCESS_CRITERIA" | jq empty 2>/dev/null; then
|
|
635
|
-
export AGENT_SUCCESS_CRITERIA="$SUCCESS_CRITERIA"
|
|
636
|
-
TEST_SUITE_COUNT=$(echo "$SUCCESS_CRITERIA" | jq -r '.test_suites | length' 2>/dev/null || echo "0")
|
|
637
|
-
echo " ✅ Success criteria loaded ($TEST_SUITE_COUNT test suites)" >&2
|
|
638
|
-
else
|
|
639
|
-
echo " ⚠️ Invalid success criteria JSON - skipping" >&2
|
|
640
|
-
fi
|
|
641
|
-
fi
|
|
642
|
-
fi
|
|
643
|
-
|
|
644
|
-
# Convert comma-separated agents to array
|
|
645
|
-
IFS=',' read -ra AGENT_ARRAY <<< "$agents"
|
|
646
|
-
|
|
647
|
-
# Track agent instance counts for unique ID generation
|
|
648
|
-
declare -A AGENT_INSTANCE_COUNTS
|
|
649
|
-
|
|
650
|
-
# Spawn each agent via CLI
|
|
651
|
-
for agent_type in "${AGENT_ARRAY[@]}"; do
|
|
652
|
-
# Generate unique agent ID (agent-type-iteration-instance)
|
|
653
|
-
AGENT_INSTANCE_COUNTS["$agent_type"]=$((${AGENT_INSTANCE_COUNTS["$agent_type"]:-0} + 1))
|
|
654
|
-
INSTANCE_NUM="${AGENT_INSTANCE_COUNTS["$agent_type"]}"
|
|
655
|
-
UNIQUE_AGENT_ID="${agent_type}-${iteration}-${INSTANCE_NUM}"
|
|
656
|
-
|
|
657
|
-
echo " Spawning: $agent_type (ID: $UNIQUE_AGENT_ID)"
|
|
658
|
-
|
|
659
|
-
# Validate agent input
|
|
660
|
-
local safe_agent_type safe_task_id safe_agent_id
|
|
661
|
-
safe_agent_type=$(sanitize_input "$agent_type") || continue
|
|
662
|
-
safe_task_id=$(sanitize_input "$task_id") || continue
|
|
663
|
-
safe_agent_id=$(sanitize_input "$UNIQUE_AGENT_ID") || continue
|
|
664
|
-
|
|
665
|
-
# Dual-mode agent spawning: Docker or CLI
|
|
666
|
-
# Mode Selection Priority:
|
|
667
|
-
# 1. Explicit CFN_DOCKER_MODE='true'/'false' (highest priority - user override)
|
|
668
|
-
# 2. Automatic Docker socket detection (if CFN_DOCKER_MODE unset)
|
|
669
|
-
# 3. Default CLI mode (fallback if no Docker socket)
|
|
670
|
-
#
|
|
671
|
-
# BUG FIX: Respect CFN_DOCKER_MODE='false' even when Docker socket exists
|
|
672
|
-
SPAWN_MODE="cli" # Default
|
|
673
|
-
SPAWN_REASON=""
|
|
674
|
-
|
|
675
|
-
if [[ "${CFN_DOCKER_MODE:-}" == "true" ]]; then
|
|
676
|
-
SPAWN_MODE="docker"
|
|
677
|
-
SPAWN_REASON="explicit CFN_DOCKER_MODE=true"
|
|
678
|
-
elif [[ "${CFN_DOCKER_MODE:-}" == "false" ]]; then
|
|
679
|
-
SPAWN_MODE="cli"
|
|
680
|
-
SPAWN_REASON="explicit CFN_DOCKER_MODE=false (overrides Docker socket detection)"
|
|
681
|
-
elif [[ -S /var/run/docker.sock ]]; then
|
|
682
|
-
SPAWN_MODE="docker"
|
|
683
|
-
SPAWN_REASON="automatic Docker socket detection"
|
|
684
|
-
else
|
|
685
|
-
SPAWN_MODE="cli"
|
|
686
|
-
SPAWN_REASON="default (no Docker socket)"
|
|
687
|
-
fi
|
|
688
|
-
|
|
689
|
-
if [[ "$SPAWN_MODE" == "docker" ]]; then
|
|
690
|
-
# Docker-based spawning (prevents WebAssembly OOM)
|
|
691
|
-
echo " → Docker mode: ${SPAWN_REASON}" >&2
|
|
692
|
-
|
|
693
|
-
# SECURITY FIX: Sanitize Docker environment variables to prevent command injection
|
|
694
|
-
CFN_DOCKER_IMAGE_SAFE=$(sanitize_input "${CFN_DOCKER_IMAGE:-claude-flow-novice:agent}") || {
|
|
695
|
-
echo "❌ Invalid CFN_DOCKER_IMAGE" >&2
|
|
696
|
-
exit 1
|
|
697
|
-
}
|
|
698
|
-
CFN_DOCKER_NETWORK_SAFE=$(sanitize_input "${CFN_DOCKER_NETWORK:-mcp-network}") || {
|
|
699
|
-
echo "❌ Invalid CFN_DOCKER_NETWORK" >&2
|
|
700
|
-
exit 1
|
|
701
|
-
}
|
|
702
|
-
CFN_MEMORY_LIMIT_SAFE=$(sanitize_input "${CFN_MEMORY_LIMIT:-2g}") || {
|
|
703
|
-
echo "❌ Invalid CFN_MEMORY_LIMIT" >&2
|
|
704
|
-
exit 1
|
|
705
|
-
}
|
|
706
|
-
|
|
707
|
-
# Build Docker command as array (prevents injection, no eval needed)
|
|
708
|
-
DOCKER_CMD=(
|
|
709
|
-
docker run --detach
|
|
710
|
-
--name "agent-${safe_agent_id}"
|
|
711
|
-
--memory "$CFN_MEMORY_LIMIT_SAFE"
|
|
712
|
-
--cpus 1.5
|
|
713
|
-
--network "$CFN_DOCKER_NETWORK_SAFE"
|
|
714
|
-
--env REDIS_URL=redis://redis:6379
|
|
715
|
-
--env "AGENT_ID=${safe_agent_id}"
|
|
716
|
-
--env "AGENT_TYPE=${safe_agent_type}"
|
|
717
|
-
--env "TASK_ID=${safe_task_id}"
|
|
718
|
-
--env "ITERATION=${iteration}"
|
|
719
|
-
)
|
|
720
|
-
|
|
721
|
-
# SECURITY FIX: Base64-encode success criteria to prevent shell injection
|
|
722
|
-
if [[ -n "${AGENT_SUCCESS_CRITERIA:-}" ]]; then
|
|
723
|
-
ENCODED_CRITERIA=$(echo -n "$AGENT_SUCCESS_CRITERIA" | base64 -w 0)
|
|
724
|
-
|
|
725
|
-
# SECURITY FIX: Validate size AFTER encoding to prevent expansion bypass (10MB → 13.9MB)
|
|
726
|
-
ENCODED_SIZE=$(echo -n "$ENCODED_CRITERIA" | wc -c)
|
|
727
|
-
MAX_ENCODED_SIZE=10485760 # 10MB
|
|
728
|
-
|
|
729
|
-
if [[ "$ENCODED_SIZE" -gt "$MAX_ENCODED_SIZE" ]]; then
|
|
730
|
-
echo "❌ Encoded success criteria exceeds 10MB limit: ${ENCODED_SIZE} bytes" >&2
|
|
731
|
-
echo " (Original: $(echo -n "$AGENT_SUCCESS_CRITERIA" | wc -c) bytes, Expanded: +33% via base64)" >&2
|
|
732
|
-
exit 1
|
|
733
|
-
fi
|
|
734
|
-
|
|
735
|
-
DOCKER_CMD+=(--env "AGENT_SUCCESS_CRITERIA_B64=${ENCODED_CRITERIA}")
|
|
736
|
-
fi
|
|
737
|
-
|
|
738
|
-
# Add volumes and image
|
|
739
|
-
DOCKER_CMD+=(
|
|
740
|
-
--volume "${PROJECT_ROOT}/.claude:/app/.claude:ro"
|
|
741
|
-
--volume "${PROJECT_ROOT}/packages:/app/packages"
|
|
742
|
-
--volume "/tmp/agent-workspace-${safe_agent_id}:/app/workspace"
|
|
743
|
-
"$CFN_DOCKER_IMAGE_SAFE"
|
|
744
|
-
sh -c "npx claude-flow-novice agent \"${safe_agent_type}\" --task-id \"${safe_task_id}\" --agent-id \"${safe_agent_id}\" --iteration \"${iteration}\""
|
|
745
|
-
)
|
|
746
|
-
|
|
747
|
-
# Execute safely without eval (prevents command injection)
|
|
748
|
-
"${DOCKER_CMD[@]}" >/dev/null 2>&1 &
|
|
749
|
-
|
|
750
|
-
AGENT_PID=$!
|
|
751
|
-
else
|
|
752
|
-
# CLI-based spawning (traditional approach)
|
|
753
|
-
echo " → CLI mode: ${SPAWN_REASON}" >&2
|
|
754
|
-
|
|
755
|
-
if command -v execute_instrumented >/dev/null 2>&1; then
|
|
756
|
-
execute_instrumented "npx" "$CFN_VALIDATION_TIMEOUT" "$CFN_MEMORY_LIMIT" \
|
|
757
|
-
claude-flow-novice agent "$safe_agent_type" \
|
|
758
|
-
--task-id "$safe_task_id" \
|
|
759
|
-
--agent-id "$safe_agent_id" \
|
|
760
|
-
--iteration "$iteration" \
|
|
761
|
-
--context "$(build_agent_context "$safe_task_id" "$iteration" "$safe_agent_type" "" "loop3")" &
|
|
762
|
-
else
|
|
763
|
-
# Fallback to raw spawn if instrumentation unavailable
|
|
764
|
-
npx claude-flow-novice agent "$safe_agent_type" \
|
|
765
|
-
--task-id "$safe_task_id" \
|
|
766
|
-
--agent-id "$safe_agent_id" \
|
|
767
|
-
--iteration "$iteration" \
|
|
768
|
-
--context "$(build_agent_context "$safe_task_id" "$iteration" "$safe_agent_type" "" "loop3")" &
|
|
769
|
-
fi
|
|
770
|
-
|
|
771
|
-
AGENT_PID=$!
|
|
772
|
-
fi
|
|
773
|
-
|
|
774
|
-
# Store PID for monitoring using unique agent ID
|
|
775
|
-
"$REDIS_COORD_SKILL/store-context.sh" \
|
|
776
|
-
--task-id "$task_id" \
|
|
777
|
-
--key "${UNIQUE_AGENT_ID}:pid" \
|
|
778
|
-
--value "{\"pid\": $AGENT_PID}" \
|
|
779
|
-
--namespace "swarm" >/dev/null
|
|
780
|
-
|
|
781
|
-
# ⚠️ ANTI-023 MEMORY LEAK PROTECTION: Start telemetry monitoring
|
|
782
|
-
if [[ -f "$PROJECT_ROOT/.claude/skills/cfn-telemetry/collect-metrics.sh" ]]; then
|
|
783
|
-
MONITOR_PID=$("$PROJECT_ROOT/.claude/skills/cfn-telemetry/collect-metrics.sh" start-monitoring "$UNIQUE_AGENT_ID" "$AGENT_PID" "$iteration" "$safe_agent_type")
|
|
784
|
-
"$REDIS_COORD_SKILL/store-context.sh" \
|
|
785
|
-
--task-id "$task_id" \
|
|
786
|
-
--key "${UNIQUE_AGENT_ID}:monitor_pid" \
|
|
787
|
-
--value "{\"pid\": $MONITOR_PID}" \
|
|
788
|
-
--namespace "swarm" >/dev/null
|
|
789
|
-
echo "🔍 Started monitoring for $UNIQUE_AGENT_ID (Agent PID: $AGENT_PID, Monitor PID: $MONITOR_PID)" >&2
|
|
790
|
-
fi
|
|
791
|
-
|
|
792
|
-
# SECURITY FIX: Atomic SADD + EXPIRE using Lua script (prevent race condition)
|
|
793
|
-
redis-cli -h "${REDIS_HOST:-localhost}" -p "${REDIS_PORT:-6379}" --eval - \
|
|
794
|
-
"swarm:${task_id}:loop3:agent_ids:iteration${iteration}" "$UNIQUE_AGENT_ID" <<'LUA' >/dev/null
|
|
795
|
-
redis.call('SADD', KEYS[1], ARGV[1])
|
|
796
|
-
redis.call('EXPIRE', KEYS[1], 86400)
|
|
797
|
-
return redis.call('SCARD', KEYS[1])
|
|
798
|
-
LUA
|
|
799
|
-
done
|
|
800
|
-
|
|
801
|
-
echo "[Loop 3] All agents spawned"
|
|
802
|
-
echo ""
|
|
803
|
-
}
|
|
804
|
-
|
|
805
|
-
function wait_for_agents() {
|
|
806
|
-
local task_id="$1"
|
|
807
|
-
local agents="$2"
|
|
808
|
-
local timeout="$3"
|
|
809
|
-
local iteration="${4:-1}"
|
|
810
|
-
|
|
811
|
-
echo "Waiting for agents to complete (timeout: ${timeout}s)..."
|
|
812
|
-
|
|
813
|
-
# Retrieve actual agent IDs from Redis (stored during spawn using SADD)
|
|
814
|
-
local stored_ids
|
|
815
|
-
stored_ids=$(redis-cli -h "${REDIS_HOST:-localhost}" -p "${REDIS_PORT:-6379}" SMEMBERS "swarm:${task_id}:loop3:agent_ids:iteration${iteration}" 2>/dev/null | tr '\n' ',' | sed 's/,$//')
|
|
816
|
-
|
|
817
|
-
# If stored IDs exist, use them; otherwise fallback to generating from agent types
|
|
818
|
-
local -a AGENT_IDS
|
|
819
|
-
if [ -n "$stored_ids" ]; then
|
|
820
|
-
IFS=',' read -ra AGENT_IDS <<< "$stored_ids"
|
|
821
|
-
echo " Retrieved ${#AGENT_IDS[@]} agent IDs from Redis"
|
|
822
|
-
else
|
|
823
|
-
# Fallback: Convert agent types to IDs (legacy compatibility)
|
|
824
|
-
echo " Warning: No stored agent IDs, using agent types as fallback"
|
|
825
|
-
IFS=',' read -ra AGENT_TYPES <<< "$agents"
|
|
826
|
-
|
|
827
|
-
# Track instance counts to match spawn behavior
|
|
828
|
-
declare -A AGENT_INSTANCE_COUNTS
|
|
829
|
-
for agent_type in "${AGENT_TYPES[@]}"; do
|
|
830
|
-
AGENT_INSTANCE_COUNTS["$agent_type"]=$((${AGENT_INSTANCE_COUNTS["$agent_type"]:-0} + 1))
|
|
831
|
-
INSTANCE_NUM="${AGENT_INSTANCE_COUNTS["$agent_type"]}"
|
|
832
|
-
AGENT_IDS+=("${agent_type}-${iteration}-${INSTANCE_NUM}")
|
|
833
|
-
done
|
|
834
|
-
fi
|
|
835
|
-
|
|
836
|
-
# Parallel BLPOP implementation with shared timeout
|
|
837
|
-
# Track start time for global timeout calculation
|
|
838
|
-
local start_time=$(date +%s)
|
|
839
|
-
|
|
840
|
-
# Spawn parallel BLPOP processes for each agent
|
|
841
|
-
local pids=()
|
|
842
|
-
local temp_files=()
|
|
843
|
-
|
|
844
|
-
for unique_agent_id in "${AGENT_IDS[@]}"; do
|
|
845
|
-
# Create temporary file for this agent's result
|
|
846
|
-
local temp_file="/tmp/cfn-wait-${task_id}-${unique_agent_id}-$$.tmp"
|
|
847
|
-
temp_files+=("$temp_file")
|
|
848
|
-
|
|
849
|
-
echo " Waiting for: $unique_agent_id"
|
|
850
|
-
|
|
851
|
-
# Spawn BLPOP in background, write result to temp file
|
|
852
|
-
(
|
|
853
|
-
local result
|
|
854
|
-
if redis-cli -h "${REDIS_HOST:-localhost}" -p "${REDIS_PORT:-6379}" blpop "swarm:${task_id}:${unique_agent_id}:done" "$timeout" >/dev/null 2>&1; then
|
|
855
|
-
echo "success" > "$temp_file"
|
|
856
|
-
else
|
|
857
|
-
echo "timeout" > "$temp_file"
|
|
858
|
-
fi
|
|
859
|
-
exit 0
|
|
860
|
-
) &
|
|
861
|
-
|
|
862
|
-
pids+=($!)
|
|
863
|
-
done
|
|
864
|
-
|
|
865
|
-
# Wait for all parallel BLPOP processes to complete
|
|
866
|
-
# This ensures timeout is global (60s total), not per-agent (60s * N)
|
|
867
|
-
for pid in "${pids[@]}"; do
|
|
868
|
-
wait "$pid" 2>/dev/null || true
|
|
869
|
-
done
|
|
870
|
-
|
|
871
|
-
# ⚠️ ANTI-023 MEMORY LEAK PROTECTION: Stop monitoring for all agents
|
|
872
|
-
echo " Stopping telemetry monitoring for Loop 3 agents..." >&2
|
|
873
|
-
for unique_agent_id in "${AGENT_IDS[@]}"; do
|
|
874
|
-
local monitor_pid=$("$REDIS_COORD_SKILL/get-context.sh" --task-id "$task_id" --key "${unique_agent_id}:monitor_pid" --namespace "swarm" 2>/dev/null | jq -r '.pid // 0' || echo "0")
|
|
875
|
-
if [[ "$monitor_pid" -gt 0 ]] && kill -0 "$monitor_pid" 2>/dev/null; then
|
|
876
|
-
"$PROJECT_ROOT/.claude/skills/cfn-telemetry/collect-metrics.sh" stop-monitoring "$monitor_pid" >/dev/null 2>&1 || true
|
|
877
|
-
echo " Stopped monitoring for $unique_agent_id (Monitor PID: $monitor_pid)" >&2
|
|
878
|
-
fi
|
|
879
|
-
done
|
|
880
|
-
|
|
881
|
-
# Calculate actual elapsed time
|
|
882
|
-
local end_time=$(date +%s)
|
|
883
|
-
local elapsed=$((end_time - start_time))
|
|
884
|
-
|
|
885
|
-
# Check results and report status
|
|
886
|
-
local completed=0
|
|
887
|
-
local timed_out=0
|
|
888
|
-
|
|
889
|
-
for i in "${!AGENT_IDS[@]}"; do
|
|
890
|
-
local unique_agent_id="${AGENT_IDS[$i]}"
|
|
891
|
-
local temp_file="${temp_files[$i]}"
|
|
892
|
-
|
|
893
|
-
if [ -f "$temp_file" ]; then
|
|
894
|
-
local result=$(cat "$temp_file")
|
|
895
|
-
if [ "$result" = "success" ]; then
|
|
896
|
-
((completed++))
|
|
897
|
-
echo " ✅ $unique_agent_id completed"
|
|
898
|
-
else
|
|
899
|
-
((timed_out++))
|
|
900
|
-
echo " ⚠️ $unique_agent_id did not complete within timeout"
|
|
901
|
-
fi
|
|
902
|
-
rm -f "$temp_file"
|
|
903
|
-
else
|
|
904
|
-
((timed_out++))
|
|
905
|
-
echo " ❌ $unique_agent_id result file missing"
|
|
906
|
-
fi
|
|
907
|
-
done
|
|
908
|
-
|
|
909
|
-
echo "Agents completed: $completed/${#AGENT_IDS[@]} (elapsed: ${elapsed}s)"
|
|
910
|
-
echo ""
|
|
911
|
-
}
|
|
912
|
-
|
|
913
|
-
function wait_for_loop2_agents() {
|
|
914
|
-
local task_id="$1"
|
|
915
|
-
local agents="$2"
|
|
916
|
-
local timeout="$3"
|
|
917
|
-
local iteration="${4:-1}"
|
|
918
|
-
|
|
919
|
-
echo "Waiting for Loop 2 validators to complete (timeout: ${timeout}s)..."
|
|
920
|
-
|
|
921
|
-
# Retrieve actual agent IDs from Redis (stored during spawn using SADD)
|
|
922
|
-
local stored_ids
|
|
923
|
-
stored_ids=$(redis-cli -h "${REDIS_HOST:-localhost}" -p "${REDIS_PORT:-6379}" SMEMBERS "swarm:${task_id}:loop2:agent_ids:iteration${iteration}" 2>/dev/null | tr '\n' ',' | sed 's/,$//')
|
|
924
|
-
|
|
925
|
-
# If stored IDs exist, use them; otherwise fallback to generating from agent types
|
|
926
|
-
local -a VALIDATOR_IDS
|
|
927
|
-
if [ -n "$stored_ids" ]; then
|
|
928
|
-
IFS=',' read -ra VALIDATOR_IDS <<< "$stored_ids"
|
|
929
|
-
echo " Retrieved ${#VALIDATOR_IDS[@]} validator IDs from Redis"
|
|
930
|
-
else
|
|
931
|
-
# Fallback: Convert agent types to IDs (legacy compatibility)
|
|
932
|
-
echo " Warning: No stored validator IDs, using agent types as fallback"
|
|
933
|
-
IFS=',' read -ra AGENT_TYPES <<< "$agents"
|
|
934
|
-
|
|
935
|
-
# Track instance counts to match spawn behavior
|
|
936
|
-
declare -A AGENT_INSTANCE_COUNTS
|
|
937
|
-
for agent_type in "${AGENT_TYPES[@]}"; do
|
|
938
|
-
AGENT_INSTANCE_COUNTS["$agent_type"]=$((${AGENT_INSTANCE_COUNTS["$agent_type"]:-0} + 1))
|
|
939
|
-
INSTANCE_NUM="${AGENT_INSTANCE_COUNTS["$agent_type"]}"
|
|
940
|
-
VALIDATOR_IDS+=("${agent_type}-${iteration}-${INSTANCE_NUM}")
|
|
941
|
-
done
|
|
942
|
-
fi
|
|
943
|
-
|
|
944
|
-
# Parallel BLPOP implementation
|
|
945
|
-
local start_time=$(date +%s)
|
|
946
|
-
local pids=()
|
|
947
|
-
local temp_files=()
|
|
948
|
-
|
|
949
|
-
for unique_validator_id in "${VALIDATOR_IDS[@]}"; do
|
|
950
|
-
local temp_file="/tmp/cfn-wait-${task_id}-${unique_validator_id}-$$.tmp"
|
|
951
|
-
temp_files+=("$temp_file")
|
|
952
|
-
|
|
953
|
-
echo " Waiting for: $unique_validator_id"
|
|
954
|
-
|
|
955
|
-
# Spawn BLPOP in background
|
|
956
|
-
(
|
|
957
|
-
if redis-cli -h "${REDIS_HOST:-localhost}" -p "${REDIS_PORT:-6379}" blpop "swarm:${task_id}:${unique_validator_id}:done" "$timeout" >/dev/null 2>&1; then
|
|
958
|
-
echo "success" > "$temp_file"
|
|
959
|
-
else
|
|
960
|
-
echo "timeout" > "$temp_file"
|
|
961
|
-
fi
|
|
962
|
-
exit 0
|
|
963
|
-
) &
|
|
964
|
-
|
|
965
|
-
pids+=($!)
|
|
966
|
-
done
|
|
967
|
-
|
|
968
|
-
# Wait for all processes
|
|
969
|
-
for pid in "${pids[@]}"; do
|
|
970
|
-
wait "$pid" 2>/dev/null || true
|
|
971
|
-
done
|
|
972
|
-
|
|
973
|
-
# Check results
|
|
974
|
-
local end_time=$(date +%s)
|
|
975
|
-
local elapsed=$((end_time - start_time))
|
|
976
|
-
local completed=0
|
|
977
|
-
local timed_out=0
|
|
978
|
-
|
|
979
|
-
for i in "${!VALIDATOR_IDS[@]}"; do
|
|
980
|
-
local unique_validator_id="${VALIDATOR_IDS[$i]}"
|
|
981
|
-
local temp_file="${temp_files[$i]}"
|
|
982
|
-
|
|
983
|
-
if [ -f "$temp_file" ]; then
|
|
984
|
-
local result=$(cat "$temp_file")
|
|
985
|
-
if [ "$result" = "success" ]; then
|
|
986
|
-
((completed++))
|
|
987
|
-
echo " ✅ $unique_validator_id completed"
|
|
988
|
-
else
|
|
989
|
-
((timed_out++))
|
|
990
|
-
echo " ⚠️ $unique_validator_id did not complete within timeout"
|
|
991
|
-
fi
|
|
992
|
-
rm -f "$temp_file"
|
|
993
|
-
else
|
|
994
|
-
((timed_out++))
|
|
995
|
-
echo " ❌ $unique_validator_id result file missing"
|
|
996
|
-
fi
|
|
997
|
-
done
|
|
998
|
-
|
|
999
|
-
echo "Validators completed: $completed/${#VALIDATOR_IDS[@]} (elapsed: ${elapsed}s)"
|
|
1000
|
-
echo ""
|
|
1001
|
-
}
|
|
1002
|
-
|
|
1003
|
-
function spawn_loop2_agents() {
|
|
1004
|
-
local task_id="$1"
|
|
1005
|
-
local iteration="$2"
|
|
1006
|
-
local agents="$3"
|
|
1007
|
-
|
|
1008
|
-
echo "[Loop 2] Spawning validator agents (iteration $iteration)..."
|
|
1009
|
-
|
|
1010
|
-
# Load success criteria from Redis (if available)
|
|
1011
|
-
export AGENT_SUCCESS_CRITERIA=""
|
|
1012
|
-
if [[ -n "$task_id" ]] && [[ -x "$SCRIPT_DIR/../cfn-redis-coordination/get-success-criteria.sh" ]]; then
|
|
1013
|
-
SUCCESS_CRITERIA=$("$SCRIPT_DIR/../cfn-redis-coordination/get-success-criteria.sh" --task-id "$task_id" 2>/dev/null || echo "")
|
|
1014
|
-
|
|
1015
|
-
if [[ -n "$SUCCESS_CRITERIA" ]]; then
|
|
1016
|
-
# SECURITY FIX: Validate JSON size before parsing (prevent DoS)
|
|
1017
|
-
CRITERIA_SIZE=$(echo -n "$SUCCESS_CRITERIA" | wc -c)
|
|
1018
|
-
MAX_SIZE=10485760 # 10MB
|
|
1019
|
-
|
|
1020
|
-
if [[ "$CRITERIA_SIZE" -gt "$MAX_SIZE" ]]; then
|
|
1021
|
-
echo " ❌ Success criteria exceeds maximum size (10MB): ${CRITERIA_SIZE} bytes" >&2
|
|
1022
|
-
exit 1
|
|
1023
|
-
fi
|
|
1024
|
-
|
|
1025
|
-
# Validate JSON before exporting
|
|
1026
|
-
if echo "$SUCCESS_CRITERIA" | jq empty 2>/dev/null; then
|
|
1027
|
-
export AGENT_SUCCESS_CRITERIA="$SUCCESS_CRITERIA"
|
|
1028
|
-
TEST_SUITE_COUNT=$(echo "$SUCCESS_CRITERIA" | jq -r '.test_suites | length' 2>/dev/null || echo "0")
|
|
1029
|
-
echo " ✅ Success criteria loaded ($TEST_SUITE_COUNT test suites)" >&2
|
|
1030
|
-
else
|
|
1031
|
-
echo " ⚠️ Invalid success criteria JSON - skipping" >&2
|
|
1032
|
-
fi
|
|
1033
|
-
fi
|
|
1034
|
-
fi
|
|
1035
|
-
|
|
1036
|
-
# Convert comma-separated agents to array
|
|
1037
|
-
IFS=',' read -ra AGENT_ARRAY <<< "$agents"
|
|
1038
|
-
|
|
1039
|
-
# Track agent instance counts for unique ID generation
|
|
1040
|
-
declare -A AGENT_INSTANCE_COUNTS
|
|
1041
|
-
|
|
1042
|
-
# Spawn each agent via CLI
|
|
1043
|
-
for agent_type in "${AGENT_ARRAY[@]}"; do
|
|
1044
|
-
# Generate unique agent ID (agent-type-iteration-instance)
|
|
1045
|
-
AGENT_INSTANCE_COUNTS["$agent_type"]=$((${AGENT_INSTANCE_COUNTS["$agent_type"]:-0} + 1))
|
|
1046
|
-
INSTANCE_NUM="${AGENT_INSTANCE_COUNTS["$agent_type"]}"
|
|
1047
|
-
UNIQUE_VALIDATOR_ID="${agent_type}-${iteration}-${INSTANCE_NUM}"
|
|
1048
|
-
|
|
1049
|
-
echo " Spawning: $agent_type (ID: $UNIQUE_VALIDATOR_ID)"
|
|
1050
|
-
|
|
1051
|
-
# Spawn validator in background with process instrumentation and memory limits
|
|
1052
|
-
if command -v execute_instrumented >/dev/null 2>&1; then
|
|
1053
|
-
execute_instrumented "npx" "$CFN_VALIDATION_TIMEOUT" "$CFN_MEMORY_LIMIT" \
|
|
1054
|
-
claude-flow-novice agent "$agent_type" \
|
|
1055
|
-
--task-id "$task_id" \
|
|
1056
|
-
--agent-id "$UNIQUE_VALIDATOR_ID" \
|
|
1057
|
-
--iteration "$iteration" \
|
|
1058
|
-
--context "$(build_agent_context "$task_id" "$iteration" "$agent_type" "" "loop2")" &
|
|
1059
|
-
else
|
|
1060
|
-
# Fallback to raw spawn if instrumentation unavailable
|
|
1061
|
-
npx claude-flow-novice agent "$agent_type" \
|
|
1062
|
-
--task-id "$task_id" \
|
|
1063
|
-
--agent-id "$UNIQUE_VALIDATOR_ID" \
|
|
1064
|
-
--iteration "$iteration" \
|
|
1065
|
-
--context "$(build_agent_context "$task_id" "$iteration" "$agent_type" "" "loop2")" &
|
|
1066
|
-
fi
|
|
1067
|
-
|
|
1068
|
-
# Store PID for monitoring using unique agent ID
|
|
1069
|
-
AGENT_PID=$!
|
|
1070
|
-
"$REDIS_COORD_SKILL/store-context.sh" \
|
|
1071
|
-
--task-id "$task_id" \
|
|
1072
|
-
--key "${UNIQUE_VALIDATOR_ID}:pid" \
|
|
1073
|
-
--value "{\"pid\": $AGENT_PID}" \
|
|
1074
|
-
--namespace "swarm" >/dev/null
|
|
1075
|
-
|
|
1076
|
-
# Store agent ID mapping for later retrieval using Redis SADD for set storage
|
|
1077
|
-
# SECURITY FIX: Atomic SADD + EXPIRE using Lua script (prevent race condition)
|
|
1078
|
-
redis-cli -h "${REDIS_HOST:-localhost}" -p "${REDIS_PORT:-6379}" --eval - \
|
|
1079
|
-
"swarm:${task_id}:loop2:agent_ids:iteration${iteration}" "$UNIQUE_VALIDATOR_ID" <<'LUA' >/dev/null
|
|
1080
|
-
redis.call('SADD', KEYS[1], ARGV[1])
|
|
1081
|
-
redis.call('EXPIRE', KEYS[1], 86400)
|
|
1082
|
-
return redis.call('SCARD', KEYS[1])
|
|
1083
|
-
LUA
|
|
1084
|
-
done
|
|
1085
|
-
|
|
1086
|
-
echo "[Loop 2] All agents spawned"
|
|
1087
|
-
echo ""
|
|
1088
|
-
}
|
|
1089
|
-
|
|
1090
|
-
function spawn_product_owner() {
|
|
1091
|
-
local task_id="$1"
|
|
1092
|
-
local iteration="$2"
|
|
1093
|
-
|
|
1094
|
-
echo "[Product Owner] Spawning decision agent..."
|
|
1095
|
-
|
|
1096
|
-
# BLOCKER #2 FIX: Match execute-decision.sh actual parameters
|
|
1097
|
-
# Required: --task-id, --agent-id, --consensus, --threshold, --iteration, --max-iterations
|
|
1098
|
-
local decision_output
|
|
1099
|
-
decision_output=$("$PROJECT_ROOT/.claude/skills/cfn-product-owner-decision/execute-decision.sh" \
|
|
1100
|
-
--task-id "$task_id" \
|
|
1101
|
-
--agent-id "$PRODUCT_OWNER" \
|
|
1102
|
-
--consensus "$LOOP2_FINAL_CONSENSUS" \
|
|
1103
|
-
--threshold "$CONSENSUS" \
|
|
1104
|
-
--iteration "$iteration" \
|
|
1105
|
-
--max-iterations "$MAX_ITERATIONS")
|
|
1106
|
-
|
|
1107
|
-
# Parse decision from output
|
|
1108
|
-
if echo "$decision_output" | grep -q "PROCEED"; then
|
|
1109
|
-
FINAL_DECISION="PROCEED"
|
|
1110
|
-
elif echo "$decision_output" | grep -q "ITERATE"; then
|
|
1111
|
-
FINAL_DECISION="ITERATE"
|
|
1112
|
-
elif echo "$decision_output" | grep -q "ABORT"; then
|
|
1113
|
-
FINAL_DECISION="ABORT"
|
|
1114
|
-
else
|
|
1115
|
-
echo "Warning: Could not parse Product Owner decision, defaulting to ITERATE"
|
|
1116
|
-
FINAL_DECISION="ITERATE"
|
|
1117
|
-
fi
|
|
1118
|
-
|
|
1119
|
-
echo "[Product Owner] Decision: $FINAL_DECISION"
|
|
1120
|
-
echo ""
|
|
1121
|
-
}
|
|
1122
|
-
|
|
1123
|
-
function output_result() {
|
|
1124
|
-
local status="$1"
|
|
1125
|
-
local end_time=$(date +%s)
|
|
1126
|
-
local execution_time=$((end_time - START_TIME))
|
|
1127
|
-
|
|
1128
|
-
echo "=============================================="
|
|
1129
|
-
echo "CFN Loop Execution Complete"
|
|
1130
|
-
echo "=============================================="
|
|
1131
|
-
echo "Status: $status"
|
|
1132
|
-
echo "Iterations: $ITERATIONS_COMPLETED"
|
|
1133
|
-
echo "Final Decision: $FINAL_DECISION"
|
|
1134
|
-
echo "Loop 3 Confidence: $LOOP3_FINAL_CONFIDENCE"
|
|
1135
|
-
echo "Loop 2 Consensus: $LOOP2_FINAL_CONSENSUS"
|
|
1136
|
-
echo "Deliverables Verified: $DELIVERABLES_VERIFIED"
|
|
1137
|
-
echo "Execution Time: ${execution_time}s"
|
|
1138
|
-
echo "=============================================="
|
|
1139
|
-
|
|
1140
|
-
# Output structured JSON result
|
|
1141
|
-
cat <<EOF
|
|
1142
|
-
{
|
|
1143
|
-
"status": "$status",
|
|
1144
|
-
"iterations_completed": $ITERATIONS_COMPLETED,
|
|
1145
|
-
"final_decision": "$FINAL_DECISION",
|
|
1146
|
-
"loop3_confidence": $LOOP3_FINAL_CONFIDENCE,
|
|
1147
|
-
"loop2_consensus": $LOOP2_FINAL_CONSENSUS,
|
|
1148
|
-
"deliverables_verified": $DELIVERABLES_VERIFIED,
|
|
1149
|
-
"execution_time_seconds": $execution_time
|
|
1150
|
-
}
|
|
1151
|
-
EOF
|
|
1152
|
-
}
|
|
1153
|
-
|
|
1154
|
-
##############################################################################
|
|
1155
|
-
# Main CFN Loop
|
|
1156
|
-
##############################################################################
|
|
1157
|
-
|
|
1158
|
-
# Store context in Redis
|
|
1159
|
-
store_context "$TASK_ID"
|
|
1160
|
-
|
|
1161
|
-
# Iteration loop
|
|
1162
|
-
for ((ITERATION=1; ITERATION<=MAX_ITERATIONS; ITERATION++)); do
|
|
1163
|
-
echo ""
|
|
1164
|
-
echo "=========================================="
|
|
1165
|
-
echo "Iteration $ITERATION / $MAX_ITERATIONS"
|
|
1166
|
-
echo "=========================================="
|
|
1167
|
-
echo ""
|
|
1168
|
-
|
|
1169
|
-
ITERATIONS_COMPLETED=$ITERATION
|
|
1170
|
-
|
|
1171
|
-
# Step 1: Spawn Loop 3 agents (implementers)
|
|
1172
|
-
spawn_loop3_agents "$TASK_ID" "$ITERATION" "$LOOP3_AGENTS"
|
|
1173
|
-
|
|
1174
|
-
# Step 2: Wait for Loop 3 completion
|
|
1175
|
-
wait_for_agents "$TASK_ID" "$LOOP3_AGENTS" "$TIMEOUT" "$ITERATION"
|
|
1176
|
-
|
|
1177
|
-
# Step 3: Verify deliverables (prevent "consensus on vapor")
|
|
1178
|
-
if [ -n "$EXPECTED_FILES" ] || [ -n "$EPIC_CONTEXT" ]; then
|
|
1179
|
-
# Extract task type from epic context for keyword detection
|
|
1180
|
-
TASK_TYPE=""
|
|
1181
|
-
if [ -n "$EPIC_CONTEXT" ]; then
|
|
1182
|
-
TASK_TYPE=$(echo "$EPIC_CONTEXT" | jq -r '.epicGoal // ""' 2>/dev/null || echo "")
|
|
1183
|
-
fi
|
|
1184
|
-
|
|
1185
|
-
if "$HELPERS_DIR/deliverable-verifier.sh" \
|
|
1186
|
-
--expected-files "${EXPECTED_FILES:-}" \
|
|
1187
|
-
--task-type "${TASK_TYPE:-}"; then
|
|
1188
|
-
DELIVERABLES_VERIFIED=true
|
|
1189
|
-
else
|
|
1190
|
-
echo "❌ Deliverable verification failed - forcing Loop 3 iteration"
|
|
1191
|
-
# Use iteration manager to wake Loop 3 agents with explicit feedback
|
|
1192
|
-
"$HELPERS_DIR/iteration-manager.sh" \
|
|
1193
|
-
--task-id "$TASK_ID" \
|
|
1194
|
-
--iteration "$((ITERATION + 1))" \
|
|
1195
|
-
--agents "$LOOP3_AGENTS" \
|
|
1196
|
-
--feedback-source "swarm:${TASK_ID}:feedback"
|
|
1197
|
-
continue
|
|
1198
|
-
fi
|
|
1199
|
-
fi
|
|
1200
|
-
|
|
1201
|
-
# Step 4: Gate check (Loop 3 self-validation)
|
|
1202
|
-
# Retrieve actual Loop 3 agent IDs for validation
|
|
1203
|
-
LOOP3_IDS=$(redis-cli -h "${REDIS_HOST:-localhost}" -p "${REDIS_PORT:-6379}" SMEMBERS "swarm:${TASK_ID}:loop3:agent_ids:iteration${ITERATION}" 2>/dev/null | tr '\n' ',' | sed 's/,$//')
|
|
1204
|
-
|
|
1205
|
-
if [ -z "$LOOP3_IDS" ]; then
|
|
1206
|
-
echo "⚠️ WARNING: No Loop 3 agent IDs found in Redis, using agent types as fallback"
|
|
1207
|
-
LOOP3_IDS="$LOOP3_AGENTS"
|
|
1208
|
-
fi
|
|
1209
|
-
|
|
1210
|
-
if "$HELPERS_DIR/gate-check.sh" \
|
|
1211
|
-
--task-id "$TASK_ID" \
|
|
1212
|
-
--agents "$LOOP3_IDS" \
|
|
1213
|
-
--threshold "$GATE" \
|
|
1214
|
-
--min-quorum "$MIN_QUORUM_LOOP3"; then
|
|
1215
|
-
# Gate passed - store confidence
|
|
1216
|
-
LOOP3_FINAL_CONFIDENCE=$("$REDIS_COORD_SKILL/invoke-waiting-mode.sh" collect \
|
|
1217
|
-
--task-id "$TASK_ID" \
|
|
1218
|
-
--agent-ids "$LOOP3_IDS" \
|
|
1219
|
-
--min-quorum "$MIN_QUORUM_LOOP3")
|
|
1220
|
-
else
|
|
1221
|
-
# Gate failed - iterate Loop 3
|
|
1222
|
-
echo "❌ Gate check failed - iterating Loop 3"
|
|
1223
|
-
"$HELPERS_DIR/iteration-manager.sh" \
|
|
1224
|
-
--task-id "$TASK_ID" \
|
|
1225
|
-
--iteration "$((ITERATION + 1))" \
|
|
1226
|
-
--agents "$LOOP3_AGENTS" \
|
|
1227
|
-
--feedback-source "swarm:${TASK_ID}:feedback"
|
|
1228
|
-
continue
|
|
1229
|
-
fi
|
|
1230
|
-
|
|
1231
|
-
# Step 5: Spawn Loop 2 agents (validators)
|
|
1232
|
-
spawn_loop2_agents "$TASK_ID" "$ITERATION" "$LOOP2_AGENTS"
|
|
1233
|
-
|
|
1234
|
-
# Step 6: Wait for Loop 2 completion
|
|
1235
|
-
wait_for_loop2_agents "$TASK_ID" "$LOOP2_AGENTS" "$TIMEOUT" "$ITERATION"
|
|
1236
|
-
|
|
1237
|
-
# Step 7: Consensus check (Loop 2 validation)
|
|
1238
|
-
# Retrieve actual Loop 2 agent IDs for validation
|
|
1239
|
-
LOOP2_IDS=$(redis-cli -h "${REDIS_HOST:-localhost}" -p "${REDIS_PORT:-6379}" SMEMBERS "swarm:${TASK_ID}:loop2:agent_ids:iteration${ITERATION}" 2>/dev/null | tr '\n' ',' | sed 's/,$//')
|
|
1240
|
-
|
|
1241
|
-
if [ -z "$LOOP2_IDS" ]; then
|
|
1242
|
-
echo "⚠️ WARNING: No Loop 2 agent IDs found in Redis, using agent types as fallback"
|
|
1243
|
-
LOOP2_IDS="$LOOP2_AGENTS"
|
|
1244
|
-
fi
|
|
1245
|
-
|
|
1246
|
-
if "$HELPERS_DIR/consensus.sh" \
|
|
1247
|
-
--task-id "$TASK_ID" \
|
|
1248
|
-
--agents "$LOOP2_IDS" \
|
|
1249
|
-
--threshold "$CONSENSUS" \
|
|
1250
|
-
--min-quorum "$MIN_QUORUM_LOOP2"; then
|
|
1251
|
-
# Consensus reached - store score
|
|
1252
|
-
LOOP2_FINAL_CONSENSUS=$("$REDIS_COORD_SKILL/invoke-waiting-mode.sh" collect \
|
|
1253
|
-
--task-id "$TASK_ID" \
|
|
1254
|
-
--agent-ids "$LOOP2_IDS" \
|
|
1255
|
-
--min-quorum "$MIN_QUORUM_LOOP2")
|
|
1256
|
-
else
|
|
1257
|
-
# Consensus failed - iterate all agents
|
|
1258
|
-
echo "❌ Consensus check failed - iterating all agents"
|
|
1259
|
-
"$HELPERS_DIR/iteration-manager.sh" \
|
|
1260
|
-
--task-id "$TASK_ID" \
|
|
1261
|
-
--iteration "$((ITERATION + 1))" \
|
|
1262
|
-
--agents "$LOOP3_AGENTS,$LOOP2_AGENTS" \
|
|
1263
|
-
--feedback-source "swarm:${TASK_ID}:feedback"
|
|
1264
|
-
continue
|
|
1265
|
-
fi
|
|
1266
|
-
|
|
1267
|
-
# Step 8: Product Owner Decision
|
|
1268
|
-
spawn_product_owner "$TASK_ID" "$ITERATION"
|
|
1269
|
-
|
|
1270
|
-
# Step 9: Execute decision
|
|
1271
|
-
case "$FINAL_DECISION" in
|
|
1272
|
-
PROCEED)
|
|
1273
|
-
# Launch ACE reflection in background (Loop 5)
|
|
1274
|
-
echo "[Loop 5] Launching reflection in background..."
|
|
1275
|
-
|
|
1276
|
-
# Ensure log directory exists
|
|
1277
|
-
mkdir -p "$PROJECT_ROOT/.artifacts/logs"
|
|
1278
|
-
|
|
1279
|
-
# Build reflection context from CFN Loop execution
|
|
1280
|
-
REFLECTION_CONTEXT=$(cat <<EOF
|
|
1281
|
-
{
|
|
1282
|
-
"task_id": "$TASK_ID",
|
|
1283
|
-
"task_type": "cfn_loop",
|
|
1284
|
-
"mode": "$MODE",
|
|
1285
|
-
"iterations_completed": $ITERATIONS_COMPLETED,
|
|
1286
|
-
"loop3_agents": "$LOOP3_AGENTS",
|
|
1287
|
-
"loop2_agents": "$LOOP2_AGENTS",
|
|
1288
|
-
"loop3_confidence": $LOOP3_FINAL_CONFIDENCE,
|
|
1289
|
-
"loop2_consensus": $LOOP2_FINAL_CONSENSUS,
|
|
1290
|
-
"gate_threshold": $GATE,
|
|
1291
|
-
"consensus_threshold": $CONSENSUS,
|
|
1292
|
-
"deliverables_verified": $DELIVERABLES_VERIFIED,
|
|
1293
|
-
"epic_context": $EPIC_CONTEXT,
|
|
1294
|
-
"phase_context": $PHASE_CONTEXT,
|
|
1295
|
-
"success_criteria": $SUCCESS_CRITERIA
|
|
1296
|
-
}
|
|
1297
|
-
EOF
|
|
1298
|
-
)
|
|
1299
|
-
|
|
1300
|
-
# Launch reflection in background (non-blocking)
|
|
1301
|
-
(
|
|
1302
|
-
"$PROJECT_ROOT/.claude/skills/cfn-ace-system/invoke-context-reflect.sh" \
|
|
1303
|
-
--context "$REFLECTION_CONTEXT" \
|
|
1304
|
-
--output "/tmp/reflection-${TASK_ID}.json" 2>&1 | \
|
|
1305
|
-
tee -a "$PROJECT_ROOT/.artifacts/logs/ace-reflection-${TASK_ID}.log"
|
|
1306
|
-
|
|
1307
|
-
# Log completion
|
|
1308
|
-
echo "[$(date -Iseconds)] Reflection complete for task $TASK_ID" >> \
|
|
1309
|
-
"$PROJECT_ROOT/.artifacts/logs/ace-reflection-${TASK_ID}.log"
|
|
1310
|
-
) &
|
|
1311
|
-
|
|
1312
|
-
REFLECTION_PID=$!
|
|
1313
|
-
echo "[Loop 5] Reflection launched (PID: $REFLECTION_PID)"
|
|
1314
|
-
echo ""
|
|
1315
|
-
|
|
1316
|
-
# Continue with output (don't wait for reflection)
|
|
1317
|
-
output_result "success"
|
|
1318
|
-
exit 0
|
|
1319
|
-
;;
|
|
1320
|
-
ABORT)
|
|
1321
|
-
output_result "aborted"
|
|
1322
|
-
exit 1
|
|
1323
|
-
;;
|
|
1324
|
-
ITERATE)
|
|
1325
|
-
if [ $ITERATION -ge $MAX_ITERATIONS ]; then
|
|
1326
|
-
echo "❌ Max iterations reached"
|
|
1327
|
-
output_result "failed"
|
|
1328
|
-
exit 1
|
|
1329
|
-
fi
|
|
1330
|
-
|
|
1331
|
-
echo "🔄 Product Owner requested iteration"
|
|
1332
|
-
"$HELPERS_DIR/iteration-manager.sh" \
|
|
1333
|
-
--task-id "$TASK_ID" \
|
|
1334
|
-
--iteration "$((ITERATION + 1))" \
|
|
1335
|
-
--agents "$LOOP3_AGENTS,$LOOP2_AGENTS" \
|
|
1336
|
-
--feedback-source "swarm:${TASK_ID}:feedback"
|
|
1337
|
-
continue
|
|
1338
|
-
;;
|
|
1339
|
-
esac
|
|
1340
|
-
done
|
|
1341
|
-
|
|
1342
|
-
# Max iterations reached without success
|
|
1343
|
-
echo "❌ Max iterations ($MAX_ITERATIONS) reached without PROCEED decision"
|
|
1344
|
-
output_result "failed"
|
|
1345
|
-
exit 1
|