From e5d426eddf3f148ac0f01a80c7cb8585336c81a4 Mon Sep 17 00:00:00 2001 From: Jonah Schulte Date: Mon, 26 Jan 2026 21:42:37 -0500 Subject: [PATCH] fix: make story verification executable with REQUIRED bash commands in orchestrator **Critical Enhancement:** Main orchestrator now MUST run bash verification **Changes:** - Added tags around verification commands - Orchestrator must execute these bash commands (not just read instructions) - Bash commands output to /tmp files for conditional logic - Auto-fix procedure has explicit bash commands to run - Both Sequential and Wave execution have same enforcement **Enforcement Strategy:** 1. Orchestrator spawns Task agent 2. Task agent completes 3. Orchestrator MUST run bash verification commands 4. If verification fails, orchestrator MUST run auto-fix bash commands 5. If auto-fix fails, mark story as in-progress and continue **This creates layered enforcement:** - Reconciler agent (inside pipeline) has bash exit 1 on failure - Main orchestrator (batch-super-dev) has bash verification on failure - Both layers must pass for story to be marked done **Version:** 6.0.0-Beta.5 --- .../batch-super-dev/instructions.md | 148 +++++++++++++----- 1 file changed, 111 insertions(+), 37 deletions(-) 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 79d8c72f..30e9a47c 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 @@ -1301,53 +1301,127 @@ Spawning Task agent... Load reconciliation instructions: {installed_path}/step-4.5-reconcile-story-status.md Execute reconciliation with story_key={{story_key}} - 🚨 AUTO-FIX RECONCILIATION - MAKE IT RIGHT NOW - Verify reconciliation by checking story file: - 1. Re-read story file: {{story_file_path}} - 2. Count checked tasks: grep -c "^\- \[x\]" {{story_file_path}} - 3. Count total tasks: grep -c "^\- \[.\]" {{story_file_path}} - 4. Verify Dev Agent Record filled + 🚨 MANDATORY STORY FILE VERIFICATION - YOU MUST RUN THESE BASH COMMANDS - + STEP 1: Run bash verification commands (REQUIRED): + + +# Get story file path from story_key +STORY_FILE="docs/sprint-artifacts/{{story_key}}.md" + +echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━" +echo "🔍 VERIFYING STORY FILE: {{story_key}}" +echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━" + +# Check 1: Count checked tasks +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" + +# Check 2: Verify Dev Agent Record filled +RECORD_FILLED=$(grep -A 20 "^### Dev Agent Record" "$STORY_FILE" 2>/dev/null | grep -c "Claude Sonnet" || echo "0") +echo "Dev Agent Record filled: $RECORD_FILLED" + +# Store results for conditional logic +echo "$CHECKED_COUNT" > /tmp/checked_count.txt +echo "$RECORD_FILLED" > /tmp/record_filled.txt + + + STEP 2: Read bash results and decide: + + -❌ Story {{story_key}}: Agent failed to update story file +━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ +❌ STORY FILE VERIFICATION FAILED +━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ -Checked tasks: {{checked_tasks}}/{{total_tasks}} -Dev Agent Record: {{empty/filled}} +Story: {{story_key}} +Checked tasks: {{checked_count}}/{{total_count}} +Dev Agent Record: {{#if record_filled > 0}}FILLED{{else}}EMPTY{{/if}} -🔧 EXECUTING IMMEDIATE AUTO-FIX RECONCILIATION... +🚨 The agent DID NOT update the story file. + +YOU (the main orchestrator) must fix this NOW. +━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ - AUTO-FIX STEPS: - 1. Read the agent's git commit for this story - 2. Extract files created/modified from commit - 3. Read story Tasks section - 4. For each task: - - Check if task mentions a file from the commit - - Check if task mentions a function that exists in those files - - If yes: Use Edit tool to check off task (- [ ] → - [x]) - - Verify edit worked with grep - - If edit failed: Retry with exact line match - - If still failed: Log and continue to next task - 5. Fill in Dev Agent Record: - - Agent Model: Extract from state file - - File List: From git diff --name-only - - Completion Notes: From commit message - - Use Edit tool to replace placeholder text - 6. Verify auto-fix worked: - - Re-count checked tasks - - Verify Dev Agent Record no longer empty + MANDATORY AUTO-FIX - MAIN ORCHESTRATOR MUST EXECUTE THIS - - ✅ AUTO-FIX SUCCESS: {{checked_tasks}}/{{total_tasks}} tasks now checked + 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 PARTIAL: Only {{checked_tasks}}/{{total_tasks}} tasks reconciled - Mark story as "review" (not done) in sprint-status - Add detailed warning to reconciliation_warnings - Continue (do not halt entire batch) + + +❌ 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)