claude-flow-novice 2.18.39 → 2.19.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 (117) hide show
  1. package/.claude/agents/SHARED_PROTOCOL.md +25 -1
  2. package/.claude/agents/cfn-dev-team/dev-ops/fly-io-specialist.md +418 -0
  3. package/.claude/agents/cfn-dev-team/developers/database/mem0-specialist.md +579 -0
  4. package/.claude/agents/cfn-dev-team/developers/database/memgraph-specialist.md +722 -0
  5. package/.claude/agents/cfn-dev-team/documentation/pseudocode.md +1 -1
  6. package/.claude/agents/cfn-dev-team/documentation/specification-agent.md +1 -1
  7. package/.claude/agents/cfn-dev-team/testers/tester.md +35 -0
  8. package/.claude/commands/{cfn-ruvector → cfn-codesearch}/cfn-codebase-reindex.md +4 -4
  9. package/.claude/commands/{cfn-ruvector → cfn-codesearch}/cfn-codebase-search.md +7 -7
  10. package/.claude/commands/{cfn-ruvector → cfn-codesearch}/cfn-detect-stale-docs.md +3 -3
  11. package/.claude/commands/{cfn-ruvector-search.md → cfn-codesearch-search.md} +7 -7
  12. package/.claude/commands/cfn-fix-errors.md +1 -1
  13. package/.claude/commands/cfn-loop-task.md +291 -291
  14. package/.claude/skills/{bulk-add-ruvector-instructions.sh → bulk-add-codesearch-instructions.sh} +12 -12
  15. package/.claude/skills/{cfn-local-ruvector-accelerator → cfn-codesearch}/AGENT_INTEGRATION_PATTERNS.md +20 -20
  16. package/.claude/skills/{cfn-local-ruvector-accelerator → cfn-codesearch}/AGENT_LIFECYCLE_INTEGRATION.md +11 -11
  17. package/.claude/skills/{cfn-local-ruvector-accelerator → cfn-codesearch}/Cargo.toml +9 -4
  18. package/.claude/skills/{cfn-local-ruvector-accelerator → cfn-codesearch}/EXTRACTION_EXAMPLES.md +6 -6
  19. package/.claude/skills/{cfn-local-ruvector-accelerator → cfn-codesearch}/IMMEDIATE_ACTION_REQUIRED.md +9 -9
  20. package/.claude/skills/{cfn-local-ruvector-accelerator → cfn-codesearch}/README.md +7 -7
  21. package/.claude/skills/{cfn-local-ruvector-accelerator → cfn-codesearch}/SCHEMA_V2_IMPLEMENTATION.md +1 -1
  22. package/.claude/skills/{cfn-local-ruvector-accelerator → cfn-codesearch}/SECURITY_IMPLEMENTATION.md +3 -3
  23. package/.claude/skills/{cfn-local-ruvector-accelerator → cfn-codesearch}/SECURITY_TESTING_COMPLETION.md +4 -4
  24. package/.claude/skills/{cfn-local-ruvector-accelerator → cfn-codesearch}/SKILL.md +31 -31
  25. package/.claude/skills/{cfn-local-ruvector-accelerator → cfn-codesearch}/analyze-agent-failures.sh +11 -11
  26. package/.claude/skills/{cfn-local-ruvector-accelerator → cfn-codesearch}/cfn-integration.sh +27 -27
  27. package/.claude/skills/{cfn-local-ruvector-accelerator → cfn-codesearch}/index-code.sh +11 -11
  28. package/.claude/skills/{cfn-local-ruvector-accelerator → cfn-codesearch}/index_all.sh +2 -2
  29. package/.claude/skills/{cfn-local-ruvector-accelerator → cfn-codesearch}/ingest-agent-transcript.sh +10 -10
  30. package/.claude/skills/{cfn-local-ruvector-accelerator/init-local-ruvector.sh → cfn-codesearch/init-local-codesearch.sh} +16 -16
  31. package/.claude/skills/{cfn-local-ruvector-accelerator → cfn-codesearch}/project-structure.md +10 -10
  32. package/.claude/skills/{cfn-local-ruvector-accelerator → cfn-codesearch}/query-local.sh +6 -6
  33. package/.claude/skills/{cfn-local-ruvector-accelerator → cfn-codesearch}/src/cli/index.rs +233 -4
  34. package/.claude/skills/{cfn-local-ruvector-accelerator → cfn-codesearch}/src/cli/init.rs +18 -18
  35. package/.claude/skills/{cfn-local-ruvector-accelerator → cfn-codesearch}/src/cli/query.rs +64 -3
  36. package/.claude/skills/{cfn-local-ruvector-accelerator → cfn-codesearch}/src/embeddings.rs +19 -5
  37. package/.claude/skills/{cfn-local-ruvector-accelerator → cfn-codesearch}/src/lib.rs +6 -4
  38. package/.claude/skills/{cfn-local-ruvector-accelerator → cfn-codesearch}/src/main.rs +35 -25
  39. package/.claude/skills/{cfn-local-ruvector-accelerator → cfn-codesearch}/src/paths.rs +19 -13
  40. package/.claude/skills/{cfn-local-ruvector-accelerator → cfn-codesearch}/src/query_v2.rs +3 -4
  41. package/.claude/skills/cfn-codesearch/src/store_pgvector.rs +301 -0
  42. package/.claude/skills/{cfn-local-ruvector-accelerator → cfn-codesearch}/src/store_v2.rs +12 -1
  43. package/.claude/skills/{cfn-local-ruvector-accelerator → cfn-codesearch}/test-agent-lifecycle-integration.sh +6 -6
  44. package/.claude/skills/{cfn-local-ruvector-accelerator/test-local-ruvector.sh → cfn-codesearch/test-local-codesearch.sh} +7 -7
  45. package/.claude/skills/{cfn-local-ruvector-accelerator → cfn-codesearch}/test_query_api.sh +2 -2
  46. package/.claude/skills/cfn-epic-creator/SKILL.md +110 -2
  47. package/.claude/skills/cfn-epic-creator/invoke.sh +120 -1
  48. package/.claude/skills/cfn-mdap-context-injection/SKILL.md +2 -2
  49. package/.claude/skills/cfn-mdap-context-injection/inject.sh +21 -21
  50. package/package.json +11 -11
  51. package/readme/feature-status.md +405 -0
  52. package/.claude/agents/docker-ts-fixer.md +0 -65
  53. /package/.claude/agents/cfn-dev-team/{testing → testers}/test-validation-agent.md +0 -0
  54. /package/.claude/{agents/cfn-dev-team/utility → cfn-extras/agents}/context-curator.md +0 -0
  55. /package/.claude/{agents/custom → cfn-extras/agents/custom-agents}/cfn-docker-expert.md +0 -0
  56. /package/.claude/{agents/custom → cfn-extras/agents/custom-agents}/cfn-loops-cli-expert.md +0 -0
  57. /package/.claude/{agents/custom → cfn-extras/agents/custom-agents}/cfn-redis-operations.md +0 -0
  58. /package/.claude/{agents/custom → cfn-extras/agents/custom-agents}/cfn-system-expert.md +0 -0
  59. /package/.claude/{agents/csuite → cfn-extras/agents/custom-agents}/cto-agent.md +0 -0
  60. /package/.claude/{agents/custom → cfn-extras/agents/custom-agents}/trigger-dev-expert.md +0 -0
  61. /package/.claude/{agents/cfn-dev-team/coordinators → cfn-extras/agents/deprecated-coordinators}/consensus-builder.md +0 -0
  62. /package/.claude/{agents/cfn-dev-team/coordinators → cfn-extras/agents/deprecated-coordinators}/multi-sprint-coordinator.md +0 -0
  63. /package/.claude/{agents → cfn-extras/agents/docker-team}/docker-coordinators/cfn-docker-v3-coordinator.md +0 -0
  64. /package/.claude/{agents/cfn-dev-team/dev-ops → cfn-extras/agents}/kubernetes-specialist.md +0 -0
  65. /package/.claude/{agents/cfn-dev-team/architecture → cfn-extras/agents}/planner.md +0 -0
  66. /package/.claude/skills/{cfn-local-ruvector-accelerator → cfn-codesearch}/.claude/hooks/SessionStart-cfn-build-ruvector.sh +0 -0
  67. /package/.claude/skills/{cfn-local-ruvector-accelerator → cfn-codesearch}/Cargo.toml.backup +0 -0
  68. /package/.claude/skills/{cfn-local-ruvector-accelerator → cfn-codesearch}/SECURITY_FINDINGS_SUMMARY.txt +0 -0
  69. /package/.claude/skills/{cfn-local-ruvector-accelerator → cfn-codesearch}/docs/EXECUTIVE_SUMMARY.txt +0 -0
  70. /package/.claude/skills/{cfn-local-ruvector-accelerator → cfn-codesearch}/docs/PHASE_4_QUERY_API.md +0 -0
  71. /package/.claude/skills/{cfn-local-ruvector-accelerator → cfn-codesearch}/docs/RUST_AST_EXTRACTOR_IMPLEMENTATION.md +0 -0
  72. /package/.claude/skills/{cfn-local-ruvector-accelerator → cfn-codesearch}/docs/TRANSACTION_MANAGEMENT.md +0 -0
  73. /package/.claude/skills/{cfn-local-ruvector-accelerator → cfn-codesearch}/docs/VALIDATION_FINDINGS.txt +0 -0
  74. /package/.claude/skills/{cfn-local-ruvector-accelerator → cfn-codesearch}/embeddings_manager.py.backup +0 -0
  75. /package/.claude/skills/{cfn-local-ruvector-accelerator → cfn-codesearch}/epic-ast-indexer.json +0 -0
  76. /package/.claude/skills/{cfn-local-ruvector-accelerator → cfn-codesearch}/index/index.bin +0 -0
  77. /package/.claude/skills/{cfn-local-ruvector-accelerator → cfn-codesearch}/index/metadata.json +0 -0
  78. /package/.claude/skills/{cfn-local-ruvector-accelerator → cfn-codesearch}/index-code.sh.backup +0 -0
  79. /package/.claude/skills/{cfn-local-ruvector-accelerator → cfn-codesearch}/query-agent-patterns.sh +0 -0
  80. /package/.claude/skills/{cfn-local-ruvector-accelerator → cfn-codesearch}/requirements.txt +0 -0
  81. /package/.claude/skills/{cfn-local-ruvector-accelerator → cfn-codesearch}/search_engine_v2.py.backup +0 -0
  82. /package/.claude/skills/{cfn-local-ruvector-accelerator → cfn-codesearch}/sqlite_store.py.backup +0 -0
  83. /package/.claude/skills/{cfn-local-ruvector-accelerator → cfn-codesearch}/src/cli/cleanup.rs +0 -0
  84. /package/.claude/skills/{cfn-local-ruvector-accelerator → cfn-codesearch}/src/cli/export.rs +0 -0
  85. /package/.claude/skills/{cfn-local-ruvector-accelerator → cfn-codesearch}/src/cli/find.rs +0 -0
  86. /package/.claude/skills/{cfn-local-ruvector-accelerator → cfn-codesearch}/src/cli/index_ast.rs +0 -0
  87. /package/.claude/skills/{cfn-local-ruvector-accelerator → cfn-codesearch}/src/cli/index_modified.rs +0 -0
  88. /package/.claude/skills/{cfn-local-ruvector-accelerator → cfn-codesearch}/src/cli/migration.rs +0 -0
  89. /package/.claude/skills/{cfn-local-ruvector-accelerator → cfn-codesearch}/src/cli/mod.rs +0 -0
  90. /package/.claude/skills/{cfn-local-ruvector-accelerator → cfn-codesearch}/src/cli/refs.rs +0 -0
  91. /package/.claude/skills/{cfn-local-ruvector-accelerator → cfn-codesearch}/src/cli/reset.rs +0 -0
  92. /package/.claude/skills/{cfn-local-ruvector-accelerator → cfn-codesearch}/src/cli/stats.rs +0 -0
  93. /package/.claude/skills/{cfn-local-ruvector-accelerator → cfn-codesearch}/src/extractors/mod.rs +0 -0
  94. /package/.claude/skills/{cfn-local-ruvector-accelerator → cfn-codesearch}/src/extractors/rust.rs +0 -0
  95. /package/.claude/skills/{cfn-local-ruvector-accelerator → cfn-codesearch}/src/extractors/rust_placeholder.rs +0 -0
  96. /package/.claude/skills/{cfn-local-ruvector-accelerator → cfn-codesearch}/src/extractors/text_fallback.rs +0 -0
  97. /package/.claude/skills/{cfn-local-ruvector-accelerator → cfn-codesearch}/src/extractors/typescript.rs +0 -0
  98. /package/.claude/skills/{cfn-local-ruvector-accelerator → cfn-codesearch}/src/extractors/typescript_full.rs +0 -0
  99. /package/.claude/skills/{cfn-local-ruvector-accelerator → cfn-codesearch}/src/main.rs.backup +0 -0
  100. /package/.claude/skills/{cfn-local-ruvector-accelerator → cfn-codesearch}/src/migration.rs +0 -0
  101. /package/.claude/skills/{cfn-local-ruvector-accelerator → cfn-codesearch}/src/migration_backup.rs +0 -0
  102. /package/.claude/skills/{cfn-local-ruvector-accelerator → cfn-codesearch}/src/migration_tx.rs +0 -0
  103. /package/.claude/skills/{cfn-local-ruvector-accelerator → cfn-codesearch}/src/migration_v2.rs +0 -0
  104. /package/.claude/skills/{cfn-local-ruvector-accelerator → cfn-codesearch}/src/path_validator.rs +0 -0
  105. /package/.claude/skills/{cfn-local-ruvector-accelerator → cfn-codesearch}/src/query_api.rs +0 -0
  106. /package/.claude/skills/{cfn-local-ruvector-accelerator → cfn-codesearch}/src/schema_v2.rs +0 -0
  107. /package/.claude/skills/{cfn-local-ruvector-accelerator → cfn-codesearch}/src/search_engine.rs +0 -0
  108. /package/.claude/skills/{cfn-local-ruvector-accelerator → cfn-codesearch}/src/security_tests.rs +0 -0
  109. /package/.claude/skills/{cfn-local-ruvector-accelerator → cfn-codesearch}/src/sqlite_store.rs +0 -0
  110. /package/.claude/skills/{cfn-local-ruvector-accelerator → cfn-codesearch}/src/store_v2_backup.rs +0 -0
  111. /package/.claude/skills/{cfn-local-ruvector-accelerator → cfn-codesearch}/src/store_v2_fixed.rs +0 -0
  112. /package/.claude/skills/{cfn-local-ruvector-accelerator → cfn-codesearch}/src/store_v2_tx.rs +0 -0
  113. /package/.claude/skills/{cfn-local-ruvector-accelerator → cfn-codesearch}/src/test_schema.rs +0 -0
  114. /package/.claude/skills/{cfn-local-ruvector-accelerator → cfn-codesearch}/src/transaction_tests.rs +0 -0
  115. /package/.claude/skills/{cfn-local-ruvector-accelerator → cfn-codesearch}/test_ast_indexing.rs +0 -0
  116. /package/.claude/skills/{cfn-local-ruvector-accelerator → cfn-codesearch}/test_schema.sql +0 -0
  117. /package/.claude/skills/{cfn-local-ruvector-accelerator → cfn-codesearch}/test_schema_v2.sql +0 -0
@@ -1,359 +1,359 @@
1
1
  ---
2
2
  description: "Execute CFN Loop in Task Mode with direct agent spawning (visible in main chat)"
3
- argument-hint: "<task description> [--mode=mvp|standard|enterprise] [--max-iterations=n] [--ace-reflect]"
4
- allowed-tools: ["Task", "TodoWrite", "Read", "Bash", "SlashCommand"]
3
+ argument-hint: "<task description> [--mode=mvp|standard|enterprise] [--max-iterations=n]"
4
+ allowed-tools: ["Task", "TodoWrite", "Read", "Bash", "Grep", "Glob"]
5
5
  ---
6
6
 
7
- # CFN Loop Task Mode - Direct Agent Spawning
7
+ # CFN Loop Task Mode
8
8
 
9
- **Version:** 1.4.0 | **Date:** 2025-12-25 | **Status:** Production Ready
9
+ **You are the coordinator. You MUST execute this loop until PROCEED or max iterations.**
10
10
 
11
- ## Quick Overview
11
+ ---
12
+
13
+ ## ⚡ AUTONOMOUS PROGRESSION (CRITICAL)
12
14
 
13
- Task Mode spawns agents directly in main chat with full visibility. Uses test-driven gate validation (not confidence scores).
15
+ **DO NOT stop to ask questions. Keep progressing by launching agents for next steps.**
14
16
 
15
- ### Autonomous Progression (MANDATORY)
17
+ | Stop For | Keep Going For |
18
+ |----------|----------------|
19
+ | Major regression (tests went from passing to failing) | Minor test failures (iterate to fix) |
20
+ | Structural mismatch (wrong architecture/framework) | Missing files (create them) |
21
+ | Security vulnerability found | Code style issues |
22
+ | Corrupted state requiring manual recovery | Ambiguous implementation details |
23
+ | Unclear requirements (feedback for epic improvement) | |
16
24
 
17
- **Keep moving forward. Only pause for critical issues.**
25
+ **Rules:**
26
+ - If uncertain about approach, pick the simpler option and iterate
27
+ - Spawn agents to investigate unknowns instead of asking user
28
+ - Only escalate to user for irreversible decisions or access issues
29
+ - Test failures are expected - that's why we iterate
18
30
 
19
- - **AUTO-PROGRESS:** After each step completes, immediately spawn agents for the next step
20
- - **NO WAITING:** Do not wait for user confirmation between iterations or steps
21
- - **KEEP SPAWNING:** Gate fail → spawn Loop 3 again. Gate pass → spawn validators. Validators pass → spawn next task.
31
+ ---
22
32
 
23
- **STOP FOR USER FEEDBACK ONLY WHEN:**
24
- 1. **Corruption/rollback needed** - Commits broke the codebase beyond repair, need git rollback
25
- 2. **Architectural mismatch** - RCA identifies fundamental design conflicts that require rewrite
26
- 3. **Critical security issue** - Credentials exposed, injection vulnerabilities found
27
- 4. **External system failure** - CI/CD down, package registry unavailable, API deprecated
33
+ ## 🎯 0/0 POLICY (EXIT CRITERIA)
28
34
 
29
- **DO NOT STOP FOR:**
30
- - Test regressions (loop fixes them - keep iterating)
31
- - Test pass rate drops (keep iterating, RCA will analyze)
32
- - Coverage gaps (keep iterating)
33
- - Single file conflicts (RCA handles it)
34
- - Validator rejections (incorporate feedback and continue)
35
- - Max iterations reached (report results but don't block)
35
+ **Before PROCEED decision, verify:**
36
36
 
37
- ### When to Use Task Mode
38
- - **Debugging** - Need to see agent thought process
39
- - **Learning** - Understanding how agents work
40
- - **Complex coordination** - Require custom agent interactions
37
+ | Metric | Requirement |
38
+ |--------|-------------|
39
+ | Compilation errors (scoped work) | **0** |
40
+ | Compilation errors (scoped tests) | **0** |
41
+ | Todos remaining (scoped work) | **0** |
42
+
43
+ ```bash
44
+ # Verify 0/0 before PROCEED
45
+ npm run typecheck 2>&1 | grep -c "error" || echo "0" # Must be 0
46
+ npm run build 2>&1 | grep -c "error" || echo "0" # Must be 0
47
+ # Review TodoWrite - all scoped items must be completed
48
+ ```
49
+
50
+ **If not 0/0:** ITERATE, do not PROCEED. Fix errors before next gate check.
41
51
 
42
52
  ---
43
53
 
44
- ## TDD Gate Enforcement (MANDATORY)
54
+ ## MANDATORY: Initialize State Tracking
45
55
 
46
- **Gate checks are based on TEST PASS RATES, not confidence scores.**
56
+ **IMMEDIATELY create this todo list using TodoWrite:**
47
57
 
48
- After Loop 3 agents complete, run gate validation:
49
- ```bash
50
- # Get test results
51
- TEST_OUTPUT=$(npm test 2>&1 || true)
52
- PASS_COUNT=$(echo "$TEST_OUTPUT" | grep -oP '\d+(?= passed)' | head -1 || echo "0")
53
- TOTAL_COUNT=$(echo "$TEST_OUTPUT" | grep -oP '\d+(?= total)' | head -1 || echo "1")
54
-
55
- # Calculate pass rate
56
- if [ "$TOTAL_COUNT" -gt 0 ]; then
57
- PASS_RATE=$(echo "scale=4; $PASS_COUNT / $TOTAL_COUNT" | bc)
58
- else
59
- PASS_RATE="0"
60
- fi
61
-
62
- # Validate gate
63
- npx ts-node .claude/skills/cfn-loop-orchestration-v2/lib/orchestrator/src/helpers/gate-check.ts \
64
- --pass-rate "$PASS_RATE" \
65
- --mode "$MODE"
58
+ ```
59
+ 1. [pending] Parse arguments and initialize task
60
+ 2. [pending] LOOP 3: Spawn implementation agents
61
+ 3. [pending] GATE CHECK: Run tests and validate pass rate
62
+ 4. [pending] LOOP 2: Spawn validator agents (ONLY if gate passed)
63
+ 5. [pending] PRODUCT OWNER: Review validator feedback, filter out-of-scope, decide
66
64
  ```
67
65
 
68
- ### Gate Thresholds
69
- | Mode | Pass Rate Threshold |
70
- |------|-------------------|
71
- | MVP | 70% |
72
- | Standard | 95% |
73
- | Enterprise | 98% |
66
+ **You MUST update todo status as you complete each phase. Do NOT skip phases.**
74
67
 
75
- **CRITICAL:** Validators MUST NOT start until gate check passes.
68
+ ---
69
+
70
+ ## THE LOOP (Execute Until Done)
71
+
72
+ ```
73
+ ┌─────────────────────────────────────────────────────────────┐
74
+ │ ITERATION = 1 │
75
+ │ │
76
+ │ WHILE iteration <= MAX_ITERATIONS: │
77
+ │ ├── LOOP 3: Spawn implementation agents │
78
+ │ ├── GATE CHECK: Run npm test, calculate pass rate │
79
+ │ │ ├── IF pass_rate < threshold: iteration++, CONTINUE│
80
+ │ │ └── IF pass_rate >= threshold: PROCEED to Loop 2 │
81
+ │ ├── LOOP 2: Spawn validator agents │
82
+ │ ├── PRODUCT OWNER: Review validator feedback │
83
+ │ │ ├── Filter out-of-scope validator requirements │
84
+ │ │ ├── PROCEED: In-scope work complete, EXIT │
85
+ │ │ ├── ITERATE: In-scope issues remain, CONTINUE │
86
+ │ │ └── ABORT: Corruption/security only, EXIT │
87
+ │ └── END WHILE │
88
+ │ │
89
+ │ MAX_ITERATIONS reached: Report and EXIT │
90
+ └─────────────────────────────────────────────────────────────┘
91
+ ```
76
92
 
77
93
  ---
78
94
 
79
- ## Post-Edit Pipeline (MANDATORY)
95
+ ## PHASE 1: Parse Arguments
96
+
97
+ **Mark todo #1 as in_progress, then execute:**
80
98
 
81
- After ANY file modification, run:
82
99
  ```bash
83
- ./.claude/hooks/cfn-invoke-post-edit.sh "$FILE_PATH" --agent-id "$AGENT_ID"
100
+ # Parse from $ARGUMENTS
101
+ MODE="standard" # or mvp, enterprise
102
+ MAX_ITERATIONS=10
103
+ TASK_ID="cfn-task-$(date +%s)-${RANDOM}"
104
+ ITERATION=1
84
105
  ```
85
106
 
86
- Or if using project-local pipeline:
87
- ```bash
88
- node config/hooks/post-edit-pipeline.js "$FILE" --agent-id "${AGENT_ID:-hook}"
107
+ | Mode | Gate Threshold | Consensus Threshold |
108
+ |------|----------------|---------------------|
109
+ | mvp | 70% | 80% |
110
+ | standard | 95% | 90% |
111
+ | enterprise | 98% | 95% |
112
+
113
+ **Mark todo #1 as completed. Proceed to Phase 2.**
114
+
115
+ ---
116
+
117
+ ## PHASE 2: LOOP 3 - Implementation Agents
118
+
119
+ **Mark todo #2 as in_progress.**
120
+
121
+ **Spawn using Task tool with subagent_type="backend-developer":**
122
+
123
+ ```
124
+ TASK: Implement for iteration ${ITERATION}: ${TASK_DESCRIPTION}
125
+
126
+ REQUIREMENTS:
127
+ 1. Write tests FIRST (TDD)
128
+ 2. Implement to make tests pass
129
+ 3. Run: npm test
130
+ 4. Report: { "tests_passed": N, "tests_total": M, "files_modified": [...] }
131
+
132
+ AGENT_ID: loop3-impl-${TASK_ID}-iter${ITERATION}
89
133
  ```
90
134
 
135
+ **WAIT for agent to complete and return results.**
136
+
137
+ **Mark todo #2 as completed. Proceed to Phase 3.**
138
+
91
139
  ---
92
140
 
93
- ## Execution Instructions (AUTO-EXECUTE)
141
+ ## PHASE 3: GATE CHECK (Mandatory Before Loop 2)
142
+
143
+ **Mark todo #3 as in_progress.**
144
+
145
+ **YOU MUST RUN THIS - DO NOT SKIP:**
94
146
 
95
- **Step 1: Parse Arguments**
96
147
  ```bash
97
- TASK_DESCRIPTION="$ARGUMENTS"
98
- TASK_DESCRIPTION=$(echo "$TASK_DESCRIPTION" | sed 's/--mode[[:space:]]*[a-zA-Z]*//' | sed 's/--max-iterations[[:space:]]*[0-9]*//' | xargs)
148
+ # Run tests
149
+ npm test 2>&1 | tee /tmp/test-output-${TASK_ID}.txt
99
150
 
100
- MODE="standard"
101
- MAX_ITERATIONS=10
151
+ # Parse results (adjust grep pattern for your test runner)
152
+ PASS_COUNT=$(grep -oP '\d+(?= pass)' /tmp/test-output-${TASK_ID}.txt | head -1 || echo 0)
153
+ TOTAL_COUNT=$(grep -oP '\d+(?= (test|spec))' /tmp/test-output-${TASK_ID}.txt | head -1 || echo 1)
154
+ PASS_RATE=$(echo "scale=2; $PASS_COUNT / $TOTAL_COUNT" | bc)
102
155
 
103
- for arg in $ARGUMENTS; do
104
- case $arg in
105
- --mode=*) MODE="${arg#*=}" ;;
106
- --max-iterations=*) MAX_ITERATIONS="${arg#*=}" ;;
107
- esac
108
- done
156
+ echo "Gate Check: ${PASS_COUNT}/${TOTAL_COUNT} = ${PASS_RATE}"
157
+ ```
109
158
 
110
- if [[ ! "$MODE" =~ ^(mvp|standard|enterprise)$ ]]; then
111
- echo "ERROR: Invalid mode '$MODE'. Must be: mvp, standard, enterprise"
112
- exit 1
113
- fi
159
+ **DECISION POINT:**
114
160
 
115
- TASK_ID="cfn-task-$(date +%s%N | tail -c 7)-${RANDOM}"
116
- echo "Task ID: $TASK_ID | Mode: $MODE | Max Iterations: $MAX_ITERATIONS"
161
+ ```
162
+ IF pass_rate >= threshold:
163
+ → Mark todo #3 completed
164
+ → PROCEED to Phase 4 (Loop 2)
165
+
166
+ IF pass_rate < threshold:
167
+ → Log: "Gate FAILED (${PASS_RATE} < ${THRESHOLD}). Iterating..."
168
+ → ITERATION = ITERATION + 1
169
+ → IF iteration > MAX_ITERATIONS: Report failure and EXIT
170
+ → Reset todo #2 to pending, mark #3 as pending
171
+ → GO BACK TO PHASE 2 (spawn Loop 3 again with failure context)
117
172
  ```
118
173
 
119
- **Step 2: Spawn Loop 3 Agents (Implementation)**
120
- ```bash
121
- case $MODE in
122
- "mvp")
123
- Task("backend-developer", `
124
- AGENT_ID="backend-dev-${TASK_ID}"
125
-
126
- TASK: Implement MVP for: ${TASK_DESCRIPTION}
127
-
128
- TDD REQUIREMENTS (MANDATORY):
129
- 1. Write tests BEFORE implementation (Red phase)
130
- 2. Implement to make tests pass (Green phase)
131
- 3. Refactor while keeping tests green
132
- 4. Run: npm test -- --reporter=json after implementation
133
- 5. Report actual pass/fail counts, NOT confidence scores
134
-
135
- POST-EDIT (MANDATORY):
136
- After each file edit, run:
137
- ./.claude/hooks/cfn-invoke-post-edit.sh "$FILE_PATH" --agent-id "$AGENT_ID"
138
-
139
- RETURN FORMAT:
140
- {
141
- "tests_passed": <number>,
142
- "tests_total": <number>,
143
- "pass_rate": <0.0-1.0>,
144
- "files_created": [...],
145
- "files_modified": [...]
146
- }
147
- `)
148
- ;;
149
-
150
- "standard"|"enterprise")
151
- Task("backend-developer", `
152
- AGENT_ID="backend-dev-${TASK_ID}"
153
-
154
- TASK: Implement production solution for: ${TASK_DESCRIPTION}
155
-
156
- TDD REQUIREMENTS (MANDATORY - London School):
157
- 1. Write unit tests with mocks FIRST
158
- 2. Write integration tests for component interactions
159
- 3. Implement to make all tests pass
160
- 4. Achieve ${MODE === 'standard' ? '80' : '95'}% coverage minimum
161
- 5. Run: npm test -- --reporter=json after implementation
162
- 6. Report actual pass/fail counts, NOT confidence scores
163
-
164
- POST-EDIT (MANDATORY):
165
- After each file edit, run:
166
- ./.claude/hooks/cfn-invoke-post-edit.sh "$FILE_PATH" --agent-id "$AGENT_ID"
167
-
168
- RETURN FORMAT:
169
- {
170
- "tests_passed": <number>,
171
- "tests_total": <number>,
172
- "pass_rate": <0.0-1.0>,
173
- "coverage_percent": <number>,
174
- "files_created": [...],
175
- "files_modified": [...]
176
- }
177
- `)
178
- ;;
179
- esac
174
+ **DO NOT proceed to Loop 2 if gate failed. ITERATE.**
175
+
176
+ ---
177
+
178
+ ## PHASE 4: LOOP 2 - Validator Agents
179
+
180
+ **Mark todo #4 as in_progress.**
181
+
182
+ **ONLY execute this phase if Gate Check passed.**
183
+
184
+ **Spawn validators in parallel using Task tool:**
185
+
186
+ **Validator 1: code-reviewer**
180
187
  ```
188
+ TASK: Review implementation for: ${TASK_DESCRIPTION}
181
189
 
182
- **Step 3: Run Gate Check (BEFORE validators)**
183
- ```bash
184
- echo "Running gate check..."
190
+ CHECKLIST:
191
+ - [ ] Tests exist and pass
192
+ - [ ] No hardcoded secrets
193
+ - [ ] Code follows project patterns
185
194
 
186
- # HARD CAP: Max 10 iterations regardless of mode
187
- MAX_ITERATIONS=10
195
+ Return: PASS or FAIL with findings
196
+ AGENT_ID: loop2-reviewer-${TASK_ID}
197
+ ```
188
198
 
189
- # Parse agent output for test results
190
- TESTS_PASSED=${LOOP3_RESULT.tests_passed:-0}
191
- TESTS_TOTAL=${LOOP3_RESULT.tests_total:-1}
192
- PASS_RATE=$(echo "scale=4; $TESTS_PASSED / $TESTS_TOTAL" | bc)
193
-
194
- # Run gate validation
195
- GATE_RESULT=$(npx ts-node .claude/skills/cfn-loop-orchestration-v2/lib/orchestrator/src/helpers/gate-check.ts \
196
- --pass-rate "$PASS_RATE" \
197
- --mode "$MODE" 2>&1)
198
-
199
- if echo "$GATE_RESULT" | grep -q '"passed": false'; then
200
- echo "GATE FAILED - Iterating Loop 3"
201
- ITERATION=$((ITERATION + 1))
202
-
203
- # Test regressions are NOT a stop condition - the loop fixes them
204
- # Only stop for: corruption needing rollback, architectural mismatch, security issues
205
- echo "Pass rate: ${PASS_RATE} - Loop will continue iterating to fix"
206
-
207
- # After 3 failed iterations, invoke root cause analysis
208
- if [ $ITERATION -eq 3 ]; then
209
- echo "3 iterations failed - Spawning root cause analyst..."
210
-
211
- Task("root-cause-analyst", `
212
- AGENT_ID="rca-${TASK_ID}"
213
-
214
- TASK: Analyze why Loop 3 implementation keeps failing for: ${TASK_DESCRIPTION}
215
-
216
- INVESTIGATION SCOPE:
217
- 1. Review test failures from previous iterations
218
- 2. Identify blocking patterns (missing dependencies, architectural issues, incorrect assumptions)
219
- 3. Check for circular dependencies or integration conflicts
220
- 4. Analyze error logs and stack traces
221
-
222
- REQUIRED OUTPUT:
223
- {
224
- "root_causes": [
225
- {"issue": "<description>", "severity": "critical|high|medium", "fix": "<specific solution>"}
226
- ],
227
- "recommended_approach": "<concrete implementation strategy>",
228
- "files_to_modify": [...],
229
- "tests_to_add": [...],
230
- "blockers_to_remove": [...]
231
- }
232
-
233
- This analysis will be passed to the next Loop 3 iteration to prevent repeated failures.
234
- `)
235
-
236
- # Store RCA findings for next iteration
237
- RCA_FINDINGS=${RCA_RESULT}
238
- echo "Root cause analysis complete. Findings will guide next iteration."
239
- fi
240
-
241
- if [ $ITERATION -lt $MAX_ITERATIONS ]; then
242
- # Spawn Loop 3 again with failure context (and RCA findings if available)
243
- if [ -n "$RCA_FINDINGS" ]; then
244
- echo "Re-running Loop 3 with root cause analysis guidance..."
245
- # RCA_FINDINGS passed to Loop 3 agents in next iteration
246
- fi
247
- continue
248
- else
249
- echo "Max iterations (10) reached. Gate still failing."
250
- exit 1
251
- fi
252
- fi
253
-
254
- echo "GATE PASSED - Proceeding to validators"
199
+ **Validator 2: tester**
255
200
  ```
201
+ TASK: Validate test coverage for: ${TASK_DESCRIPTION}
256
202
 
257
- **Step 4: Spawn Loop 2 Validators (ONLY after gate passes)**
258
- ```bash
259
- Task("code-reviewer", `
260
- AGENT_ID="reviewer-${TASK_ID}"
203
+ Execute: npm test -- --coverage
204
+ Return: { "pass": true/false, "coverage": N%, "findings": [...] }
205
+ AGENT_ID: loop2-tester-${TASK_ID}
206
+ ```
261
207
 
262
- TASK: Validate implementation for: ${TASK_DESCRIPTION}
208
+ **Collect results from both validators.**
263
209
 
264
- VALIDATION CHECKLIST:
265
- - [ ] Tests exist for all new code
266
- - [ ] Tests follow TDD pattern (written before implementation)
267
- - [ ] Coverage meets threshold for ${MODE} mode
268
- - [ ] No hardcoded secrets or credentials
269
- - [ ] Post-edit hooks were invoked
210
+ **Mark todo #4 as completed. Proceed to Phase 5.**
270
211
 
271
- Return: PASS or FAIL with specific findings
272
- `)
212
+ ---
273
213
 
274
- Task("tester", `
275
- AGENT_ID="tester-${TASK_ID}"
214
+ ## PHASE 5: Product Owner Decision
276
215
 
277
- TASK: Run comprehensive tests for: ${TASK_DESCRIPTION}
216
+ **Mark todo #5 as in_progress.**
278
217
 
279
- Execute:
280
- 1. npm test -- --coverage
281
- 2. Report pass/fail counts
282
- 3. Report coverage percentages
218
+ **Spawn Product Owner agent using Task tool with subagent_type="product-owner":**
283
219
 
284
- Return: Test report with actual metrics, not estimates
285
- `)
220
+ ```
221
+ TASK: Review validator feedback and make scope-aware decision
222
+
223
+ CONTEXT:
224
+ - Task: ${TASK_DESCRIPTION}
225
+ - Mode: ${MODE}
226
+ - Iteration: ${ITERATION}
227
+ - Gate pass rate: ${PASS_RATE}
228
+ - Epic file: ${EPIC_FILE_PATH} (if applicable)
229
+
230
+ VALIDATOR FEEDBACK:
231
+ ${VALIDATOR_1_FEEDBACK}
232
+ ${VALIDATOR_2_FEEDBACK}
233
+
234
+ YOUR RESPONSIBILITIES:
235
+ 1. Review each validator finding
236
+ 2. Classify each finding as IN-SCOPE or OUT-OF-SCOPE
237
+ 3. OUT-OF-SCOPE items: Log for backlog, do NOT require iteration
238
+ 4. IN-SCOPE items: Determine if they block PROCEED
239
+ 5. **EPIC CONSISTENCY CHECK**: Identify naming/reference mismatches in epic document
240
+
241
+ EPIC CONSISTENCY CHECK:
242
+ - Compare implemented names (files, modules, functions) against epic references
243
+ - Flag mismatches (e.g., phase 1 creates "AuthService" but phase 3 references "AuthenticationService")
244
+ - If mismatches found: Update epic document to match implementation
245
+ - Document all corrections in epic_corrections field
246
+
247
+ DECISION CRITERIA:
248
+ - PROCEED: All in-scope requirements met, tests pass, no blocking issues
249
+ - ITERATE: In-scope issues remain that need fixing
250
+ - ABORT: Only for corruption, security vulnerabilities, or architectural dead-ends
251
+
252
+ RETURN FORMAT:
253
+ {
254
+ "decision": "PROCEED" | "ITERATE" | "ABORT",
255
+ "in_scope_findings": [...],
256
+ "out_of_scope_findings": [...],
257
+ "reasoning": "...",
258
+ "iteration_guidance": "..." (if ITERATE),
259
+ "epic_corrections": [
260
+ {"location": "Phase 3, step 2", "was": "XY", "now": "X", "reason": "Match phase 1 implementation"}
261
+ ]
262
+ }
263
+
264
+ AGENT_ID: product-owner-${TASK_ID}-iter${ITERATION}
286
265
  ```
287
266
 
288
- **Step 5: Product Owner Decision**
289
- ```bash
290
- # Collect validator results
291
- VALIDATOR_PASS_COUNT=0
292
- VALIDATOR_TOTAL=2
293
-
294
- for result in "${VALIDATOR_RESULTS[@]}"; do
295
- if echo "$result" | grep -qi "PASS"; then
296
- VALIDATOR_PASS_COUNT=$((VALIDATOR_PASS_COUNT + 1))
297
- fi
298
- done
299
-
300
- CONSENSUS_RATE=$(echo "scale=2; $VALIDATOR_PASS_COUNT / $VALIDATOR_TOTAL" | bc)
301
-
302
- # Mode-specific consensus thresholds
303
- case $MODE in
304
- "mvp") CONSENSUS_THRESHOLD="0.80" ;;
305
- "standard") CONSENSUS_THRESHOLD="0.90" ;;
306
- "enterprise") CONSENSUS_THRESHOLD="0.95" ;;
307
- esac
308
-
309
- # AUTONOMOUS PROGRESSION: Default to ITERATE, rarely ABORT
310
- if (( $(echo "$CONSENSUS_RATE >= $CONSENSUS_THRESHOLD" | bc -l) )); then
311
- echo "PROCEED - Consensus reached ($CONSENSUS_RATE >= $CONSENSUS_THRESHOLD)"
312
- # Immediately spawn next task if queued
313
- else
314
- echo "ITERATE - Consensus not met ($CONSENSUS_RATE < $CONSENSUS_THRESHOLD)"
315
- # Auto-continue to next iteration - DO NOT STOP
316
- # Loop back to Step 2 immediately
317
- fi
318
-
319
- # ABORT CONDITIONS (RARE - only use when truly unrecoverable):
320
- # - Fundamental architectural mismatch that RCA confirms cannot be fixed
321
- # - Security vulnerability that cannot be patched without full rewrite
322
- # - External dependency completely unavailable (API deprecated, package removed)
323
- #
324
- # DO NOT ABORT FOR:
325
- # - Test failures (iterate)
326
- # - Coverage gaps (iterate)
327
- # - Validator rejections (iterate with feedback)
328
- # - Performance issues (iterate with optimization)
267
+ **If epic_corrections returned:** Update the epic file to fix inconsistencies before next iteration.
268
+
269
+ **WAIT for Product Owner agent to return decision.**
270
+
271
+ **Handle Decision:**
272
+
329
273
  ```
274
+ IF decision == "PROCEED":
275
+ → Mark todo #5 completed
276
+ → Report success: "Task complete. Out-of-scope items logged to backlog."
277
+ → EXIT
278
+
279
+ IF decision == "ITERATE":
280
+ → Log: "PO requested iteration. In-scope issues: ${IN_SCOPE_FINDINGS}"
281
+ → ITERATION = ITERATION + 1
282
+ → IF iteration > MAX_ITERATIONS: Report and EXIT
283
+ → Reset todos #2-#5 to pending
284
+ → Include PO's iteration_guidance in next Loop 3 context
285
+ → GO BACK TO PHASE 2
286
+
287
+ IF decision == "ABORT":
288
+ → Log: "PO aborted: ${REASONING}"
289
+ → Report failure with reasoning
290
+ → EXIT
291
+ ```
292
+
293
+ **The Product Owner is the ONLY agent that can approve PROCEED or request ABORT.**
330
294
 
331
295
  ---
332
296
 
333
- ## Validation Flow Summary
297
+ ## Iteration Context Injection
298
+
299
+ **When iterating, include this context for Loop 3 agents:**
300
+
301
+ ```
302
+ PREVIOUS ITERATION FAILED:
303
+ - Iteration: ${ITERATION - 1}
304
+ - Gate pass rate: ${PASS_RATE}
305
+ - Validator feedback: ${FEEDBACK}
306
+ - Files with issues: ${PROBLEM_FILES}
334
307
 
335
- 1. **Loop 3 Gate:** Test pass rate must meet mode threshold before validators start
336
- 2. **Root Cause Analysis:** After 3 failed iterations, `root-cause-analyst` agent investigates blockers
337
- 3. **Loop 2 Validators:** Need access to Loop 3 outputs, tests, and logs
338
- 4. **Product Owner Decision:** Auto-progress; ABORT is rare (corruption/rollback only)
339
- 5. **Gate Failure:** Auto-iterate Loop 3 (max 10 iterations) - test regressions are NOT a stop condition
340
- 6. **Gate Pass:** Auto-proceed to validators
341
- 7. **Decision Outcomes:** PROCEED (done), ITERATE (auto-repeat), ABORT (rare - corruption/security only)
308
+ FIX THESE SPECIFIC ISSUES before re-running tests.
309
+ ```
342
310
 
343
- **Stop conditions:** Corruption needing rollback, architectural mismatch requiring rewrite, security issues, external system failures. Test failures/regressions are handled by the loop.
311
+ **After 3 failed iterations, spawn root-cause-analyst before next Loop 3:**
312
+ ```
313
+ Task(subagent_type="root-cause-analyst", prompt="Analyze repeated failures...")
314
+ ```
344
315
 
345
316
  ---
346
317
 
347
- ## Related Documentation
318
+ ## Quick Reference
319
+
320
+ | Phase | What Happens | Next If Success | Next If Fail |
321
+ |-------|--------------|-----------------|--------------|
322
+ | 1. Parse | Initialize vars | → Phase 2 | N/A |
323
+ | 2. Loop 3 | Implementation agents | → Phase 3 | Retry |
324
+ | 3. Gate | Test pass rate check | → Phase 4 | → Phase 2 (iterate) |
325
+ | 4. Loop 2 | Validator agents | → Phase 5 | Retry |
326
+ | 5. PO | Scope filter + decision | EXIT (PROCEED) | → Phase 2 (iterate) |
327
+
328
+ **Product Owner Role:**
329
+ - Filters validator feedback into IN-SCOPE vs OUT-OF-SCOPE
330
+ - OUT-OF-SCOPE items go to backlog, don't block PROCEED
331
+ - Only IN-SCOPE issues can trigger ITERATE
332
+ - ABORT is rare (corruption, security, dead-end architecture)
333
+ - **Epic consistency**: Fixes naming mismatches between phases (e.g., "X" vs "XY")
334
+
335
+ ---
348
336
 
349
- - **Full Task Mode Guide**: `.claude/commands/cfn-loop/cfn-loop-task.md`
350
- - **CLI Mode Guide**: `.claude/commands/cfn-loop/cfn-loop-cli.md`
351
- - **Gate Check Implementation**: `.claude/skills/cfn-loop-orchestration-v2/lib/orchestrator/src/helpers/gate-check.ts`
337
+ ## Reminders
338
+
339
+ - **DO NOT skip Gate Check** - Phase 3 is mandatory after every Loop 3
340
+ - **DO NOT spawn Loop 2 if gate failed** - Iterate Loop 3 instead
341
+ - **DO NOT skip Product Owner** - Only PO can approve PROCEED
342
+ - **DO NOT iterate on out-of-scope items** - PO filters these to backlog
343
+ - **DO NOT stop on test failures** - That's what iteration fixes
344
+ - **DO NOT ask the user questions** - Make reasonable assumptions and iterate
345
+ - **DO update todos** - This tracks your state as coordinator
346
+ - **DO pass validator feedback to PO** - PO needs full context to decide
347
+ - **DO inject PO guidance into next iteration** - Use iteration_guidance from PO
348
+ - **DO spawn agents to investigate unknowns** - Instead of asking user
349
+
350
+ **When to escalate to user (ONLY these cases):**
351
+ - Access denied / permission errors
352
+ - Irreversible destructive action needed
353
+ - Major regression detected (tests were passing, now failing)
354
+ - Structural mismatch with existing codebase
355
+ - Unclear requirements (helps improve epic creation process)
352
356
 
353
357
  ---
354
358
 
355
- **Version History:**
356
- - v1.4.0 (2025-12-25) - Hard cap 10 iterations for all modes; root cause analyst after 3 failures
357
- - v1.3.0 (2025-12-14) - Fixed to use test-based gate checks, not confidence scores
358
- - v1.2.0 (2025-12-08) - Added TDD enforcement
359
- - v1.1.0 (2025-12-01) - Added RuVector integration
359
+ **Version:** 2.2.0 | **Date:** 2026-01-13 | Added 0/0 policy, epic consistency check, autonomous progression