Implement enforcement-based workflow patterns to fix chronic reliability issues (story file updates failing 40% of the time, agents skipping work). ## Key Improvements ### 1. Auto-Fix Missing Prerequisites (Guardrail 1) - Workflows now auto-create missing story files and gap analysis - No more blocking errors - self-healing approach - Follows "mind the gap, mend the gap" philosophy Files: super-dev-pipeline/workflow.md, batch-super-dev/workflow.md ### 2. File-Based Completion Verification (Guardrail 2) - All 4 agents (builder, inspector, reviewer, fixer) create completion.json artifacts - Binary verification: file exists = work done (simple, reliable) - Orchestrator parses JSON for structured data (no complex output parsing) Files: agents/builder.md, agents/inspector.md, agents/reviewer.md, agents/fixer.md ### 3. Verification Gates (Guardrail 4) - Hard stops after each agent phase - Verify completion artifact exists - Verify claimed files actually exist - Clear error messages if verification fails File: super-dev-pipeline/workflow.md ### 4. Orchestrator-Driven Reconciliation - Orchestrator (not agents) updates story files - Uses completion artifacts for reliable data - Mechanical task with verification built-in - Auto-fix if updates fail Files: super-dev-pipeline/workflow.md, batch-super-dev/workflow.md ## Documentation - Created: docs/sprint-artifacts/completions/README.md * Documents completion artifact contract * Example artifacts for each agent type * Verification flow diagrams - Created: docs/implementation-notes/gsd-style-guardrails-phase1.md * Complete implementation summary * Testing checklist * Success metrics and rollback strategy ## Benefits ✅ Story file updates: 60% → targeting 100% success ✅ Binary verification: file exists or doesn't (no ambiguity) ✅ Self-healing: auto-fixes missing prerequisites ✅ Hard stops: prevents proceeding with bad state ✅ Auditable: JSON artifacts version controlled ✅ Debuggable: can inspect artifacts when issues occur ## Files Changed Modified (6): - super-dev-pipeline/workflow.md (~100 lines) - batch-super-dev/workflow.md (~80 lines) - agents/builder.md (~30 lines) - agents/inspector.md (~25 lines) - agents/reviewer.md (~30 lines) - agents/fixer.md (~35 lines) Created (2): - docs/sprint-artifacts/completions/README.md - docs/implementation-notes/gsd-style-guardrails-phase1.md Total: ~300 lines of enforcement-based improvements ## Next Steps (Phase 2) - Remove redundant Reconciler agent (-227 lines) - Extract common patterns to patterns/ directory - Add explicit step enumeration (14-step checklist) Part of: v6.1.0-Beta.1 Related: GSD-style refactoring plan |
||
|---|---|---|
| .. | ||
| README.md | ||
README.md
| title | description |
|---|---|
| Agent Completion Artifacts | Documentation for agent completion artifact contract and formats |
Agent Completion Artifacts
This directory stores completion artifacts created by BMAD workflow agents.
Purpose
Problem: Agents were failing to update story files reliably (60% success rate).
Solution: Agents create JSON completion artifacts instead. Orchestrator reads these artifacts to update story files mechanically.
Contract
Agent Responsibility
Each agent MUST create a completion artifact before finishing:
- File path:
{{story_key}}-{{agent_name}}.json - Format: Structured JSON (see formats below)
- Verification: File exists = work done (binary check)
Orchestrator Responsibility
Orchestrator reads completion artifacts and:
- Parses JSON for structured data
- Updates story file tasks (check off completed)
- Fills Dev Agent Record with evidence
- Verifies updates succeeded
Why This Works
File-based verification:
- ✅ Binary check: File exists or doesn't
- ✅ No complex parsing of agent output
- ✅ No reconciliation logic needed
- ✅ Hard stop if artifact missing
JSON format:
- ✅ Easy to parse reliably
- ✅ Structured data (not prose)
- ✅ Version controllable
- ✅ Auditable trail
Artifact Formats
Builder Completion ({{story_key}}-builder.json)
{
"story_key": "19-4",
"agent": "builder",
"status": "SUCCESS",
"tasks_completed": [
"Create PaymentProcessor service",
"Add retry logic with exponential backoff"
],
"files_created": [
"lib/billing/payment-processor.ts",
"lib/billing/__tests__/payment-processor.test.ts"
],
"files_modified": [
"lib/billing/worker.ts"
],
"tests": {
"files": 2,
"cases": 15
},
"timestamp": "2026-01-27T02:30:00Z"
}
Inspector Completion ({{story_key}}-inspector.json)
{
"story_key": "19-4",
"agent": "inspector",
"status": "PASS",
"quality_checks": {
"type_check": "PASS",
"lint": "PASS",
"build": "PASS"
},
"tests": {
"passing": 45,
"failing": 0,
"total": 45,
"coverage": 95
},
"files_verified": [
"lib/billing/payment-processor.ts",
"lib/billing/__tests__/payment-processor.test.ts"
],
"timestamp": "2026-01-27T02:35:00Z"
}
Reviewer Completion ({{story_key}}-reviewer.json)
{
"story_key": "19-4",
"agent": "reviewer",
"status": "ISSUES_FOUND",
"issues": {
"critical": 2,
"high": 3,
"medium": 4,
"low": 2,
"total": 11
},
"must_fix": [
{
"severity": "CRITICAL",
"location": "api/occupant/agreement/route.ts:45",
"description": "SQL injection vulnerability"
},
{
"severity": "HIGH",
"location": "lib/rentals/expiration-alerts.ts:67",
"description": "N+1 query pattern"
}
],
"files_reviewed": [
"api/occupant/agreement/route.ts",
"lib/rentals/expiration-alerts.ts"
],
"timestamp": "2026-01-27T02:40:00Z"
}
Fixer Completion ({{story_key}}-fixer.json)
This is the FINAL artifact used by orchestrator for reconciliation.
{
"story_key": "19-4",
"agent": "fixer",
"status": "SUCCESS",
"issues_fixed": {
"critical": 2,
"high": 3,
"total": 5
},
"fixes_applied": [
"Fixed SQL injection in agreement route (CRITICAL)",
"Added authorization check in admin route (CRITICAL)",
"Fixed N+1 query pattern (HIGH)"
],
"files_modified": [
"api/occupant/agreement/route.ts",
"api/admin/rentals/spaces/[id]/route.ts",
"lib/rentals/expiration-alerts.ts"
],
"quality_checks": {
"type_check": "PASS",
"lint": "PASS",
"build": "PASS"
},
"tests": {
"passing": 48,
"failing": 0,
"total": 48,
"coverage": 96
},
"git_commit": "a1b2c3d4e5f",
"timestamp": "2026-01-27T02:50:00Z"
}
Verification Flow
┌─────────────────────────────────────────────────────────────┐
│ Agent Phase │
├─────────────────────────────────────────────────────────────┤
│ 1. Agent does work (build/inspect/review/fix) │
│ 2. Agent creates completion.json with Write tool │
│ 3. Agent returns "AGENT COMPLETE" message │
└─────────────────────────────────────────────────────────────┘
│
▼
┌─────────────────────────────────────────────────────────────┐
│ Verification Gate │
├─────────────────────────────────────────────────────────────┤
│ 1. Orchestrator checks: [ -f "$COMPLETION_FILE" ] │
│ 2. If missing → HALT (hard stop) │
│ 3. If exists → Verify files claimed actually exist │
│ 4. If files missing → HALT (hard stop) │
└─────────────────────────────────────────────────────────────┘
│
▼
┌─────────────────────────────────────────────────────────────┐
│ Reconciliation Phase (After Fixer) │
├─────────────────────────────────────────────────────────────┤
│ 1. Orchestrator reads fixer completion.json │
│ 2. Orchestrator parses JSON for structured data │
│ 3. Orchestrator updates story file using Edit tool │
│ 4. Orchestrator verifies updates with bash checks │
│ 5. If verification fails → Fix and retry │
└─────────────────────────────────────────────────────────────┘
Benefits
Reliability: 60% → 100% (file exists is binary) Simplicity: No complex output parsing Auditability: JSON files are version controlled Debuggability: Can inspect completion artifacts when issues occur Enforcement: Can't proceed without completion artifact (hard stop)
Cleanup
Completion artifacts can be deleted after successful reconciliation, or kept for audit trail.
Suggested cleanup: After story marked "done", move artifacts to archive or delete.
# Archive completed story artifacts
mv docs/sprint-artifacts/completions/19-4-*.json \
docs/sprint-artifacts/completions/archive/
# Or delete after verification
rm docs/sprint-artifacts/completions/19-4-*.json