fix: add CRITICAL enforcement to prevent workflow failures (from production battle-testing)\n**Root Cause Analysis:**

Agents marked stories 'done' but left ALL tasks unchecked, Dev Agent Records empty,
and implemented different code than story specifications. This happened because
workflows had NO ENFORCEMENT - everything was optional theater.

**Enforcement Added (7 files changed):**

1. **workflow.xml** - Filename validation at completion
   - Verifies output matches canonical format
   - Auto-renames wrong-named files
   - Prevents 'story-' prefix proliferation

2. **step-04-implement.md** - Per-task checkbox enforcement
   - After EVERY task: Verify checkbox updated
   - Auto-fix with Edit tool if missing
   - 3-attempt retry before halt
   - Batch tasks: Loop through all, verify each

3. **step-10-complete.md** - Final verification before commit
   - Count checked tasks (HALT if zero)
   - Verify Dev Agent Record filled (HALT if empty)
   - Auto-fix from git commit if missing

4. **batch-super-dev Step 4.5** - Mandatory reconciliation
   - Verify checked_tasks > 0 after reconciliation
   - Auto-fix: Read commit → match tasks → check boxes
   - Fill Dev Agent Record from commit message
   - Override status to 'in-progress' if <80% complete

5. **super-dev-pipeline/workflow.yaml** - Canonical filename pattern
   - Changed: story-*.md → *.md (removed 'story-' prefix)

6. **multi-agent-review/workflow.yaml** - Canonical format
   - Changed: story-{story_id}.md → {story_id}.md

7. **batch-super-dev instructions** - ONE canonical format
   - Format: {epic}-{story}-{slug}.md (NO 'story-' prefix)
   - Auto-rename legacy 'story-' files
   - Removed all 6 pattern variations
   - Single format everywhere

**Behavioral Changes:**
- Before: Agents could skip tasks, leave checkboxes unchecked, claim 'done'
- After: Auto-fix with retry, HALT only if all attempts exhausted
- Before: Multiple filename formats caused confusion
- After: ONE format, auto-rename legacy files
- Before: No verification, trust agent claims
- After: Verify EVERYTHING, auto-fix failures

**Tested in production:**
- Epic 18 batch execution revealed all failure modes
- Every enforcement added addresses real observed failure
- No theoretical fixes - all battle-tested

**Quality Standards:**
Lives are at stake. Zero tolerance for unchecked tasks or missing documentation.

Ref: craftedcall commits 9e299817e, e607a4422, 6a9d87176, 0240b4742, 91f73c7f4
This commit is contained in:
Jonah Schulte 2026-01-26 09:43:33 -05:00
parent 0df4c73872
commit bc950dec99
7 changed files with 503 additions and 74 deletions

View File

@ -99,7 +99,29 @@
<step n="3" title="Completion"> <step n="3" title="Completion">
<check>Confirm document saved to output path</check> <check>Confirm document saved to output path</check>
<action>Report workflow completion</action>
<critical>🚨 FILENAME VALIDATION - CANONICAL FORMAT ENFORCEMENT</critical>
<action>Verify output filename matches expected pattern from workflow.yaml</action>
<action>
Expected: {default_output_file} (from workflow.yaml)
Actual: {file_actually_created}
If filenames don't match:
❌ CRITICAL: Agent created file with WRONG name
Expected: {default_output_file}
Got: {file_actually_created}
Auto-fix: Rename file to canonical format
```bash
mv "{file_actually_created}" "{default_output_file}"
```
Verify rename worked:
test -f "{default_output_file}" || (echo "Rename failed - HALT" && exit 1)
</action>
<action>Report workflow completion with verified filename</action>
</step> </step>
</flow> </flow>

View File

@ -94,30 +94,40 @@ Run `/bmad_bmm_sprint-status` to see current status.</output>
<example>Input: "20-11" → epic=20, story=11, suffix=""</example> <example>Input: "20-11" → epic=20, story=11, suffix=""</example>
</substep> </substep>
<substep n="2b" title="Try multiple file patterns using Glob tool"> <substep n="2b" title="Check for story file using CANONICAL format only">
<action>Use Glob tool to search for files matching these patterns (in priority order):</action> <critical>🚨 ONE CANONICAL FORMAT - NO VARIATIONS</critical>
<pattern n="1">story-{epic_num}.{story_num}.md</pattern> <action>CANONICAL FORMAT: {story_key}.md</action>
<example>story-20.9.md (DOT notation, no suffix)</example> <example>20-9-megamenu-navigation.md (epic-story-slug, NO prefix)</example>
<example>18-1-charge-model-state-machine.md (epic-story-slug, NO prefix)</example>
<pattern n="2">story-{epic_num}.{story_num}*.md</pattern> <action>Check if file exists: {sprint_artifacts}/{story_key}.md</action>
<example>story-20.9-megamenu-navigation.md (DOT notation WITH suffix - use Glob wildcard)</example>
<pattern n="3">{epic_num}-{story_num}.md</pattern> <check if="file exists">
<example>20-9.md (HYPHEN notation, no "story-" prefix)</example> <action>Set file_status = ✅ EXISTS</action>
<action>Store file_path = {sprint_artifacts}/{story_key}.md</action>
</check>
<pattern n="4">{epic_num}-{story_num}*.md</pattern> <check if="file does NOT exist">
<example>20-9-megamenu-navigation.md (HYPHEN notation WITH suffix)</example> <action>Set file_status = ❌ MISSING</action>
<pattern n="5">story-{story_key}.md</pattern> <action>Check for legacy wrong-named files:</action>
<example>story-20-9-megamenu-navigation.md (literal story_key with "story-" prefix)</example> <action> Search for: story-{story_key}.md (wrong - has "story-" prefix)</action>
<pattern n="6">{story_key}.md</pattern> <check if="found wrong-named file">
<example>20-9-megamenu-navigation.md (literal story_key)</example> <output>⚠️ Found legacy file: story-{story_key}.md</output>
<output>🔧 AUTO-RENAMING to canonical: {story_key}.md</output>
<action>Stop at first match and store file_path</action> <action>Rename: mv story-{story_key}.md {story_key}.md</action>
<action>If NO match found after all 6 patterns → file_status = ❌ MISSING</action> <action>Verify rename worked</action>
<action>If match found → file_status = ✅ EXISTS</action> <action>Set file_status = ✅ EXISTS (after rename)</action>
<action>Store file_path = {sprint_artifacts}/{story_key}.md</action>
</check>
<check if="no file found (canonical OR legacy)">
<action>file_status = ❌ MISSING (genuinely missing)</action>
</check>
</check>
</substep> </substep>
<action>Mark stories as: ✅ (file exists), ❌ (file missing), 🔄 (already implemented but not marked done)</action> <action>Mark stories as: ✅ (file exists), ❌ (file missing), 🔄 (already implemented but not marked done)</action>
@ -1116,8 +1126,73 @@ Wave {{wave_num}} complete: {{completed_in_wave}} succeeded, {{failed_in_wave}}
<action>Load reconciliation instructions: {installed_path}/step-4.5-reconcile-story-status.md</action> <action>Load reconciliation instructions: {installed_path}/step-4.5-reconcile-story-status.md</action>
<action>Execute reconciliation with story_key={{story_key}}</action> <action>Execute reconciliation with story_key={{story_key}}</action>
<check if="reconciliation succeeded"> <critical>🚨 AUTO-FIX RECONCILIATION - MAKE IT RIGHT NOW</critical>
<output>✅ COMPLETED: {{story_key}} (reconciled)</output> <action>Verify reconciliation by checking story file:</action>
<action> 1. Re-read story file: {{story_file_path}}</action>
<action> 2. Count checked tasks: grep -c "^\- \[x\]" {{story_file_path}}</action>
<action> 3. Count total tasks: grep -c "^\- \[.\]" {{story_file_path}}</action>
<action> 4. Verify Dev Agent Record filled</action>
<check if="checked_tasks == 0 OR dev_agent_record_empty">
<output>
❌ Story {{story_key}}: Agent failed to update story file
Checked tasks: {{checked_tasks}}/{{total_tasks}}
Dev Agent Record: {{empty/filled}}
🔧 EXECUTING IMMEDIATE AUTO-FIX RECONCILIATION...
</output>
<action>AUTO-FIX STEPS:</action>
<action>1. Read the agent's git commit for this story</action>
<action>2. Extract files created/modified from commit</action>
<action>3. Read story Tasks section</action>
<action>4. For each task:</action>
<action> - Check if task mentions a file from the commit</action>
<action> - Check if task mentions a function that exists in those files</action>
<action> - If yes: Use Edit tool to check off task (- [ ] → - [x])</action>
<action> - Verify edit worked with grep</action>
<action> - If edit failed: Retry with exact line match</action>
<action> - If still failed: Log and continue to next task</action>
<action>5. Fill in Dev Agent Record:</action>
<action> - Agent Model: Extract from state file</action>
<action> - File List: From git diff --name-only</action>
<action> - Completion Notes: From commit message</action>
<action> - Use Edit tool to replace placeholder text</action>
<action>6. Verify auto-fix worked:</action>
<action> - Re-count checked tasks</action>
<action> - Verify Dev Agent Record no longer empty</action>
<check if="auto_fix_succeeded AND checked_tasks > 0">
<output>✅ AUTO-FIX SUCCESS: {{checked_tasks}}/{{total_tasks}} tasks now checked</output>
<action>Continue with story as completed</action>
</check>
<check if="auto_fix_failed OR checked_tasks still == 0">
<output>⚠️ AUTO-FIX PARTIAL: Only {{checked_tasks}}/{{total_tasks}} tasks reconciled</output>
<action>Mark story as "review" (not done) in sprint-status</action>
<action>Add detailed warning to reconciliation_warnings</action>
<action>Continue (do not halt entire batch)</action>
</check>
</check>
<check if="task_completion_pct < 80">
<output>
⚠️ 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.
</output>
<action>Override story status to "in-progress"</action>
<action>Override sprint-status to "in-progress"</action>
<action>Add to reconciliation_warnings</action>
</check>
<check if="reconciliation succeeded AND checked_tasks > 0 AND dev_agent_record_filled">
<output>✅ COMPLETED: {{story_key}} (reconciled and verified)</output>
<output> Tasks: {{checked_tasks}}/{{total_tasks}} ({{task_completion_pct}}%)</output>
<action>Increment completed counter</action> <action>Increment completed counter</action>
<check if="execution_mode == 'interactive_checkpoint'"> <check if="execution_mode == 'interactive_checkpoint'">
@ -1317,15 +1392,62 @@ Press [C] to continue or [P] to pause:
<action>Load reconciliation instructions: {installed_path}/step-4.5-reconcile-story-status.md</action> <action>Load reconciliation instructions: {installed_path}/step-4.5-reconcile-story-status.md</action>
<action>Execute reconciliation with story_key={{story_key}}</action> <action>Execute reconciliation with story_key={{story_key}}</action>
<check if="reconciliation succeeded"> <critical>🚨 MANDATORY RECONCILIATION AUTO-FIX - MAKE IT RIGHT</critical>
<output>✅ COMPLETED: {{story_key}} (reconciled)</output> <action>Verify reconciliation by checking story file:</action>
<action> 1. Re-read story file: {{story_file_path}}</action>
<action> 2. Count checked tasks vs total tasks</action>
<action> 3. Check Dev Agent Record filled</action>
<check if="checked_tasks == 0 OR dev_agent_record_empty">
<output>
❌ 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...
</output>
<action>AUTO-FIX PROCEDURE:</action>
<action>1. Read agent's commit to see what files were created/modified</action>
<action>2. Read story Tasks section to see what was supposed to be built</action>
<action>3. For each task, check if corresponding code exists in commit</action>
<action>4. If code exists, check off the task using Edit tool</action>
<action>5. Fill in Dev Agent Record with commit details</action>
<action>6. Verify fixes worked (re-count checked tasks)</action>
<check if="auto_fix_succeeded AND checked_tasks > 0">
<output>✅ AUTO-FIX SUCCESS: {{checked_tasks}}/{{total_tasks}} tasks now checked</output>
<action>Continue with story completion</action>
</check>
<check if="auto_fix_failed OR checked_tasks still == 0">
<output>
❌ 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.
</output>
<action>Override story status to "in-progress"</action>
<action>Add to reconciliation_warnings with detailed diagnostic</action>
<action>Continue (do NOT kill workers)</action>
</check>
</check>
<check if="reconciliation succeeded AND checked_tasks > 0 AND dev_agent_record_filled">
<output>✅ COMPLETED: {{story_key}} (reconciled and verified)</output>
<output> Tasks: {{checked_tasks}}/{{total_tasks}} ({{task_completion_pct}}%)</output>
<action>Add to completed_stories</action> <action>Add to completed_stories</action>
</check> </check>
<check if="reconciliation failed"> <check if="task_completion_pct < 80">
<output>⚠️ WARNING: {{story_key}} completed but reconciliation failed</output> <output>⚠️ WARNING: {{story_key}} - Low completion ({{task_completion_pct}}%)</output>
<action>Add to completed_stories (implementation successful)</action> <action>Add to reconciliation_warnings: {story_key: {{story_key}}, warning_message: "Only {{task_completion_pct}}% tasks checked - manual verification needed"}</action>
<action>Add to reconciliation_warnings: {story_key: {{story_key}}, warning_message: "Reconciliation failed - manual verification needed"}</action>
</check> </check>
<action>Remove worker_id from active_workers (free the slot)</action> <action>Remove worker_id from active_workers (free the slot)</action>

View File

@ -15,7 +15,7 @@ instructions: "{installed_path}/instructions.md"
# Input parameters # Input parameters
story_id: "{story_id}" # Required story_id: "{story_id}" # Required
story_file: "{sprint_artifacts}/story-{story_id}.md" story_file: "{sprint_artifacts}/{story_id}.md" # CANONICAL FORMAT: epic-story-slug.md (NO "story-" prefix)
base_branch: "main" # Optional: branch to compare against base_branch: "main" # Optional: branch to compare against
complexity_level: "standard" # micro | standard | complex (passed from super-dev-pipeline) complexity_level: "standard" # micro | standard | complex (passed from super-dev-pipeline)
@ -55,4 +55,3 @@ review_settings:
review_report: "{sprint_artifacts}/review-{story_id}-multi-agent.md" review_report: "{sprint_artifacts}/review-{story_id}-multi-agent.md"
standalone: true standalone: true
web_bundle: false

View File

@ -44,52 +44,83 @@ Check if running in batch or interactive mode:
Set `{mode}` variable. Set `{mode}` variable.
### 2. Resolve Story File Path ### 2. Resolve Story File Path (CANONICAL FORMAT ONLY)
<critical>🚨 ONE CANONICAL NAMING FORMAT - NO VARIATIONS ALLOWED</critical>
**Canonical Format:** `{epic}-{story_num}-{slug}.md`
**Examples:**
- 1-1-multi-tenant-data-isolation-security.md
- 18-1-charge-model-state-machine.md
- 20-3-payment-dashboard.md
**From input parameters:** **From input parameters:**
- `story_id`: e.g., "1-4" - `story_key`: Full key like "18-1-charge-model-state-machine"
- `story_file`: Full path to story file - `story_file`: Full path (if explicitly provided)
**If story_file not provided:** **If story_file not provided:**
```bash
sprint_artifacts="{sprint_artifacts}"
story_key="{story_key}" # e.g., "18-1-charge-model-state-machine"
# CANONICAL PATH (only one pattern):
story_file="${sprint_artifacts}/${story_key}.md"
# Example: /path/to/docs/sprint-artifacts/18-1-charge-model-state-machine.md
``` ```
story_file = {sprint_artifacts}/story-{story_id}.md
``` **NO FALLBACKS. NO ALTERNATIVES. ONE FORMAT.**
### 3. Verify Story Exists (Auto-Create if Missing - NEW v1.4.0) ### 3. Verify Story Exists (Auto-Create if Missing - NEW v1.4.0)
### 3. Verify Story File Exists (Auto-Fix Wrong Names)
```bash ```bash
# Check if story file exists # Check if canonical file exists
test -f "{story_file}" if [ ! -f "$story_file" ]; then
``` echo "⚠️ Canonical file not found: $story_file"
echo ""
echo "🔍 Searching for wrong-named versions..."
**If story does NOT exist:** # Check for common wrong patterns
``` wrong_patterns=(
⚠️ Story file not found at {story_file} "${sprint_artifacts}/story-${story_key}.md" # story- prefix (legacy)
"${sprint_artifacts}/${epic_num}.${story_num}-*.md" # dot notation
)
🔄 AUTO-CREATING: Invoking /create-story-with-gap-analysis... found_wrong=""
``` for wrong_pattern in "${wrong_patterns[@]}"; do
if ls $wrong_pattern 2>/dev/null | head -1 | read wrong_file; then
found_wrong="$wrong_file"
break
fi
done
<invoke-workflow path="{create_story_workflow}/workflow.yaml"> if [ -n "$found_wrong" ]; then
<input name="story_id">{story_id}</input> echo "✅ Found wrong-named file: $found_wrong"
<input name="epic_num">{epic_num}</input> echo "🔧 AUTO-RENAMING to canonical format: $story_file"
<input name="story_num">{story_num}</input>
</invoke-workflow>
After workflow completes, verify story was created: mv "$found_wrong" "$story_file"
```bash
test -f "{story_file}" && echo "✅ Story created successfully" || echo "❌ Story creation failed - HALT"
```
**If story was created, set flag for smart gap analysis:** if [ -f "$story_file" ]; then
```yaml echo "✅ Renamed successfully"
# Set state flag to skip redundant gap analysis in step 2 else
story_just_created: true echo "❌ Rename failed - HALT"
gap_analysis_completed: true # Already done in create-story-with-gap-analysis exit 1
``` fi
else
echo "❌ No story file found (canonical OR wrong names)"
echo ""
echo "**STORY FILE REQUIRED - CANNOT VIBE CODE**"
echo ""
echo "Creating story file now..."
# Invoke create-story workflow
fi
fi
**If story exists:** echo "✅ Story file verified: $story_file"
```
✅ Story file found: {story_file}
``` ```
### 4. Load Story File ### 4. Load Story File

View File

@ -219,18 +219,59 @@ npm test -- --run && npm run lint
**D. If Validation Succeeds:** **D. If Validation Succeeds:**
``` ```
✅ Batch Complete ✅ Batch Complete - All {task_count} tasks executed successfully!
```
All {task_count} tasks in batch executed successfully! <critical>🚨 AUTO-FIX: CHECK OFF ALL BATCH TASKS WITH RETRY LOGIC</critical>
Marking all tasks complete: **For EACH task in batch:**
- [x] {task_1}
- [x] {task_2} ```
- [x] {task_3} FOR task_text IN [task_1, task_2, task_3, ...]:
...
ATTEMPT 1: Use Edit tool to check off task
Read story file
Find line: "- [ ] {task_text}"
Edit to: "- [x] {task_text}"
VERIFY:
Re-read story file
Check if "- [x] {task_text}" exists
IF FAILED:
ATTEMPT 2: Retry with exact line matching
Read story file with line numbers
Find exact line text (with spacing/indentation)
Edit with exact old_string match
Verify again
IF FAILED:
ATTEMPT 3: Write entire section
Read full Tasks section
Update all batch task checkboxes to [x]
Write back to story file
Verify again
IF STILL FAILED:
❌ CRITICAL: Cannot check off task after 3 attempts
Log diagnostic info:
- Task text we're trying to check
- What Edit tool is matching against
- Edit tool error messages
HALT - Fundamental tool failure
SUCCESS:
✅ Task checked: {task_text}
Continue to next task in batch
END FOR
✅ All {task_count} batch tasks verified checked
```
**Guarantee:** Every task gets 3 attempts to check off. Only HALT if all methods exhausted.
Time: {actual_time} minutes Time: {actual_time} minutes
```
**E. If Validation Fails:** **E. If Validation Fails:**
``` ```
@ -360,10 +401,56 @@ After implementing task, verify:
- [ ] No TypeScript errors - [ ] No TypeScript errors
- [ ] Follows project patterns - [ ] Follows project patterns
**Mark task complete in story file:** **MANDATORY: Mark task complete in story file:**
```markdown
- [x] {task_description} <critical>🚨 AUTO-FIX ENFORCEMENT - CHECK OFF TASK OR RETRY UNTIL SUCCESS</critical>
``` ```
STEP 1: Attempt to check off task using Edit tool
Read current task line from story file
Use Edit tool to change: "- [ ] {task_text}" → "- [x] {task_text}"
STEP 2: VERIFY checkbox was updated (MANDATORY)
Re-read story file
Count checked tasks for this specific task
IF VERIFICATION FAILS:
❌ Edit tool failed to check off task
RETRY LOGIC:
1. Read story file again (get latest content)
2. Find exact task line (with line numbers)
3. Use Edit tool with EXACT old_string (including indentation, spacing)
4. Update to [x]
5. Verify again
IF RETRY FAILS:
❌ Still not checked after retry
DIAGNOSTIC:
- Show actual line from story file
- Show what Edit tool tried to match
- Show error message from Edit tool
THEN: Use Write tool to rewrite entire story file with task checked
THEN: Verify AGAIN
IF STILL FAILS:
HALT - Something is fundamentally broken, cannot continue
STEP 3: Confirmation
✅ Task checkbox verified: {task_text}
Story file updated: {checked_count} tasks now complete
```
**Auto-fix loop:** Try Edit → Verify → Retry Edit → Verify → Write file → Verify → HALT only if all methods fail
**Maximum 3 attempts before HALT.**
**Update state file with progress.** **Update state file with progress.**
@ -459,7 +546,50 @@ Ready for Post-Validation
## QUALITY GATE ## QUALITY GATE
Before proceeding: **MANDATORY PRE-FLIGHT CHECKS (with verification code):**
### 1. Verify Files Match Story File List
```bash
# Extract expected files from story File List section
story_file="{story_file}"
# Check each file in File List exists
missing_files=0
while IFS= read -r file_line; do
if [[ "$file_line" =~ ^-[[:space:]]+(.*\.ts|.*\.tsx|.*\.sql)$ ]]; then
expected_file="${BASH_REMATCH[1]}"
if [ ! -f "$expected_file" ]; then
echo "❌ MISSING FILE: $expected_file (specified in File List)"
missing_files=$((missing_files + 1))
fi
fi
done < <(sed -n '/## File List/,/##/p' "$story_file")
if [ "$missing_files" -gt 0 ]; then
echo ""
echo "❌ CRITICAL: $missing_files files from File List not created"
echo "This means you built DIFFERENT code than the story specified."
echo ""
echo "HALTING - Implementation does not match story."
exit 1
fi
```
### 2. Verify Tasks Match Implementation
```bash
# For each task, verify corresponding code exists
# Example: Task says "Create validateStateTransition function"
# Verify: grep "function validateStateTransition" billing-service.ts
# This requires reading tasks and checking file contents
# Implementation: Read each task checkbox text, extract expected artifact (function/model/file)
# Check if that artifact exists in the codebase
```
### 3. Standard Quality Checks
- [ ] All unchecked tasks completed - [ ] All unchecked tasks completed
- [ ] All tests pass - [ ] All tests pass
- [ ] Lint clean - [ ] Lint clean
@ -470,8 +600,73 @@ Before proceeding:
## CRITICAL STEP COMPLETION ## CRITICAL STEP COMPLETION
**ONLY WHEN** [all tasks complete AND all tests pass AND lint clean AND build succeeds], **MANDATORY VERIFICATION BEFORE PROCEEDING:**
load and execute `{nextStepFile}` for post-validation.
<critical>🚨 FINAL TASK AUDIT - AUTO-FIX MISSING CHECKBOXES</critical>
**Execute verification with auto-fix retry:**
```bash
story_file="{story_file}"
# Count checked vs total tasks
checked_tasks=$(grep -c "^- \[x\]" "$story_file" || echo "0")
total_tasks=$(grep -c "^- \[[x ]\]" "$story_file" || echo "0")
if [ "$checked_tasks" -eq 0 ] && [ "$total_tasks" -gt 0 ]; then
echo "❌ CRITICAL: ZERO tasks checked but $total_tasks tasks exist"
echo ""
echo "This means you FAILED to update the story file during implementation."
echo ""
echo "ATTEMPTING AUTO-FIX:"
echo "Reading story file to find what should be checked..."
# Extract all task lines
# For each task that has corresponding code (from File List or tests)
# Use Edit tool to check it off
# Re-verify after each edit
# After auto-fix attempts:
checked_tasks=$(grep -c "^- \[x\]" "$story_file" || echo "0")
if [ "$checked_tasks" -eq 0 ]; then
echo ""
echo "❌ AUTO-FIX FAILED: Still zero tasks checked"
echo ""
echo "YOU MUST manually review story file and check off completed tasks."
echo "HALTING - Cannot proceed with broken task tracking."
exit 1
else
echo "✅ AUTO-FIX SUCCESS: $checked_tasks tasks now checked"
fi
fi
completion_pct=$((checked_tasks * 100 / total_tasks))
if [ "$completion_pct" -lt 80 ]; then
echo "⚠️ WARNING: Only $completion_pct% complete ($checked_tasks/$total_tasks)"
echo ""
echo "ATTEMPTING TO IDENTIFY MISSING TASKS:"
# Read unchecked tasks
# For each unchecked task, check if code exists
# If code exists, auto-check the task
# If code missing, report which tasks are genuinely incomplete
fi
echo "✅ Final verification: $checked_tasks/$total_tasks tasks checked ($completion_pct%)"
```
**ONLY WHEN:**
- [x] Tasks verified: checked_tasks > 0 (HALT if zero)
- [x] Completion ≥ 80% (WARN if lower, allow continuation with warning)
- [x] All tests pass
- [x] Lint clean
- [x] Build succeeds
- [x] No TypeScript errors
**THEN** load and execute `{nextStepFile}` for post-validation.
**IF VERIFICATION FAILS:** HALT workflow, do not proceed to Step 5.
--- ---

View File

@ -298,7 +298,67 @@ Ready for Summary Generation
## QUALITY GATE ## QUALITY GATE
**MANDATORY AUTO-FIX VERIFICATION:**
<critical>🚨 DETECT FAILURES AND FIX THEM - DO NOT HALT</critical>
```bash
story_file="{story_file}"
# 1. Check if tasks were checked off
checked_tasks=$(grep -c "^- \[x\]" "$story_file" || echo "0")
total_tasks=$(grep -c "^- \[[x ]\]" "$story_file" || echo "0")
if [ "$checked_tasks" -eq 0 ] && [ "$total_tasks" -gt 0 ]; then
echo "❌ FAILURE DETECTED: $total_tasks tasks exist but ZERO checked"
echo ""
echo "🔧 EXECUTING AUTO-FIX RECONCILIATION:"
echo " 1. Reading git commit to see what was built"
echo " 2. Comparing to story tasks"
echo " 3. Checking off tasks with matching code"
echo ""
fi
# AUTO-FIX: For each unchecked task, check if code exists, then check it off
# (Actual implementation: Use Edit tool iteratively for each task)
# (Verify after each edit, retry if failed, continue until all viable tasks checked)
# Re-count after auto-fix
checked_tasks=$(grep -c "^- \[x\]" "$story_file" || echo "0")
completion_pct=$((checked_tasks * 100 / total_tasks))
echo "✅ After auto-fix: $checked_tasks/$total_tasks tasks checked ($completion_pct%)"
# 2. Check if Dev Agent Record empty
if grep -q "To be filled by dev agent" "$story_file"; then
echo "❌ FAILURE DETECTED: Dev Agent Record is empty"
echo ""
echo "🔧 EXECUTING AUTO-FIX:"
echo " Extracting commit details"
echo " Populating Dev Agent Record section"
echo ""
# AUTO-FIX: Fill in Dev Agent Record
# - Agent Model Used: Get from context
# - File List: Extract from git diff --name-only
# - Completion Notes: Extract from commit message
# Use Edit tool to replace "To be filled" sections
echo "✅ Dev Agent Record populated"
fi
# After all auto-fixes, verify minimum standards met
if [ "$checked_tasks" -eq 0 ]; then
echo "❌ CRITICAL: Auto-fix could not check any tasks"
echo " Story implementation may be empty or broken"
echo " Marking story as 'in-progress' (not done)"
# Override status but continue (don't halt)
fi
```
Before proceeding (BLOCKING - ALL must pass): Before proceeding (BLOCKING - ALL must pass):
- [ ] **Tasks verified: checked_tasks > 0 (HALT if zero)**
- [ ] **Dev Agent Record filled (HALT if empty)**
- [ ] Targeted files staged (from File List) - [ ] Targeted files staged (from File List)
- [ ] Commit message generated - [ ] Commit message generated
- [ ] Commit created successfully - [ ] Commit created successfully

View File

@ -256,7 +256,7 @@ quality_gates:
input_file_patterns: input_file_patterns:
story: story:
description: "Story file being developed" description: "Story file being developed"
pattern: "{sprint_artifacts}/story-*.md" pattern: "{sprint_artifacts}/*.md" # CANONICAL: epic-story-slug.md (NO "story-" prefix)
load_strategy: "FULL_LOAD" load_strategy: "FULL_LOAD"
cache: true cache: true