diff --git a/src/bmm/workflows/4-implementation/batch-super-dev/instructions.md b/src/bmm/workflows/4-implementation/batch-super-dev/instructions.md index 230ccdab..c7fd4498 100644 --- a/src/bmm/workflows/4-implementation/batch-super-dev/instructions.md +++ b/src/bmm/workflows/4-implementation/batch-super-dev/instructions.md @@ -895,11 +895,20 @@ Enter number (2-10) or 'all': ✅ Implementation complete: {{story_key}} - Execute Step 4.5: Smart Story Reconciliation - Load reconciliation instructions: {installed_path}/step-4.5-reconcile-story-status.md - Execute reconciliation with story_key={{story_key}} + ORCHESTRATOR: You must execute reconciliation directly using Bash/Read/Edit tools. + Do NOT delegate this to an agent. YOU do it. - + + 1. Use Bash: `git log -3 --oneline | grep "{{story_key}}"` to find commit + 2. Use Bash: `git diff HEAD~1 --name-only` to get files changed + 3. Use Read: `docs/sprint-artifacts/{{story_key}}.md` to see tasks + 4. Use Edit: Check off tasks (change `- [ ]` to `- [x]`) for completed work + 5. Use Edit: Fill Dev Agent Record with files/date/summary + 6. Use Bash: Verify with `grep -c "^- \[x\]"` (must be > 0) + 7. Use Edit: Update sprint-status.yaml to "done" or "review" + + + ✅ COMPLETED: {{story_key}} (reconciled) Increment completed counter @@ -1096,16 +1105,24 @@ Press [C] to continue or [P] to pause: ✅ Worker {{worker_id}} completed: {{story_key}} - Execute Step 4.5: Smart Story Reconciliation - Load reconciliation instructions: {installed_path}/step-4.5-reconcile-story-status.md - Execute reconciliation with story_key={{story_key}} + ORCHESTRATOR: You must execute reconciliation directly using Bash/Read/Edit tools. - + + 1. Use Bash: `git log -3 --oneline | grep "{{story_key}}"` to find commit + 2. Use Bash: `git diff HEAD~1 --name-only` to get files changed + 3. Use Read: `docs/sprint-artifacts/{{story_key}}.md` to see tasks + 4. Use Edit: Check off tasks (change `- [ ]` to `- [x]`) for completed work + 5. Use Edit: Fill Dev Agent Record with files/date/summary + 6. Use Bash: Verify with `grep -c "^- \[x\]"` (must be > 0) + 7. Use Edit: Update sprint-status.yaml to "done" or "review" + + + ✅ COMPLETED: {{story_key}} (reconciled) Add to completed_stories - + ⚠️ WARNING: {{story_key}} completed but reconciliation failed Add to completed_stories (implementation successful) Add to reconciliation_warnings: {story_key: {{story_key}}, warning_message: "Reconciliation failed - manual verification needed"} diff --git a/src/bmm/workflows/4-implementation/batch-super-dev/step-4.5-reconcile-story-status.md b/src/bmm/workflows/4-implementation/batch-super-dev/step-4.5-reconcile-story-status.md index ad2e49dc..daf96e00 100644 --- a/src/bmm/workflows/4-implementation/batch-super-dev/step-4.5-reconcile-story-status.md +++ b/src/bmm/workflows/4-implementation/batch-super-dev/step-4.5-reconcile-story-status.md @@ -1,390 +1,171 @@ -# Step 4.5: Smart Story Reconciliation +# Step 4.5: Story Reconciliation (Orchestrator-Driven) -Execute AFTER super-dev-pipeline completes but BEFORE marking story as "completed" -This ensures story checkboxes and status accurately reflect actual implementation - -## Goal - -Verify story file accuracy by reconciling: -1. **Acceptance Criteria checkboxes** vs Dev Agent Record -2. **Tasks/Subtasks checkboxes** vs Dev Agent Record -3. **Definition of Done checkboxes** vs Dev Agent Record -4. **Story status** (should be "done" if implementation complete) -5. **sprint-status.yaml entry** (should match story file status) +**Version:** 2.1.0 +**Execute:** AFTER super-dev-pipeline completes, BEFORE marking story done +**Who:** Orchestrator (YOU) - not an agent --- -## Execution +## Why Orchestrator Does This -### 1. Load Story File - -Read story file: {story_file_path} -Extract sections: - - Acceptance Criteria (## Acceptance Criteria) - - Tasks / Subtasks (## Tasks / Subtasks) - - Definition of Done (## Definition of Done) - - Dev Agent Record (## Dev Agent Record) - - Story status header (**Status:** ...) - - -### 2. Analyze Dev Agent Record - -Read "Dev Agent Record" section - - - ⚠️ Story {{story_key}}: Dev Agent Record is empty - cannot reconcile - This suggests super-dev-pipeline did not complete successfully. - Mark story as FAILED reconciliation - Return early (skip remaining checks) - - -Parse Dev Agent Record fields: - - **Agent Model Used** (should have model name, not empty) - - **Implementation Summary** (should describe what was built) - - **File List** (should list new/modified files) - - **Test Results** (should show test counts) - - **Completion Notes** (should document what works) - - - - Set implementation_status = COMPLETE - - - - Set implementation_status = INCOMPLETE - ⚠️ Story {{story_key}}: Implementation appears incomplete based on Dev Agent Record - - -### 3. Reconcile Acceptance Criteria - -For each AC subsection (AC1, AC2, AC3, AC4, etc.): - -For each checkbox in AC section: - - - Search Implementation Summary and File List for keywords from checkbox text - - - Checkbox: "[ ] FlexibleGridSection component (renders dynamic grid layouts)" - Implementation Summary mentions: "FlexibleGridSection component created" - File List includes: "FlexibleGridSection.tsx" - → Expected status: CHECKED - - - Determine expected_checkbox_status: - - CHECKED if Implementation Summary confirms it OR File List shows created files OR Test Results mention it - - UNCHECKED if no evidence in Dev Agent Record - - PARTIAL if mentioned as "pending" or "infrastructure ready" - - - - - Read actual checkbox state from story file ([x] vs [ ] vs [~]) - - - 🔧 Reconciling AC: "{{checkbox_text}}" - Actual: {{actual_status}} - Expected: {{expected_status}} - Reason: {{evidence_from_dev_record}} - - Add to reconciliation_changes list - - - -After checking all ACs: - - Count total AC items - - Count checked AC items (after reconciliation) - - Calculate AC completion percentage - - -### 4. Reconcile Tasks / Subtasks - -For each Task (Task 1, Task 2, etc.): - -For each checkbox in Tasks section: - - - Search Implementation Summary and File List for task keywords - - - Task checkbox: "[ ] **2.2:** Create FlexibleGridSection component" - File List includes: "apps/frontend/web/src/components/FlexibleGridSection.tsx" - → Expected status: CHECKED - - - Determine expected_checkbox_status using same logic as AC section - - - - Read actual checkbox state - - - 🔧 Reconciling Task: "{{task_text}}" - Actual: {{actual_status}} - Expected: {{expected_status}} - Reason: {{evidence_from_dev_record}} - - Add to reconciliation_changes list - - - -After checking all Tasks: - - Count total task items - - Count checked task items (after reconciliation) - - Calculate task completion percentage - - -### 5. Reconcile Definition of Done - -For each DoD category (Code Quality, Testing, Security, etc.): - -For each checkbox in DoD section: - - - Check Test Results, Completion Notes for evidence - - - DoD checkbox: "[ ] Type check passes: `pnpm type-check` (zero errors)" - Completion Notes say: "Type check passes ✅" - → Expected status: CHECKED - - - - DoD checkbox: "[ ] Unit tests: 90%+ coverage" - Test Results say: "37 tests passing" - Completion Notes say: "100% coverage on FlexibleGridSection" - → Expected status: CHECKED - - - Determine expected_checkbox_status - - - - Read actual checkbox state - - - 🔧 Reconciling DoD: "{{dod_text}}" - Actual: {{actual_status}} - Expected: {{expected_status}} - Reason: {{evidence_from_dev_record}} - - Add to reconciliation_changes list - - - -After checking all DoD items: - - Count total DoD items - - Count checked DoD items (after reconciliation) - - Calculate DoD completion percentage - - -### 6. Determine Correct Story Status - -Based on completion percentages, determine correct story status: - - - Set correct_story_status = "done" - - - - Set correct_story_status = "review" - - - - Set correct_story_status = "in-progress" - - - - Override: Set correct_story_status = "in-progress" - ⚠️ Overriding status to "in-progress" due to incomplete implementation - - -Read current story status from story file (**Status:** ...) - - - 🔧 Story status mismatch: - Current: {{current_story_status}} - Expected: {{correct_story_status}} - Reason: AC={{ac_pct}}% Tasks={{tasks_pct}}% DoD={{dod_pct}}% - - Add to reconciliation_changes list - - -### 7. Verify sprint-status.yaml Entry - -Read {sprint_status} file -Find entry for {{story_key}} -Extract current status from sprint-status.yaml - - - 🔧 sprint-status.yaml mismatch: - Current: {{sprint_status_yaml_status}} - Expected: {{correct_story_status}} - - Add to reconciliation_changes list - - -### 8. Apply Reconciliation Changes - - - ✅ Story {{story_key}}: Already accurate (0 changes needed) - Return SUCCESS (no updates needed) - - - - -🔧 Story {{story_key}}: Reconciling {{count}} issues - -**Changes to apply:** -{{#each reconciliation_changes}} -{{@index}}. {{change_description}} -{{/each}} - - - Apply these reconciliation changes? (yes/no): - - - ⏭️ Skipping reconciliation for {{story_key}} - Return SUCCESS (user declined changes) - - - - For each AC checkbox that needs updating: - Use Edit tool to update checkbox from [ ] to [x] or [~] - Add note explaining why: "- [x] Item - COMPLETE: {{evidence}}" - - - - For each Task checkbox that needs updating: - Use Edit tool to update checkbox - Update task header if all subtasks complete: "### Task 1: ... ✅ COMPLETE" - - - - For each DoD checkbox that needs updating: - Use Edit tool to update checkbox - Add verification note: "- [x] Item ✅ (verified in Dev Agent Record)" - - - - - Use Edit tool to update status line - Change from: **Status:** {{old_status}} - Change to: **Status:** {{correct_story_status}} - - - - - - Use Edit tool to update status entry - - Count tasks from story file: - - total_tasks = all top-level tasks - - checked_tasks = tasks marked [x] - - progress_pct = (checked_tasks / total_tasks) × 100 - - - Update comment with progress tracking (NEW v1.3.0): - If status == "in-progress": - Format: {{story_key}}: in-progress # {{checked_tasks}}/{{total_tasks}} tasks ({{progress_pct}}%) - - If status == "review": - Format: {{story_key}}: review # {{checked_tasks}}/{{total_tasks}} tasks ({{progress_pct}}%) - awaiting review - - If status == "done": - Format: {{story_key}}: done # ✅ COMPLETED: {{brief_summary}} - - - - Before: 20-8-...: ready-for-dev # Story description - During: 20-8-...: in-progress # 3/10 tasks (30%) - During: 20-8-...: in-progress # 7/10 tasks (70%) - Review: 20-8-...: review # 10/10 tasks (100%) - awaiting review - After: 20-8-...: done # ✅ COMPLETED: Component + tests + docs - - - - - ✅ Story {{story_key}}: Reconciliation complete ({{count}} changes applied) - - -### 9. Final Verification - -Re-read story file to verify changes applied correctly -Calculate final completion percentages - - -📊 Story {{story_key}} - Final Status - -**Acceptance Criteria:** {{ac_checked}}/{{ac_total}} ({{ac_pct}}%) -**Tasks/Subtasks:** {{tasks_checked}}/{{tasks_total}} ({{tasks_pct}}%) -**Definition of Done:** {{dod_checked}}/{{dod_total}} ({{dod_pct}}%) - -**Story Status:** {{correct_story_status}} -**sprint-status.yaml:** {{correct_story_status}} - -{{#if correct_story_status == "done"}} -✅ Story is COMPLETE and accurately reflects implementation -{{/if}} - -{{#if correct_story_status == "review"}} -⚠️ Story needs review (some items incomplete) -{{/if}} - -{{#if correct_story_status == "in-progress"}} -⚠️ Story has significant gaps (implementation incomplete) -{{/if}} - - -Return SUCCESS with reconciliation summary +Agents ignore reconciliation instructions. The orchestrator: +- Has full context of what just happened +- Can use tools directly (Bash, Read, Edit) +- Won't skip "boring" bookkeeping tasks --- -## Success Criteria +## Execute These Steps -Story reconciliation succeeds when: -1. ✅ All checkboxes match Dev Agent Record evidence -2. ✅ Story status accurately reflects completion (done/review/in-progress) -3. ✅ sprint-status.yaml entry matches story file status -4. ✅ Completion percentages calculated and reported -5. ✅ Changes documented in reconciliation summary +### Step 1: Get What Was Built ---- +Run this command with Bash tool: -## Error Handling +```bash +echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━" +echo "🔧 STORY RECONCILIATION: {{story_key}}" +echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━" - - ❌ Story {{story_key}}: File not found at {{story_file_path}} - Return FAILED reconciliation - +# Get the commit for this story +echo "Recent commits:" +git log -5 --oneline | grep -i "{{story_key}}" || echo "(no commits found with story key)" - - ⚠️ Story {{story_key}}: Cannot reconcile - Dev Agent Record not populated - Mark as INCOMPLETE (not implemented yet) - Return WARNING reconciliation - - - - ❌ Story {{story_key}}: Failed to apply changes (Edit tool error) - Log error details - Return FAILED reconciliation - - ---- - -## Integration with batch-super-dev - -**Insert this step:** -- **Sequential mode:** After Step 4s-a (Process individual story), before marking completed -- **Parallel mode:** After Step 4p-a (Spawn Task agents), after agent completes but before marking completed - -**Flow:** -``` -super-dev-pipeline completes → Step 4.5 (Reconcile) → Mark as completed/failed +# Get files changed +echo "" +echo "Files changed in last commit:" +git diff HEAD~1 --name-only | grep -v "__tests__" | grep -v "\.test\." | head -20 ``` -**Benefits:** -- Ensures all batch-processed stories have accurate status -- Catches mismatches automatically -- Prevents "done" stories with unchecked items -- Maintains sprint-status.yaml accuracy +Store the output - you'll need it for the next steps. + +### Step 2: Read Story File + +Use Read tool on: `docs/sprint-artifacts/{{story_key}}.md` + +Find these sections: +- **Tasks** (lines starting with `- [ ]` or `- [x]`) +- **Dev Agent Record** (section with Agent Model, Implementation Date, etc.) + +### Step 3: Check Off Completed Tasks + +For EACH task in the Tasks section that relates to files changed: + +Use Edit tool: +``` +file_path: docs/sprint-artifacts/{{story_key}}.md +old_string: "- [ ] Create the SomeComponent" +new_string: "- [x] Create the SomeComponent" +``` + +**Match logic:** +- If task mentions a file that was created → check it off +- If task mentions a service/component that now exists → check it off +- If unsure → leave unchecked (don't over-claim) + +### Step 4: Fill Dev Agent Record + +Use Edit tool to replace the placeholder record: + +``` +file_path: docs/sprint-artifacts/{{story_key}}.md +old_string: "### Dev Agent Record +- **Agent Model Used:** [Not set] +- **Implementation Date:** [Not set] +- **Files Created/Modified:** [Not set] +- **Tests Added:** [Not set] +- **Completion Notes:** [Not set]" +new_string: "### Dev Agent Record +- **Agent Model Used:** Claude Sonnet 4 (multi-agent pipeline) +- **Implementation Date:** 2026-01-26 +- **Files Created/Modified:** + - path/to/file1.ts + - path/to/file2.ts + [list all files from git diff] +- **Tests Added:** X tests (from Inspector report) +- **Completion Notes:** Implemented [brief summary]" +``` + +### Step 5: Verify Updates + +Run this command with Bash tool: + +```bash +echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━" +echo "🔍 RECONCILIATION VERIFICATION" +echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━" + +STORY_FILE="docs/sprint-artifacts/{{story_key}}.md" + +# Count checked tasks +CHECKED=$(grep -c "^- \[x\]" "$STORY_FILE" 2>/dev/null || echo "0") +UNCHECKED=$(grep -c "^- \[ \]" "$STORY_FILE" 2>/dev/null || echo "0") +TOTAL=$((CHECKED + UNCHECKED)) +echo "Tasks: $CHECKED/$TOTAL checked" + +if [ "$CHECKED" -eq 0 ]; then + echo "" + echo "❌ BLOCKER: Zero tasks checked off" + echo "You MUST go back to Step 3 and check off tasks" + exit 1 +fi + +# Check Dev Agent Record filled +if grep -q "Implementation Date: \[Not set\]" "$STORY_FILE" 2>/dev/null; then + echo "❌ BLOCKER: Dev Agent Record not filled" + echo "You MUST go back to Step 4 and fill it" + exit 1 +fi + +if grep -A 3 "### Dev Agent Record" "$STORY_FILE" | grep -q "Implementation Date: 202"; then + echo "✅ Dev Agent Record: Filled" +else + echo "❌ BLOCKER: Dev Agent Record incomplete" + exit 1 +fi + +echo "" +echo "✅ RECONCILIATION COMPLETE" +echo " Checked tasks: $CHECKED/$TOTAL" +echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━" +``` + +### Step 6: Update Sprint Status + +Use Read tool: `docs/sprint-artifacts/sprint-status.yaml` + +Find the entry for {{story_key}} and use Edit tool to update: + +``` +old_string: "{{story_key}}: ready-for-dev" +new_string: "{{story_key}}: done # ✅ COMPLETED 2026-01-26" +``` + +Or if 95%+ complete but not 100%: +``` +new_string: "{{story_key}}: review # 8/10 tasks - awaiting review" +``` + +--- + +## Status Decision Logic + +Based on verification results: + +| Condition | Status | +|-----------|--------| +| 95%+ tasks checked + Dev Record filled | `done` | +| 80-94% tasks checked | `review` | +| <80% tasks checked | `in-progress` | +| Dev Record not filled | `in-progress` | + +--- + +## If Verification Fails + +1. **DO NOT** proceed to next story +2. **DO NOT** mark story as done +3. **FIX** the issue using Edit tool +4. **RE-RUN** verification command +5. **REPEAT** until verification passes + +This is mandatory. No shortcuts. diff --git a/src/bmm/workflows/4-implementation/super-dev-pipeline/agents/builder.md b/src/bmm/workflows/4-implementation/super-dev-pipeline/agents/builder.md index b1699681..6c100cbc 100644 --- a/src/bmm/workflows/4-implementation/super-dev-pipeline/agents/builder.md +++ b/src/bmm/workflows/4-implementation/super-dev-pipeline/agents/builder.md @@ -93,4 +93,43 @@ When complete, provide: --- +## When Complete, Return This Format + +```markdown +## AGENT COMPLETE + +**Agent:** builder +**Story:** {{story_key}} +**Status:** SUCCESS | FAILED + +### Files Created +- path/to/new/file1.ts +- path/to/new/file2.ts + +### Files Modified +- path/to/existing/file.ts + +### Tests Added +- X test files +- Y test cases total + +### Implementation Summary +Brief description of what was built and key decisions made. + +### Known Gaps +- Any functionality not implemented +- Any edge cases not handled +- NONE if all tasks complete + +### Ready For +Inspector validation (next phase) +``` + +**Why this format?** The orchestrator parses this output to: +- Verify claimed files actually exist +- Track what was built for reconciliation +- Route to next phase appropriately + +--- + **Remember:** You are the BUILDER. Build it well, but don't validate or review your own work. Other agents will do that with fresh eyes. diff --git a/src/bmm/workflows/4-implementation/super-dev-pipeline/agents/fixer.md b/src/bmm/workflows/4-implementation/super-dev-pipeline/agents/fixer.md index 0e8fa2e1..32343483 100644 --- a/src/bmm/workflows/4-implementation/super-dev-pipeline/agents/fixer.md +++ b/src/bmm/workflows/4-implementation/super-dev-pipeline/agents/fixer.md @@ -20,15 +20,15 @@ You are the **FIXER** agent. Your job is to fix CRITICAL and HIGH issues from th - Fix security vulnerabilities immediately - Fix logic bugs and edge cases - Re-run tests after each fix -- Update story checkboxes -- Update sprint-status.yaml -- Commit changes +- Commit code changes with descriptive message **DO NOT:** - Skip CRITICAL issues - Skip HIGH issues - Spend time on LOW issues - Make unnecessary changes +- Update story checkboxes (orchestrator does this) +- Update sprint-status.yaml (orchestrator does this) --- @@ -79,22 +79,7 @@ low_issues: [#10, #11] # SKIP (gold-plating) ## After Fixing Issues -### 1. Update Story File - -**Mark completed tasks:** -```bash -# Update checkboxes in story file -# Change [ ] to [x] for completed tasks -``` - -### 2. Update Sprint Status - -**Update sprint-status.yaml:** -```yaml -17-10-occupant-agreement-view: done # was: ready-for-dev -``` - -### 3. Commit Changes +### Commit Changes ```bash git add . @@ -153,10 +138,6 @@ All tests passing, type check clean, lint clean." **Git:** - ✅ Commit created: a1b2c3d -- ✅ Story checkboxes updated -- ✅ Sprint status updated - -**Story Status:** COMPLETE ``` --- @@ -183,4 +164,47 @@ All tests passing, type check clean, lint clean." --- +## When Complete, Return This Format + +```markdown +## AGENT COMPLETE + +**Agent:** fixer +**Story:** {{story_key}} +**Status:** SUCCESS | PARTIAL | FAILED + +### Issues Fixed +- **CRITICAL:** X/Y fixed +- **HIGH:** X/Y fixed +- **Total:** X issues resolved + +### Fixes Applied +1. [CRITICAL] file.ts:45 - Fixed SQL injection with parameterized query +2. [HIGH] file.ts:89 - Added null check + +### Files Modified +- path/to/file1.ts +- path/to/file2.ts + +### Quality Checks +- **Type Check:** PASS | FAIL +- **Lint:** PASS | FAIL +- **Tests:** X passing, Y failing + +### Git Commit +- **Hash:** abc123 +- **Message:** fix({{story_key}}): address code review findings + +### Deferred Issues +- MEDIUM: X issues (defer to follow-up) +- LOW: X issues (skip as gold-plating) + +### Ready For +Orchestrator reconciliation (story file updates) +``` + +**Note:** Story checkboxes and sprint-status updates are done by the orchestrator, not you. + +--- + **Remember:** You are the FIXER. Fix real problems, skip gold-plating, commit when done. diff --git a/src/bmm/workflows/4-implementation/super-dev-pipeline/agents/inspector.md b/src/bmm/workflows/4-implementation/super-dev-pipeline/agents/inspector.md index 0a14d6c4..93d92625 100644 --- a/src/bmm/workflows/4-implementation/super-dev-pipeline/agents/inspector.md +++ b/src/bmm/workflows/4-implementation/super-dev-pipeline/agents/inspector.md @@ -150,4 +150,35 @@ Cannot proceed to code review until these are fixed. --- +## When Complete, Return This Format + +```markdown +## AGENT COMPLETE + +**Agent:** inspector +**Story:** {{story_key}} +**Status:** PASS | FAIL + +### Evidence +- **Type Check:** PASS (0 errors) | FAIL (X errors) +- **Lint:** PASS (0 warnings) | FAIL (X warnings) +- **Build:** PASS | FAIL +- **Tests:** X passing, Y failing, Z% coverage + +### Files Verified +- path/to/file1.ts ✓ +- path/to/file2.ts ✓ +- path/to/missing.ts ✗ (NOT FOUND) + +### Failures (if FAIL status) +1. Specific failure with file:line reference +2. Another specific failure + +### Ready For +- If PASS: Reviewer (next phase) +- If FAIL: Builder needs to fix before proceeding +``` + +--- + **Remember:** You are the INSPECTOR. Your job is to find the truth, not rubber-stamp the Builder's work. If something is wrong, say so with evidence. diff --git a/src/bmm/workflows/4-implementation/super-dev-pipeline/agents/reviewer.md b/src/bmm/workflows/4-implementation/super-dev-pipeline/agents/reviewer.md index 39e7232f..72038cc6 100644 --- a/src/bmm/workflows/4-implementation/super-dev-pipeline/agents/reviewer.md +++ b/src/bmm/workflows/4-implementation/super-dev-pipeline/agents/reviewer.md @@ -187,4 +187,37 @@ Before completing review, check: --- +## When Complete, Return This Format + +```markdown +## AGENT COMPLETE + +**Agent:** reviewer +**Story:** {{story_key}} +**Status:** ISSUES_FOUND | CLEAN + +### Issue Summary +- **CRITICAL:** X issues (security, data loss) +- **HIGH:** X issues (production bugs) +- **MEDIUM:** X issues (tech debt) +- **LOW:** X issues (nice-to-have) +- **TOTAL:** X issues + +### Must Fix (CRITICAL + HIGH) +1. [CRITICAL] file.ts:45 - SQL injection in user query +2. [HIGH] file.ts:89 - Missing null check causes crash + +### Should Fix (MEDIUM) +1. file.ts:123 - No error handling for API call + +### Files Reviewed +- path/to/file1.ts ✓ +- path/to/file2.ts ✓ + +### Ready For +Fixer agent to address CRITICAL and HIGH issues +``` + +--- + **Remember:** You are the ADVERSARIAL REVIEWER. Your success is measured by finding legitimate issues. Don't be nice - be thorough. diff --git a/src/bmm/workflows/4-implementation/super-dev-pipeline/workflow.md b/src/bmm/workflows/4-implementation/super-dev-pipeline/workflow.md index 02e4208c..40384e1e 100644 --- a/src/bmm/workflows/4-implementation/super-dev-pipeline/workflow.md +++ b/src/bmm/workflows/4-implementation/super-dev-pipeline/workflow.md @@ -1,15 +1,19 @@ -# Super-Dev Pipeline - Multi-Agent Architecture +# Super-Dev-Pipeline v2.1 - Multi-Agent Architecture +**Version:** 2.1.0 **Architecture:** GSDMAD (GSD + BMAD) -**Philosophy:** Trust but verify, separation of concerns +**Philosophy:** Agents do creative work, orchestrator does bookkeeping --- ## Overview -This workflow implements a story using **4 independent agents** with external validation at each phase. +This workflow implements a story using **4 independent agents** with orchestrator-driven reconciliation. -**Key Innovation:** Each agent has single responsibility and fresh context. No agent validates its own work. +**Key Innovation:** +- Each agent has single responsibility and fresh context +- No agent validates its own work +- **Orchestrator does bookkeeping** (story file updates, verification) - not agents --- @@ -21,40 +25,48 @@ This workflow implements a story using **4 independent agents** with external va │ - Loads story │ │ - Spawns agents sequentially │ │ - Verifies each phase │ +│ - DOES RECONCILIATION DIRECTLY (not via agent) │ │ - Final quality gate │ └─────────────────────────────────────────────────────────────┘ │ - ├──> Phase 1: Builder (Steps 1-4) + ├──> Phase 1: Builder (Steps 1-4) [AGENT] │ - Load story, analyze gaps │ - Write tests (TDD) │ - Implement code │ - Report what was built (NO VALIDATION) │ - ├──> Phase 2: Inspector (Steps 5-6) + ├──> Phase 2: Inspector (Steps 5-6) [AGENT] │ - Fresh context, no Builder knowledge │ - Verify files exist │ - Run tests independently │ - Run quality checks │ - PASS or FAIL verdict │ - ├──> Phase 3: Reviewer (Step 7) + ├──> Phase 3: Reviewer (Step 7) [AGENT] │ - Fresh context, adversarial stance │ - Find security vulnerabilities │ - Find performance problems │ - Find logic bugs │ - Report issues with severity │ - ├──> Phase 4: Fixer (Steps 8-9) + ├──> Phase 4: Fixer (Steps 8-9) [AGENT] │ - Fix CRITICAL issues (all) │ - Fix HIGH issues (all) │ - Fix MEDIUM issues (if time) │ - Skip LOW issues (gold-plating) - │ - Update story + sprint-status - │ - Commit changes + │ - Commit code changes │ - └──> Final Verification (Main) + ├──> Phase 5: Reconciliation (Step 10) [ORCHESTRATOR] 🔧 + │ - Orchestrator uses Bash/Read/Edit tools directly + │ - Check off completed tasks in story file + │ - Fill Dev Agent Record with details + │ - Verify updates with bash commands + │ - BLOCKER if verification fails + │ + └──> Final Verification [ORCHESTRATOR] - Check git commits exist - - Check story checkboxes updated + - Check story checkboxes updated (count > 0) + - Check Dev Agent Record filled - Check sprint-status updated - Check tests passed - Mark COMPLETE or FAILED @@ -182,45 +194,181 @@ Task({ **Wait for Fixer to complete.** +### Phase 5: Orchestrator Reconciliation (MANDATORY) + +🚨 **THIS PHASE IS MANDATORY. ORCHESTRATOR DOES THIS DIRECTLY. NO AGENT SPAWN.** 🚨 + +**Why orchestrator, not agent?** Agents ignore instructions. The orchestrator has the context +and can use tools directly. This is bookkeeping work, not creative work. + +**YOU (the orchestrator) must execute these commands directly:** + +**Step 5.1: Get what was built** +```bash +# Get commit for this story +COMMIT_INFO=$(git log -5 --oneline | grep "{{story_key}}" | head -1) +echo "Commit: $COMMIT_INFO" + +# Get files changed (production code only) +FILES_CHANGED=$(git diff HEAD~1 --name-only | grep -v "__tests__" | grep -v "\.test\." | grep -v "\.spec\.") +echo "Files changed:" +echo "$FILES_CHANGED" +``` + +**Step 5.2: Read story file tasks** +Use Read tool: `{{story_file}}` + +Find the Tasks section and identify which tasks relate to the files changed. + +**Step 5.3: Check off completed tasks** +Use Edit tool for EACH task that was completed: +``` +old_string: "- [ ] Task description here" +new_string: "- [x] Task description here" +``` + +**Step 5.4: Fill Dev Agent Record** +Use Edit tool to update the Dev Agent Record section: +``` +old_string: "### Dev Agent Record +- **Agent Model Used:** [Not set] +- **Implementation Date:** [Not set] +- **Files Created/Modified:** [Not set] +- **Tests Added:** [Not set] +- **Completion Notes:** [Not set]" + +new_string: "### Dev Agent Record +- **Agent Model Used:** Claude Sonnet 4 (multi-agent: Builder + Inspector + Reviewer + Fixer) +- **Implementation Date:** {{date}} +- **Files Created/Modified:** + {{#each files_changed}} + - {{this}} + {{/each}} +- **Tests Added:** [count from Inspector report] +- **Completion Notes:** [brief summary of what was implemented]" +``` + +**Step 5.5: Verify updates (BLOCKER)** +```bash +echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━" +echo "🔍 RECONCILIATION VERIFICATION" +echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━" + +# Count checked tasks +CHECKED=$(grep -c "^- \[x\]" {{story_file}}) +echo "Checked tasks: $CHECKED" + +if [ "$CHECKED" -eq 0 ]; then + echo "❌ BLOCKER: Zero checked tasks" + echo "Go back to Step 5.3 and check off tasks" + exit 1 +fi + +# Verify Dev Agent Record +RECORD=$(grep -A 5 "### Dev Agent Record" {{story_file}} | grep -c "Implementation Date:") +if [ "$RECORD" -eq 0 ]; then + echo "❌ BLOCKER: Dev Agent Record not filled" + echo "Go back to Step 5.4 and fill it" + exit 1 +fi + +echo "✅ Reconciliation verified: $CHECKED tasks checked" +echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━" +``` + +**If verification fails:** DO NOT proceed. Fix immediately using Edit tool, then re-verify. + --- ## Final Verification (Main Orchestrator) -**After all agents complete, verify:** +🚨 **CRITICAL: This verification is MANDATORY. DO NOT skip.** 🚨 + +**After all agents complete (including Reconciler), YOU (the main orchestrator) must:** + +1. **Use the Bash tool** to run these commands +2. **Read the output** to see if verification passed +3. **If verification fails**, use Edit and Bash tools to fix it NOW +4. **Do not proceed** until verification passes + +**COMMAND TO RUN WITH BASH TOOL:** ```bash -# 1. Check git commits +echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━" +echo "🔍 FINAL VERIFICATION (MANDATORY)" +echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━" + +# 1. Check git commits exist +echo "Checking git commits..." git log --oneline -3 | grep "{{story_key}}" if [ $? -ne 0 ]; then - echo "❌ FAILED: No commit found" + echo "❌ FAILED: No commit found for {{story_key}}" + echo "The Fixer agent did not commit changes." exit 1 fi +echo "✅ Git commit found" -# 2. Check story checkboxes -before=$(git show HEAD~1:{{story_file}} | grep -c '^- \[x\]') -after=$(grep -c '^- \[x\]' {{story_file}}) -if [ $after -le $before ]; then - echo "❌ FAILED: Checkboxes not updated" +# 2. Check story file has checked tasks (ABSOLUTE BLOCKER) +echo "Checking story file updates..." +CHECKED_COUNT=$(grep -c '^- \[x\]' {{story_file}}) +echo "Checked tasks: $CHECKED_COUNT" + +if [ "$CHECKED_COUNT" -eq 0 ]; then + echo "" + echo "❌ BLOCKER: Story file has ZERO checked tasks" + echo "" + echo "This means the Fixer agent did NOT update the story file." + echo "The story CANNOT be marked complete without checked tasks." + echo "" + echo "You must:" + echo " 1. Read the git commit to see what was built" + echo " 2. Read the story Tasks section" + echo " 3. Use Edit tool to check off completed tasks" + echo " 4. Fill in Dev Agent Record" + echo " 5. Verify with grep" + echo " 6. Re-run this verification" + echo "" exit 1 fi +echo "✅ Story file has $CHECKED_COUNT checked tasks" -# 3. Check sprint-status -git diff HEAD~1 {{sprint_status}} | grep "{{story_key}}: done" +# 3. Check Dev Agent Record filled +echo "Checking Dev Agent Record..." +RECORD_FILLED=$(grep -A 20 "^### Dev Agent Record" {{story_file}} | grep -c "Agent Model") +if [ "$RECORD_FILLED" -eq 0 ]; then + echo "❌ BLOCKER: Dev Agent Record NOT filled" + echo "The Fixer agent did not document what was built." + exit 1 +fi +echo "✅ Dev Agent Record filled" + +# 4. Check sprint-status updated +echo "Checking sprint-status..." +git diff HEAD~1 {{sprint_status}} | grep "{{story_key}}" if [ $? -ne 0 ]; then - echo "❌ FAILED: Sprint status not updated" + echo "❌ FAILED: Sprint status not updated for {{story_key}}" exit 1 fi +echo "✅ Sprint status updated" -# 4. Check Inspector output for test evidence -grep -E "PASS|tests.*passing" inspector_output.txt -if [ $? -ne 0 ]; then - echo "❌ FAILED: No test evidence" - exit 1 +# 5. Check test evidence (optional - may have test failures) +echo "Checking test evidence..." +if [ -f "inspector_output.txt" ]; then + grep -E "PASS|tests.*passing" inspector_output.txt && echo "✅ Tests passing" fi +echo "" +echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━" echo "✅ STORY COMPLETE - All verifications passed" +echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━" ``` +**IF VERIFICATION FAILS:** +- DO NOT mark story as "done" +- DO NOT proceed to next story +- FIX the failure immediately +- Re-run verification until it passes + --- ## Benefits Over Single-Agent diff --git a/src/bmm/workflows/4-implementation/super-dev-pipeline/workflow.yaml b/src/bmm/workflows/4-implementation/super-dev-pipeline/workflow.yaml index 122750d3..6ab01b6d 100644 --- a/src/bmm/workflows/4-implementation/super-dev-pipeline/workflow.yaml +++ b/src/bmm/workflows/4-implementation/super-dev-pipeline/workflow.yaml @@ -67,6 +67,8 @@ agents: trust_level: "medium" # Incentive to minimize work timeout: 2400 # 40 minutes +# Reconciliation: orchestrator does this directly (see workflow.md Phase 5) + # Complexity level (determines which steps to execute) complexity_level: "standard" # micro | standard | complex diff --git a/src/modules/bmm/workflows/4-implementation/batch-super-dev/instructions.md b/src/modules/bmm/workflows/4-implementation/batch-super-dev/instructions.md index bcd4652c..c7fd4498 100644 --- a/src/modules/bmm/workflows/4-implementation/batch-super-dev/instructions.md +++ b/src/modules/bmm/workflows/4-implementation/batch-super-dev/instructions.md @@ -94,40 +94,30 @@ Run `/bmad_bmm_sprint-status` to see current status. Input: "20-11" → epic=20, story=11, suffix="" - - 🚨 ONE CANONICAL FORMAT - NO VARIATIONS + + Use Glob tool to search for files matching these patterns (in priority order): - CANONICAL FORMAT: {story_key}.md - 20-9-megamenu-navigation.md (epic-story-slug, NO prefix) - 18-1-charge-model-state-machine.md (epic-story-slug, NO prefix) + story-{epic_num}.{story_num}.md + story-20.9.md (DOT notation, no suffix) - Check if file exists: {sprint_artifacts}/{story_key}.md + story-{epic_num}.{story_num}*.md + story-20.9-megamenu-navigation.md (DOT notation WITH suffix - use Glob wildcard) - - Set file_status = ✅ EXISTS - Store file_path = {sprint_artifacts}/{story_key}.md - + {epic_num}-{story_num}.md + 20-9.md (HYPHEN notation, no "story-" prefix) - - Set file_status = ❌ MISSING + {epic_num}-{story_num}*.md + 20-9-megamenu-navigation.md (HYPHEN notation WITH suffix) - Check for legacy wrong-named files: - Search for: story-{story_key}.md (wrong - has "story-" prefix) + story-{story_key}.md + story-20-9-megamenu-navigation.md (literal story_key with "story-" prefix) - - ⚠️ Found legacy file: story-{story_key}.md - 🔧 AUTO-RENAMING to canonical: {story_key}.md + {story_key}.md + 20-9-megamenu-navigation.md (literal story_key) - Rename: mv story-{story_key}.md {story_key}.md - Verify rename worked - Set file_status = ✅ EXISTS (after rename) - Store file_path = {sprint_artifacts}/{story_key}.md - - - - file_status = ❌ MISSING (genuinely missing) - - + Stop at first match and store file_path + If NO match found after all 6 patterns → file_status = ❌ MISSING + If match found → file_status = ✅ EXISTS Mark stories as: ✅ (file exists), ❌ (file missing), 🔄 (already implemented but not marked done) @@ -685,59 +675,24 @@ Gap analysis will happen just-in-time during implementation (Step 2 of super-dev - 🚀 Spawning {{needs_creation.length}} parallel agents for story creation... - - Spawn Task agents in PARALLEL (send all Task calls in SINGLE message): - For each story in needs_creation: - - - Task tool call: - - subagent_type: "general-purpose" - - description: "Create story {{story_key}}" - - prompt: "Create basic story file for {{story_key}}. + + 📝 Creating story {{@index}}/{{needs_creation.length}}: {{story_key}}... - INSTRUCTIONS: - 1. Read epic description from docs/epics.md (Epic {{epic_num}}) - 2. Read PRD requirements (docs/prd-art-collective-tenants.md) - 3. Read architecture (docs/architecture-space-rentals.md) - 4. Extract FRs for this story from PRD - 5. Break down into 3-7 tasks with subtasks - 6. Create story file at: docs/sprint-artifacts/{{story_key}}.md - 7. Use template from: _bmad/bmm/workflows/4-implementation/create-story/template.md - 8. NO gap analysis (defer to implementation) - 9. Commit story file when complete - 10. Report: story file path - - Mode: batch (lightweight, no codebase scanning)" - - Store returned agent_id for tracking + Invoke workflow: /bmad_bmm_create-story + Parameters: + - story_key: {{story_key}} + - epic_num: {{epic_num}} + - mode: batch (auto-approve, minimal prompts) - - -⏳ Waiting for {{needs_creation.length}} parallel agents to complete... - -Story creation agents: -{{#each needs_creation}} - - Agent {{@index}}: {{story_key}} -{{/each}} - - - Wait for ALL agents to complete (blocking) - - Check each agent output: - - - Parse agent output for {{story_key}} - - + ✅ Story created: {{story_key}} - Verify file exists at docs/sprint-artifacts/{{story_key}}.md Mark story.needs_story_creation = false - + ❌ Failed to create story: {{story_key}} Add to failed_creations list Remove from selected_stories @@ -830,93 +785,25 @@ QUALITY OVER SPEED: Taking time to ensure correctness. Set quality_multiplier = 1.5 - - -━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ -📊 ANALYZING STORY DEPENDENCIES -━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ - - - For each selected story: - - Read story file Tasks section - Analyze task descriptions for dependencies on other selected stories: - - Dependency detection rules: - - Look for mentions of other story keys (e.g., "18-1", "18-2") - - Look for phrases like "requires", "depends on", "needs", "after" - - Look for file paths that other stories create - - Look for models/services that other stories define - - - Build dependency map: - story_key: { - depends_on: [list of story keys this depends on], - blocks: [list of story keys that depend on this] - } - - - Compute waves using topological sort: - - Wave 1: Stories with no dependencies (can start immediately) - Wave 2: Stories that only depend on Wave 1 - Wave 3: Stories that depend on Wave 2 - ... - - - -📊 **Dependency Analysis Complete** - -{{#each waves}} -**Wave {{@index}}** ({{count}} stories): -{{#each stories}} - - {{story_key}}{{#if depends_on}} [depends on: {{depends_on}}]{{/if}} -{{/each}} -{{/each}} - -**Execution Strategy:** -{{#if waves.length == 1}} -✅ All stories are independent - can run fully in parallel -{{else}} -⚙️ Dependencies detected - wave-based execution recommended -- Wave 1: {{wave_1_count}} stories (parallel) -- Total waves: {{waves.length}} -- Sequential time: {{total_time_sequential}} -- Wave-based time: {{total_time_waves}} ({{time_savings}}% faster) -{{/if}} -━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ - - - **How should these stories be processed?** Options: -- **S**: Sequential - Run stories one-by-one (Task agent finishes before next starts) -- **P**: Parallel - Run stories concurrently (Multiple Task agents running simultaneously) +- **sequential**: Run stories one-by-one in this session (slower, easier to monitor) +- **parallel**: Spawn Task agents to process stories concurrently (faster, autonomous) -**Note:** Both modes use Task agents to keep story context out of the main thread. -The only difference is the number running at once. - -Enter: S or P +Enter: sequential or parallel - Capture response as: execution_strategy + Capture response as: execution_mode - - Set execution_mode = "sequential" + Set parallel_count = 1 - Set use_task_agents = true - -⏺ ✅ Sequential mode selected - stories will be processed one-by-one - -Each story runs in its own Task agent. Agents execute sequentially (one completes before next starts). -This keeps the main thread clean while maintaining easy monitoring. - + Set use_task_agents = false + ✅ Sequential mode selected - stories will be processed one-by-one in this session - - Set execution_mode = "parallel" + Set use_task_agents = true @@ -939,33 +826,26 @@ Enter number (2-10) or 'all': ⚠️ Requested {{original_count}} agents, capped at 10 (safety limit) - - -⏺ ✅ Parallel mode selected - {{parallel_count}} Task agents will run concurrently - -Each story runs in its own Task agent. Multiple agents execute in parallel for faster completion. - ## ⚙️ Execution Plan **Mode:** {{execution_mode}} -**Task Agents:** {{parallel_count}} {{#if parallel_count > 1}}running concurrently{{else}}running sequentially{{/if}} +{{#if use_task_agents}} +**Task Agents:** {{parallel_count}} running concurrently **Agent Type:** general-purpose (autonomous) +{{else}} +**Sequential processing** in current session +{{/if}} **Stories to process:** {{count}} **Estimated total time:** -{{#if parallel_count > 1}} +{{#if use_task_agents}} - With {{parallel_count}} agents: {{estimated_hours / parallel_count}} hours {{else}} - Sequential: {{estimated_hours}} hours {{/if}} - -**Complexity Routing:** -{{#each stories_by_complexity}} -- {{complexity}}: {{count}} stories ({{pipeline_description}}) -{{/each}} Confirm execution plan? (yes/no): @@ -980,476 +860,56 @@ Each story runs in its own Task agent. Multiple agents execute in parallel for f Initialize counters: completed=0, failed=0, failed_stories=[], reconciliation_warnings=[], reconciliation_warnings_count=0 Set start_time = current timestamp - - Jump to Step 4-Sequential (Task agents, one at a time) + + Jump to Step 4-Parallel (Task Agent execution) - - Jump to Step 4-Wave (Task agents, wave-based parallel) - - - - Jump to Step 4-Parallel (Task agents, multiple concurrent) + + Continue to Step 4-Sequential (In-session execution) - - -━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ -🚀 WAVE-BASED PARALLEL PROCESSING STARTED -━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ -**Stories:** {{count}} -**Total waves:** {{waves.length}} -**Mode:** Task agents (parallel by wave) -**Max concurrent agents:** {{parallel_count}} -**Continue on failure:** {{continue_on_failure}} -**Pattern:** Wave barrier (complete wave before next wave) -━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ - -📊 **Wave Plan (from dependency analysis):** -{{#each waves}} -Wave {{@index}}: {{count}} stories -{{#each stories}} - - {{story_key}}{{#if depends_on}} [depends on: {{depends_on}}]{{/if}} -{{/each}} -{{/each}} - - - Set abort_batch = false - - For each wave in waves (in order): - - - -━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ -🌊 STARTING WAVE {{@index}} -━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ -Stories in this wave: -{{#each stories}} - - {{story_key}}{{#if depends_on}} (depends on: {{depends_on}}){{/if}} -{{/each}} -━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ - - - Initialize wave worker pool state: - - - wave_queue = stories - - Resolve wave_queue items to full story objects by matching story_key in selected_stories (include complexity_level, story_file_path) - - active_workers = {} (map of worker_id → {story_key, task_id, started_at}) - - completed_wave_stories = [] - - failed_wave_stories = [] - - next_story_index = 0 - - max_workers = min(parallel_count, wave_queue.length) - - - - - -━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ -🔧 Initializing {{max_workers}} worker slots for Wave {{@index}}... -━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ - - - Spawn first {{max_workers}} agents (or fewer if less stories): - - While next_story_index < min(max_workers, wave_queue.length): - - - story_key = wave_queue[next_story_index].story_key - complexity_level = wave_queue[next_story_index].complexity_level - story_file_path = wave_queue[next_story_index].story_file_path - worker_id = next_story_index + 1 - - Spawn Task agent: - - subagent_type: "general-purpose" - - description: "Implement story {{story_key}}" - - prompt: "Execute super-dev-pipeline workflow for story {{story_key}}. - - Story file: docs/sprint-artifacts/{{story_key}}.md - Complexity: {{complexity_level}} - Mode: batch - - Load workflow: /Users/jonahschulte/git/BMAD-METHOD/src/modules/bmm/workflows/4-implementation/super-dev-pipeline - Follow the multi-agent pipeline (builder, inspector, reviewer, fixer). - Commit when complete, update story status, report results." - - run_in_background: true (non-blocking) - - Store in active_workers[worker_id]: - story_key: {{story_key}} - task_id: {{returned_task_id}} - started_at: {{timestamp}} - status: "running" - - - Increment next_story_index - 🚀 Worker {{worker_id}} started: {{story_key}} - - - - WAVE BARRIER: Complete all stories in this wave before starting next wave - - While active_workers.size > 0 OR next_story_index < wave_queue.length: - - Poll for completed workers (check task outputs non-blocking): - - For each worker_id in active_workers: - - Check if worker task completed using TaskOutput(task_id, block=false) - - - Continue to next worker (don't wait) - - - - Get worker details: story_key = active_workers[worker_id].story_key - - ✅ Worker {{worker_id}} completed: {{story_key}} - - Execute Step 4.5: Smart Story Reconciliation - Load reconciliation instructions: {installed_path}/step-4.5-reconcile-story-status.md - Execute reconciliation with story_key={{story_key}} - - 🚨 MANDATORY STORY FILE VERIFICATION - MAIN ORCHESTRATOR MUST RUN BASH - - -STORY_FILE="docs/sprint-artifacts/{{story_key}}.md" -echo "🔍 Verifying story file: {{story_key}}" - -CHECKED_COUNT=$(grep -c "^- \[x\]" "$STORY_FILE" 2>/dev/null || echo "0") -TOTAL_COUNT=$(grep -c "^- \[.\]" "$STORY_FILE" 2>/dev/null || echo "0") -echo " Checked tasks: $CHECKED_COUNT/$TOTAL_COUNT" - -RECORD_FILLED=$(grep -A 20 "^### Dev Agent Record" "$STORY_FILE" 2>/dev/null | grep -c "Claude Sonnet" || echo "0") -echo " Dev Agent Record: $RECORD_FILLED" - -echo "$CHECKED_COUNT" > /tmp/checked_{{story_key}}.txt -echo "$RECORD_FILLED" > /tmp/record_{{story_key}}.txt - - - - -❌ Story {{story_key}}: Agent FAILED to update story file - -Checked tasks: {{checked_tasks}}/{{total_tasks}} -Dev Agent Record: {{dev_agent_record_status}} - -🔧 EXECUTING AUTO-FIX RECONCILIATION... - - - AUTO-FIX PROCEDURE: - 1. Read agent's commit to see what files were created/modified - 2. Read story Tasks section to see what was supposed to be built - 3. For each task, check if corresponding code exists in commit - 4. If code exists, check off the task using Edit tool - 5. Fill in Dev Agent Record with commit details - 6. Verify fixes worked (re-count checked tasks) - - - ✅ AUTO-FIX SUCCESS: {{checked_tasks}}/{{total_tasks}} tasks now checked - Continue with story completion - - - - -❌ AUTO-FIX FAILED: Cannot reconcile story {{story_key}} - -After auto-fix attempts: -- Checked tasks: {{checked_tasks}}/{{total_tasks}} -- Dev Agent Record: {{dev_agent_record_status}} - -**Agent produced code but story file cannot be updated.** - -Marking story as "in-progress" (not done) and continuing with warnings. - - Override story status to "in-progress" - Add to reconciliation_warnings with detailed diagnostic - Continue (do NOT kill workers) - - - - - ✅ COMPLETED: {{story_key}} (reconciled and verified) - Tasks: {{checked_tasks}}/{{total_tasks}} ({{task_completion_pct}}%) - Increment completed counter - Add to completed_wave_stories - - - - ⚠️ WARNING: {{story_key}} - Low completion ({{task_completion_pct}}%) - Add to reconciliation_warnings: {story_key: {{story_key}}, warning_message: "Only {{task_completion_pct}}% tasks checked - manual verification needed"} - - - Remove worker_id from active_workers (free the slot) - - IMMEDIATELY refill slot if stories remain in this wave: - - story_key = wave_queue[next_story_index].story_key - complexity_level = wave_queue[next_story_index].complexity_level - story_file_path = wave_queue[next_story_index].story_file_path - - 🔄 Worker {{worker_id}} refilled: {{story_key}} - - Spawn new Task agent for this worker_id (same parameters as init) - Update active_workers[worker_id] with new task_id and story_key - Increment next_story_index - - - - - Get worker details: story_key = active_workers[worker_id].story_key - - ❌ Worker {{worker_id}} failed: {{story_key}} - - Increment failed counter - Add story_key to failed_stories list - Add to failed_wave_stories - Remove worker_id from active_workers (free the slot) - - - ⚠️ Stopping wave and batch due to failure (continue_on_failure=false) - Kill all active workers - Clear active_workers - Set abort_batch = true - Break worker pool loop - - - - story_key = wave_queue[next_story_index].story_key - complexity_level = wave_queue[next_story_index].complexity_level - story_file_path = wave_queue[next_story_index].story_file_path - - 🔄 Worker {{worker_id}} refilled: {{story_key}} (despite previous failure) - - Spawn new Task agent for this worker_id - Update active_workers[worker_id] with new task_id and story_key - Increment next_story_index - - - - - Break worker pool loop - - - Display live progress every 30 seconds: - -━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ -📊 Live Progress (Wave {{@index}} - {{timestamp}}) -━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ -✅ Completed: {{completed}} -❌ Failed: {{failed}} -🔄 Active workers: {{active_workers.size}} -📋 Queued in wave: {{wave_queue.length - next_story_index}} -━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ - - - Sleep 5 seconds before next poll (prevents tight loop) - - - - - ⛔ Aborting remaining waves due to failure and continue_on_failure=false - Jump to Step 5 (Summary) - - - -━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ -✅ WAVE {{@index}} COMPLETE -Stories completed: {{completed_wave_stories.length}} -Stories failed: {{failed_wave_stories.length}} -━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ - - - After all waves processed, jump to Step 5 (Summary) - - - + ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 🚀 SEQUENTIAL BATCH PROCESSING STARTED ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ **Stories:** {{count}} -**Mode:** Task agents (sequential, one at a time) +**Mode:** super-dev-pipeline (batch, sequential) **Continue on failure:** {{continue_on_failure}} ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ For each story in selected_stories: - + ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 📦 Story {{current_index}}/{{total_count}}: {{story_key}} ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ - -Complexity: {{complexity_level}} -Pipeline: {{#if complexity_level == 'micro'}}Lightweight (skip tests, skip review){{else if complexity_level == 'standard'}}Full quality gates{{else}}Enhanced validation{{/if}} - -Spawning Task agent... - - Use Task tool to spawn agent: - - subagent_type: "general-purpose" - - description: "Implement story {{story_key}}" - - prompt: "Execute super-dev-pipeline workflow for story {{story_key}}. + Invoke workflow: /bmad:bmm:workflows:super-dev-pipeline + Parameters: mode=batch, story_key={{story_key}}, complexity_level={{story_key}}.complexity.level - Story file: docs/sprint-artifacts/{{story_key}}.md - Complexity: {{complexity_level}} - Mode: batch - - Load workflow: /Users/jonahschulte/git/BMAD-METHOD/src/modules/bmm/workflows/4-implementation/super-dev-pipeline - Follow the multi-agent pipeline (builder, inspector, reviewer, fixer). - Commit when complete, update story status, report results." - - Store agent_id - - - WAIT for agent to complete (blocking call) - - + ✅ Implementation complete: {{story_key}} - 🚨 STORY RECONCILIATION - ORCHESTRATOR DOES THIS NOW (NOT AGENTS) + ORCHESTRATOR: You must execute reconciliation directly using Bash/Read/Edit tools. + Do NOT delegate this to an agent. YOU do it. - -━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ -🔧 RECONCILING STORY FILE: {{story_key}} -━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ -Main orchestrator performing reconciliation (not delegating) - + + 1. Use Bash: `git log -3 --oneline | grep "{{story_key}}"` to find commit + 2. Use Bash: `git diff HEAD~1 --name-only` to get files changed + 3. Use Read: `docs/sprint-artifacts/{{story_key}}.md` to see tasks + 4. Use Edit: Check off tasks (change `- [ ]` to `- [x]`) for completed work + 5. Use Edit: Fill Dev Agent Record with files/date/summary + 6. Use Bash: Verify with `grep -c "^- \[x\]"` (must be > 0) + 7. Use Edit: Update sprint-status.yaml to "done" or "review" + - YOU (orchestrator) must use Bash tool NOW with this command: - - -STORY_FILE="docs/sprint-artifacts/{{story_key}}.md" - -echo "Verifying story file: $STORY_FILE" - -CHECKED_COUNT=$(grep -c "^- \[x\]" "$STORY_FILE" 2>/dev/null || echo "0") -TOTAL_COUNT=$(grep -c "^- \[.\]" "$STORY_FILE" 2>/dev/null || echo "0") -echo "Checked tasks: $CHECKED_COUNT/$TOTAL_COUNT" - -RECORD_FILLED=$(grep -A 20 "^### Dev Agent Record" "$STORY_FILE" 2>/dev/null | grep -c "Claude Sonnet" || echo "0") -echo "Dev Agent Record: $RECORD_FILLED" - -echo "checked_count=$CHECKED_COUNT" -echo "record_filled=$RECORD_FILLED" - - - After running Bash tool, read the output and extract checked_count and record_filled values - - - -━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ -❌ STORY FILE VERIFICATION FAILED -━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ - -Story: {{story_key}} -Checked tasks: {{checked_count}}/{{total_count}} -Dev Agent Record: {{#if record_filled > 0}}FILLED{{else}}EMPTY{{/if}} - -🚨 The agent DID NOT update the story file. - -YOU (the main orchestrator) must fix this NOW. -━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ - - - MANDATORY AUTO-FIX - MAIN ORCHESTRATOR MUST EXECUTE THIS - - AUTO-FIX PROCEDURE (YOU MUST DO THIS): - - -# Step 1: Get commit for this story -COMMIT_SHA=$(git log -1 --grep="{{story_key}}" --pretty=format:"%H" 2>/dev/null) -if [ -z "$COMMIT_SHA" ]; then - # Try finding by story key pattern - COMMIT_SHA=$(git log -5 --pretty=format:"%H %s" | grep -i "{{story_key}}" | head -1 | cut -d' ' -f1) -fi - -echo "Found commit: $COMMIT_SHA" - -# Step 2: Get files changed -git diff ${COMMIT_SHA}~1 $COMMIT_SHA --name-only | grep -v "test/" | grep -v "__tests__" - - - Step 3: Read story file to get Tasks section: - docs/sprint-artifacts/{{story_key}}.md - - Step 4: For EACH task in Tasks section: - For each line starting with "- [ ]": - - - - Extract task description - - Check if git diff contains related file/function - - If YES: Use Edit tool to change "- [ ]" to "- [x]" - - Verify edit: Run bash grep to confirm checkbox is now checked - - - Step 5: Fill Dev Agent Record using Edit tool: - - - Find "### Dev Agent Record" section - - Replace with actual data: - * Agent Model: Claude Sonnet 4.5 (multi-agent pipeline) - * Date: {{current_date}} - * Files: {{files_from_git_diff}} - * Notes: {{from_commit_message}} - - - Step 6: Re-run verification bash commands: - - -CHECKED_COUNT=$(grep -c "^- \[x\]" "$STORY_FILE") -RECORD_FILLED=$(grep -A 20 "^### Dev Agent Record" "$STORY_FILE" | grep -c "Claude Sonnet") - -echo "After auto-fix:" -echo " Checked tasks: $CHECKED_COUNT" -echo " Dev Agent Record: $RECORD_FILLED" - -if [ "$CHECKED_COUNT" -eq 0 ]; then - echo "❌ AUTO-FIX FAILED: Story file still not updated" - exit 1 -fi - -echo "✅ AUTO-FIX SUCCESS" - - - - ✅ AUTO-FIX SUCCESS: Story file now updated ({{checked_count}} tasks checked) - Continue with story as completed - - - - -❌ AUTO-FIX FAILED: Cannot reconcile story {{story_key}} - -After multiple fix attempts, story file still shows: -- Checked tasks: {{checked_count}} -- Dev Agent Record: {{record_status}} - -Marking story as "in-progress" (not done). - - Update sprint-status to "in-progress" instead of "done" - Add to failed_stories list - Continue to next story (if continue_on_failure) - - - - - -⚠️ WARNING: Story {{story_key}} - LOW TASK COMPLETION - -Only {{checked_tasks}}/{{total_tasks}} tasks checked ({{task_completion_pct}}%). - -This suggests incomplete implementation. Cannot mark as "done". -Marking as "in-progress" instead. - - Override story status to "in-progress" - Override sprint-status to "in-progress" - Add to reconciliation_warnings - - - - ✅ COMPLETED: {{story_key}} (reconciled and verified) - Tasks: {{checked_tasks}}/{{total_tasks}} ({{task_completion_pct}}%) + + ✅ COMPLETED: {{story_key}} (reconciled) Increment completed counter @@ -1594,13 +1054,15 @@ Press [C] to continue or [P] to pause: - description: "Implement story {{story_key}}" - prompt: "Execute super-dev-pipeline workflow for story {{story_key}}. - Story file: docs/sprint-artifacts/{{story_key}}.md - Complexity: {{complexity_level}} - Mode: batch + CRITICAL INSTRUCTIONS: + 1. Load workflow.xml: _bmad/core/tasks/workflow.xml + 2. Load workflow config: _bmad/bmm/workflows/4-implementation/super-dev-pipeline/workflow.yaml + 3. Execute in BATCH mode with story_key={{story_key}} and complexity_level={{story_key}}.complexity.level + 4. Follow all 7 pipeline steps (init, pre-gap, implement, post-validate, code-review, complete, summary) + 5. Commit changes when complete + 6. Report final status (done/failed) with file list - Load workflow: /Users/jonahschulte/git/BMAD-METHOD/src/modules/bmm/workflows/4-implementation/super-dev-pipeline - Follow the multi-agent pipeline (builder, inspector, reviewer, fixer). - Commit when complete, update story status, report results." + Story file will be auto-resolved from multiple naming conventions." - run_in_background: true (non-blocking - critical for semaphore pattern) Store in active_workers[worker_id]: @@ -1643,77 +1105,27 @@ Press [C] to continue or [P] to pause: ✅ Worker {{worker_id}} completed: {{story_key}} - Execute Step 4.5: Smart Story Reconciliation - Load reconciliation instructions: {installed_path}/step-4.5-reconcile-story-status.md - Execute reconciliation with story_key={{story_key}} + ORCHESTRATOR: You must execute reconciliation directly using Bash/Read/Edit tools. - 🚨 MANDATORY STORY FILE VERIFICATION - MAIN ORCHESTRATOR MUST RUN BASH + + 1. Use Bash: `git log -3 --oneline | grep "{{story_key}}"` to find commit + 2. Use Bash: `git diff HEAD~1 --name-only` to get files changed + 3. Use Read: `docs/sprint-artifacts/{{story_key}}.md` to see tasks + 4. Use Edit: Check off tasks (change `- [ ]` to `- [x]`) for completed work + 5. Use Edit: Fill Dev Agent Record with files/date/summary + 6. Use Bash: Verify with `grep -c "^- \[x\]"` (must be > 0) + 7. Use Edit: Update sprint-status.yaml to "done" or "review" + - -STORY_FILE="docs/sprint-artifacts/{{story_key}}.md" -echo "🔍 Verifying story file: {{story_key}}" - -CHECKED_COUNT=$(grep -c "^- \[x\]" "$STORY_FILE" 2>/dev/null || echo "0") -TOTAL_COUNT=$(grep -c "^- \[.\]" "$STORY_FILE" 2>/dev/null || echo "0") -echo " Checked tasks: $CHECKED_COUNT/$TOTAL_COUNT" - -RECORD_FILLED=$(grep -A 20 "^### Dev Agent Record" "$STORY_FILE" 2>/dev/null | grep -c "Claude Sonnet" || echo "0") -echo " Dev Agent Record: $RECORD_FILLED" - -echo "$CHECKED_COUNT" > /tmp/checked_{{story_key}}.txt -echo "$RECORD_FILLED" > /tmp/record_{{story_key}}.txt - - - - -❌ Story {{story_key}}: Agent FAILED to update story file - -Checked tasks: {{checked_tasks}}/{{total_tasks}} -Dev Agent Record: {{dev_agent_record_status}} - -🔧 EXECUTING AUTO-FIX RECONCILIATION... - - - AUTO-FIX PROCEDURE: - 1. Read agent's commit to see what files were created/modified - 2. Read story Tasks section to see what was supposed to be built - 3. For each task, check if corresponding code exists in commit - 4. If code exists, check off the task using Edit tool - 5. Fill in Dev Agent Record with commit details - 6. Verify fixes worked (re-count checked tasks) - - - ✅ AUTO-FIX SUCCESS: {{checked_tasks}}/{{total_tasks}} tasks now checked - Continue with story completion - - - - -❌ AUTO-FIX FAILED: Cannot reconcile story {{story_key}} - -After auto-fix attempts: -- Checked tasks: {{checked_tasks}}/{{total_tasks}} -- Dev Agent Record: {{dev_agent_record_status}} - -**Agent produced code but story file cannot be updated.** - -Marking story as "in-progress" (not done) and continuing with warnings. - - Override story status to "in-progress" - Add to reconciliation_warnings with detailed diagnostic - Continue (do NOT kill workers) - - - - - ✅ COMPLETED: {{story_key}} (reconciled and verified) - Tasks: {{checked_tasks}}/{{total_tasks}} ({{task_completion_pct}}%) + + ✅ COMPLETED: {{story_key}} (reconciled) Add to completed_stories - - ⚠️ WARNING: {{story_key}} - Low completion ({{task_completion_pct}}%) - Add to reconciliation_warnings: {story_key: {{story_key}}, warning_message: "Only {{task_completion_pct}}% tasks checked - manual verification needed"} + + ⚠️ WARNING: {{story_key}} completed but reconciliation failed + Add to completed_stories (implementation successful) + Add to reconciliation_warnings: {story_key: {{story_key}}, warning_message: "Reconciliation failed - manual verification needed"} Remove worker_id from active_workers (free the slot) diff --git a/src/modules/bmm/workflows/4-implementation/batch-super-dev/step-4.5-reconcile-story-status.md b/src/modules/bmm/workflows/4-implementation/batch-super-dev/step-4.5-reconcile-story-status.md index ad2e49dc..daf96e00 100644 --- a/src/modules/bmm/workflows/4-implementation/batch-super-dev/step-4.5-reconcile-story-status.md +++ b/src/modules/bmm/workflows/4-implementation/batch-super-dev/step-4.5-reconcile-story-status.md @@ -1,390 +1,171 @@ -# Step 4.5: Smart Story Reconciliation +# Step 4.5: Story Reconciliation (Orchestrator-Driven) -Execute AFTER super-dev-pipeline completes but BEFORE marking story as "completed" -This ensures story checkboxes and status accurately reflect actual implementation - -## Goal - -Verify story file accuracy by reconciling: -1. **Acceptance Criteria checkboxes** vs Dev Agent Record -2. **Tasks/Subtasks checkboxes** vs Dev Agent Record -3. **Definition of Done checkboxes** vs Dev Agent Record -4. **Story status** (should be "done" if implementation complete) -5. **sprint-status.yaml entry** (should match story file status) +**Version:** 2.1.0 +**Execute:** AFTER super-dev-pipeline completes, BEFORE marking story done +**Who:** Orchestrator (YOU) - not an agent --- -## Execution +## Why Orchestrator Does This -### 1. Load Story File - -Read story file: {story_file_path} -Extract sections: - - Acceptance Criteria (## Acceptance Criteria) - - Tasks / Subtasks (## Tasks / Subtasks) - - Definition of Done (## Definition of Done) - - Dev Agent Record (## Dev Agent Record) - - Story status header (**Status:** ...) - - -### 2. Analyze Dev Agent Record - -Read "Dev Agent Record" section - - - ⚠️ Story {{story_key}}: Dev Agent Record is empty - cannot reconcile - This suggests super-dev-pipeline did not complete successfully. - Mark story as FAILED reconciliation - Return early (skip remaining checks) - - -Parse Dev Agent Record fields: - - **Agent Model Used** (should have model name, not empty) - - **Implementation Summary** (should describe what was built) - - **File List** (should list new/modified files) - - **Test Results** (should show test counts) - - **Completion Notes** (should document what works) - - - - Set implementation_status = COMPLETE - - - - Set implementation_status = INCOMPLETE - ⚠️ Story {{story_key}}: Implementation appears incomplete based on Dev Agent Record - - -### 3. Reconcile Acceptance Criteria - -For each AC subsection (AC1, AC2, AC3, AC4, etc.): - -For each checkbox in AC section: - - - Search Implementation Summary and File List for keywords from checkbox text - - - Checkbox: "[ ] FlexibleGridSection component (renders dynamic grid layouts)" - Implementation Summary mentions: "FlexibleGridSection component created" - File List includes: "FlexibleGridSection.tsx" - → Expected status: CHECKED - - - Determine expected_checkbox_status: - - CHECKED if Implementation Summary confirms it OR File List shows created files OR Test Results mention it - - UNCHECKED if no evidence in Dev Agent Record - - PARTIAL if mentioned as "pending" or "infrastructure ready" - - - - - Read actual checkbox state from story file ([x] vs [ ] vs [~]) - - - 🔧 Reconciling AC: "{{checkbox_text}}" - Actual: {{actual_status}} - Expected: {{expected_status}} - Reason: {{evidence_from_dev_record}} - - Add to reconciliation_changes list - - - -After checking all ACs: - - Count total AC items - - Count checked AC items (after reconciliation) - - Calculate AC completion percentage - - -### 4. Reconcile Tasks / Subtasks - -For each Task (Task 1, Task 2, etc.): - -For each checkbox in Tasks section: - - - Search Implementation Summary and File List for task keywords - - - Task checkbox: "[ ] **2.2:** Create FlexibleGridSection component" - File List includes: "apps/frontend/web/src/components/FlexibleGridSection.tsx" - → Expected status: CHECKED - - - Determine expected_checkbox_status using same logic as AC section - - - - Read actual checkbox state - - - 🔧 Reconciling Task: "{{task_text}}" - Actual: {{actual_status}} - Expected: {{expected_status}} - Reason: {{evidence_from_dev_record}} - - Add to reconciliation_changes list - - - -After checking all Tasks: - - Count total task items - - Count checked task items (after reconciliation) - - Calculate task completion percentage - - -### 5. Reconcile Definition of Done - -For each DoD category (Code Quality, Testing, Security, etc.): - -For each checkbox in DoD section: - - - Check Test Results, Completion Notes for evidence - - - DoD checkbox: "[ ] Type check passes: `pnpm type-check` (zero errors)" - Completion Notes say: "Type check passes ✅" - → Expected status: CHECKED - - - - DoD checkbox: "[ ] Unit tests: 90%+ coverage" - Test Results say: "37 tests passing" - Completion Notes say: "100% coverage on FlexibleGridSection" - → Expected status: CHECKED - - - Determine expected_checkbox_status - - - - Read actual checkbox state - - - 🔧 Reconciling DoD: "{{dod_text}}" - Actual: {{actual_status}} - Expected: {{expected_status}} - Reason: {{evidence_from_dev_record}} - - Add to reconciliation_changes list - - - -After checking all DoD items: - - Count total DoD items - - Count checked DoD items (after reconciliation) - - Calculate DoD completion percentage - - -### 6. Determine Correct Story Status - -Based on completion percentages, determine correct story status: - - - Set correct_story_status = "done" - - - - Set correct_story_status = "review" - - - - Set correct_story_status = "in-progress" - - - - Override: Set correct_story_status = "in-progress" - ⚠️ Overriding status to "in-progress" due to incomplete implementation - - -Read current story status from story file (**Status:** ...) - - - 🔧 Story status mismatch: - Current: {{current_story_status}} - Expected: {{correct_story_status}} - Reason: AC={{ac_pct}}% Tasks={{tasks_pct}}% DoD={{dod_pct}}% - - Add to reconciliation_changes list - - -### 7. Verify sprint-status.yaml Entry - -Read {sprint_status} file -Find entry for {{story_key}} -Extract current status from sprint-status.yaml - - - 🔧 sprint-status.yaml mismatch: - Current: {{sprint_status_yaml_status}} - Expected: {{correct_story_status}} - - Add to reconciliation_changes list - - -### 8. Apply Reconciliation Changes - - - ✅ Story {{story_key}}: Already accurate (0 changes needed) - Return SUCCESS (no updates needed) - - - - -🔧 Story {{story_key}}: Reconciling {{count}} issues - -**Changes to apply:** -{{#each reconciliation_changes}} -{{@index}}. {{change_description}} -{{/each}} - - - Apply these reconciliation changes? (yes/no): - - - ⏭️ Skipping reconciliation for {{story_key}} - Return SUCCESS (user declined changes) - - - - For each AC checkbox that needs updating: - Use Edit tool to update checkbox from [ ] to [x] or [~] - Add note explaining why: "- [x] Item - COMPLETE: {{evidence}}" - - - - For each Task checkbox that needs updating: - Use Edit tool to update checkbox - Update task header if all subtasks complete: "### Task 1: ... ✅ COMPLETE" - - - - For each DoD checkbox that needs updating: - Use Edit tool to update checkbox - Add verification note: "- [x] Item ✅ (verified in Dev Agent Record)" - - - - - Use Edit tool to update status line - Change from: **Status:** {{old_status}} - Change to: **Status:** {{correct_story_status}} - - - - - - Use Edit tool to update status entry - - Count tasks from story file: - - total_tasks = all top-level tasks - - checked_tasks = tasks marked [x] - - progress_pct = (checked_tasks / total_tasks) × 100 - - - Update comment with progress tracking (NEW v1.3.0): - If status == "in-progress": - Format: {{story_key}}: in-progress # {{checked_tasks}}/{{total_tasks}} tasks ({{progress_pct}}%) - - If status == "review": - Format: {{story_key}}: review # {{checked_tasks}}/{{total_tasks}} tasks ({{progress_pct}}%) - awaiting review - - If status == "done": - Format: {{story_key}}: done # ✅ COMPLETED: {{brief_summary}} - - - - Before: 20-8-...: ready-for-dev # Story description - During: 20-8-...: in-progress # 3/10 tasks (30%) - During: 20-8-...: in-progress # 7/10 tasks (70%) - Review: 20-8-...: review # 10/10 tasks (100%) - awaiting review - After: 20-8-...: done # ✅ COMPLETED: Component + tests + docs - - - - - ✅ Story {{story_key}}: Reconciliation complete ({{count}} changes applied) - - -### 9. Final Verification - -Re-read story file to verify changes applied correctly -Calculate final completion percentages - - -📊 Story {{story_key}} - Final Status - -**Acceptance Criteria:** {{ac_checked}}/{{ac_total}} ({{ac_pct}}%) -**Tasks/Subtasks:** {{tasks_checked}}/{{tasks_total}} ({{tasks_pct}}%) -**Definition of Done:** {{dod_checked}}/{{dod_total}} ({{dod_pct}}%) - -**Story Status:** {{correct_story_status}} -**sprint-status.yaml:** {{correct_story_status}} - -{{#if correct_story_status == "done"}} -✅ Story is COMPLETE and accurately reflects implementation -{{/if}} - -{{#if correct_story_status == "review"}} -⚠️ Story needs review (some items incomplete) -{{/if}} - -{{#if correct_story_status == "in-progress"}} -⚠️ Story has significant gaps (implementation incomplete) -{{/if}} - - -Return SUCCESS with reconciliation summary +Agents ignore reconciliation instructions. The orchestrator: +- Has full context of what just happened +- Can use tools directly (Bash, Read, Edit) +- Won't skip "boring" bookkeeping tasks --- -## Success Criteria +## Execute These Steps -Story reconciliation succeeds when: -1. ✅ All checkboxes match Dev Agent Record evidence -2. ✅ Story status accurately reflects completion (done/review/in-progress) -3. ✅ sprint-status.yaml entry matches story file status -4. ✅ Completion percentages calculated and reported -5. ✅ Changes documented in reconciliation summary +### Step 1: Get What Was Built ---- +Run this command with Bash tool: -## Error Handling +```bash +echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━" +echo "🔧 STORY RECONCILIATION: {{story_key}}" +echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━" - - ❌ Story {{story_key}}: File not found at {{story_file_path}} - Return FAILED reconciliation - +# Get the commit for this story +echo "Recent commits:" +git log -5 --oneline | grep -i "{{story_key}}" || echo "(no commits found with story key)" - - ⚠️ Story {{story_key}}: Cannot reconcile - Dev Agent Record not populated - Mark as INCOMPLETE (not implemented yet) - Return WARNING reconciliation - - - - ❌ Story {{story_key}}: Failed to apply changes (Edit tool error) - Log error details - Return FAILED reconciliation - - ---- - -## Integration with batch-super-dev - -**Insert this step:** -- **Sequential mode:** After Step 4s-a (Process individual story), before marking completed -- **Parallel mode:** After Step 4p-a (Spawn Task agents), after agent completes but before marking completed - -**Flow:** -``` -super-dev-pipeline completes → Step 4.5 (Reconcile) → Mark as completed/failed +# Get files changed +echo "" +echo "Files changed in last commit:" +git diff HEAD~1 --name-only | grep -v "__tests__" | grep -v "\.test\." | head -20 ``` -**Benefits:** -- Ensures all batch-processed stories have accurate status -- Catches mismatches automatically -- Prevents "done" stories with unchecked items -- Maintains sprint-status.yaml accuracy +Store the output - you'll need it for the next steps. + +### Step 2: Read Story File + +Use Read tool on: `docs/sprint-artifacts/{{story_key}}.md` + +Find these sections: +- **Tasks** (lines starting with `- [ ]` or `- [x]`) +- **Dev Agent Record** (section with Agent Model, Implementation Date, etc.) + +### Step 3: Check Off Completed Tasks + +For EACH task in the Tasks section that relates to files changed: + +Use Edit tool: +``` +file_path: docs/sprint-artifacts/{{story_key}}.md +old_string: "- [ ] Create the SomeComponent" +new_string: "- [x] Create the SomeComponent" +``` + +**Match logic:** +- If task mentions a file that was created → check it off +- If task mentions a service/component that now exists → check it off +- If unsure → leave unchecked (don't over-claim) + +### Step 4: Fill Dev Agent Record + +Use Edit tool to replace the placeholder record: + +``` +file_path: docs/sprint-artifacts/{{story_key}}.md +old_string: "### Dev Agent Record +- **Agent Model Used:** [Not set] +- **Implementation Date:** [Not set] +- **Files Created/Modified:** [Not set] +- **Tests Added:** [Not set] +- **Completion Notes:** [Not set]" +new_string: "### Dev Agent Record +- **Agent Model Used:** Claude Sonnet 4 (multi-agent pipeline) +- **Implementation Date:** 2026-01-26 +- **Files Created/Modified:** + - path/to/file1.ts + - path/to/file2.ts + [list all files from git diff] +- **Tests Added:** X tests (from Inspector report) +- **Completion Notes:** Implemented [brief summary]" +``` + +### Step 5: Verify Updates + +Run this command with Bash tool: + +```bash +echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━" +echo "🔍 RECONCILIATION VERIFICATION" +echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━" + +STORY_FILE="docs/sprint-artifacts/{{story_key}}.md" + +# Count checked tasks +CHECKED=$(grep -c "^- \[x\]" "$STORY_FILE" 2>/dev/null || echo "0") +UNCHECKED=$(grep -c "^- \[ \]" "$STORY_FILE" 2>/dev/null || echo "0") +TOTAL=$((CHECKED + UNCHECKED)) +echo "Tasks: $CHECKED/$TOTAL checked" + +if [ "$CHECKED" -eq 0 ]; then + echo "" + echo "❌ BLOCKER: Zero tasks checked off" + echo "You MUST go back to Step 3 and check off tasks" + exit 1 +fi + +# Check Dev Agent Record filled +if grep -q "Implementation Date: \[Not set\]" "$STORY_FILE" 2>/dev/null; then + echo "❌ BLOCKER: Dev Agent Record not filled" + echo "You MUST go back to Step 4 and fill it" + exit 1 +fi + +if grep -A 3 "### Dev Agent Record" "$STORY_FILE" | grep -q "Implementation Date: 202"; then + echo "✅ Dev Agent Record: Filled" +else + echo "❌ BLOCKER: Dev Agent Record incomplete" + exit 1 +fi + +echo "" +echo "✅ RECONCILIATION COMPLETE" +echo " Checked tasks: $CHECKED/$TOTAL" +echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━" +``` + +### Step 6: Update Sprint Status + +Use Read tool: `docs/sprint-artifacts/sprint-status.yaml` + +Find the entry for {{story_key}} and use Edit tool to update: + +``` +old_string: "{{story_key}}: ready-for-dev" +new_string: "{{story_key}}: done # ✅ COMPLETED 2026-01-26" +``` + +Or if 95%+ complete but not 100%: +``` +new_string: "{{story_key}}: review # 8/10 tasks - awaiting review" +``` + +--- + +## Status Decision Logic + +Based on verification results: + +| Condition | Status | +|-----------|--------| +| 95%+ tasks checked + Dev Record filled | `done` | +| 80-94% tasks checked | `review` | +| <80% tasks checked | `in-progress` | +| Dev Record not filled | `in-progress` | + +--- + +## If Verification Fails + +1. **DO NOT** proceed to next story +2. **DO NOT** mark story as done +3. **FIX** the issue using Edit tool +4. **RE-RUN** verification command +5. **REPEAT** until verification passes + +This is mandatory. No shortcuts. diff --git a/src/modules/bmm/workflows/4-implementation/super-dev-pipeline/agents/builder.md b/src/modules/bmm/workflows/4-implementation/super-dev-pipeline/agents/builder.md index b1699681..6c100cbc 100644 --- a/src/modules/bmm/workflows/4-implementation/super-dev-pipeline/agents/builder.md +++ b/src/modules/bmm/workflows/4-implementation/super-dev-pipeline/agents/builder.md @@ -93,4 +93,43 @@ When complete, provide: --- +## When Complete, Return This Format + +```markdown +## AGENT COMPLETE + +**Agent:** builder +**Story:** {{story_key}} +**Status:** SUCCESS | FAILED + +### Files Created +- path/to/new/file1.ts +- path/to/new/file2.ts + +### Files Modified +- path/to/existing/file.ts + +### Tests Added +- X test files +- Y test cases total + +### Implementation Summary +Brief description of what was built and key decisions made. + +### Known Gaps +- Any functionality not implemented +- Any edge cases not handled +- NONE if all tasks complete + +### Ready For +Inspector validation (next phase) +``` + +**Why this format?** The orchestrator parses this output to: +- Verify claimed files actually exist +- Track what was built for reconciliation +- Route to next phase appropriately + +--- + **Remember:** You are the BUILDER. Build it well, but don't validate or review your own work. Other agents will do that with fresh eyes. diff --git a/src/modules/bmm/workflows/4-implementation/super-dev-pipeline/agents/fixer.md b/src/modules/bmm/workflows/4-implementation/super-dev-pipeline/agents/fixer.md index 487982aa..32343483 100644 --- a/src/modules/bmm/workflows/4-implementation/super-dev-pipeline/agents/fixer.md +++ b/src/modules/bmm/workflows/4-implementation/super-dev-pipeline/agents/fixer.md @@ -20,15 +20,15 @@ You are the **FIXER** agent. Your job is to fix CRITICAL and HIGH issues from th - Fix security vulnerabilities immediately - Fix logic bugs and edge cases - Re-run tests after each fix -- Update story checkboxes -- Update sprint-status.yaml -- Commit changes +- Commit code changes with descriptive message **DO NOT:** - Skip CRITICAL issues - Skip HIGH issues - Spend time on LOW issues - Make unnecessary changes +- Update story checkboxes (orchestrator does this) +- Update sprint-status.yaml (orchestrator does this) --- @@ -79,118 +79,7 @@ low_issues: [#10, #11] # SKIP (gold-plating) ## After Fixing Issues -### 1. Update Story File (MANDATORY) - -**THIS STEP IS MANDATORY. DO NOT SKIP.** - -**Step 1a: Identify what was built** -```bash -# Get list of files changed in latest commit -git diff HEAD~1 --name-only - -# Get commit message -git log -1 --pretty=%B -``` - -**Step 1b: Read story Tasks section** -```bash -# Find the Tasks section in story file -grep -A 100 "^## Tasks" docs/sprint-artifacts/{{story_key}}.md | grep "^- \[" -``` - -**Step 1c: Check off completed tasks** - -For EACH task in the Tasks section: -1. Read the task description -2. Check if related files/functions exist in git diff -3. If code for that task exists, use Edit tool to change `- [ ]` to `- [x]` -4. Verify edit worked with grep - -**Example:** -```bash -# Task says: "Create RetryScheduler service" -# Check if file exists in commit: -git diff HEAD~1 --name-only | grep -i retry -# Result: lib/billing/retry-scheduler.ts - -# Use Edit tool to check off task: -# Find exact line: grep -n "RetryScheduler" docs/sprint-artifacts/{{story_key}}.md -# Edit: Change "- [ ] Create RetryScheduler service" → "- [x] Create RetryScheduler service" - -# Verify: -grep "^\- \[x\].*RetryScheduler" docs/sprint-artifacts/{{story_key}}.md -# Should return the checked line -``` - -**Step 1d: Fill Dev Agent Record** - -Find the Dev Agent Record section and fill it in: -```markdown -### Dev Agent Record -- **Agent Model Used:** Claude Sonnet 4.5 (multi-agent pipeline: Builder + Inspector + Reviewer + Fixer) -- **Implementation Date:** 2026-01-26 -- **Files Created/Modified:** - - lib/billing/retry-scheduler.ts - - lib/billing/payment-processor.ts - - lib/billing/worker.ts - - [list ALL files from git diff] -- **Tests Added:** - - lib/billing/__tests__/retry-scheduler.test.ts - - lib/billing/__tests__/payment-processor.test.ts - - lib/billing/__tests__/worker.test.ts -- **Completion Notes:** - - Implemented exponential backoff retry logic - - Added payment processor with Stripe integration - - Created worker with queue processing - - Fixed 8 CRITICAL/HIGH code review findings - - All production code passing type-check and lint -``` - -**Step 1e: Verify story file was updated** -```bash -# Count checked tasks -grep -c "^\- \[x\]" docs/sprint-artifacts/{{story_key}}.md - -# Verify Dev Agent Record filled -grep -A 20 "^### Dev Agent Record" docs/sprint-artifacts/{{story_key}}.md | grep -c "Agent Model" - -# If count is 0, STOP and fix it. DO NOT PROCEED to commit. -``` - -### 2. Update Sprint Status - -**Update sprint-status.yaml:** -```yaml -{{story_key}}: done # was: ready-for-dev -``` - -### 3. Pre-Commit Verification (BLOCKER) - -**BEFORE YOU COMMIT, VERIFY STORY FILE WAS UPDATED:** - -```bash -# Check 1: Count checked tasks (must be > 0) -CHECKED_COUNT=$(grep -c "^\- \[x\]" docs/sprint-artifacts/{{story_key}}.md) -echo "Checked tasks: $CHECKED_COUNT" - -# Check 2: Verify Dev Agent Record filled (must be 1) -RECORD_FILLED=$(grep -A 20 "^### Dev Agent Record" docs/sprint-artifacts/{{story_key}}.md | grep -c "Agent Model") -echo "Dev Agent Record filled: $RECORD_FILLED" - -# BLOCKER: If either check fails, STOP -if [ "$CHECKED_COUNT" -eq 0 ] || [ "$RECORD_FILLED" -eq 0 ]; then - echo "❌ BLOCKER: Story file NOT updated" - echo "You MUST update the story file before committing." - echo "Go back to Step 1 and complete the story reconciliation." - exit 1 -fi - -echo "✅ Story file verification passed" -``` - -### 4. Commit Changes - -**Only proceed if Step 3 verification passed:** +### Commit Changes ```bash git add . @@ -247,21 +136,8 @@ All tests passing, type check clean, lint clean." - ✅ Build: PASS - ✅ Tests: 48/48 passing (96% coverage) -**Story File Updates (MANDATORY):** -- ✅ Tasks checked off: X/Y tasks marked complete -- ✅ Dev Agent Record filled with files and notes -- ✅ Verified with grep (counts > 0) - **Git:** - ✅ Commit created: a1b2c3d -- ✅ Sprint status updated to "done" - -**Pre-Commit Verification:** -- ✅ Checked tasks count: X (must be > 0) -- ✅ Dev Agent Record filled: YES (must be 1) -- ✅ BLOCKER passed - -**Story Status:** COMPLETE ``` --- @@ -288,4 +164,47 @@ All tests passing, type check clean, lint clean." --- +## When Complete, Return This Format + +```markdown +## AGENT COMPLETE + +**Agent:** fixer +**Story:** {{story_key}} +**Status:** SUCCESS | PARTIAL | FAILED + +### Issues Fixed +- **CRITICAL:** X/Y fixed +- **HIGH:** X/Y fixed +- **Total:** X issues resolved + +### Fixes Applied +1. [CRITICAL] file.ts:45 - Fixed SQL injection with parameterized query +2. [HIGH] file.ts:89 - Added null check + +### Files Modified +- path/to/file1.ts +- path/to/file2.ts + +### Quality Checks +- **Type Check:** PASS | FAIL +- **Lint:** PASS | FAIL +- **Tests:** X passing, Y failing + +### Git Commit +- **Hash:** abc123 +- **Message:** fix({{story_key}}): address code review findings + +### Deferred Issues +- MEDIUM: X issues (defer to follow-up) +- LOW: X issues (skip as gold-plating) + +### Ready For +Orchestrator reconciliation (story file updates) +``` + +**Note:** Story checkboxes and sprint-status updates are done by the orchestrator, not you. + +--- + **Remember:** You are the FIXER. Fix real problems, skip gold-plating, commit when done. diff --git a/src/modules/bmm/workflows/4-implementation/super-dev-pipeline/agents/inspector.md b/src/modules/bmm/workflows/4-implementation/super-dev-pipeline/agents/inspector.md index 0a14d6c4..93d92625 100644 --- a/src/modules/bmm/workflows/4-implementation/super-dev-pipeline/agents/inspector.md +++ b/src/modules/bmm/workflows/4-implementation/super-dev-pipeline/agents/inspector.md @@ -150,4 +150,35 @@ Cannot proceed to code review until these are fixed. --- +## When Complete, Return This Format + +```markdown +## AGENT COMPLETE + +**Agent:** inspector +**Story:** {{story_key}} +**Status:** PASS | FAIL + +### Evidence +- **Type Check:** PASS (0 errors) | FAIL (X errors) +- **Lint:** PASS (0 warnings) | FAIL (X warnings) +- **Build:** PASS | FAIL +- **Tests:** X passing, Y failing, Z% coverage + +### Files Verified +- path/to/file1.ts ✓ +- path/to/file2.ts ✓ +- path/to/missing.ts ✗ (NOT FOUND) + +### Failures (if FAIL status) +1. Specific failure with file:line reference +2. Another specific failure + +### Ready For +- If PASS: Reviewer (next phase) +- If FAIL: Builder needs to fix before proceeding +``` + +--- + **Remember:** You are the INSPECTOR. Your job is to find the truth, not rubber-stamp the Builder's work. If something is wrong, say so with evidence. diff --git a/src/modules/bmm/workflows/4-implementation/super-dev-pipeline/agents/reconciler.md b/src/modules/bmm/workflows/4-implementation/super-dev-pipeline/agents/reconciler.md deleted file mode 100644 index d821c4ce..00000000 --- a/src/modules/bmm/workflows/4-implementation/super-dev-pipeline/agents/reconciler.md +++ /dev/null @@ -1,226 +0,0 @@ -# Reconciler Agent - Story File Update (MANDATORY) - -**Role:** Update story file with implementation results -**Step:** 10 (final - runs after Fixer completes) -**Trust Level:** HIGH (simple, focused task) -**Mandatory:** YES (cannot be skipped) - ---- - -## Your Mission - -You are the **RECONCILER** agent. Your ONLY job is to update the story file to reflect what was built. - -🚨 **THIS IS THE MOST IMPORTANT STEP** 🚨 - -Without this step, no one knows what was built. The story file is the source of truth. - ---- - -## What You Must Do - -### Step 1: Read the Git Commit - -```bash -# Get the commit message for this story -git log -1 --pretty=format:"%H %s %b" | head -20 - -# Get files changed -git diff HEAD~1 --name-only | grep -v "^test/" | grep -v "__tests__" -``` - -**Extract:** -- Commit SHA -- Files created/modified (production code only, exclude tests for now) -- What was built (from commit message) - ---- - -### Step 2: Read the Story File - -```bash -# Read the full story file -cat docs/sprint-artifacts/{{story_key}}.md -``` - -**Find:** -- Tasks section (look for `## Tasks`) -- Dev Agent Record section (look for `### Dev Agent Record`) -- Current completion status - ---- - -### Step 3: Check Off Completed Tasks - -**For EACH task in the Tasks section:** - -1. **Read the task description** -2. **Check if related code exists in git diff** - - Does the task mention a file that was created/modified? - - Does the task mention a function/service that now exists? -3. **If YES: Use Edit tool to check it off** - - Change `- [ ]` to `- [x]` - - Use exact string matching -4. **Verify the edit worked:** - ```bash - grep "^\- \[x\].*{{task keyword}}" docs/sprint-artifacts/{{story_key}}.md - ``` - -**Example:** - -Task: `- [ ] Create BillingWorker service` - -Check if it exists: -```bash -git diff HEAD~1 --name-only | grep -i "worker" -# Returns: lib/billing/worker.ts -``` - -Edit the story file: -```typescript -old_string: "- [ ] Create BillingWorker service" -new_string: "- [x] Create BillingWorker service" -``` - -Verify: -```bash -grep "^\- \[x\].*BillingWorker" docs/sprint-artifacts/{{story_key}}.md -# Should return the checked line -``` - ---- - -### Step 4: Fill Dev Agent Record - -Find the Dev Agent Record section and replace it with actual data: - -**BEFORE:** -```markdown -### Dev Agent Record -- **Agent Model Used:** [Not set] -- **Implementation Date:** [Not set] -- **Files Created/Modified:** [Not set] -- **Tests Added:** [Not set] -- **Completion Notes:** [Not set] -``` - -**AFTER:** -```markdown -### Dev Agent Record -- **Agent Model Used:** Claude Sonnet 4.5 (multi-agent: Builder + Inspector + Reviewer + Fixer + Reconciler) -- **Implementation Date:** 2026-01-26 -- **Files Created/Modified:** - - lib/billing/worker.ts - - lib/billing/payment-processor.ts - - lib/billing/retry-scheduler.ts - - [ALL files from git diff --name-only HEAD~1] -- **Tests Added:** - - lib/billing/__tests__/worker.test.ts - - lib/billing/__tests__/payment-processor.test.ts - - lib/billing/__tests__/retry-scheduler.test.ts -- **Completion Notes:** - - Implemented retry logic with exponential backoff - - Fixed 8 CRITICAL/HIGH code review findings - - All type checks passing, lint clean - - Tests: [status from Inspector report] -``` - -Use the Edit tool to replace the entire Dev Agent Record section. - ---- - -### Step 5: Verify Your Work (BLOCKER) - -🚨 **THIS VERIFICATION IS MANDATORY. YOU MUST RUN IT.** 🚨 - -```bash -echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━" -echo "🔍 RECONCILIATION VERIFICATION" -echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━" - -# Check 1: Count checked tasks -CHECKED_COUNT=$(grep -c "^\- \[x\]" docs/sprint-artifacts/{{story_key}}.md) -echo "Checked tasks: $CHECKED_COUNT" - -if [ "$CHECKED_COUNT" -eq 0 ]; then - echo "" - echo "❌ RECONCILIATION FAILED" - echo "Story file has ZERO checked tasks." - echo "You MUST go back to Step 3 and check off tasks." - echo "" - exit 1 -fi - -# Check 2: Verify Dev Agent Record filled -RECORD_FILLED=$(grep -A 20 "^### Dev Agent Record" docs/sprint-artifacts/{{story_key}}.md | grep -c "Claude Sonnet") -echo "Dev Agent Record filled: $RECORD_FILLED" - -if [ "$RECORD_FILLED" -eq 0 ]; then - echo "" - echo "❌ RECONCILIATION FAILED" - echo "Dev Agent Record NOT filled." - echo "You MUST go back to Step 4 and fill it in." - echo "" - exit 1 -fi - -echo "" -echo "✅ RECONCILIATION SUCCESSFUL" -echo " - Checked tasks: $CHECKED_COUNT" -echo " - Dev Agent Record: FILLED" -echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━" -``` - -**If verification fails:** -- STOP immediately -- Fix the issue -- Re-run verification -- DO NOT report "COMPLETE" until verification passes - -**If verification passes:** -- Report success with task count -- Story is now officially complete - ---- - -## Output Requirements - -**Provide Reconciliation Summary:** - -```markdown -## Reconciliation Complete - -**Story File Updated:** -- ✅ Tasks checked: X/Y tasks marked complete -- ✅ Dev Agent Record filled with implementation details -- ✅ Verification passed - -**What Was Built:** -- File 1: lib/billing/worker.ts (BillingWorker service) -- File 2: lib/billing/payment-processor.ts (Payment processing) -- File 3: lib/billing/retry-scheduler.ts (Retry scheduling) -- [List ALL production files from git diff] - -**Tests:** -- X tests added -- Y tests passing -- Coverage: Z% - -**Story Status:** READY FOR COMPLETION -``` - ---- - -## Remember - -🚨 **Your job is RECONCILIATION, not implementation** 🚨 - -- Don't write code -- Don't fix bugs -- Don't run tests -- ONLY update the story file -- ONLY verify it worked - -If you do this right, the user will know EXACTLY what was built and can mark the story done with confidence. - -**This is the last step. Make it count.** diff --git a/src/modules/bmm/workflows/4-implementation/super-dev-pipeline/agents/reviewer.md b/src/modules/bmm/workflows/4-implementation/super-dev-pipeline/agents/reviewer.md index 39e7232f..72038cc6 100644 --- a/src/modules/bmm/workflows/4-implementation/super-dev-pipeline/agents/reviewer.md +++ b/src/modules/bmm/workflows/4-implementation/super-dev-pipeline/agents/reviewer.md @@ -187,4 +187,37 @@ Before completing review, check: --- +## When Complete, Return This Format + +```markdown +## AGENT COMPLETE + +**Agent:** reviewer +**Story:** {{story_key}} +**Status:** ISSUES_FOUND | CLEAN + +### Issue Summary +- **CRITICAL:** X issues (security, data loss) +- **HIGH:** X issues (production bugs) +- **MEDIUM:** X issues (tech debt) +- **LOW:** X issues (nice-to-have) +- **TOTAL:** X issues + +### Must Fix (CRITICAL + HIGH) +1. [CRITICAL] file.ts:45 - SQL injection in user query +2. [HIGH] file.ts:89 - Missing null check causes crash + +### Should Fix (MEDIUM) +1. file.ts:123 - No error handling for API call + +### Files Reviewed +- path/to/file1.ts ✓ +- path/to/file2.ts ✓ + +### Ready For +Fixer agent to address CRITICAL and HIGH issues +``` + +--- + **Remember:** You are the ADVERSARIAL REVIEWER. Your success is measured by finding legitimate issues. Don't be nice - be thorough. diff --git a/src/modules/bmm/workflows/4-implementation/super-dev-pipeline/workflow.md b/src/modules/bmm/workflows/4-implementation/super-dev-pipeline/workflow.md index d2603244..40384e1e 100644 --- a/src/modules/bmm/workflows/4-implementation/super-dev-pipeline/workflow.md +++ b/src/modules/bmm/workflows/4-implementation/super-dev-pipeline/workflow.md @@ -1,16 +1,19 @@ -# Super-Dev-Pipeline v2.0 - Multi-Agent Architecture +# Super-Dev-Pipeline v2.1 - Multi-Agent Architecture -**Version:** 2.0.0 +**Version:** 2.1.0 **Architecture:** GSDMAD (GSD + BMAD) -**Philosophy:** Trust but verify, separation of concerns +**Philosophy:** Agents do creative work, orchestrator does bookkeeping --- ## Overview -This workflow implements a story using **4 independent agents** with external validation at each phase. +This workflow implements a story using **4 independent agents** with orchestrator-driven reconciliation. -**Key Innovation:** Each agent has single responsibility and fresh context. No agent validates its own work. +**Key Innovation:** +- Each agent has single responsibility and fresh context +- No agent validates its own work +- **Orchestrator does bookkeeping** (story file updates, verification) - not agents --- @@ -22,44 +25,45 @@ This workflow implements a story using **4 independent agents** with external va │ - Loads story │ │ - Spawns agents sequentially │ │ - Verifies each phase │ +│ - DOES RECONCILIATION DIRECTLY (not via agent) │ │ - Final quality gate │ └─────────────────────────────────────────────────────────────┘ │ - ├──> Phase 1: Builder (Steps 1-4) + ├──> Phase 1: Builder (Steps 1-4) [AGENT] │ - Load story, analyze gaps │ - Write tests (TDD) │ - Implement code │ - Report what was built (NO VALIDATION) │ - ├──> Phase 2: Inspector (Steps 5-6) + ├──> Phase 2: Inspector (Steps 5-6) [AGENT] │ - Fresh context, no Builder knowledge │ - Verify files exist │ - Run tests independently │ - Run quality checks │ - PASS or FAIL verdict │ - ├──> Phase 3: Reviewer (Step 7) + ├──> Phase 3: Reviewer (Step 7) [AGENT] │ - Fresh context, adversarial stance │ - Find security vulnerabilities │ - Find performance problems │ - Find logic bugs │ - Report issues with severity │ - ├──> Phase 4: Fixer (Steps 8-9) + ├──> Phase 4: Fixer (Steps 8-9) [AGENT] │ - Fix CRITICAL issues (all) │ - Fix HIGH issues (all) │ - Fix MEDIUM issues (if time) │ - Skip LOW issues (gold-plating) │ - Commit code changes │ - ├──> Phase 5: Reconciler (Step 10) 🚨 MANDATORY - │ - Read git commit to see what was built + ├──> Phase 5: Reconciliation (Step 10) [ORCHESTRATOR] 🔧 + │ - Orchestrator uses Bash/Read/Edit tools directly │ - Check off completed tasks in story file │ - Fill Dev Agent Record with details - │ - VERIFY updates with bash commands - │ - BLOCKER: Exit 1 if verification fails + │ - Verify updates with bash commands + │ - BLOCKER if verification fails │ - └──> Final Verification (Main) + └──> Final Verification [ORCHESTRATOR] - Check git commits exist - Check story checkboxes updated (count > 0) - Check Dev Agent Record filled @@ -190,52 +194,89 @@ Task({ **Wait for Fixer to complete.** -### Phase 5: Spawn Reconciler (MANDATORY) +### Phase 5: Orchestrator Reconciliation (MANDATORY) -🚨 **THIS PHASE IS MANDATORY. ALWAYS RUN. CANNOT BE SKIPPED.** 🚨 +🚨 **THIS PHASE IS MANDATORY. ORCHESTRATOR DOES THIS DIRECTLY. NO AGENT SPAWN.** 🚨 -```javascript -Task({ - subagent_type: "general-purpose", - description: "Reconcile story {{story_key}}", - prompt: ` - You are the RECONCILER agent for story {{story_key}}. +**Why orchestrator, not agent?** Agents ignore instructions. The orchestrator has the context +and can use tools directly. This is bookkeeping work, not creative work. - Load and execute: {agents_path}/reconciler.md +**YOU (the orchestrator) must execute these commands directly:** - Story file: {{story_file}} - Story key: {{story_key}} +**Step 5.1: Get what was built** +```bash +# Get commit for this story +COMMIT_INFO=$(git log -5 --oneline | grep "{{story_key}}" | head -1) +echo "Commit: $COMMIT_INFO" - Complete Step 10 - Story Reconciliation: - - Your ONLY job: - 1. Read git commit to see what was built - 2. Check off completed tasks in story file (Edit tool) - 3. Fill Dev Agent Record with files/dates/notes - 4. Verify updates worked (bash grep commands) - 5. Exit 1 if verification fails - - DO NOT: - - Write code - - Fix bugs - - Run tests - - Do anything except update the story file - - This is the LAST step. The story cannot be marked complete - without your verification passing. - - Output: Reconciliation summary with checked task count. - ` -}); +# Get files changed (production code only) +FILES_CHANGED=$(git diff HEAD~1 --name-only | grep -v "__tests__" | grep -v "\.test\." | grep -v "\.spec\.") +echo "Files changed:" +echo "$FILES_CHANGED" ``` -**Wait for Reconciler to complete. Verification MUST pass.** +**Step 5.2: Read story file tasks** +Use Read tool: `{{story_file}}` -**If Reconciler verification fails (exit 1):** -- DO NOT proceed -- DO NOT mark story complete -- Fix the reconciliation immediately -- Re-run Reconciler until it passes +Find the Tasks section and identify which tasks relate to the files changed. + +**Step 5.3: Check off completed tasks** +Use Edit tool for EACH task that was completed: +``` +old_string: "- [ ] Task description here" +new_string: "- [x] Task description here" +``` + +**Step 5.4: Fill Dev Agent Record** +Use Edit tool to update the Dev Agent Record section: +``` +old_string: "### Dev Agent Record +- **Agent Model Used:** [Not set] +- **Implementation Date:** [Not set] +- **Files Created/Modified:** [Not set] +- **Tests Added:** [Not set] +- **Completion Notes:** [Not set]" + +new_string: "### Dev Agent Record +- **Agent Model Used:** Claude Sonnet 4 (multi-agent: Builder + Inspector + Reviewer + Fixer) +- **Implementation Date:** {{date}} +- **Files Created/Modified:** + {{#each files_changed}} + - {{this}} + {{/each}} +- **Tests Added:** [count from Inspector report] +- **Completion Notes:** [brief summary of what was implemented]" +``` + +**Step 5.5: Verify updates (BLOCKER)** +```bash +echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━" +echo "🔍 RECONCILIATION VERIFICATION" +echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━" + +# Count checked tasks +CHECKED=$(grep -c "^- \[x\]" {{story_file}}) +echo "Checked tasks: $CHECKED" + +if [ "$CHECKED" -eq 0 ]; then + echo "❌ BLOCKER: Zero checked tasks" + echo "Go back to Step 5.3 and check off tasks" + exit 1 +fi + +# Verify Dev Agent Record +RECORD=$(grep -A 5 "### Dev Agent Record" {{story_file}} | grep -c "Implementation Date:") +if [ "$RECORD" -eq 0 ]; then + echo "❌ BLOCKER: Dev Agent Record not filled" + echo "Go back to Step 5.4 and fill it" + exit 1 +fi + +echo "✅ Reconciliation verified: $CHECKED tasks checked" +echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━" +``` + +**If verification fails:** DO NOT proceed. Fix immediately using Edit tool, then re-verify. --- diff --git a/src/modules/bmm/workflows/4-implementation/super-dev-pipeline/workflow.yaml b/src/modules/bmm/workflows/4-implementation/super-dev-pipeline/workflow.yaml index f3165c02..6ab01b6d 100644 --- a/src/modules/bmm/workflows/4-implementation/super-dev-pipeline/workflow.yaml +++ b/src/modules/bmm/workflows/4-implementation/super-dev-pipeline/workflow.yaml @@ -67,15 +67,7 @@ agents: trust_level: "medium" # Incentive to minimize work timeout: 2400 # 40 minutes - reconciler: - description: "Story reconciliation - MANDATORY story file updates" - steps: [10] - subagent_type: "general-purpose" - prompt_file: "{agents_path}/reconciler.md" - trust_level: "high" # Simple, focused task - timeout: 600 # 10 minutes - mandatory: true # Cannot be skipped - runs_after: "fixer" +# Reconciliation: orchestrator does this directly (see workflow.md Phase 5) # Complexity level (determines which steps to execute) complexity_level: "standard" # micro | standard | complex