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.
Files changed (636) hide show
  1. package/.claude/cfn-extras/agents/cfn-v3-coordinator.md +517 -0
  2. package/.claude/commands/cfn-loop-cli.md +158 -464
  3. package/.claude/commands/cfn-loop-trigger.md +114 -0
  4. package/.claude/hooks/cfn-invoke-post-edit-ts.sh +100 -0
  5. package/.claude/hooks/cfn-invoke-post-edit-ts.sh.backup +78 -0
  6. package/.claude/hooks/cfn-invoke-post-edit.sh +22 -0
  7. package/.claude/hooks/cfn-invoke-post-edit.sh.backup +87 -0
  8. package/.claude/hooks/cfn-invoke-pre-edit-ts.sh +116 -0
  9. package/.claude/hooks/cfn-invoke-pre-edit-ts.sh.backup +94 -0
  10. package/.claude/hooks/cfn-invoke-pre-edit.sh +22 -0
  11. package/.claude/hooks/cfn-invoke-pre-edit.sh.backup +88 -0
  12. package/.claude/skills/cfn-agent-spawning/SKILL.md +48 -1
  13. package/.claude/skills/cfn-agent-spawning/SKILL.md.backup +135 -0
  14. package/.claude/skills/cfn-agent-spawning/TYPESCRIPT_MIGRATION.md +567 -0
  15. package/.claude/skills/cfn-agent-spawning/check-dependencies.sh +22 -0
  16. package/.claude/skills/{cfn-redis-coordination/check-dependencies.sh → cfn-agent-spawning/check-dependencies.sh.backup} +3 -5
  17. package/.claude/skills/cfn-agent-spawning/get-agent-provider-env.sh +22 -0
  18. package/.claude/skills/cfn-agent-spawning/get-agent-provider-env.sh.backup +127 -0
  19. package/.claude/skills/cfn-agent-spawning/parse-agent-provider.sh +22 -0
  20. package/.claude/skills/cfn-agent-spawning/parse-agent-provider.sh.backup +59 -0
  21. package/.claude/skills/cfn-agent-spawning/spawn-agent-wrapper.sh +63 -0
  22. package/.claude/skills/cfn-agent-spawning/spawn-agent-wrapper.sh.backup +41 -0
  23. package/.claude/skills/cfn-agent-spawning/spawn-agent.sh +26 -1
  24. package/.claude/skills/cfn-agent-spawning/spawn-templates.sh +22 -0
  25. package/.claude/skills/cfn-agent-spawning/spawn-templates.sh.backup +613 -0
  26. package/.claude/skills/cfn-agent-spawning/spawn-worker.sh +22 -0
  27. package/.claude/skills/cfn-agent-spawning/spawn-worker.sh.backup +176 -0
  28. package/.claude/skills/cfn-loop-orchestration/.backups/unknown/1763619700_33aff4a69b99159e4e849107ebc4d09f/metadata.json +8 -0
  29. package/.claude/skills/cfn-loop-orchestration/.backups/unknown/1763619700_33aff4a69b99159e4e849107ebc4d09f/original +271 -0
  30. package/.claude/skills/cfn-loop-orchestration/.backups/unknown/1763619700_33aff4a69b99159e4e849107ebc4d09f/revert.sh +7 -0
  31. package/.claude/skills/cfn-loop-orchestration/.backups/unknown/1763671642_06496e8c399a79db08167cc00ed4b31e/metadata.json +8 -0
  32. package/.claude/skills/cfn-loop-orchestration/.backups/unknown/1763671642_06496e8c399a79db08167cc00ed4b31e/original +325 -0
  33. package/.claude/skills/cfn-loop-orchestration/.backups/unknown/1763671642_06496e8c399a79db08167cc00ed4b31e/revert.sh +7 -0
  34. package/.claude/skills/cfn-loop-orchestration/CLI_IMPLEMENTATION_SUMMARY.md +330 -0
  35. package/.claude/skills/cfn-loop-orchestration/CONFIGURATION_IMPROVEMENTS.md +318 -0
  36. package/.claude/skills/cfn-loop-orchestration/CONTEXT_LOOKUP_MIGRATION.md +308 -0
  37. package/.claude/skills/cfn-loop-orchestration/CONTEXT_LOOKUP_QUICK_START.md +378 -0
  38. package/.claude/skills/cfn-loop-orchestration/E2E_VALIDATION_REPORT.md +262 -0
  39. package/.claude/skills/cfn-loop-orchestration/IMPLEMENTATION_SUMMARY.md +319 -519
  40. package/.claude/skills/cfn-loop-orchestration/NORTH_STAR_E2E_REPORT.md +299 -0
  41. package/.claude/skills/cfn-loop-orchestration/NORTH_STAR_EXECUTION_SUMMARY.md +403 -0
  42. package/.claude/skills/cfn-loop-orchestration/NORTH_STAR_INDEX.md +323 -0
  43. package/.claude/skills/cfn-loop-orchestration/SKILL.md +159 -48
  44. package/.claude/skills/cfn-loop-orchestration/SPAWN_AGENTS_IMPLEMENTATION.md +188 -0
  45. package/.claude/skills/cfn-loop-orchestration/TEST_COVERAGE_REPORT.md +335 -0
  46. package/.claude/skills/cfn-loop-orchestration/TEST_COVERAGE_SUMMARY.md +456 -0
  47. package/.claude/skills/cfn-loop-orchestration/TYPESCRIPT_INTEGRATION_REPORT.md +709 -0
  48. package/.claude/skills/cfn-loop-orchestration/TYPESCRIPT_INTEGRATION_SUMMARY.md +257 -0
  49. package/.claude/skills/cfn-loop-orchestration/VALIDATION_REPORT.md +572 -0
  50. package/.claude/skills/cfn-loop-orchestration/VALIDATION_SUMMARY.txt +196 -0
  51. package/.claude/skills/cfn-loop-orchestration/VALIDATOR_MODULE_GUIDE.md +526 -0
  52. package/.claude/skills/cfn-loop-orchestration/archive/legacy-bash/README.md +167 -0
  53. package/.claude/skills/cfn-loop-orchestration/archive/legacy-bash/orchestrate-enhanced.sh +548 -0
  54. package/{claude-assets/skills/cfn-loop-orchestration → .claude/skills/cfn-loop-orchestration/archive/legacy-bash}/orchestrate-wrapper.sh +11 -1
  55. package/.claude/skills/cfn-loop-orchestration/archive/legacy-bash/orchestrate.sh +182 -0
  56. package/.claude/skills/cfn-loop-orchestration/e2e-validation-fixed.js +240 -0
  57. package/.claude/skills/cfn-loop-orchestration/e2e-validation.js +213 -0
  58. package/.claude/skills/cfn-loop-orchestration/package-lock.json +3 -0
  59. package/.claude/skills/cfn-loop-orchestration/package.json +4 -0
  60. package/.claude/skills/cfn-loop-orchestration/run-north-star-e2e.ts +210 -0
  61. package/.claude/skills/cfn-loop-orchestration/src/cli/orchestrator-cli.ts +396 -0
  62. package/.claude/skills/cfn-loop-orchestration/src/helpers/CONFIDENCE_AGGREGATOR.md +564 -0
  63. package/.claude/skills/cfn-loop-orchestration/src/helpers/CONFIDENCE_AGGREGATOR_QUICK_REF.md +241 -0
  64. package/.claude/skills/cfn-loop-orchestration/src/helpers/CONTEXT_INJECTOR_IMPLEMENTATION.md +375 -0
  65. package/.claude/skills/cfn-loop-orchestration/src/helpers/CONTEXT_INJECTOR_QUICK_REFERENCE.md +362 -0
  66. package/.claude/skills/cfn-loop-orchestration/src/helpers/CONTEXT_INJECTOR_README.md +307 -0
  67. package/.claude/skills/cfn-loop-orchestration/src/helpers/CONTEXT_INJECTOR_USAGE_GUIDE.md +508 -0
  68. package/.claude/skills/cfn-loop-orchestration/src/helpers/confidence-aggregator.ts +473 -0
  69. package/.claude/skills/cfn-loop-orchestration/src/helpers/consensus.ts +1 -1
  70. package/.claude/skills/cfn-loop-orchestration/src/helpers/context-injector.ts +349 -0
  71. package/.claude/skills/cfn-loop-orchestration/src/helpers/context-lookup.ts +486 -0
  72. package/.claude/skills/cfn-loop-orchestration/src/helpers/deliverable-verifier.ts +6 -2
  73. package/.claude/skills/cfn-loop-orchestration/src/helpers/gate-check.ts +1 -1
  74. package/.claude/skills/cfn-loop-orchestration/src/helpers/product-owner-decision.ts +316 -0
  75. package/.claude/skills/cfn-loop-orchestration/src/helpers/spawn-agents.ts +357 -0
  76. package/.claude/skills/cfn-loop-orchestration/src/helpers/validator.ts +276 -0
  77. package/.claude/skills/cfn-loop-orchestration/src/index.ts +2 -0
  78. package/.claude/skills/cfn-loop-orchestration/src/orchestrate.ts +743 -2
  79. package/.claude/skills/cfn-loop-orchestration/src/types.ts +56 -0
  80. package/.claude/skills/cfn-loop-orchestration/test-cli.sh +92 -0
  81. package/.claude/skills/cfn-loop-orchestration/test-typescript-integration.sh +442 -0
  82. package/.claude/skills/cfn-loop-orchestration/tests/agent-spawner.test.ts +124 -0
  83. package/.claude/skills/cfn-loop-orchestration/tests/confidence-aggregator.test.ts +604 -0
  84. package/.claude/skills/cfn-loop-orchestration/tests/context-injector.test.ts +561 -0
  85. package/.claude/skills/cfn-loop-orchestration/tests/context-lookup.test.ts +661 -0
  86. package/.claude/skills/cfn-loop-orchestration/tests/deliverable-verifier.test.ts +2 -2
  87. package/.claude/skills/cfn-loop-orchestration/tests/gate-check-edge-cases.test.ts +422 -0
  88. package/.claude/skills/cfn-loop-orchestration/tests/gate-checker.test.ts +276 -0
  89. package/.claude/skills/cfn-loop-orchestration/tests/logger.test.ts +291 -0
  90. package/.claude/skills/cfn-loop-orchestration/tests/north-star-e2e.test.ts +334 -0
  91. package/.claude/skills/cfn-loop-orchestration/tests/redis-coordinator.test.ts +321 -0
  92. package/.claude/skills/cfn-loop-orchestration/tests/spawn-agents.test.ts +284 -0
  93. package/.claude/skills/cfn-loop-orchestration/tests/validator.test.ts +643 -0
  94. package/.claude/skills/cfn-loop-validation/IMPLEMENTATION_SUMMARY.md +672 -0
  95. package/.claude/skills/cfn-loop-validation/INDEX.md +531 -0
  96. package/.claude/skills/cfn-loop-validation/README_TYPESCRIPT.md +454 -0
  97. package/.claude/skills/cfn-loop-validation/SKILL.md +48 -1
  98. package/.claude/skills/cfn-loop-validation/SKILL.md.backup +353 -0
  99. package/.claude/skills/cfn-loop-validation/SKILL_TYPESCRIPT.md +782 -0
  100. package/.claude/skills/cfn-loop-validation/VAPOR_DETECTION_EXAMPLES.md +598 -0
  101. package/.claude/skills/cfn-loop-validation/check-dependencies.sh +22 -0
  102. package/{claude-assets/skills/cfn-redis-coordination/check-dependencies.sh → .claude/skills/cfn-loop-validation/check-dependencies.sh.backup} +4 -5
  103. package/.claude/skills/cfn-loop-validation/detect-vapor.sh +59 -0
  104. package/.claude/skills/cfn-loop-validation/detect-vapor.sh.backup +37 -0
  105. package/.claude/skills/cfn-loop-validation/dist/.tsbuildinfo +1 -0
  106. package/.claude/skills/cfn-loop-validation/dist/cli/detect-vapor.d.ts +14 -0
  107. package/.claude/skills/cfn-loop-validation/dist/cli/detect-vapor.d.ts.map +1 -0
  108. package/.claude/skills/cfn-loop-validation/dist/cli/detect-vapor.js +185 -0
  109. package/.claude/skills/cfn-loop-validation/dist/cli/detect-vapor.js.map +1 -0
  110. package/.claude/skills/cfn-loop-validation/dist/cli/validate-deliverables.d.ts +14 -0
  111. package/.claude/skills/cfn-loop-validation/dist/cli/validate-deliverables.d.ts.map +1 -0
  112. package/.claude/skills/cfn-loop-validation/dist/cli/validate-deliverables.js +176 -0
  113. package/.claude/skills/cfn-loop-validation/dist/cli/validate-deliverables.js.map +1 -0
  114. package/.claude/skills/cfn-loop-validation/dist/cli/validate-gate.d.ts +19 -0
  115. package/.claude/skills/cfn-loop-validation/dist/cli/validate-gate.d.ts.map +1 -0
  116. package/.claude/skills/cfn-loop-validation/dist/cli/validate-gate.js +123 -0
  117. package/.claude/skills/cfn-loop-validation/dist/cli/validate-gate.js.map +1 -0
  118. package/.claude/skills/cfn-loop-validation/dist/types.d.ts +156 -0
  119. package/.claude/skills/cfn-loop-validation/dist/types.d.ts.map +1 -0
  120. package/.claude/skills/cfn-loop-validation/dist/types.js +66 -0
  121. package/.claude/skills/cfn-loop-validation/dist/types.js.map +1 -0
  122. package/.claude/skills/cfn-loop-validation/dist/validator.d.ts +85 -0
  123. package/.claude/skills/cfn-loop-validation/dist/validator.d.ts.map +1 -0
  124. package/.claude/skills/cfn-loop-validation/dist/validator.js +411 -0
  125. package/.claude/skills/cfn-loop-validation/dist/validator.js.map +1 -0
  126. package/.claude/skills/cfn-loop-validation/orchestrate-cfn-loop.sh +22 -0
  127. package/.claude/skills/cfn-loop-validation/orchestrate-cfn-loop.sh.backup +252 -0
  128. package/.claude/skills/cfn-loop-validation/package.json +93 -0
  129. package/.claude/skills/cfn-loop-validation/src/cli/detect-vapor.ts +177 -0
  130. package/.claude/skills/cfn-loop-validation/src/cli/validate-deliverables.ts +161 -0
  131. package/.claude/skills/cfn-loop-validation/src/cli/validate-gate.ts +139 -0
  132. package/.claude/skills/cfn-loop-validation/src/types.ts +215 -0
  133. package/.claude/skills/cfn-loop-validation/src/validator.ts +503 -0
  134. package/.claude/skills/cfn-loop-validation/tests/validator.test.ts +537 -0
  135. package/.claude/skills/{cfn-redis-coordination → cfn-loop-validation}/tsconfig.json +34 -31
  136. package/.claude/skills/cfn-loop-validation/validate-deliverables.sh +59 -0
  137. package/.claude/skills/cfn-loop-validation/validate-deliverables.sh.backup +37 -0
  138. package/.claude/skills/cfn-loop-validation/validate-gate.sh +63 -0
  139. package/.claude/skills/cfn-loop-validation/validate-gate.sh.backup +41 -0
  140. package/.claude/skills/cfn-loop-validation/validate-iteration.sh +22 -0
  141. package/.claude/skills/cfn-loop-validation/validate-iteration.sh.backup +134 -0
  142. package/.claude/skills/cfn-product-owner-decision/SKILL.md +479 -147
  143. package/.claude/skills/cfn-product-owner-decision/TYPESCRIPT_IMPLEMENTATION.md +653 -0
  144. package/{claude-assets/skills/cfn-product-owner-decision → .claude/skills/cfn-product-owner-decision/archive/legacy-bash}/execute-decision.sh +24 -2
  145. package/.claude/skills/pre-edit-backup/SKILL.md +324 -0
  146. package/.claude/skills/pre-edit-backup/SKILL.md.backup +277 -0
  147. package/.claude/skills/pre-edit-backup/backup.sh +22 -0
  148. package/.claude/skills/pre-edit-backup/backup.sh.backup +107 -0
  149. package/claude-assets/agents/cfn-dev-team/coordinators/cfn-frontend-coordinator.md +1 -0
  150. package/claude-assets/agents/cfn-dev-team/coordinators/consensus-builder.md +1 -0
  151. package/claude-assets/agents/cfn-dev-team/coordinators/handoff-coordinator.md +1 -0
  152. package/claude-assets/agents/cfn-dev-team/coordinators/multi-sprint-coordinator.md +1 -0
  153. package/claude-assets/agents/cfn-dev-team/dev-ops/devops-engineer.md +10 -0
  154. package/claude-assets/agents/cfn-dev-team/dev-ops/docker-specialist.md +56 -33
  155. package/claude-assets/agents/cfn-dev-team/dev-ops/kubernetes-specialist.md +46 -36
  156. package/claude-assets/agents/cfn-dev-team/dev-ops/monitoring-specialist.md +9 -0
  157. package/claude-assets/agents/cfn-dev-team/developers/api-gateway-specialist.md +17 -17
  158. package/claude-assets/agents/cfn-dev-team/developers/backend-developer.md +40 -58
  159. package/claude-assets/agents/cfn-dev-team/developers/data/data-engineer.md +18 -20
  160. package/claude-assets/agents/cfn-dev-team/developers/database/database-architect.md +19 -28
  161. package/claude-assets/agents/cfn-dev-team/developers/frontend/mobile-dev.md +15 -19
  162. package/claude-assets/agents/cfn-dev-team/developers/frontend/react-frontend-engineer.md +15 -10
  163. package/claude-assets/agents/cfn-dev-team/developers/frontend/typescript-specialist.md +15 -10
  164. package/claude-assets/agents/cfn-dev-team/developers/frontend/ui-designer.md +15 -25
  165. package/claude-assets/agents/cfn-dev-team/developers/graphql-specialist.md +17 -21
  166. package/claude-assets/agents/cfn-dev-team/developers/rust-developer.md +17 -21
  167. package/claude-assets/agents/cfn-dev-team/product-owners/product-owner.md +1 -5
  168. package/claude-assets/agents/cfn-dev-team/reviewers/code-reviewer.md +20 -51
  169. package/claude-assets/agents/cfn-dev-team/reviewers/quality/code-quality-validator.md +22 -71
  170. package/claude-assets/agents/cfn-dev-team/reviewers/quality/perf-analyzer.md +21 -64
  171. package/claude-assets/agents/cfn-dev-team/reviewers/quality/performance-benchmarker.md +22 -67
  172. package/claude-assets/agents/cfn-dev-team/reviewers/quality/security-specialist.md +23 -67
  173. package/claude-assets/agents/cfn-dev-team/testers/api-testing-specialist.md +7 -35
  174. package/claude-assets/agents/cfn-dev-team/testers/chaos-engineering-specialist.md +8 -37
  175. package/claude-assets/agents/cfn-dev-team/testers/contract-tester.md +16 -54
  176. package/claude-assets/agents/cfn-dev-team/testers/integration-tester.md +17 -55
  177. package/claude-assets/agents/cfn-dev-team/testers/interaction-tester.md +9 -37
  178. package/claude-assets/agents/cfn-dev-team/testers/load-testing-specialist.md +17 -55
  179. package/claude-assets/agents/cfn-dev-team/testers/mutation-testing-specialist.md +17 -48
  180. package/claude-assets/agents/cfn-dev-team/testers/playwright-tester.md +8 -37
  181. package/claude-assets/agents/cfn-dev-team/testers/tester.md +7 -27
  182. package/claude-assets/agents/cfn-dev-team/utility/analyst.md +12 -28
  183. package/claude-assets/agents/cfn-dev-team/utility/code-booster.md +13 -13
  184. package/claude-assets/agents/cfn-dev-team/utility/context-curator.md +7 -2
  185. package/claude-assets/agents/cfn-dev-team/utility/epic-creator.md +5 -10
  186. package/claude-assets/agents/cfn-dev-team/utility/memory-leak-specialist.md +120 -714
  187. package/claude-assets/agents/cfn-dev-team/utility/researcher.md +12 -21
  188. package/claude-assets/agents/cfn-dev-team/utility/z-ai-specialist.md +146 -572
  189. package/claude-assets/agents/custom/cfn-docker-expert.md +102 -0
  190. package/claude-assets/agents/custom/cfn-loops-cli-expert.md +129 -0
  191. package/claude-assets/cfn-extras/agents/cfn-v3-coordinator.md +517 -0
  192. package/claude-assets/commands/cfn-loop-cli.md +158 -464
  193. package/claude-assets/commands/cfn-loop-trigger.md +114 -0
  194. package/claude-assets/hooks/SKILL.md +518 -0
  195. package/claude-assets/hooks/SKILL.md.backup +471 -0
  196. package/claude-assets/hooks/cfn-invoke-post-edit-ts.sh +100 -0
  197. package/claude-assets/hooks/cfn-invoke-post-edit-ts.sh.backup +78 -0
  198. package/claude-assets/hooks/cfn-invoke-post-edit.sh +22 -0
  199. package/claude-assets/hooks/cfn-invoke-post-edit.sh.backup +87 -0
  200. package/claude-assets/hooks/cfn-invoke-pre-edit-ts.sh +116 -0
  201. package/claude-assets/hooks/cfn-invoke-pre-edit-ts.sh.backup +94 -0
  202. package/claude-assets/hooks/cfn-invoke-pre-edit.sh +22 -0
  203. package/claude-assets/hooks/cfn-invoke-pre-edit.sh.backup +88 -0
  204. package/claude-assets/skills/cfn-agent-selection-with-fallback/DELIVERABLES.md +409 -0
  205. package/claude-assets/skills/cfn-agent-selection-with-fallback/IMPLEMENTATION_SUMMARY.md +396 -0
  206. package/claude-assets/skills/cfn-agent-selection-with-fallback/INTEGRATION_GUIDE.md +308 -0
  207. package/claude-assets/skills/cfn-agent-selection-with-fallback/QUICK_REFERENCE.md +239 -0
  208. package/claude-assets/skills/cfn-agent-selection-with-fallback/SKILL.md +107 -1
  209. package/claude-assets/skills/cfn-agent-selection-with-fallback/SKILL.md.backup +302 -0
  210. package/claude-assets/skills/cfn-agent-selection-with-fallback/TYPESCRIPT_MIGRATION.md +295 -0
  211. package/claude-assets/skills/cfn-agent-selection-with-fallback/dist/agent-selector.cjs +297 -0
  212. package/claude-assets/skills/cfn-agent-selection-with-fallback/dist/agent-selector.js +297 -0
  213. package/claude-assets/skills/cfn-agent-selection-with-fallback/dist/cli.cjs +96 -0
  214. package/claude-assets/skills/cfn-agent-selection-with-fallback/dist/cli.js +96 -0
  215. package/claude-assets/skills/cfn-agent-selection-with-fallback/select-agents-ts.sh +45 -0
  216. package/claude-assets/skills/cfn-agent-selection-with-fallback/select-agents-ts.sh.backup +23 -0
  217. package/claude-assets/skills/cfn-agent-selection-with-fallback/select-agents.sh +22 -0
  218. package/claude-assets/skills/cfn-agent-selection-with-fallback/select-agents.sh.backup +173 -0
  219. package/claude-assets/skills/cfn-agent-selection-with-fallback/src/agent-selector.test.ts +357 -0
  220. package/claude-assets/skills/cfn-agent-selection-with-fallback/src/agent-selector.ts +350 -0
  221. package/claude-assets/skills/cfn-agent-selection-with-fallback/src/cli.ts +74 -0
  222. package/claude-assets/skills/cfn-agent-selection-with-fallback/task-classifier.sh +22 -0
  223. package/claude-assets/skills/cfn-agent-selection-with-fallback/task-classifier.sh.backup +71 -0
  224. package/claude-assets/skills/cfn-agent-selection-with-fallback/tsconfig.json +18 -0
  225. package/claude-assets/skills/cfn-agent-spawning/SKILL.md +48 -1
  226. package/claude-assets/skills/cfn-agent-spawning/SKILL.md.backup +135 -0
  227. package/claude-assets/skills/cfn-agent-spawning/TYPESCRIPT_MIGRATION.md +567 -0
  228. package/claude-assets/skills/cfn-agent-spawning/check-dependencies.sh +22 -0
  229. package/claude-assets/skills/cfn-agent-spawning/check-dependencies.sh.backup +30 -0
  230. package/claude-assets/skills/cfn-agent-spawning/get-agent-provider-env.sh +22 -0
  231. package/claude-assets/skills/cfn-agent-spawning/get-agent-provider-env.sh.backup +127 -0
  232. package/claude-assets/skills/cfn-agent-spawning/parse-agent-provider.sh +22 -0
  233. package/claude-assets/skills/cfn-agent-spawning/parse-agent-provider.sh.backup +59 -0
  234. package/claude-assets/skills/cfn-agent-spawning/spawn-agent-wrapper.sh +63 -0
  235. package/claude-assets/skills/cfn-agent-spawning/spawn-agent-wrapper.sh.backup +41 -0
  236. package/claude-assets/skills/cfn-agent-spawning/spawn-agent.sh +26 -1
  237. package/claude-assets/skills/cfn-agent-spawning/spawn-templates.sh +22 -0
  238. package/claude-assets/skills/cfn-agent-spawning/spawn-templates.sh.backup +613 -0
  239. package/claude-assets/skills/cfn-agent-spawning/spawn-worker.sh +22 -0
  240. package/claude-assets/skills/cfn-agent-spawning/spawn-worker.sh.backup +176 -0
  241. package/claude-assets/skills/cfn-coordination/agent-completion.sh.backup +36 -0
  242. package/claude-assets/skills/cfn-coordination/coordination-signal.sh.backup +36 -0
  243. package/claude-assets/skills/cfn-coordination/coordination-wait.sh.backup +36 -0
  244. package/claude-assets/skills/cfn-dependency-ingestion/README.md +101 -0
  245. package/claude-assets/skills/cfn-dependency-ingestion/SKILL.md +369 -0
  246. package/claude-assets/skills/cfn-dependency-ingestion/build.sh +23 -0
  247. package/claude-assets/skills/cfn-dependency-ingestion/dist/ingest-dependencies.js +478 -0
  248. package/claude-assets/skills/cfn-dependency-ingestion/ingest-dependencies.sh +295 -0
  249. package/claude-assets/skills/cfn-dependency-ingestion/src/ingest-dependencies.ts +563 -0
  250. package/claude-assets/skills/cfn-loop-orchestration/.backups/unknown/1763619700_33aff4a69b99159e4e849107ebc4d09f/metadata.json +8 -0
  251. package/claude-assets/skills/cfn-loop-orchestration/.backups/unknown/1763619700_33aff4a69b99159e4e849107ebc4d09f/original +271 -0
  252. package/claude-assets/skills/cfn-loop-orchestration/.backups/unknown/1763619700_33aff4a69b99159e4e849107ebc4d09f/revert.sh +7 -0
  253. package/claude-assets/skills/cfn-loop-orchestration/.backups/unknown/1763671642_06496e8c399a79db08167cc00ed4b31e/metadata.json +8 -0
  254. package/claude-assets/skills/cfn-loop-orchestration/.backups/unknown/1763671642_06496e8c399a79db08167cc00ed4b31e/original +325 -0
  255. package/claude-assets/skills/cfn-loop-orchestration/.backups/unknown/1763671642_06496e8c399a79db08167cc00ed4b31e/revert.sh +7 -0
  256. package/claude-assets/skills/cfn-loop-orchestration/CLI_IMPLEMENTATION_SUMMARY.md +330 -0
  257. package/claude-assets/skills/cfn-loop-orchestration/CONFIGURATION_IMPROVEMENTS.md +318 -0
  258. package/claude-assets/skills/cfn-loop-orchestration/CONTEXT_LOOKUP_MIGRATION.md +308 -0
  259. package/claude-assets/skills/cfn-loop-orchestration/CONTEXT_LOOKUP_QUICK_START.md +378 -0
  260. package/claude-assets/skills/cfn-loop-orchestration/E2E_VALIDATION_REPORT.md +262 -0
  261. package/claude-assets/skills/cfn-loop-orchestration/IMPLEMENTATION_SUMMARY.md +319 -519
  262. package/claude-assets/skills/cfn-loop-orchestration/NORTH_STAR_E2E_REPORT.md +299 -0
  263. package/claude-assets/skills/cfn-loop-orchestration/NORTH_STAR_EXECUTION_SUMMARY.md +403 -0
  264. package/claude-assets/skills/cfn-loop-orchestration/NORTH_STAR_INDEX.md +323 -0
  265. package/claude-assets/skills/cfn-loop-orchestration/SKILL.md +159 -48
  266. package/claude-assets/skills/cfn-loop-orchestration/SPAWN_AGENTS_IMPLEMENTATION.md +188 -0
  267. package/claude-assets/skills/cfn-loop-orchestration/TEST_COVERAGE_REPORT.md +335 -0
  268. package/claude-assets/skills/cfn-loop-orchestration/TEST_COVERAGE_SUMMARY.md +456 -0
  269. package/claude-assets/skills/cfn-loop-orchestration/TYPESCRIPT_INTEGRATION_REPORT.md +709 -0
  270. package/claude-assets/skills/cfn-loop-orchestration/TYPESCRIPT_INTEGRATION_SUMMARY.md +257 -0
  271. package/claude-assets/skills/cfn-loop-orchestration/VALIDATION_REPORT.md +572 -0
  272. package/claude-assets/skills/cfn-loop-orchestration/VALIDATION_SUMMARY.txt +196 -0
  273. package/claude-assets/skills/cfn-loop-orchestration/VALIDATOR_MODULE_GUIDE.md +526 -0
  274. package/claude-assets/skills/cfn-loop-orchestration/archive/legacy-bash/README.md +167 -0
  275. package/claude-assets/skills/cfn-loop-orchestration/archive/legacy-bash/orchestrate-enhanced.sh +548 -0
  276. package/{.claude/skills/cfn-loop-orchestration → claude-assets/skills/cfn-loop-orchestration/archive/legacy-bash}/orchestrate-wrapper.sh +11 -1
  277. package/claude-assets/skills/cfn-loop-orchestration/archive/legacy-bash/orchestrate.sh +182 -0
  278. package/claude-assets/skills/cfn-loop-orchestration/e2e-validation-fixed.js +240 -0
  279. package/claude-assets/skills/cfn-loop-orchestration/e2e-validation.js +213 -0
  280. package/claude-assets/skills/cfn-loop-orchestration/package-lock.json +3 -0
  281. package/claude-assets/skills/cfn-loop-orchestration/package.json +4 -0
  282. package/claude-assets/skills/cfn-loop-orchestration/run-north-star-e2e.ts +210 -0
  283. package/claude-assets/skills/cfn-loop-orchestration/src/cli/orchestrator-cli.ts +396 -0
  284. package/claude-assets/skills/cfn-loop-orchestration/src/helpers/CONFIDENCE_AGGREGATOR.md +564 -0
  285. package/claude-assets/skills/cfn-loop-orchestration/src/helpers/CONFIDENCE_AGGREGATOR_QUICK_REF.md +241 -0
  286. package/claude-assets/skills/cfn-loop-orchestration/src/helpers/CONTEXT_INJECTOR_IMPLEMENTATION.md +375 -0
  287. package/claude-assets/skills/cfn-loop-orchestration/src/helpers/CONTEXT_INJECTOR_QUICK_REFERENCE.md +362 -0
  288. package/claude-assets/skills/cfn-loop-orchestration/src/helpers/CONTEXT_INJECTOR_README.md +307 -0
  289. package/claude-assets/skills/cfn-loop-orchestration/src/helpers/CONTEXT_INJECTOR_USAGE_GUIDE.md +508 -0
  290. package/claude-assets/skills/cfn-loop-orchestration/src/helpers/confidence-aggregator.ts +473 -0
  291. package/claude-assets/skills/cfn-loop-orchestration/src/helpers/consensus.ts +1 -1
  292. package/claude-assets/skills/cfn-loop-orchestration/src/helpers/context-injector.ts +349 -0
  293. package/claude-assets/skills/cfn-loop-orchestration/src/helpers/context-lookup.ts +486 -0
  294. package/claude-assets/skills/cfn-loop-orchestration/src/helpers/deliverable-verifier.ts +6 -2
  295. package/claude-assets/skills/cfn-loop-orchestration/src/helpers/gate-check.ts +1 -1
  296. package/claude-assets/skills/cfn-loop-orchestration/src/helpers/product-owner-decision.ts +316 -0
  297. package/claude-assets/skills/cfn-loop-orchestration/src/helpers/spawn-agents.ts +357 -0
  298. package/claude-assets/skills/cfn-loop-orchestration/src/helpers/validator.ts +276 -0
  299. package/claude-assets/skills/cfn-loop-orchestration/src/index.ts +2 -0
  300. package/claude-assets/skills/cfn-loop-orchestration/src/orchestrate.ts +743 -2
  301. package/claude-assets/skills/cfn-loop-orchestration/src/types.ts +56 -0
  302. package/claude-assets/skills/cfn-loop-orchestration/test-cli.sh +92 -0
  303. package/claude-assets/skills/cfn-loop-orchestration/test-typescript-integration.sh +442 -0
  304. package/claude-assets/skills/cfn-loop-orchestration/tests/agent-spawner.test.ts +124 -0
  305. package/claude-assets/skills/cfn-loop-orchestration/tests/confidence-aggregator.test.ts +604 -0
  306. package/claude-assets/skills/cfn-loop-orchestration/tests/context-injector.test.ts +561 -0
  307. package/claude-assets/skills/cfn-loop-orchestration/tests/context-lookup.test.ts +661 -0
  308. package/claude-assets/skills/cfn-loop-orchestration/tests/deliverable-verifier.test.ts +2 -2
  309. package/claude-assets/skills/cfn-loop-orchestration/tests/gate-check-edge-cases.test.ts +422 -0
  310. package/claude-assets/skills/cfn-loop-orchestration/tests/gate-checker.test.ts +276 -0
  311. package/claude-assets/skills/cfn-loop-orchestration/tests/logger.test.ts +291 -0
  312. package/claude-assets/skills/cfn-loop-orchestration/tests/north-star-e2e.test.ts +334 -0
  313. package/claude-assets/skills/cfn-loop-orchestration/tests/redis-coordinator.test.ts +321 -0
  314. package/claude-assets/skills/cfn-loop-orchestration/tests/spawn-agents.test.ts +284 -0
  315. package/claude-assets/skills/cfn-loop-orchestration/tests/validator.test.ts +643 -0
  316. package/claude-assets/skills/cfn-loop-output-processing/.eslintrc.json +33 -0
  317. package/claude-assets/skills/cfn-loop-output-processing/DELIVERY_SUMMARY.txt +462 -0
  318. package/claude-assets/skills/cfn-loop-output-processing/DEPRECATION_NOTICE.md +183 -0
  319. package/claude-assets/skills/cfn-loop-output-processing/EXAMPLES.md +609 -0
  320. package/claude-assets/skills/cfn-loop-output-processing/IMPLEMENTATION_SUMMARY.md +418 -0
  321. package/claude-assets/skills/cfn-loop-output-processing/INDEX.md +531 -0
  322. package/claude-assets/skills/cfn-loop-output-processing/MIGRATION.md +362 -0
  323. package/claude-assets/skills/cfn-loop-output-processing/README.md +114 -0
  324. package/claude-assets/skills/cfn-loop-output-processing/SKILL.md +633 -0
  325. package/{.claude/skills/cfn-docker-redis-coordination → claude-assets/skills/cfn-loop-output-processing}/jest.config.js +7 -15
  326. package/claude-assets/skills/cfn-loop-output-processing/package.json +50 -0
  327. package/claude-assets/skills/cfn-loop-output-processing/src/cli/process-loop2.ts +195 -0
  328. package/claude-assets/skills/cfn-loop-output-processing/src/cli/process-loop3.ts +157 -0
  329. package/claude-assets/skills/cfn-loop-output-processing/src/output-processor.ts +632 -0
  330. package/claude-assets/skills/cfn-loop-output-processing/tests/output-processor.test.ts +617 -0
  331. package/claude-assets/skills/{cfn-docker-redis-coordination → cfn-loop-output-processing}/tsconfig.json +16 -7
  332. package/claude-assets/skills/cfn-loop-validation/IMPLEMENTATION_SUMMARY.md +672 -0
  333. package/claude-assets/skills/cfn-loop-validation/INDEX.md +531 -0
  334. package/claude-assets/skills/cfn-loop-validation/README_TYPESCRIPT.md +454 -0
  335. package/claude-assets/skills/cfn-loop-validation/SKILL.md +48 -1
  336. package/claude-assets/skills/cfn-loop-validation/SKILL.md.backup +353 -0
  337. package/claude-assets/skills/cfn-loop-validation/SKILL_TYPESCRIPT.md +782 -0
  338. package/claude-assets/skills/cfn-loop-validation/VAPOR_DETECTION_EXAMPLES.md +598 -0
  339. package/claude-assets/skills/cfn-loop-validation/check-dependencies.sh +22 -0
  340. package/claude-assets/skills/cfn-loop-validation/check-dependencies.sh.backup +31 -0
  341. package/claude-assets/skills/cfn-loop-validation/detect-vapor.sh +59 -0
  342. package/claude-assets/skills/cfn-loop-validation/detect-vapor.sh.backup +37 -0
  343. package/claude-assets/skills/cfn-loop-validation/dist/.tsbuildinfo +1 -0
  344. package/claude-assets/skills/cfn-loop-validation/dist/cli/detect-vapor.d.ts +14 -0
  345. package/claude-assets/skills/cfn-loop-validation/dist/cli/detect-vapor.d.ts.map +1 -0
  346. package/claude-assets/skills/cfn-loop-validation/dist/cli/detect-vapor.js +185 -0
  347. package/claude-assets/skills/cfn-loop-validation/dist/cli/detect-vapor.js.map +1 -0
  348. package/claude-assets/skills/cfn-loop-validation/dist/cli/validate-deliverables.d.ts +14 -0
  349. package/claude-assets/skills/cfn-loop-validation/dist/cli/validate-deliverables.d.ts.map +1 -0
  350. package/claude-assets/skills/cfn-loop-validation/dist/cli/validate-deliverables.js +176 -0
  351. package/claude-assets/skills/cfn-loop-validation/dist/cli/validate-deliverables.js.map +1 -0
  352. package/claude-assets/skills/cfn-loop-validation/dist/cli/validate-gate.d.ts +19 -0
  353. package/claude-assets/skills/cfn-loop-validation/dist/cli/validate-gate.d.ts.map +1 -0
  354. package/claude-assets/skills/cfn-loop-validation/dist/cli/validate-gate.js +123 -0
  355. package/claude-assets/skills/cfn-loop-validation/dist/cli/validate-gate.js.map +1 -0
  356. package/claude-assets/skills/cfn-loop-validation/dist/types.d.ts +156 -0
  357. package/claude-assets/skills/cfn-loop-validation/dist/types.d.ts.map +1 -0
  358. package/claude-assets/skills/cfn-loop-validation/dist/types.js +66 -0
  359. package/claude-assets/skills/cfn-loop-validation/dist/types.js.map +1 -0
  360. package/claude-assets/skills/cfn-loop-validation/dist/validator.d.ts +85 -0
  361. package/claude-assets/skills/cfn-loop-validation/dist/validator.d.ts.map +1 -0
  362. package/claude-assets/skills/cfn-loop-validation/dist/validator.js +411 -0
  363. package/claude-assets/skills/cfn-loop-validation/dist/validator.js.map +1 -0
  364. package/claude-assets/skills/cfn-loop-validation/orchestrate-cfn-loop.sh +22 -0
  365. package/claude-assets/skills/cfn-loop-validation/orchestrate-cfn-loop.sh.backup +252 -0
  366. package/claude-assets/skills/cfn-loop-validation/package.json +93 -0
  367. package/claude-assets/skills/cfn-loop-validation/src/cli/detect-vapor.ts +177 -0
  368. package/claude-assets/skills/cfn-loop-validation/src/cli/validate-deliverables.ts +161 -0
  369. package/claude-assets/skills/cfn-loop-validation/src/cli/validate-gate.ts +139 -0
  370. package/claude-assets/skills/cfn-loop-validation/src/types.ts +215 -0
  371. package/claude-assets/skills/cfn-loop-validation/src/validator.ts +503 -0
  372. package/claude-assets/skills/cfn-loop-validation/tests/validator.test.ts +537 -0
  373. package/claude-assets/skills/{cfn-redis-coordination → cfn-loop-validation}/tsconfig.json +34 -31
  374. package/claude-assets/skills/cfn-loop-validation/validate-deliverables.sh +59 -0
  375. package/claude-assets/skills/cfn-loop-validation/validate-deliverables.sh.backup +37 -0
  376. package/claude-assets/skills/cfn-loop-validation/validate-gate.sh +63 -0
  377. package/claude-assets/skills/cfn-loop-validation/validate-gate.sh.backup +41 -0
  378. package/claude-assets/skills/cfn-loop-validation/validate-iteration.sh +22 -0
  379. package/claude-assets/skills/cfn-loop-validation/validate-iteration.sh.backup +134 -0
  380. package/claude-assets/skills/cfn-product-owner-decision/SKILL.md +479 -147
  381. package/claude-assets/skills/cfn-product-owner-decision/TYPESCRIPT_IMPLEMENTATION.md +653 -0
  382. package/{.claude/skills/cfn-product-owner-decision → claude-assets/skills/cfn-product-owner-decision/archive/legacy-bash}/execute-decision.sh +24 -2
  383. package/claude-assets/skills/cfn-provider-routing/README.md +129 -0
  384. package/claude-assets/skills/cfn-provider-routing/SKILL.md +192 -0
  385. package/claude-assets/skills/cfn-provider-routing/resolve-provider-model.ts +223 -0
  386. package/claude-assets/skills/pre-edit-backup/SKILL.md +324 -0
  387. package/claude-assets/skills/pre-edit-backup/SKILL.md.backup +277 -0
  388. package/claude-assets/skills/pre-edit-backup/backup.sh +22 -0
  389. package/claude-assets/skills/pre-edit-backup/backup.sh.backup +107 -0
  390. package/dist/agents/agent-loader.js +146 -165
  391. package/dist/agents/agent-loader.js.map +1 -1
  392. package/dist/api/auth-endpoints.js +415 -0
  393. package/dist/api/auth-endpoints.js.map +1 -0
  394. package/dist/api/task-endpoints.js +562 -0
  395. package/dist/api/task-endpoints.js.map +1 -0
  396. package/dist/backend/server.js +418 -0
  397. package/dist/backend/server.js.map +1 -0
  398. package/dist/cfn-loop/product-owner/decision-parser.js +356 -0
  399. package/dist/cfn-loop/product-owner/decision-parser.js.map +1 -0
  400. package/dist/cfn-loop/product-owner/index.js +1 -0
  401. package/dist/cfn-loop/product-owner/index.js.map +1 -1
  402. package/dist/cli/agent-command.js +1 -1
  403. package/dist/cli/agent-command.js.map +1 -1
  404. package/dist/cli/agent-completion.js +273 -0
  405. package/dist/cli/agent-completion.js.map +1 -0
  406. package/dist/cli/agent-prompt-builder.js +83 -48
  407. package/dist/cli/agent-prompt-builder.js.map +1 -1
  408. package/dist/cli/agent-spawner.js +499 -0
  409. package/dist/cli/agent-spawner.js.map +1 -0
  410. package/dist/cli/anthropic-client.js +10 -3
  411. package/dist/cli/anthropic-client.js.map +1 -1
  412. package/dist/cli/config-manager.js +91 -109
  413. package/dist/cli/index.js +11 -0
  414. package/dist/cli/index.js.map +1 -1
  415. package/dist/cli/parse-decision-cli.js +268 -0
  416. package/dist/cli/parse-decision-cli.js.map +1 -0
  417. package/dist/cli/post-edit-hook.js +83 -0
  418. package/dist/cli/post-edit-hook.js.map +1 -0
  419. package/dist/cli/pre-edit-hook.js +77 -0
  420. package/dist/cli/pre-edit-hook.js.map +1 -0
  421. package/dist/cli/spawn-agent-cli.js +209 -0
  422. package/dist/cli/spawn-agent-cli.js.map +1 -0
  423. package/dist/coordination/coordination-wrapper.js +383 -0
  424. package/dist/coordination/coordination-wrapper.js.map +1 -0
  425. package/dist/coordination/store-success-criteria.js +68 -0
  426. package/dist/coordination/store-success-criteria.js.map +1 -0
  427. package/dist/coordination/store-task-context.js +65 -0
  428. package/dist/coordination/store-task-context.js.map +1 -0
  429. package/dist/hooks/backup-manager.js +273 -0
  430. package/dist/hooks/backup-manager.js.map +1 -0
  431. package/dist/hooks/post-edit-validator.js +388 -0
  432. package/dist/hooks/post-edit-validator.js.map +1 -0
  433. package/dist/integration/index.js +19 -0
  434. package/dist/integration/index.js.map +1 -0
  435. package/dist/integration/task-mode-adapter.js +297 -0
  436. package/dist/integration/task-mode-adapter.js.map +1 -0
  437. package/dist/integration/trigger-dev-client.js +253 -0
  438. package/dist/integration/trigger-dev-client.js.map +1 -0
  439. package/dist/integration/trigger-dev-webhooks.js +362 -0
  440. package/dist/integration/trigger-dev-webhooks.js.map +1 -0
  441. package/dist/lib/path-validator.js +14 -5
  442. package/dist/lib/path-validator.js.map +1 -1
  443. package/dist/lib/redis-queue-manager.js +5 -1
  444. package/dist/lib/redis-queue-manager.js.map +1 -1
  445. package/dist/middleware/authentication.js +317 -0
  446. package/dist/middleware/authentication.js.map +1 -0
  447. package/dist/services/authentication.js +669 -0
  448. package/dist/services/authentication.js.map +1 -0
  449. package/dist/services/session-management.js +436 -0
  450. package/dist/services/session-management.js.map +1 -0
  451. package/dist/services/skill-deployment.js +8 -6
  452. package/dist/services/skill-deployment.js.map +1 -1
  453. package/dist/services/user-service.js +710 -0
  454. package/dist/services/user-service.js.map +1 -0
  455. package/dist/types/trigger-dev-events.d.js +10 -0
  456. package/dist/types/trigger-dev-events.d.js.map +1 -0
  457. package/docs/README.md +240 -0
  458. package/package.json +13 -4
  459. package/scripts/compare-workflow-performance.sh +556 -0
  460. package/scripts/migrate-to-optimized-workflows.sh +438 -0
  461. package/scripts/organize-docs.sh +338 -0
  462. package/scripts/trigger-dev-setup.sh +267 -0
  463. package/.claude/skills/cfn-docker-redis-coordination/MIGRATION_SUMMARY.md +0 -348
  464. package/.claude/skills/cfn-docker-redis-coordination/README.md +0 -294
  465. package/.claude/skills/cfn-docker-redis-coordination/SKILL.md +0 -435
  466. package/.claude/skills/cfn-docker-redis-coordination/coordinate.sh +0 -650
  467. package/.claude/skills/cfn-docker-redis-coordination/coordinate.sh.backup-1763145142 +0 -641
  468. package/.claude/skills/cfn-docker-redis-coordination/package-lock.json +0 -5259
  469. package/.claude/skills/cfn-docker-redis-coordination/package.json +0 -40
  470. package/.claude/skills/cfn-docker-redis-coordination/src/coordinator.ts +0 -801
  471. package/.claude/skills/cfn-docker-redis-coordination/src/index.ts +0 -42
  472. package/.claude/skills/cfn-docker-redis-coordination/src/types.ts +0 -351
  473. package/.claude/skills/cfn-docker-redis-coordination/tests/coordinator.test.ts +0 -1464
  474. package/.claude/skills/cfn-docker-redis-coordination/tsconfig.json +0 -30
  475. package/.claude/skills/cfn-loop-orchestration/helpers/auto-tune-timeouts.sh +0 -228
  476. package/.claude/skills/cfn-loop-orchestration/helpers/consensus-ts.sh +0 -104
  477. package/.claude/skills/cfn-loop-orchestration/helpers/consensus.sh +0 -94
  478. package/.claude/skills/cfn-loop-orchestration/helpers/context-injection.sh +0 -142
  479. package/.claude/skills/cfn-loop-orchestration/helpers/context-lookup.sh +0 -359
  480. package/.claude/skills/cfn-loop-orchestration/helpers/deliverable-verifier-ts.sh +0 -123
  481. package/.claude/skills/cfn-loop-orchestration/helpers/deliverable-verifier.sh +0 -71
  482. package/.claude/skills/cfn-loop-orchestration/helpers/gate-check.sh +0 -56
  483. package/.claude/skills/cfn-loop-orchestration/helpers/iteration-manager-ts.sh +0 -89
  484. package/.claude/skills/cfn-loop-orchestration/helpers/iteration-manager.sh +0 -87
  485. package/.claude/skills/cfn-loop-orchestration/helpers/orchestrate-ts.sh +0 -104
  486. package/.claude/skills/cfn-loop-orchestration/helpers/parse-test-results.sh +0 -56
  487. package/.claude/skills/cfn-loop-orchestration/helpers/spawn-agents.sh +0 -290
  488. package/.claude/skills/cfn-loop-orchestration/helpers/timeout-calculator-ts.sh +0 -47
  489. package/.claude/skills/cfn-loop-orchestration/helpers/timeout-calculator.sh +0 -51
  490. package/.claude/skills/cfn-loop-orchestration/orchestrate.sh +0 -1345
  491. package/.claude/skills/cfn-redis-coordination/AGENT_LOGGING.md +0 -280
  492. package/.claude/skills/cfn-redis-coordination/BZPOPMIN_FIX_SUMMARY.md +0 -209
  493. package/.claude/skills/cfn-redis-coordination/CENTRALIZED_REDIS_WRAPPER.md +0 -319
  494. package/.claude/skills/cfn-redis-coordination/agent-log.sh.bak +0 -124
  495. package/.claude/skills/cfn-redis-coordination/config.json +0 -61
  496. package/.claude/skills/cfn-redis-coordination/demos/phase4-wake-queue-test-report.md +0 -82
  497. package/.claude/skills/cfn-redis-coordination/demos/test-bzpopmin-fix.sh +0 -274
  498. package/.claude/skills/cfn-redis-coordination/demos/test-cancel-swarm.sh +0 -0
  499. package/.claude/skills/cfn-redis-coordination/docs/migration/PHASE_3_REDIS_COORDINATION_COMPLETION_REPORT.md +0 -553
  500. package/.claude/skills/cfn-redis-coordination/jest.config.js +0 -23
  501. package/.claude/skills/cfn-redis-coordination/package-lock.json +0 -5272
  502. package/.claude/skills/cfn-redis-coordination/package.json +0 -45
  503. package/.claude/skills/cfn-redis-coordination/src/agent-logger.ts +0 -446
  504. package/.claude/skills/cfn-redis-coordination/src/agent-recovery.ts +0 -454
  505. package/.claude/skills/cfn-redis-coordination/src/completion-reporter.ts +0 -396
  506. package/.claude/skills/cfn-redis-coordination/src/context-manager.ts +0 -327
  507. package/.claude/skills/cfn-redis-coordination/src/index.ts +0 -82
  508. package/.claude/skills/cfn-redis-coordination/src/mode-detector.ts +0 -155
  509. package/.claude/skills/cfn-redis-coordination/src/redis/redis-client.ts +0 -305
  510. package/.claude/skills/cfn-redis-coordination/src/redis/redis-functions.ts +0 -283
  511. package/.claude/skills/cfn-redis-coordination/src/redis-client.ts +0 -654
  512. package/.claude/skills/cfn-redis-coordination/src/result-collector.ts +0 -437
  513. package/.claude/skills/cfn-redis-coordination/src/swarm-manager.ts +0 -494
  514. package/.claude/skills/cfn-redis-coordination/src/task-analyzer.ts +0 -404
  515. package/.claude/skills/cfn-redis-coordination/src/task-executor.ts +0 -423
  516. package/.claude/skills/cfn-redis-coordination/src/types.ts +0 -235
  517. package/.claude/skills/cfn-redis-coordination/src/waiting-coordinator.ts +0 -587
  518. package/.claude/skills/cfn-redis-coordination/store-success-criteria.sh +0 -85
  519. package/.claude/skills/cfn-redis-coordination/test-connection-attempts.js +0 -70
  520. package/.claude/skills/cfn-redis-coordination/test-mode-simple.js +0 -121
  521. package/.claude/skills/cfn-redis-coordination/test-redis-check.js +0 -84
  522. package/.claude/skills/cfn-redis-coordination/test-task-mode-redis.cjs +0 -391
  523. package/.claude/skills/cfn-redis-coordination/tests/coordination.test.ts +0 -788
  524. package/.claude/skills/cfn-redis-coordination/update-all-scripts.sh +0 -67
  525. package/claude-assets/agents/cfn-dev-team/coordinators/cfn-v3-coordinator.md +0 -980
  526. package/claude-assets/agents/typescript-specialist.md +0 -280
  527. package/claude-assets/skills/cfn-docker-redis-coordination/MIGRATION_SUMMARY.md +0 -348
  528. package/claude-assets/skills/cfn-docker-redis-coordination/README.md +0 -294
  529. package/claude-assets/skills/cfn-docker-redis-coordination/SKILL.md +0 -435
  530. package/claude-assets/skills/cfn-docker-redis-coordination/coordinate.sh +0 -650
  531. package/claude-assets/skills/cfn-docker-redis-coordination/coordinate.sh.backup-1763145142 +0 -641
  532. package/claude-assets/skills/cfn-docker-redis-coordination/jest.config.js +0 -37
  533. package/claude-assets/skills/cfn-docker-redis-coordination/package-lock.json +0 -5259
  534. package/claude-assets/skills/cfn-docker-redis-coordination/package.json +0 -40
  535. package/claude-assets/skills/cfn-docker-redis-coordination/src/coordinator.ts +0 -801
  536. package/claude-assets/skills/cfn-docker-redis-coordination/src/index.ts +0 -42
  537. package/claude-assets/skills/cfn-docker-redis-coordination/src/types.ts +0 -351
  538. package/claude-assets/skills/cfn-docker-redis-coordination/tests/coordinator.test.ts +0 -1464
  539. package/claude-assets/skills/cfn-loop-orchestration/helpers/auto-tune-timeouts.sh +0 -228
  540. package/claude-assets/skills/cfn-loop-orchestration/helpers/consensus-ts.sh +0 -104
  541. package/claude-assets/skills/cfn-loop-orchestration/helpers/consensus.sh +0 -94
  542. package/claude-assets/skills/cfn-loop-orchestration/helpers/context-injection.sh +0 -142
  543. package/claude-assets/skills/cfn-loop-orchestration/helpers/context-lookup.sh +0 -359
  544. package/claude-assets/skills/cfn-loop-orchestration/helpers/deliverable-verifier-ts.sh +0 -123
  545. package/claude-assets/skills/cfn-loop-orchestration/helpers/deliverable-verifier.sh +0 -71
  546. package/claude-assets/skills/cfn-loop-orchestration/helpers/gate-check.sh +0 -56
  547. package/claude-assets/skills/cfn-loop-orchestration/helpers/iteration-manager-ts.sh +0 -89
  548. package/claude-assets/skills/cfn-loop-orchestration/helpers/iteration-manager.sh +0 -87
  549. package/claude-assets/skills/cfn-loop-orchestration/helpers/orchestrate-ts.sh +0 -104
  550. package/claude-assets/skills/cfn-loop-orchestration/helpers/parse-test-results.sh +0 -56
  551. package/claude-assets/skills/cfn-loop-orchestration/helpers/spawn-agents.sh +0 -290
  552. package/claude-assets/skills/cfn-loop-orchestration/helpers/timeout-calculator-ts.sh +0 -47
  553. package/claude-assets/skills/cfn-loop-orchestration/helpers/timeout-calculator.sh +0 -51
  554. package/claude-assets/skills/cfn-loop-orchestration/orchestrate.sh +0 -1345
  555. package/claude-assets/skills/cfn-redis-cleanup/cleanup-redis.sh +0 -130
  556. package/claude-assets/skills/cfn-redis-coordination/AGENT_LOGGING.md +0 -280
  557. package/claude-assets/skills/cfn-redis-coordination/BZPOPMIN_FIX_SUMMARY.md +0 -209
  558. package/claude-assets/skills/cfn-redis-coordination/CENTRALIZED_REDIS_WRAPPER.md +0 -319
  559. package/claude-assets/skills/cfn-redis-coordination/agent-log.sh.bak +0 -124
  560. package/claude-assets/skills/cfn-redis-coordination/config.json +0 -61
  561. package/claude-assets/skills/cfn-redis-coordination/demos/phase4-wake-queue-test-report.md +0 -82
  562. package/claude-assets/skills/cfn-redis-coordination/demos/test-bzpopmin-fix.sh +0 -274
  563. package/claude-assets/skills/cfn-redis-coordination/demos/test-cancel-swarm.sh +0 -0
  564. package/claude-assets/skills/cfn-redis-coordination/docs/migration/PHASE_3_REDIS_COORDINATION_COMPLETION_REPORT.md +0 -553
  565. package/claude-assets/skills/cfn-redis-coordination/jest.config.js +0 -23
  566. package/claude-assets/skills/cfn-redis-coordination/package-lock.json +0 -5272
  567. package/claude-assets/skills/cfn-redis-coordination/package.json +0 -45
  568. package/claude-assets/skills/cfn-redis-coordination/src/agent-logger.ts +0 -446
  569. package/claude-assets/skills/cfn-redis-coordination/src/agent-recovery.ts +0 -454
  570. package/claude-assets/skills/cfn-redis-coordination/src/completion-reporter.ts +0 -396
  571. package/claude-assets/skills/cfn-redis-coordination/src/context-manager.ts +0 -327
  572. package/claude-assets/skills/cfn-redis-coordination/src/index.ts +0 -82
  573. package/claude-assets/skills/cfn-redis-coordination/src/mode-detector.ts +0 -155
  574. package/claude-assets/skills/cfn-redis-coordination/src/redis/redis-client.ts +0 -305
  575. package/claude-assets/skills/cfn-redis-coordination/src/redis/redis-functions.ts +0 -283
  576. package/claude-assets/skills/cfn-redis-coordination/src/redis-client.ts +0 -654
  577. package/claude-assets/skills/cfn-redis-coordination/src/result-collector.ts +0 -437
  578. package/claude-assets/skills/cfn-redis-coordination/src/swarm-manager.ts +0 -494
  579. package/claude-assets/skills/cfn-redis-coordination/src/task-analyzer.ts +0 -404
  580. package/claude-assets/skills/cfn-redis-coordination/src/task-executor.ts +0 -423
  581. package/claude-assets/skills/cfn-redis-coordination/src/types.ts +0 -235
  582. package/claude-assets/skills/cfn-redis-coordination/src/waiting-coordinator.ts +0 -587
  583. package/claude-assets/skills/cfn-redis-coordination/store-success-criteria.sh +0 -85
  584. package/claude-assets/skills/cfn-redis-coordination/test-connection-attempts.js +0 -70
  585. package/claude-assets/skills/cfn-redis-coordination/test-mode-simple.js +0 -121
  586. package/claude-assets/skills/cfn-redis-coordination/test-redis-check.js +0 -84
  587. package/claude-assets/skills/cfn-redis-coordination/test-task-mode-redis.cjs +0 -391
  588. package/claude-assets/skills/cfn-redis-coordination/tests/coordination.test.ts +0 -788
  589. package/claude-assets/skills/cfn-redis-coordination/update-all-scripts.sh +0 -67
  590. package/claude-assets/skills/cfn-redis-data-extraction/SKILL.md +0 -442
  591. package/claude-assets/skills/cfn-redis-data-extraction/extract.sh +0 -306
  592. package/dist/coordination/index.js +0 -25
  593. package/dist/coordination/index.js.map +0 -1
  594. package/docs/BUG_19_MEMORY_LEAK_TASK_MODE.md +0 -405
  595. package/docs/MEMORY_CLEANUP_GUIDE.md +0 -358
  596. package/docs/MEMORY_LEAK_FIX_SUMMARY.md +0 -322
  597. package/docs/REDIS_CLEANUP_EXECUTIVE_SUMMARY.md +0 -319
  598. package/docs/REDIS_CLEANUP_VERIFICATION_REPORT.md +0 -574
  599. /package/.claude/skills/cfn-loop-orchestration/{inject-loop-context.sh → archive/legacy-bash/inject-loop-context.sh} +0 -0
  600. /package/.claude/skills/cfn-loop-orchestration/{monitor-execution.sh → archive/legacy-bash/monitor-execution.sh} +0 -0
  601. /package/.claude/skills/cfn-redis-coordination/{agent-log.sh → agent-log.sh.backup} +0 -0
  602. /package/.claude/skills/cfn-redis-coordination/{agent-recovery.sh → agent-recovery.sh.backup} +0 -0
  603. /package/.claude/skills/cfn-redis-coordination/{analyze-task-complexity.sh → analyze-task-complexity.sh.backup} +0 -0
  604. /package/.claude/skills/cfn-redis-coordination/bash-wrappers/{store-context.sh → store-context.sh.backup} +0 -0
  605. /package/.claude/skills/cfn-redis-coordination/{cancel-swarm.sh → cancel-swarm.sh.backup} +0 -0
  606. /package/.claude/skills/cfn-redis-coordination/{cfn-loop-exec.sh → cfn-loop-exec.sh.backup} +0 -0
  607. /package/.claude/skills/cfn-redis-coordination/{cfn-loop-relaunch.sh → cfn-loop-relaunch.sh.backup} +0 -0
  608. /package/.claude/skills/cfn-redis-coordination/{collect-confidence-scores.sh → collect-confidence-scores.sh.backup} +0 -0
  609. /package/.claude/skills/cfn-redis-coordination/{collect-results.sh → collect-results.sh.backup} +0 -0
  610. /package/.claude/skills/cfn-redis-coordination/{complete-swarm.sh → complete-swarm.sh.backup} +0 -0
  611. /package/.claude/skills/cfn-redis-coordination/{get-context.sh → get-context.sh.backup} +0 -0
  612. /package/.claude/skills/cfn-redis-coordination/{get-success-criteria.sh → get-success-criteria.sh.backup} +0 -0
  613. /package/.claude/skills/cfn-redis-coordination/{invoke-waiting-mode.sh → invoke-waiting-mode.sh.backup} +0 -0
  614. /package/.claude/skills/cfn-redis-coordination/{redis-cli-wrapper.sh → redis-cli-wrapper.sh.backup} +0 -0
  615. /package/.claude/skills/cfn-redis-coordination/{redis-functions.sh → redis-functions.sh.backup} +0 -0
  616. /package/.claude/skills/cfn-redis-coordination/{report-completion.sh → report-completion.sh.backup} +0 -0
  617. /package/.claude/skills/cfn-redis-coordination/{store-context.sh → store-context.sh.backup} +0 -0
  618. /package/claude-assets/skills/cfn-loop-orchestration/{inject-loop-context.sh → archive/legacy-bash/inject-loop-context.sh} +0 -0
  619. /package/claude-assets/skills/cfn-loop-orchestration/{monitor-execution.sh → archive/legacy-bash/monitor-execution.sh} +0 -0
  620. /package/claude-assets/skills/cfn-redis-coordination/{agent-log.sh → agent-log.sh.backup} +0 -0
  621. /package/claude-assets/skills/cfn-redis-coordination/{agent-recovery.sh → agent-recovery.sh.backup} +0 -0
  622. /package/claude-assets/skills/cfn-redis-coordination/{analyze-task-complexity.sh → analyze-task-complexity.sh.backup} +0 -0
  623. /package/claude-assets/skills/cfn-redis-coordination/bash-wrappers/{store-context.sh → store-context.sh.backup} +0 -0
  624. /package/claude-assets/skills/cfn-redis-coordination/{cancel-swarm.sh → cancel-swarm.sh.backup} +0 -0
  625. /package/claude-assets/skills/cfn-redis-coordination/{cfn-loop-exec.sh → cfn-loop-exec.sh.backup} +0 -0
  626. /package/claude-assets/skills/cfn-redis-coordination/{cfn-loop-relaunch.sh → cfn-loop-relaunch.sh.backup} +0 -0
  627. /package/claude-assets/skills/cfn-redis-coordination/{collect-confidence-scores.sh → collect-confidence-scores.sh.backup} +0 -0
  628. /package/claude-assets/skills/cfn-redis-coordination/{collect-results.sh → collect-results.sh.backup} +0 -0
  629. /package/claude-assets/skills/cfn-redis-coordination/{complete-swarm.sh → complete-swarm.sh.backup} +0 -0
  630. /package/claude-assets/skills/cfn-redis-coordination/{get-context.sh → get-context.sh.backup} +0 -0
  631. /package/claude-assets/skills/cfn-redis-coordination/{get-success-criteria.sh → get-success-criteria.sh.backup} +0 -0
  632. /package/claude-assets/skills/cfn-redis-coordination/{invoke-waiting-mode.sh → invoke-waiting-mode.sh.backup} +0 -0
  633. /package/claude-assets/skills/cfn-redis-coordination/{redis-cli-wrapper.sh → redis-cli-wrapper.sh.backup} +0 -0
  634. /package/claude-assets/skills/cfn-redis-coordination/{redis-functions.sh → redis-functions.sh.backup} +0 -0
  635. /package/claude-assets/skills/cfn-redis-coordination/{report-completion.sh → report-completion.sh.backup} +0 -0
  636. /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