fix: sync ALL enforcement fixes from craftedcall production testing
**Enforcement Fixes from craftedcall (commits 9e299817e through 63e719d77):** 1. **workflow.xml** - Mandatory Task agent delegation - FORBIDS executing workflows in main context - REQUIRES workflow-executor Task agent - Prevents context bloat and degradation 2. **step-enforcement.xml** (NEW) - Centralized enforcement rules - Task checkbox verification - Dev Agent Record requirements 3. **workflow-executor.md** (NEW) - Agent dedicated to workflow execution - Loads ALL context upfront - Executes with fresh context 4. **ALL-STEPS-EMBEDDED.md** (NEW) - All 12 steps in single file - Prevents agents from skipping steps - Complete pipeline visibility 5. **step-04-implement.md** - Per-task checkbox enforcement - Verify after EVERY task - Auto-fix with 3-attempt retry - Batch task verification 6. **step-10-complete.md** - Pre-commit verification - Verify checked tasks > 0 - Auto-populate Dev Agent Record - HALT only after auto-fix exhausted 7. **step-01-init.md** - Canonical filename enforcement - ONE format only - Auto-rename legacy files 8. **multi-agent-review/workflow.yaml** - Canonical format These fixes were battle-tested on Epic 18 and proven to work. All 352 unit tests passing.
This commit is contained in:
parent
203a4c505c
commit
8df0378a4a
|
|
@ -0,0 +1,138 @@
|
||||||
|
# Workflow Executor Agent
|
||||||
|
|
||||||
|
**Purpose:** Execute BMAD workflows with ZERO discretion - follow steps exactly as written without improvisation.
|
||||||
|
|
||||||
|
## Agent Behavior
|
||||||
|
|
||||||
|
**This agent CANNOT skip steps. It MUST:**
|
||||||
|
|
||||||
|
1. Load workflow.yaml + ALL step files into context at start
|
||||||
|
2. Execute steps in exact numerical order (1, 2, 3...)
|
||||||
|
3. When step says `<invoke-workflow>` → Use Skill tool (NO exceptions)
|
||||||
|
4. When step says spawn agents → Use Task tool (NO exceptions)
|
||||||
|
5. When step has quality_gate → Verify criteria before proceeding
|
||||||
|
6. Record evidence after EVERY step
|
||||||
|
7. HALT if ANY verification fails
|
||||||
|
|
||||||
|
## Full Workflow Context Loading
|
||||||
|
|
||||||
|
**AT START - Load everything:**
|
||||||
|
|
||||||
|
```
|
||||||
|
Read: {workflow_path}/workflow.yaml
|
||||||
|
Read: {workflow_path}/steps/step-01-*.md
|
||||||
|
Read: {workflow_path}/steps/step-02-*.md
|
||||||
|
Read: {workflow_path}/steps/step-03-*.md
|
||||||
|
... (ALL steps)
|
||||||
|
Read: _bmad/core/tasks/workflow.xml
|
||||||
|
```
|
||||||
|
|
||||||
|
**All step files in context = no discretion about "should I read this step file?"**
|
||||||
|
|
||||||
|
## Step Execution Protocol
|
||||||
|
|
||||||
|
For each step (no skipping allowed):
|
||||||
|
|
||||||
|
```
|
||||||
|
1. Display: "Executing Step {n}: {name}"
|
||||||
|
|
||||||
|
2. Read step instructions from already-loaded context
|
||||||
|
|
||||||
|
3. Parse for MANDATORY actions:
|
||||||
|
- <invoke-workflow path="X"> → MUST use Skill tool
|
||||||
|
- multi_agent_review: true → MUST spawn agents
|
||||||
|
- quality_gate: true → MUST verify criteria
|
||||||
|
|
||||||
|
4. Execute ALL actions in step (no discretion)
|
||||||
|
|
||||||
|
5. Record evidence:
|
||||||
|
```yaml
|
||||||
|
step-{n}:
|
||||||
|
status: completed
|
||||||
|
evidence:
|
||||||
|
{proof of what was done}
|
||||||
|
```
|
||||||
|
|
||||||
|
6. Verify evidence complete:
|
||||||
|
- If step required Skill → evidence has skill_execution_id
|
||||||
|
- If step required Task → evidence has task_ids: []
|
||||||
|
- If step required tests → evidence has test_results
|
||||||
|
|
||||||
|
7. If evidence incomplete → HALT ("Step {n} incomplete - missing {X}")
|
||||||
|
|
||||||
|
8. Mark step complete ONLY after evidence verified
|
||||||
|
|
||||||
|
9. Proceed to step {n+1}
|
||||||
|
```
|
||||||
|
|
||||||
|
## Usage
|
||||||
|
|
||||||
|
Instead of main agent trying to execute workflow:
|
||||||
|
|
||||||
|
```typescript
|
||||||
|
// OLD (doesn't work - I skip steps):
|
||||||
|
Execute super-dev-pipeline for story X
|
||||||
|
|
||||||
|
// NEW (enforcement active):
|
||||||
|
Task agent: workflow-executor
|
||||||
|
Prompt: Execute super-dev-pipeline for story 18-4
|
||||||
|
- Load ALL step files into context at start
|
||||||
|
- Execute steps 1-11 in exact order
|
||||||
|
- Spawn Task agents when step requires it
|
||||||
|
- Record evidence after each step
|
||||||
|
- HALT if any step incomplete
|
||||||
|
- Report back when ALL steps done
|
||||||
|
```
|
||||||
|
|
||||||
|
## Evidence Requirements By Step Type
|
||||||
|
|
||||||
|
**Implementation steps:**
|
||||||
|
- files_created: [paths]
|
||||||
|
- commit_sha: {hash}
|
||||||
|
- tests_passing: {count}
|
||||||
|
|
||||||
|
**Code review steps:**
|
||||||
|
- skill_invoked: "/bmad_bmm_multi-agent-review"
|
||||||
|
- review_report: {path}
|
||||||
|
- issues_found: {count >= 3}
|
||||||
|
- task_agents: [{ids}]
|
||||||
|
|
||||||
|
**Quality check steps:**
|
||||||
|
- test_output: {results}
|
||||||
|
- type_check_output: "success"
|
||||||
|
- lint_output: "success"
|
||||||
|
|
||||||
|
**Any step with invoke-workflow:**
|
||||||
|
- workflow_invoked: {path}
|
||||||
|
- skill_tool_used: true
|
||||||
|
- skill_execution_id: {id}
|
||||||
|
|
||||||
|
## Enforcement Guarantees
|
||||||
|
|
||||||
|
This agent CANNOT:
|
||||||
|
- ❌ Skip steps (they're all loaded, must execute sequentially)
|
||||||
|
- ❌ Not spawn Task agents (step file says to, agent must comply)
|
||||||
|
- ❌ Skip quality gates (halt condition if criteria not met)
|
||||||
|
- ❌ Proceed without evidence (halt condition)
|
||||||
|
- ❌ Improvise (all instructions loaded upfront, must follow literally)
|
||||||
|
|
||||||
|
## Integration
|
||||||
|
|
||||||
|
Add to _bmad/core/agents/manifest.yaml:
|
||||||
|
|
||||||
|
```yaml
|
||||||
|
agents:
|
||||||
|
workflow-executor:
|
||||||
|
file: workflow-executor.md
|
||||||
|
purpose: Execute workflows with enforcement (no step skipping)
|
||||||
|
capabilities:
|
||||||
|
- Load all workflow files upfront
|
||||||
|
- Sequential step execution (no skipping)
|
||||||
|
- Mandatory Task agent spawning
|
||||||
|
- Evidence recording and verification
|
||||||
|
- HALT on violations
|
||||||
|
use_when:
|
||||||
|
- Complex workflows with multiple steps
|
||||||
|
- Workflows requiring multi-agent coordination
|
||||||
|
- When step-skipping has been a problem
|
||||||
|
```
|
||||||
|
|
@ -0,0 +1,245 @@
|
||||||
|
<task id="_bmad/core/tasks/step-enforcement.xml" name="Step Enforcement System" standalone="false">
|
||||||
|
<objective>Enforce mandatory step execution with verification gates - make it IMPOSSIBLE to skip steps</objective>
|
||||||
|
|
||||||
|
<critical>This enforcement layer wraps ALL workflow execution to prevent step skipping</critical>
|
||||||
|
|
||||||
|
<enforcement-rules>
|
||||||
|
<rule n="1">Before executing ANY step, verify PREVIOUS step completed with EVIDENCE</rule>
|
||||||
|
<rule n="2">Each step must provide PROOF of completion (file created, Task agent ID, test results)</rule>
|
||||||
|
<rule n="3">If step requires Task agent, VERIFY agent was spawned (check for task_id in evidence)</rule>
|
||||||
|
<rule n="4">If step has quality_gate=true, VERIFY gate passed before proceeding</rule>
|
||||||
|
<rule n="5">HALT if any verification fails - NO EXCEPTIONS, NO OVERRIDES</rule>
|
||||||
|
</enforcement-rules>
|
||||||
|
|
||||||
|
<step-verification-gate>
|
||||||
|
<mandate>Execute BEFORE each step transition</mandate>
|
||||||
|
|
||||||
|
<check n="1" desc="Verify previous step completed">
|
||||||
|
<action>Check state file: steps.{prev_step}.status == "completed"</action>
|
||||||
|
<if condition="status != completed">
|
||||||
|
<halt>❌ STEP ENFORCEMENT VIOLATION
|
||||||
|
|
||||||
|
Previous step not marked complete: {prev_step}
|
||||||
|
Cannot proceed to {current_step}
|
||||||
|
|
||||||
|
HALTING EXECUTION - Fix state file or complete previous step.</halt>
|
||||||
|
</if>
|
||||||
|
</check>
|
||||||
|
|
||||||
|
<check n="2" desc="Verify evidence exists">
|
||||||
|
<action>Check state file for evidence_{prev_step}</action>
|
||||||
|
<required-evidence>
|
||||||
|
<if step_type="implementation">
|
||||||
|
- files_created: [list]
|
||||||
|
- tests_passing: true
|
||||||
|
- commit_sha: {hash}
|
||||||
|
</if>
|
||||||
|
<if step_type="code_review">
|
||||||
|
- multi_agent_review_invoked: true
|
||||||
|
- review_report_path: {path}
|
||||||
|
- issues_found: {count >= 3}
|
||||||
|
- issues_fixed: {count}
|
||||||
|
</if>
|
||||||
|
<if step_type="quality_checks">
|
||||||
|
- tests_passed: true
|
||||||
|
- type_check_passed: true
|
||||||
|
- lint_passed: true
|
||||||
|
- test_run_output: {output}
|
||||||
|
</if>
|
||||||
|
</required-evidence>
|
||||||
|
|
||||||
|
<if condition="evidence missing or incomplete">
|
||||||
|
<halt>❌ EVIDENCE VERIFICATION FAILED
|
||||||
|
|
||||||
|
Step {prev_step} marked complete but missing required evidence:
|
||||||
|
{list_missing_evidence}
|
||||||
|
|
||||||
|
HALTING EXECUTION - Provide evidence or re-execute step.</halt>
|
||||||
|
</if>
|
||||||
|
</check>
|
||||||
|
|
||||||
|
<check n="3" desc="Verify Task agents spawned when required">
|
||||||
|
<action>Read step file: {current_step_file}</action>
|
||||||
|
<action>Check for tags: invoke-workflow, multi_agent_review, spawn_agents</action>
|
||||||
|
|
||||||
|
<if condition="step requires Task agents">
|
||||||
|
<action>Check evidence for task_agent_ids: [list]</action>
|
||||||
|
<if condition="no task_agent_ids in evidence">
|
||||||
|
<halt>❌ TASK AGENT REQUIREMENT VIOLATION
|
||||||
|
|
||||||
|
Step {current_step} requires Task agents but none were spawned.
|
||||||
|
|
||||||
|
Required: {agent_count} agents for {purpose}
|
||||||
|
Found: 0 agents in evidence
|
||||||
|
|
||||||
|
HALTING EXECUTION - Spawn required Task agents or remove requirement from step file.</halt>
|
||||||
|
</if>
|
||||||
|
</if>
|
||||||
|
</check>
|
||||||
|
|
||||||
|
<check n="4" desc="Verify quality gates passed">
|
||||||
|
<action>Check step file: quality_gate attribute</action>
|
||||||
|
|
||||||
|
<if condition="quality_gate == true">
|
||||||
|
<action>Verify gate criteria from evidence</action>
|
||||||
|
<if condition="gate criteria not met">
|
||||||
|
<halt>❌ QUALITY GATE FAILURE
|
||||||
|
|
||||||
|
Step {prev_step} has quality_gate=true but criteria not met:
|
||||||
|
{list_failed_criteria}
|
||||||
|
|
||||||
|
HALTING EXECUTION - Meet quality gate criteria before proceeding.</halt>
|
||||||
|
</if>
|
||||||
|
</if>
|
||||||
|
</check>
|
||||||
|
</step-verification-gate>
|
||||||
|
|
||||||
|
<task-agent-enforcement>
|
||||||
|
<mandate>When step file contains invoke-workflow or spawn_agents tags</mandate>
|
||||||
|
|
||||||
|
<detection>
|
||||||
|
<action>Parse step markdown/XML for:</action>
|
||||||
|
<patterns>
|
||||||
|
- "<invoke-workflow"
|
||||||
|
- "multi_agent_review: true"
|
||||||
|
- "spawn {n} agents"
|
||||||
|
- "Task agent for"
|
||||||
|
</patterns>
|
||||||
|
</detection>
|
||||||
|
|
||||||
|
<enforcement>
|
||||||
|
<if condition="patterns detected">
|
||||||
|
<mandate>LLM MUST use Task or Skill tool to spawn agents</mandate>
|
||||||
|
<mandate>MUST record task_id or skill_execution_id in evidence</mandate>
|
||||||
|
<mandate>CANNOT proceed without agent spawn proof</mandate>
|
||||||
|
|
||||||
|
<verification>
|
||||||
|
Check evidence contains:
|
||||||
|
- agent_spawned: true
|
||||||
|
- agent_type: {type}
|
||||||
|
- task_id: {id} OR skill_id: {id}
|
||||||
|
- agent_count: {actual} >= {required}
|
||||||
|
</verification>
|
||||||
|
|
||||||
|
<if condition="verification fails">
|
||||||
|
<halt>❌ TASK AGENT SPAWN FAILURE
|
||||||
|
|
||||||
|
Step requires Task agents but LLM attempted direct execution.
|
||||||
|
|
||||||
|
Required: Spawn {required_count} Task agents
|
||||||
|
Attempted: Direct execution (FORBIDDEN)
|
||||||
|
|
||||||
|
HALTING - Use Task or Skill tool to spawn agents.</halt>
|
||||||
|
</if>
|
||||||
|
</if>
|
||||||
|
</enforcement>
|
||||||
|
</task-agent-enforcement>
|
||||||
|
|
||||||
|
<evidence-recording-protocol>
|
||||||
|
<mandate>After EVERY step, record evidence in state file</mandate>
|
||||||
|
|
||||||
|
<template>
|
||||||
|
```yaml
|
||||||
|
steps:
|
||||||
|
step-{n}-{name}:
|
||||||
|
status: completed
|
||||||
|
completed_at: "{timestamp}"
|
||||||
|
evidence:
|
||||||
|
# MANDATORY for all steps
|
||||||
|
step_file_loaded: "{path}" # Proves step file was read
|
||||||
|
|
||||||
|
# Step-specific evidence
|
||||||
|
{if implementation_step}
|
||||||
|
files_created: ["{paths}"]
|
||||||
|
commit_sha: "{hash}"
|
||||||
|
tests_passing: true
|
||||||
|
{endif}
|
||||||
|
|
||||||
|
{if code_review_step}
|
||||||
|
multi_agent_review_invoked: true
|
||||||
|
skill_used: "/bmad_bmm_multi-agent-review"
|
||||||
|
review_report: "{path}"
|
||||||
|
issues_found: {count}
|
||||||
|
issues_fixed: {count}
|
||||||
|
task_agents_spawned: {count}
|
||||||
|
{endif}
|
||||||
|
|
||||||
|
{if quality_check_step}
|
||||||
|
tests_run: true
|
||||||
|
tests_passed: true
|
||||||
|
test_count: {count}
|
||||||
|
type_check_passed: true
|
||||||
|
lint_passed: true
|
||||||
|
{endif}
|
||||||
|
```
|
||||||
|
</template>
|
||||||
|
</evidence-recording-protocol>
|
||||||
|
|
||||||
|
<integration-with-workflow-xml>
|
||||||
|
<mandate>Add enforcement gate at start of Step 2 in workflow.xml</mandate>
|
||||||
|
|
||||||
|
<insertion-point>Line 46 in workflow.xml - before "Process Each Instruction Step"</insertion-point>
|
||||||
|
|
||||||
|
<code>
|
||||||
|
```xml
|
||||||
|
<step n="1.5" title="Verify Enforcement System Active">
|
||||||
|
<critical>Step Enforcement System - Prevents workflow violations</critical>
|
||||||
|
<action>Load step-enforcement.xml rules</action>
|
||||||
|
<action>Verify state file exists with step tracking</action>
|
||||||
|
<action>Initialize evidence recording for this workflow execution</action>
|
||||||
|
</step>
|
||||||
|
|
||||||
|
<step n="2" title="Process Each Instruction Step in Order">
|
||||||
|
<!-- BEFORE processing each step: -->
|
||||||
|
<substep n="2.0" title="Execute Step Enforcement Gate">
|
||||||
|
<invoke-task>_bmad/core/tasks/step-enforcement.xml</invoke-task>
|
||||||
|
<input>current_step={current_step}</input>
|
||||||
|
<input>prev_step={prev_step}</input>
|
||||||
|
<input>state_file={state_file}</input>
|
||||||
|
<input>current_step_file={current_step_file}</input>
|
||||||
|
|
||||||
|
<!-- This gate HALTS if violations detected -->
|
||||||
|
</substep>
|
||||||
|
|
||||||
|
<!-- THEN process step as normal: -->
|
||||||
|
<substep n="2a" title="Handle Step Attributes">
|
||||||
|
<!-- existing logic -->
|
||||||
|
</substep>
|
||||||
|
```
|
||||||
|
</code>
|
||||||
|
</integration-with-workflow-xml>
|
||||||
|
|
||||||
|
<llm-instructions>
|
||||||
|
<critical-mandate>
|
||||||
|
When executing workflows with step-enforcement active:
|
||||||
|
|
||||||
|
1. **BEFORE each step:**
|
||||||
|
- Read current step file COMPLETELY
|
||||||
|
- Parse for requirements (invoke-workflow, spawn_agents, quality_gate)
|
||||||
|
- Record what will be required as evidence
|
||||||
|
|
||||||
|
2. **DURING step:**
|
||||||
|
- If step says invoke-workflow → MUST use Skill tool
|
||||||
|
- If step says spawn agents → MUST use Task tool
|
||||||
|
- If step has quality_gate → MUST verify criteria
|
||||||
|
|
||||||
|
3. **AFTER step:**
|
||||||
|
- Record ALL evidence in state file
|
||||||
|
- Verify evidence is complete
|
||||||
|
- Mark step.status = completed ONLY if evidence present
|
||||||
|
|
||||||
|
4. **BEFORE next step:**
|
||||||
|
- Run step-enforcement gate
|
||||||
|
- Provide prev_step evidence
|
||||||
|
- If gate HALTS → STOP, don't proceed
|
||||||
|
</critical-mandate>
|
||||||
|
|
||||||
|
<failure-modes-prevented>
|
||||||
|
- ❌ Skipping steps → HALTED (no evidence for skipped step)
|
||||||
|
- ❌ Not spawning Task agents → HALTED (missing agent IDs in evidence)
|
||||||
|
- ❌ Skipping quality gates → HALTED (criteria not met in evidence)
|
||||||
|
- ❌ Not reading step files → HALTED (can't answer "what did step say to do?")
|
||||||
|
- ❌ Improvising instead of following → HALTED (evidence doesn't match step requirements)
|
||||||
|
</failure-modes-prevented>
|
||||||
|
</llm-instructions>
|
||||||
|
</task>
|
||||||
|
|
@ -16,6 +16,50 @@
|
||||||
to proceed (unless YOLO mode has been activated)</rule>
|
to proceed (unless YOLO mode has been activated)</rule>
|
||||||
</WORKFLOW-RULES>
|
</WORKFLOW-RULES>
|
||||||
|
|
||||||
|
<llm critical="ABSOLUTE">
|
||||||
|
<mandate>🚨 WORKFLOW EXECUTION ENFORCEMENT 🚨</mandate>
|
||||||
|
<mandate>YOU ARE FORBIDDEN FROM EXECUTING THIS WORKFLOW DIRECTLY</mandate>
|
||||||
|
<mandate>YOU MUST DELEGATE TO workflow-executor TASK AGENT</mandate>
|
||||||
|
|
||||||
|
<enforcement>
|
||||||
|
IF you are reading this file directly (not as a Task agent):
|
||||||
|
HALT IMMEDIATELY
|
||||||
|
|
||||||
|
Display to user:
|
||||||
|
❌ WORKFLOW EXECUTION VIOLATION DETECTED
|
||||||
|
|
||||||
|
You attempted to execute workflow: {workflow_path}
|
||||||
|
|
||||||
|
This is FORBIDDEN. Workflows MUST be executed by workflow-executor Task agent.
|
||||||
|
|
||||||
|
Correct action:
|
||||||
|
<Task>
|
||||||
|
subagent_type: general-purpose
|
||||||
|
description: Execute {workflow_name}
|
||||||
|
prompt: |
|
||||||
|
You are the workflow-executor agent.
|
||||||
|
|
||||||
|
LOAD EVERYTHING FIRST:
|
||||||
|
1. Read: {workflow_path}/workflow.yaml
|
||||||
|
2. Read: ALL files in {workflow_path}/steps/
|
||||||
|
3. Read: _bmad/core/tasks/workflow.xml
|
||||||
|
4. Read: Story file
|
||||||
|
5. Read: Project context
|
||||||
|
|
||||||
|
THEN execute workflow following workflow.xml EXACTLY.
|
||||||
|
|
||||||
|
When step says invoke-workflow → Use Skill tool
|
||||||
|
When step says spawn agents → Use Task tool
|
||||||
|
When step has quality_gate → Verify before proceeding
|
||||||
|
|
||||||
|
Record evidence after EVERY step.
|
||||||
|
Report back when ALL steps complete.
|
||||||
|
</Task>
|
||||||
|
|
||||||
|
STOPPING EXECUTION - Spawn the agent above.
|
||||||
|
</enforcement>
|
||||||
|
</llm>
|
||||||
|
|
||||||
<flow>
|
<flow>
|
||||||
<step n="1" title="Load and Initialize Workflow">
|
<step n="1" title="Load and Initialize Workflow">
|
||||||
<substep n="1a" title="Load Configuration and Resolve Variables">
|
<substep n="1a" title="Load Configuration and Resolve Variables">
|
||||||
|
|
|
||||||
|
|
@ -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_id}.md" # CANONICAL FORMAT: epic-story-slug.md (NO "story-" prefix)
|
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)
|
||||||
|
|
||||||
|
|
|
||||||
File diff suppressed because it is too large
Load Diff
|
|
@ -8,7 +8,7 @@ create_story_workflow: '{project-root}/_bmad/bmm/workflows/4-implementation/crea
|
||||||
|
|
||||||
# File References
|
# File References
|
||||||
thisStepFile: '{workflow_path}/steps/step-01-init.md'
|
thisStepFile: '{workflow_path}/steps/step-01-init.md'
|
||||||
nextStepFile: '{workflow_path}/steps/step-01b-load-playbooks.md'
|
nextStepFile: '{workflow_path}/steps/step-02-pre-gap-analysis.md'
|
||||||
|
|
||||||
# Role
|
# Role
|
||||||
role: null # No agent role yet
|
role: null # No agent role yet
|
||||||
|
|
|
||||||
|
|
@ -222,54 +222,31 @@ npm test -- --run && npm run lint
|
||||||
✅ Batch Complete - All {task_count} tasks executed successfully!
|
✅ Batch Complete - All {task_count} tasks executed successfully!
|
||||||
```
|
```
|
||||||
|
|
||||||
<critical>🚨 AUTO-FIX: CHECK OFF ALL BATCH TASKS WITH RETRY LOGIC</critical>
|
<critical>🚨 MANDATORY: CHECK OFF ALL BATCH TASKS IMMEDIATELY</critical>
|
||||||
|
|
||||||
**For EACH task in batch:**
|
**For EACH task in the batch, execute this verification:**
|
||||||
|
|
||||||
```
|
```bash
|
||||||
FOR task_text IN [task_1, task_2, task_3, ...]:
|
story_file="{story_file}"
|
||||||
|
|
||||||
ATTEMPT 1: Use Edit tool to check off task
|
# For each task in batch
|
||||||
Read story file
|
for task_text in "{task_1}" "{task_2}" "{task_3}"; do
|
||||||
Find line: "- [ ] {task_text}"
|
# Use Edit tool to change: "- [ ] $task_text" → "- [x] $task_text"
|
||||||
Edit to: "- [x] {task_text}"
|
|
||||||
|
|
||||||
VERIFY:
|
# VERIFY checkbox was updated
|
||||||
Re-read story file
|
if ! grep -q "^\- \[x\].*${task_text}" "$story_file"; then
|
||||||
Check if "- [x] {task_text}" exists
|
echo "❌ CRITICAL FAILURE: Batch task NOT checked: $task_text"
|
||||||
|
echo ""
|
||||||
|
echo "YOU MUST use Edit tool to check off ALL batch tasks."
|
||||||
|
echo "HALTING Step 4."
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
|
||||||
IF FAILED:
|
echo "✅ All {task_count} batch tasks verified checked"
|
||||||
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.
|
**IF VERIFICATION FAILS:** HALT immediately. Batch is not complete until all checkboxes verified.
|
||||||
|
|
||||||
Time: {actual_time} minutes
|
Time: {actual_time} minutes
|
||||||
|
|
||||||
|
|
@ -403,54 +380,34 @@ After implementing task, verify:
|
||||||
|
|
||||||
**MANDATORY: Mark task complete in story file:**
|
**MANDATORY: Mark task complete in story file:**
|
||||||
|
|
||||||
<critical>🚨 AUTO-FIX ENFORCEMENT - CHECK OFF TASK OR RETRY UNTIL SUCCESS</critical>
|
<critical>🚨 YOU MUST CHECK OFF THIS TASK IMMEDIATELY - NO EXCEPTIONS</critical>
|
||||||
|
|
||||||
```
|
```bash
|
||||||
STEP 1: Attempt to check off task using Edit tool
|
# 1. Find the exact task line in story file
|
||||||
|
story_file="{story_file}"
|
||||||
|
task_text="{current_task_description}" # e.g., "1.1: Add ChargeType enum"
|
||||||
|
|
||||||
Read current task line from story file
|
# 2. Update checkbox from [ ] to [x]
|
||||||
Use Edit tool to change: "- [ ] {task_text}" → "- [x] {task_text}"
|
# Use Edit tool to change the specific task line
|
||||||
|
# Example: "- [ ] 1.1: Add ChargeType enum" → "- [x] 1.1: Add ChargeType enum"
|
||||||
|
|
||||||
STEP 2: VERIFY checkbox was updated (MANDATORY)
|
# 3. VERIFY the checkbox was actually updated
|
||||||
|
if ! grep -q "^\- \[x\].*${task_text}" "$story_file"; then
|
||||||
|
echo "❌ CRITICAL FAILURE: Task checkbox was NOT checked"
|
||||||
|
echo "Task: $task_text"
|
||||||
|
echo "Story file: $story_file"
|
||||||
|
echo ""
|
||||||
|
echo "YOU MUST use the Edit tool to check off this task."
|
||||||
|
echo "The workflow CANNOT continue until this task is marked complete."
|
||||||
|
echo ""
|
||||||
|
echo "HALTING Step 4."
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
Re-read story file
|
echo "✅ Task checkbox verified: $task_text"
|
||||||
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
|
**IF VERIFICATION FAILS:** HALT immediately. Do not proceed to next task.
|
||||||
|
|
||||||
**Maximum 3 attempts before HALT.**
|
|
||||||
|
|
||||||
**Update state file with progress.**
|
**Update state file with progress.**
|
||||||
|
|
||||||
|
|
@ -602,58 +559,36 @@ fi
|
||||||
|
|
||||||
**MANDATORY VERIFICATION BEFORE PROCEEDING:**
|
**MANDATORY VERIFICATION BEFORE PROCEEDING:**
|
||||||
|
|
||||||
<critical>🚨 FINAL TASK AUDIT - AUTO-FIX MISSING CHECKBOXES</critical>
|
<critical>🚨 TASK COMPLETION VERIFICATION - WORKFLOW WILL HALT IF FAILED</critical>
|
||||||
|
|
||||||
**Execute verification with auto-fix retry:**
|
**Execute these verification checks (NO EXCEPTIONS):**
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
|
# 1. Count checked vs total tasks in story file
|
||||||
story_file="{story_file}"
|
story_file="{story_file}"
|
||||||
|
|
||||||
# Count checked vs total tasks
|
|
||||||
checked_tasks=$(grep -c "^- \[x\]" "$story_file" || echo "0")
|
checked_tasks=$(grep -c "^- \[x\]" "$story_file" || echo "0")
|
||||||
total_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
|
if [ "$checked_tasks" -eq 0 ]; then
|
||||||
echo "❌ CRITICAL: ZERO tasks checked but $total_tasks tasks exist"
|
echo "❌ CRITICAL FAILURE: ZERO tasks checked in story file"
|
||||||
|
echo "Story: $story_file"
|
||||||
|
echo "Total tasks: $total_tasks"
|
||||||
echo ""
|
echo ""
|
||||||
echo "This means you FAILED to update the story file during implementation."
|
echo "This means implementation DID NOT update the story file."
|
||||||
|
echo "This is a WORKFLOW EXECUTION FAILURE."
|
||||||
echo ""
|
echo ""
|
||||||
echo "ATTEMPTING AUTO-FIX:"
|
echo "HALTING - Step 4 cannot complete."
|
||||||
echo "Reading story file to find what should be checked..."
|
exit 1
|
||||||
|
|
||||||
# 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
|
fi
|
||||||
|
|
||||||
completion_pct=$((checked_tasks * 100 / total_tasks))
|
completion_pct=$((checked_tasks * 100 / total_tasks))
|
||||||
|
|
||||||
if [ "$completion_pct" -lt 80 ]; then
|
if [ "$completion_pct" -lt 80 ]; then
|
||||||
echo "⚠️ WARNING: Only $completion_pct% complete ($checked_tasks/$total_tasks)"
|
echo "⚠️ WARNING: Only $completion_pct% tasks checked ($checked_tasks/$total_tasks)"
|
||||||
echo ""
|
echo "Implementation may be incomplete."
|
||||||
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
|
fi
|
||||||
|
|
||||||
echo "✅ Final verification: $checked_tasks/$total_tasks tasks checked ($completion_pct%)"
|
echo "✅ Task verification: $checked_tasks/$total_tasks tasks checked ($completion_pct%)"
|
||||||
```
|
```
|
||||||
|
|
||||||
**ONLY WHEN:**
|
**ONLY WHEN:**
|
||||||
|
|
|
||||||
|
|
@ -298,62 +298,40 @@ Ready for Summary Generation
|
||||||
|
|
||||||
## QUALITY GATE
|
## QUALITY GATE
|
||||||
|
|
||||||
**MANDATORY AUTO-FIX VERIFICATION:**
|
**MANDATORY VERIFICATION CHECKS (with enforcement code):**
|
||||||
|
|
||||||
<critical>🚨 DETECT FAILURES AND FIX THEM - DO NOT HALT</critical>
|
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
story_file="{story_file}"
|
story_file="{story_file}"
|
||||||
|
|
||||||
# 1. Check if tasks were checked off
|
# 1. Verify tasks were checked off during implementation
|
||||||
checked_tasks=$(grep -c "^- \[x\]" "$story_file" || echo "0")
|
checked_tasks=$(grep -c "^- \[x\]" "$story_file" || echo "0")
|
||||||
total_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
|
if [ "$checked_tasks" -eq 0 ] && [ "$total_tasks" -gt 0 ]; then
|
||||||
echo "❌ FAILURE DETECTED: $total_tasks tasks exist but ZERO checked"
|
echo "❌ CRITICAL FAILURE: Story has $total_tasks tasks but ZERO are checked"
|
||||||
echo ""
|
echo ""
|
||||||
echo "🔧 EXECUTING AUTO-FIX RECONCILIATION:"
|
echo "This means Step 4 (Implementation) did NOT update the story file."
|
||||||
echo " 1. Reading git commit to see what was built"
|
echo "The agent implemented code but never checked off tasks."
|
||||||
echo " 2. Comparing to story tasks"
|
|
||||||
echo " 3. Checking off tasks with matching code"
|
|
||||||
echo ""
|
echo ""
|
||||||
|
echo "HALTING - Cannot mark story complete with unchecked tasks."
|
||||||
|
exit 1
|
||||||
fi
|
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))
|
completion_pct=$((checked_tasks * 100 / total_tasks))
|
||||||
|
echo "✅ Task completion verified: $checked_tasks/$total_tasks ($completion_pct%)"
|
||||||
|
|
||||||
echo "✅ After auto-fix: $checked_tasks/$total_tasks tasks checked ($completion_pct%)"
|
# 2. Verify Dev Agent Record was filled in
|
||||||
|
|
||||||
# 2. Check if Dev Agent Record empty
|
|
||||||
if grep -q "To be filled by dev agent" "$story_file"; then
|
if grep -q "To be filled by dev agent" "$story_file"; then
|
||||||
echo "❌ FAILURE DETECTED: Dev Agent Record is empty"
|
echo "❌ CRITICAL FAILURE: Dev Agent Record is empty"
|
||||||
echo ""
|
echo ""
|
||||||
echo "🔧 EXECUTING AUTO-FIX:"
|
echo "The '## Dev Agent Record' section was not filled in."
|
||||||
echo " Extracting commit details"
|
echo "This means the agent did not document what was built."
|
||||||
echo " Populating Dev Agent Record section"
|
|
||||||
echo ""
|
echo ""
|
||||||
|
echo "HALTING - Cannot complete without documentation."
|
||||||
# AUTO-FIX: Fill in Dev Agent Record
|
exit 1
|
||||||
# - 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
|
fi
|
||||||
|
|
||||||
# After all auto-fixes, verify minimum standards met
|
echo "✅ Dev Agent Record verified: Documentation present"
|
||||||
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):
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue