diff --git a/src/modules/bmm/agents/dev.agent.yaml b/src/modules/bmm/agents/dev.agent.yaml index 50201eea..0033feda 100644 --- a/src/modules/bmm/agents/dev.agent.yaml +++ b/src/modules/bmm/agents/dev.agent.yaml @@ -55,3 +55,11 @@ agent: - trigger: CR or fuzzy match on code-review workflow: "{project-root}/_bmad/bmm/workflows/4-implementation/code-review/workflow.yaml" description: "[CR] Perform a thorough clean context code review (Highly Recommended, use fresh context and different LLM)" + + - trigger: RVS or fuzzy match on revalidate-story + workflow: "{project-root}/_bmad/bmm/workflows/4-implementation/revalidate-story/workflow.yaml" + description: "[RVS] Revalidate Story - clear checkboxes and re-verify against codebase (detect ghost features and gaps)" + + - trigger: RVE or fuzzy match on revalidate-epic + workflow: "{project-root}/_bmad/bmm/workflows/4-implementation/revalidate-epic/workflow.yaml" + description: "[RVE] Revalidate Epic - batch revalidation of all stories in an epic with semaphore pattern" diff --git a/src/modules/bmm/agents/sm.agent.yaml b/src/modules/bmm/agents/sm.agent.yaml index 0bffebf4..7b1000ef 100644 --- a/src/modules/bmm/agents/sm.agent.yaml +++ b/src/modules/bmm/agents/sm.agent.yaml @@ -49,3 +49,15 @@ agent: - trigger: CC or fuzzy match on correct-course workflow: "{project-root}/_bmad/bmm/workflows/4-implementation/correct-course/workflow.yaml" description: "[CC] Execute correct-course task (When implementation is off-track)" + + - trigger: RVS or fuzzy match on revalidate-story + workflow: "{project-root}/_bmad/bmm/workflows/4-implementation/revalidate-story/workflow.yaml" + description: "[RVS] Revalidate Story - clear checkboxes and verify against codebase reality (find gaps and ghost features)" + + - trigger: RVE or fuzzy match on revalidate-epic + workflow: "{project-root}/_bmad/bmm/workflows/4-implementation/revalidate-epic/workflow.yaml" + description: "[RVE] Revalidate Epic - batch revalidation of all stories with semaphore pattern" + + - trigger: GFD or fuzzy match on ghost-features + workflow: "{project-root}/_bmad/bmm/workflows/4-implementation/detect-ghost-features/workflow.yaml" + description: "[GFD] Ghost Feature Detector - find orphaned code with no stories (reverse gap analysis)" diff --git a/src/modules/bmm/workflows/4-implementation/detect-ghost-features/instructions.md b/src/modules/bmm/workflows/4-implementation/detect-ghost-features/instructions.md new file mode 100644 index 00000000..dc113271 --- /dev/null +++ b/src/modules/bmm/workflows/4-implementation/detect-ghost-features/instructions.md @@ -0,0 +1,625 @@ +# Detect Ghost Features - Reverse Gap Analysis (Who You Gonna Call?) + +The workflow execution engine is governed by: {project-root}/_bmad/core/tasks/workflow.xml +You MUST have already loaded and processed: {installed_path}/workflow.yaml + + + + + Determine scan scope based on parameters: + + + Read {sprint_status} + Filter stories starting with "{{epic_number}}-" + Store as: stories_in_scope + ๐Ÿ” Scanning Epic {{epic_number}} stories for documented features... + + + + Read {sprint_status} + Get ALL story keys (exclude epics and retrospectives) + Store as: stories_in_scope + ๐Ÿ” Scanning entire sprint for documented features... + + + + Set stories_in_scope = ALL stories found in {sprint_artifacts} + ๐Ÿ” Scanning entire codebase for documented features... + + + For each story in stories_in_scope: + Read story file + Extract documented artifacts: + - File List (all paths mentioned) + - Tasks (all file/component/service names mentioned) + - ACs (all features/functionality mentioned) + Store in: documented_artifacts[story_key] = {files, components, services, apis, features} + + +โœ… Loaded {{stories_in_scope.length}} stories +๐Ÿ“‹ Documented artifacts extracted from {{total_sections}} sections + + + + + +โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ” +๐Ÿ‘ป SCANNING FOR GHOST FEATURES +โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ” +Looking for: Components, APIs, Services, DB Tables, Models +โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ” + + + + + Use Glob to find component files: + - **/*.component.{tsx,jsx,ts,js,vue} (Angular/Vue pattern) + - **/components/**/*.{tsx,jsx} (React pattern) + - **/src/**/*{Component,View,Screen,Page}.{tsx,jsx} (Named pattern) + + For each found component file: + Extract component name from filename or export + Check file size (ignore <50 lines as trivial) + Read file to determine if it's a significant feature + + Store as: codebase_components = [{name, path, size, purpose}] + + ๐Ÿ“ฆ Found {{codebase_components.length}} components + + + + + + Use Glob to find API files: + - **/api/**/*.{ts,js} (Next.js/Express pattern) + - **/*.controller.{ts,js} (NestJS pattern) + - **/routes/**/*.{ts,js} (Generic routes) + + Use Grep to find endpoint definitions: + - @Get|@Post|@Put|@Delete decorators (NestJS) + - export async function GET|POST|PUT|DELETE (Next.js App Router) + - router.get|post|put|delete (Express) + - app.route (Flask/FastAPI if Python) + + For each endpoint found: + Extract: HTTP method, path, handler name + Read file to understand functionality + + Store as: codebase_apis = [{method, path, handler, file}] + + ๐ŸŒ Found {{codebase_apis.length}} API endpoints + + + + + + Use Glob to find schema files: + - **/prisma/schema.prisma (Prisma) + - **/*.entity.{ts,js} (TypeORM) + - **/models/**/*.{ts,js} (Mongoose/Sequelize) + - **/*-table.ts (Custom) + + Use Grep to find table definitions: + - model (Prisma) + - @Entity (TypeORM) + - createTable (Migrations) + + For each table found: + Extract: table name, columns, relationships + + Store as: codebase_tables = [{name, file, columns}] + + ๐Ÿ—„๏ธ Found {{codebase_tables.length}} database tables + + + + + + Use Glob to find service files: + - **/*.service.{ts,js} + - **/services/**/*.{ts,js} + - **/*Service.{ts,js} + + For each service found: + Extract: service name, key methods, dependencies + Ignore trivial services (<100 lines) + + Store as: codebase_services = [{name, file, methods}] + + โš™๏ธ Found {{codebase_services.length}} services + + + + + + +โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ” +๐Ÿ” CROSS-REFERENCING CODEBASE โ†” STORIES +โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ” + + + Initialize: orphaned_features = [] + + + For each component in codebase_components: + + Search all stories for mentions of: + - Component name in File Lists + - Component name in Task descriptions + - Component file path in File Lists + - Feature described by component in ACs + + + Add to orphaned_features: + + type: "component" + name: {{component.name}} + path: {{component.path}} + size: {{component.size}} lines + purpose: {{inferred_purpose_from_code}} + severity: "HIGH" # Significant orphan + + ๐Ÿ‘ป ORPHAN: {{component.name}} ({{component.path}}) + + + + โœ… Documented: {{component.name}} โ†’ {{story_keys}} + + + + + For each API in codebase_apis: + + Search all stories for mentions of: + - Endpoint path (e.g., "/api/users") + - HTTP method + resource (e.g., "POST users") + - Handler file in File Lists + - API functionality in ACs (e.g., "Users can create account") + + + Add to orphaned_features: + + type: "api" + method: {{api.method}} + path: {{api.path}} + handler: {{api.handler}} + file: {{api.file}} + severity: "CRITICAL" # APIs are critical functionality + + ๐Ÿ‘ป ORPHAN: {{api.method}} {{api.path}} ({{api.file}}) + + + + + For each table in codebase_tables: + + Search all stories for mentions of: + - Table name + - Migration file in File Lists + - Data model in Tasks + + + Add to orphaned_features: + + type: "database" + name: {{table.name}} + file: {{table.file}} + columns: {{table.columns.length}} + severity: "HIGH" # Database changes are significant + + ๐Ÿ‘ป ORPHAN: Table {{table.name}} ({{table.file}}) + + + + + For each service in codebase_services: + + Search all stories for mentions of: + - Service name or class name + - Service file in File Lists + - Service functionality in Tasks/ACs + + + Add to orphaned_features: + + type: "service" + name: {{service.name}} + file: {{service.file}} + methods: {{service.methods.length}} + severity: "MEDIUM" # Services are business logic + + ๐Ÿ‘ป ORPHAN: {{service.name}} ({{service.file}}) + + + + +โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ” +Cross-Reference Complete +๐Ÿ‘ป Orphaned Features: {{orphaned_features.length}} +โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ” + + + + + Group orphans by type and severity: + + - critical_orphans (APIs, auth, payment) + - high_orphans (Components, DB tables, services) + - medium_orphans (Utilities, helpers) + - low_orphans (Config files, constants) + + + Estimate complexity for each orphan: + Based on file size, dependencies, test coverage + + Suggest epic assignment based on functionality: + - Auth components โ†’ Epic focusing on authentication + - UI components โ†’ Epic focusing on frontend + - API endpoints โ†’ Epic for that resource type + + +โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ” +๐Ÿ‘ป GHOST FEATURES DETECTED +โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ” +**Total Orphans:** {{orphaned_features.length}} + +**By Severity:** +- ๐Ÿ”ด CRITICAL: {{critical_orphans.length}} (APIs, security-critical) +- ๐ŸŸ  HIGH: {{high_orphans.length}} (Components, DB, services) +- ๐ŸŸก MEDIUM: {{medium_orphans.length}} (Utilities, helpers) +- ๐ŸŸข LOW: {{low_orphans.length}} (Config, constants) + +**By Type:** +- Components: {{component_orphans.length}} +- API Endpoints: {{api_orphans.length}} +- Database Tables: {{db_orphans.length}} +- Services: {{service_orphans.length}} +- Other: {{other_orphans.length}} + +--- + +**CRITICAL Orphans (Immediate Action Required):** +{{#each critical_orphans}} +{{@index + 1}}. **{{type | uppercase}}**: {{name}} + File: {{file}} + Purpose: {{inferred_purpose}} + Risk: {{why_critical}} + Suggested Epic: {{suggested_epic}} +{{/each}} + +--- + +**HIGH Priority Orphans:** +{{#each high_orphans}} +{{@index + 1}}. **{{type | uppercase}}**: {{name}} + File: {{file}} + Size: {{size}} lines / {{complexity}} complexity + Suggested Epic: {{suggested_epic}} +{{/each}} + +--- + +**Detection Confidence:** +- Artifacts scanned: {{total_artifacts_scanned}} +- Stories cross-referenced: {{stories_in_scope.length}} +- Documentation coverage: {{documented_pct}}% +- Orphan rate: {{orphan_rate}}% + +{{#if orphan_rate > 20}} +โš ๏ธ **HIGH ORPHAN RATE** - Over 20% of codebase is undocumented! +Recommend: Comprehensive backfill story creation session +{{/if}} + +โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ” + + + + + + +Backfill story creation disabled. To create stories for orphans, run: +/detect-ghost-features create_backfill_stories=true + + Jump to Step 7 (Generate Report) + + + + โœ… No orphans found - all code is documented in stories! + Jump to Step 7 + + + +โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ” +๐Ÿ“ PROPOSING BACKFILL STORIES ({{orphaned_features.length}}) +โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ” + + + For each orphaned feature (prioritized by severity): + + + Analyze orphan to understand functionality: + - Read implementation code + - Identify dependencies and related files + - Determine what it does (infer from code) + - Find tests (if any) to understand use cases + + Generate story draft: + +Story Title: "Document existing {{name}} {{type}}" + +Story Description: +This is a BACKFILL STORY documenting existing functionality found in the codebase +that was not tracked in any story (likely vibe-coded or manually added). + +Business Context: +{{inferred_business_purpose_from_code}} + +Current State: +โœ… **Implementation EXISTS:** {{file}} +- {{description_of_what_it_does}} +- {{key_features_or_methods}} +{{#if has_tests}}โœ… Tests exist: {{test_files}}{{else}}โŒ No tests found{{/if}} + +Acceptance Criteria: +{{#each inferred_acs_from_code}} +- [ ] {{this}} +{{/each}} + +Tasks: +- [x] {{name}} implementation (ALREADY EXISTS - {{file}}) +{{#if missing_tests}}- [ ] Add tests for {{name}}{{/if}} +{{#if missing_docs}}- [ ] Add documentation for {{name}}{{/if}} +- [ ] Verify functionality works as expected +- [ ] Add to relevant epic or create new epic for backfills + +Definition of Done: +- [x] Implementation exists and works +{{#if has_tests}}- [x] Tests exist{{else}}- [ ] Tests added{{/if}} +- [ ] Documented in story (this story) +- [ ] Assigned to appropriate epic + +Story Type: BACKFILL (documenting existing code) + + + +๐Ÿ“„ Generated backfill story draft for: {{name}} + +{{story_draft_preview}} + +--- + + + + + + Create backfill story automatically + โœ… Auto-created: {{story_filename}} + + + + +Create backfill story for {{name}}? + +**Type:** {{type}} +**File:** {{file}} +**Suggested Epic:** {{suggested_epic}} +**Complexity:** {{complexity_estimate}} + +[Y] Yes - Create this backfill story +[A] Auto - Create this and all remaining backfill stories +[E] Edit - Let me adjust the story draft first +[S] Skip - Don't create story for this orphan +[H] Halt - Stop backfill story creation + +Your choice: + + + + Create backfill story file: {sprint_artifacts}/backfill-{{type}}-{{name}}.md + Add to backfill_stories_created list + โœ… Created: {{story_filename}} + + + + Set auto_create = true + Create this story and auto-create remaining + + + + Provide your adjusted story content or instructions for modifications: + Apply user's edits to story draft + Create modified backfill story + + + + Add to skipped_backfills list + โญ๏ธ Skipped + + + + Exit backfill story creation loop + Jump to Step 6 + + + + + + Load {sprint_status} file + + For each created backfill story: + Add entry: {{backfill_story_key}}: backlog # BACKFILL - documents existing {{name}} + + Save sprint-status.yaml + + โœ… Added {{backfill_stories_created.length}} backfill stories to sprint-status.yaml + + + + + + +โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ” +๐Ÿ“Š BACKFILL STORY ORGANIZATION +โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ” + + + Group backfill stories by suggested epic: + + For each suggested_epic: + +**{{suggested_epic}}:** +{{#each backfill_stories_for_epic}} + - {{story_key}}: {{name}} ({{type}}) +{{/each}} + + + +--- + +**Recommendations:** + +1. **Option A: Create "Epic-Backfill" for all orphans** + - Single epic containing all backfill stories + - Easy to track undocumented code + - Clear separation from feature work + +2. **Option B: Distribute to existing epics** + - Add each backfill story to its logical epic + - Better thematic grouping + - May inflate epic story counts + +3. **Option C: Leave in backlog** + - Don't assign to epics yet + - Review and assign during next planning + +**Your choice:** +[A] Create Epic-Backfill (recommended) +[B] Distribute to existing epics +[C] Leave in backlog for manual assignment +[S] Skip epic assignment + + + How should backfill stories be organized? + + + Create epic-backfill.md in epics directory + Update sprint-status.yaml with epic-backfill entry + Assign all backfill stories to epic-backfill + + + + For each backfill story: + Assign to suggested_epic in sprint-status.yaml + Update story_key to match epic (e.g., 2-11-backfill-userprofile) + + + + Leave stories in backlog + + + + + + + Write report to: {sprint_artifacts}/ghost-features-report-{{timestamp}}.md + + Report structure: + +# Ghost Features Report (Reverse Gap Analysis) + +**Generated:** {{timestamp}} +**Scope:** {{scan_scope}} {{#if epic_number}}(Epic {{epic_number}}){{/if}} + +## Executive Summary + +**Codebase Artifacts Scanned:** {{total_artifacts_scanned}} +**Stories Cross-Referenced:** {{stories_in_scope.length}} +**Orphaned Features Found:** {{orphaned_features.length}} +**Documentation Coverage:** {{documented_pct}}% +**Backfill Stories Created:** {{backfill_stories_created.length}} + +## Orphaned Features Detail + +### CRITICAL Orphans ({{critical_orphans.length}}) +[Full list with files, purposes, risks] + +### HIGH Priority Orphans ({{high_orphans.length}}) +[Full list] + +### MEDIUM Priority Orphans ({{medium_orphans.length}}) +[Full list] + +## Backfill Stories Created + +{{#each backfill_stories_created}} +- {{story_key}}: {{story_file}} +{{/each}} + +## Recommendations + +[Epic assignment suggestions, next steps] + +## Appendix: Scan Methodology + +[How detection worked, patterns used, confidence levels] + + + ๐Ÿ“„ Full report: {{report_path}} + + + + + +โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ” +โœ… GHOST FEATURE DETECTION COMPLETE +โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ” +**Scan Scope:** {{scan_scope}} {{#if epic_number}}(Epic {{epic_number}}){{/if}} + +**Results:** +- ๐Ÿ‘ป Orphaned Features: {{orphaned_features.length}} +- ๐Ÿ“ Backfill Stories Created: {{backfill_stories_created.length}} +- โญ๏ธ Skipped: {{skipped_backfills.length}} +- ๐Ÿ“Š Documentation Coverage: {{documented_pct}}% + +{{#if orphaned_features.length == 0}} +โœ… **EXCELLENT!** All code is documented in stories. +Your codebase and story backlog are in perfect sync. +{{/if}} + +{{#if orphaned_features.length > 0 AND backfill_stories_created.length == 0}} +**Action Required:** +Run with create_backfill_stories=true to generate stories for orphans +{{/if}} + +{{#if backfill_stories_created.length > 0}} +**Next Steps:** + +1. **Review backfill stories** - Check generated stories for accuracy +2. **Assign to epics** - Organize backfills (or create Epic-Backfill) +3. **Update sprint-status.yaml** - Already updated with {{backfill_stories_created.length}} new entries +4. **Prioritize** - Decide when to implement tests/docs for orphans +5. **Run revalidation** - Verify orphans work as expected + +**Quick Commands:** +```bash +# Revalidate a backfill story to verify functionality +/revalidate-story story_file={{backfill_stories_created[0].file}} + +# Process backfill stories (add tests/docs) +/batch-super-dev filter_by_epic=backfill +``` +{{/if}} + +{{#if create_report}} +**Detailed Report:** {{report_path}} +{{/if}} + +โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ” + +๐Ÿ’ก **Pro Tip:** Run this periodically (e.g., end of each sprint) to catch +vibe-coded features before they become maintenance nightmares. +โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ” + + + + diff --git a/src/modules/bmm/workflows/4-implementation/detect-ghost-features/workflow.yaml b/src/modules/bmm/workflows/4-implementation/detect-ghost-features/workflow.yaml new file mode 100644 index 00000000..e5c9f6cb --- /dev/null +++ b/src/modules/bmm/workflows/4-implementation/detect-ghost-features/workflow.yaml @@ -0,0 +1,56 @@ +name: detect-ghost-features +description: "Reverse gap analysis: Find functionality in codebase that has no corresponding story (vibe-coded or undocumented features). Propose backfill stories." +author: "BMad" +version: "1.0.0" # Who you gonna call? GHOST-FEATURE-BUSTERS! ๐Ÿ‘ป + +# Critical variables from config +config_source: "{project-root}/_bmad/bmm/config.yaml" +output_folder: "{config_source}:output_folder" +sprint_artifacts: "{output_folder}/sprint-artifacts" +sprint_status: "{output_folder}/sprint-status.yaml" + +# Input parameters +epic_number: "{epic_number}" # Optional: Limit to specific epic (e.g., "2") +scan_scope: "sprint" # "sprint" | "epic" | "codebase" +create_backfill_stories: true # Propose backfill stories for orphans + +# Detection settings +detection: + scan_for: + components: true # React/Vue/Angular components + api_endpoints: true # Routes, controllers, handlers + database_tables: true # Migrations, schema + services: true # Services, modules, utilities + models: true # Data models, entities + ui_pages: true # Pages, screens, views + + ignore_patterns: + - "**/node_modules/**" + - "**/dist/**" + - "**/build/**" + - "**/*.test.*" + - "**/*.spec.*" + - "**/migrations/**" # Migrations are referenced collectively, not per-story + + # What counts as "documented"? + documented_if: + mentioned_in_file_list: true # Story File List mentions it + mentioned_in_tasks: true # Task description mentions it + mentioned_in_acs: true # AC mentions the feature + file_committed_in_story_commit: true # Git history shows it in story commit + +# Backfill story settings +backfill: + auto_create: false # Require confirmation before creating each + add_to_sprint_status: true # Add to sprint as "backlog" + mark_as_backfill: true # Add note: "Backfill story documenting existing code" + run_gap_analysis: false # Don't run gap (we know it exists) + estimate_effort: true # Estimate how complex the feature is + +# Output settings +output: + create_report: true # Generate orphaned-features-report.md + group_by_category: true # Group by component/api/db/etc + suggest_epic_assignment: true # Suggest which epic orphans belong to + +standalone: true diff --git a/src/modules/bmm/workflows/4-implementation/revalidate-epic/instructions.md b/src/modules/bmm/workflows/4-implementation/revalidate-epic/instructions.md new file mode 100644 index 00000000..e229e944 --- /dev/null +++ b/src/modules/bmm/workflows/4-implementation/revalidate-epic/instructions.md @@ -0,0 +1,273 @@ +# Revalidate Epic - Batch Story Revalidation with Semaphore Pattern + +The workflow execution engine is governed by: {project-root}/_bmad/core/tasks/workflow.xml +You MUST have already loaded and processed: {installed_path}/workflow.yaml + + + + + Verify epic_number parameter provided + + + โŒ ERROR: epic_number parameter required + +Usage: + /revalidate-epic epic_number=2 + /revalidate-epic epic_number=2 fill_gaps=true + /revalidate-epic epic_number=2 fill_gaps=true max_concurrent=5 + + HALT + + + Read {sprint_status} file + Parse development_status map + + Filter stories starting with "{{epic_number}}-" (e.g., "2-1-", "2-2-", etc.) + Exclude epics (keys starting with "epic-") and retrospectives + + Store as: epic_stories (list of story keys) + + + โŒ No stories found for Epic {{epic_number}} + +Check sprint-status.yaml to verify epic number is correct. + + HALT + + + +โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ” +๐Ÿ” EPIC {{epic_number}} REVALIDATION +โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ” +**Stories Found:** {{epic_stories.length}} +**Mode:** {{#if fill_gaps}}Verify & Fill Gaps{{else}}Verify Only{{/if}} +**Max Concurrent:** {{max_concurrent}} agents +**Pattern:** Semaphore (continuous worker pool) + +**Stories to Revalidate:** +{{#each epic_stories}} +{{@index + 1}}. {{this}} +{{/each}} +โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ” + + + Proceed with revalidation? (yes/no): + + + โŒ Revalidation cancelled + Exit workflow + + + + + +โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ” +๐Ÿš€ Starting Parallel Revalidation (Semaphore Pattern) +โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ” + + + Initialize worker pool state: + + - story_queue = epic_stories + - active_workers = {} + - completed_stories = [] + - failed_stories = [] + - verification_results = {} + - next_story_index = 0 + - max_workers = {{max_concurrent}} + + + Fill initial worker slots: + + While next_story_index < min(max_workers, story_queue.length): + + + story_key = story_queue[next_story_index] + story_file = {sprint_artifacts}/{{story_key}}.md # Try multiple naming patterns if needed + worker_id = next_story_index + 1 + + Spawn Task agent: + - subagent_type: "general-purpose" + - description: "Revalidate story {{story_key}}" + - prompt: "Execute revalidate-story workflow for {{story_key}}. + + CRITICAL INSTRUCTIONS: + 1. Load workflow: _bmad/bmm/workflows/4-implementation/revalidate-story/workflow.yaml + 2. Parameters: story_file={{story_file}}, fill_gaps={{fill_gaps}} + 3. Clear all checkboxes + 4. Verify each AC/Task/DoD against codebase + 5. Re-check verified items + 6. Report gaps + {{#if fill_gaps}}7. Fill gaps and commit{{/if}} + 8. Return verification summary" + - run_in_background: true + + Store in active_workers[worker_id]: + story_key: {{story_key}} + task_id: {{returned_task_id}} + started_at: {{timestamp}} + + + Increment next_story_index + + +โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ” +โœ… {{active_workers.size}} workers active +๐Ÿ“‹ {{story_queue.length - next_story_index}} stories queued +โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ” + + + + + SEMAPHORE PATTERN: Keep {{max_workers}} agents running continuously + + While active_workers.size > 0 OR next_story_index < story_queue.length: + + Poll for completed workers (non-blocking): + + For each worker_id in active_workers: + + Check worker status using TaskOutput(task_id, block=false) + + + Get verification results from worker output + Parse: verified_pct, gaps_found, gaps_filled + + Store in verification_results[story_key] + Add to completed_stories + Remove from active_workers + + โœ… Worker {{worker_id}}: {{story_key}} โ†’ {{verified_pct}}% verified{{#if gaps_filled > 0}}, {{gaps_filled}} gaps filled{{/if}} + + + Refill slot with next story (same pattern as batch-super-dev) + ๐Ÿ”„ Worker {{worker_id}} refilled: {{next_story_key}} + + + + + Add to failed_stories with error + Remove from active_workers + โŒ Worker {{worker_id}}: {{story_key}} failed + + + Refill slot despite failure + + + + Display live progress every 30 seconds: + +๐Ÿ“Š Live Progress: {{completed_stories.length}} completed, {{active_workers.size}} active, {{story_queue.length - next_story_index}} queued + + + Sleep 5 seconds before next poll + + + + Aggregate verification results across all stories: + + epic_total_items = sum of all items across stories + epic_verified = sum of verified items + epic_partial = sum of partial items + epic_missing = sum of missing items + epic_gaps_filled = sum of gaps filled + + epic_verified_pct = (epic_verified / epic_total_items) ร— 100 + + + Group stories by verification percentage: + + - complete_stories (โ‰ฅ95% verified) + - mostly_complete_stories (80-94% verified) + - partial_stories (50-79% verified) + - incomplete_stories (<50% verified) + + + +โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ” +๐Ÿ“Š EPIC {{epic_number}} REVALIDATION SUMMARY +โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ” +**Total Stories:** {{epic_stories.length}} +**Completed:** {{completed_stories.length}} +**Failed:** {{failed_stories.length}} + +**Epic-Wide Verification:** +- โœ… Verified: {{epic_verified}}/{{epic_total_items}} ({{epic_verified_pct}}%) +- ๐Ÿ”ถ Partial: {{epic_partial}}/{{epic_total_items}} +- โŒ Missing: {{epic_missing}}/{{epic_total_items}} +{{#if fill_gaps}}- ๐Ÿ”ง Gaps Filled: {{epic_gaps_filled}}{{/if}} + +**Story Health:** +- โœ… Complete (โ‰ฅ95%): {{complete_stories.length}} stories +- ๐Ÿ”ถ Mostly Complete (80-94%): {{mostly_complete_stories.length}} stories +- โš ๏ธ Partial (50-79%): {{partial_stories.length}} stories +- โŒ Incomplete (<50%): {{incomplete_stories.length}} stories + +--- + +**Complete Stories (โ‰ฅ95% verified):** +{{#each complete_stories}} +- {{story_key}}: {{verified_pct}}% verified +{{/each}} + +{{#if mostly_complete_stories.length > 0}} +**Mostly Complete Stories (80-94%):** +{{#each mostly_complete_stories}} +- {{story_key}}: {{verified_pct}}% verified ({{gaps_count}} gaps{{#if gaps_filled > 0}}, {{gaps_filled}} filled{{/if}}) +{{/each}} +{{/if}} + +{{#if partial_stories.length > 0}} +**โš ๏ธ Partial Stories (50-79%):** +{{#each partial_stories}} +- {{story_key}}: {{verified_pct}}% verified ({{gaps_count}} gaps{{#if gaps_filled > 0}}, {{gaps_filled}} filled{{/if}}) +{{/each}} + +Recommendation: Continue development on these stories +{{/if}} + +{{#if incomplete_stories.length > 0}} +**โŒ Incomplete Stories (<50%):** +{{#each incomplete_stories}} +- {{story_key}}: {{verified_pct}}% verified ({{gaps_count}} gaps{{#if gaps_filled > 0}}, {{gaps_filled}} filled{{/if}}) +{{/each}} + +Recommendation: Re-implement these stories from scratch +{{/if}} + +{{#if failed_stories.length > 0}} +**โŒ Failed Revalidations:** +{{#each failed_stories}} +- {{story_key}}: {{error}} +{{/each}} +{{/if}} + +--- + +**Epic Health Score:** {{epic_verified_pct}}/100 + +{{#if epic_verified_pct >= 95}} +โœ… Epic is COMPLETE and verified +{{else if epic_verified_pct >= 80}} +๐Ÿ”ถ Epic is MOSTLY COMPLETE ({{epic_missing}} items need attention) +{{else if epic_verified_pct >= 50}} +โš ๏ธ Epic is PARTIALLY COMPLETE (significant gaps remain) +{{else}} +โŒ Epic is INCOMPLETE (major rework needed) +{{/if}} + +โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ” + + + + Write epic summary to: {sprint_artifacts}/revalidation-epic-{{epic_number}}-{{timestamp}}.md + ๐Ÿ“„ Epic report: {{report_path}} + + + + Update sprint-status.yaml with revalidation timestamp and results + Add comment to epic entry: # Revalidated: {{epic_verified_pct}}% verified ({{timestamp}}) + + + + diff --git a/src/modules/bmm/workflows/4-implementation/revalidate-epic/workflow.yaml b/src/modules/bmm/workflows/4-implementation/revalidate-epic/workflow.yaml new file mode 100644 index 00000000..38b7de23 --- /dev/null +++ b/src/modules/bmm/workflows/4-implementation/revalidate-epic/workflow.yaml @@ -0,0 +1,44 @@ +name: revalidate-epic +description: "Batch revalidation of all stories in an epic. Clears checkboxes and re-verifies against codebase with semaphore pattern." +author: "BMad" +version: "1.0.0" + +# Critical variables from config +config_source: "{project-root}/_bmad/bmm/config.yaml" +output_folder: "{config_source}:output_folder" +sprint_artifacts: "{output_folder}/sprint-artifacts" +sprint_status: "{output_folder}/sprint-status.yaml" + +# Input parameters +epic_number: "{epic_number}" # Required: Epic number (e.g., "2" for Epic 2) +fill_gaps: false # Optional: Fill missing items after verification +max_concurrent: 3 # Optional: Max concurrent revalidation agents (default: 3) + +# Verification settings (inherited by story revalidations) +verification: + verify_acceptance_criteria: true + verify_tasks: true + verify_definition_of_done: true + check_for_stubs: true + require_tests: true + +# Gap filling settings +gap_filling: + max_gaps_per_story: 10 # Safety limit per story + require_confirmation_first_story: true # Ask on first story, then auto for rest + run_tests_after_each: true + commit_strategy: "per_gap" # "per_gap" | "per_story" | "all_at_once" + +# Execution settings +execution: + use_semaphore_pattern: true # Constant concurrency (not batch-and-wait) + continue_on_failure: true # Keep processing if one story fails + display_live_progress: true # Show progress updates every 30s + +# Output settings +output: + create_epic_report: true # Generate epic-level summary + create_story_reports: true # Generate per-story reports + update_sprint_status: true # Update progress in sprint-status.yaml + +standalone: true diff --git a/src/modules/bmm/workflows/4-implementation/revalidate-story/instructions.md b/src/modules/bmm/workflows/4-implementation/revalidate-story/instructions.md new file mode 100644 index 00000000..f5135606 --- /dev/null +++ b/src/modules/bmm/workflows/4-implementation/revalidate-story/instructions.md @@ -0,0 +1,510 @@ +# Revalidate Story - Verify Checkboxes Against Codebase Reality + +The workflow execution engine is governed by: {project-root}/_bmad/core/tasks/workflow.xml +You MUST have already loaded and processed: {installed_path}/workflow.yaml + + + + + Verify story_file parameter provided + + + โŒ ERROR: story_file parameter required + +Usage: + /revalidate-story story_file=path/to/story.md + /revalidate-story story_file=path/to/story.md fill_gaps=true + + HALT + + + Read COMPLETE story file: {{story_file}} + Parse sections: Acceptance Criteria, Tasks/Subtasks, Definition of Done, Dev Agent Record + + Extract story_key from filename (e.g., "2-7-image-file-handling") + + Create backup of current checkbox state: + Count currently checked items: + - ac_checked_before = count of [x] in Acceptance Criteria + - tasks_checked_before = count of [x] in Tasks/Subtasks + - dod_checked_before = count of [x] in Definition of Done + - total_checked_before = sum of above + + + +โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ” +๐Ÿ” STORY REVALIDATION STARTED +โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ” +**Story:** {{story_key}} +**File:** {{story_file}} +**Mode:** {{#if fill_gaps}}Verify & Fill Gaps{{else}}Verify Only{{/if}} + +**Current State:** +- Acceptance Criteria: {{ac_checked_before}}/{{ac_total}} checked +- Tasks: {{tasks_checked_before}}/{{tasks_total}} checked +- Definition of Done: {{dod_checked_before}}/{{dod_total}} checked +- **Total:** {{total_checked_before}}/{{total_items}} ({{pct_before}}%) + +**Action:** Clearing all checkboxes and re-verifying against codebase... +โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ” + + + + + ๐Ÿงน Clearing all checkboxes to start fresh verification... + + Use Edit tool to replace all [x] with [ ] in Acceptance Criteria section + Use Edit tool to replace all [x] with [ ] in Tasks/Subtasks section + Use Edit tool to replace all [x] with [ ] in Definition of Done section + + Save story file with all boxes unchecked + + โœ… All checkboxes cleared. Starting verification from clean slate... + + + + +โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ” +๐Ÿ“‹ VERIFYING ACCEPTANCE CRITERIA ({{ac_total}} items) +โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ” + + + Extract all AC items from Acceptance Criteria section + + For each AC item: + + + Extract AC description and identify artifacts: + - File mentions (e.g., "UserProfile component") + - Function names (e.g., "updateUser function") + - Features (e.g., "dark mode toggle") + - Test requirements (e.g., "unit tests covering edge cases") + + + Verifying AC{{@index}}: {{ac_description}} + + + + Use Glob to find relevant files: + - If AC mentions specific file: glob for that file + - If AC mentions component: glob for **/*ComponentName* + - If AC mentions feature: glob for files in related directories + + + Use Grep to search for symbols/functions/features + + Read found files to verify: + - NOT a stub (check for "TODO", "Not implemented", "throw new Error") + - Has actual implementation (not just empty function) + - Tests exist (search for *.test.* or *.spec.* files) + - Tests pass (if --fill-gaps mode, run tests) + + + + + verification_status = VERIFIED + Check box [x] in story file for this AC + Record evidence: "โœ… VERIFIED: {{files_found}}, tests: {{test_files}}" + โœ… AC{{@index}}: VERIFIED + + + + verification_status = PARTIAL + Check box [~] in story file for this AC + Record gap: "๐Ÿ”ถ PARTIAL: {{what_exists}}, missing: {{what_is_missing}}" + ๐Ÿ”ถ AC{{@index}}: PARTIAL ({{what_is_missing}}) + Add to gaps_list with details + + + + verification_status = MISSING + Leave box unchecked [ ] in story file + Record gap: "โŒ MISSING: No implementation found for {{ac_description}}" + โŒ AC{{@index}}: MISSING + Add to gaps_list with details + + + + Save story file after each AC verification + + +โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ” +Acceptance Criteria Verification Complete +โœ… Verified: {{ac_verified}} +๐Ÿ”ถ Partial: {{ac_partial}} +โŒ Missing: {{ac_missing}} +โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ” + + + + + +โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ” +๐Ÿ“‹ VERIFYING TASKS ({{tasks_total}} items) +โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ” + + + Extract all Task items from Tasks/Subtasks section + + For each Task item (same verification logic as ACs): + + Parse task description for artifacts + Search codebase with Glob/Grep + Read and verify (check for stubs, tests) + Determine status: VERIFIED | PARTIAL | MISSING + Update checkbox: [x] | [~] | [ ] + Record evidence or gap + Save story file + + +โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ” +Tasks Verification Complete +โœ… Verified: {{tasks_verified}} +๐Ÿ”ถ Partial: {{tasks_partial}} +โŒ Missing: {{tasks_missing}} +โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ” + + + + + +โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ” +๐Ÿ“‹ VERIFYING DEFINITION OF DONE ({{dod_total}} items) +โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ” + + + Extract all DoD items from Definition of Done section + + For each DoD item: + + Parse DoD requirement: + - "Type check passes" โ†’ Run type checker + - "Unit tests 90%+ coverage" โ†’ Run coverage report + - "Linting clean" โ†’ Run linter + - "Build succeeds" โ†’ Run build + - "All tests pass" โ†’ Run test suite + + + Execute verification for this DoD item + + + Check box [x] + Record: "โœ… VERIFIED: {{verification_result}}" + + + + Leave unchecked [ ] or partial [~] + Record gap if applicable + + + +โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ” +Definition of Done Verification Complete +โœ… Verified: {{dod_verified}} +๐Ÿ”ถ Partial: {{dod_partial}} +โŒ Missing: {{dod_missing}} +โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ” + + + + + Calculate overall completion: + + total_verified = ac_verified + tasks_verified + dod_verified + total_partial = ac_partial + tasks_partial + dod_partial + total_missing = ac_missing + tasks_missing + dod_missing + total_items = ac_total + tasks_total + dod_total + + verified_pct = (total_verified / total_items) ร— 100 + completion_pct = ((total_verified + total_partial) / total_items) ร— 100 + + + +โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ” +๐Ÿ“Š REVALIDATION SUMMARY +โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ” +**Story:** {{story_key}} +**File:** {{story_file}} + +**Verification Results:** +- โœ… Verified Complete: {{total_verified}}/{{total_items}} ({{verified_pct}}%) +- ๐Ÿ”ถ Partially Complete: {{total_partial}}/{{total_items}} +- โŒ Missing/Incomplete: {{total_missing}}/{{total_items}} + +**Breakdown:** +- Acceptance Criteria: {{ac_verified}}โœ… {{ac_partial}}๐Ÿ”ถ {{ac_missing}}โŒ / {{ac_total}} total +- Tasks: {{tasks_verified}}โœ… {{tasks_partial}}๐Ÿ”ถ {{tasks_missing}}โŒ / {{tasks_total}} total +- Definition of Done: {{dod_verified}}โœ… {{dod_partial}}๐Ÿ”ถ {{dod_missing}}โŒ / {{dod_total}} total + +**Status Assessment:** +{{#if verified_pct >= 95}} +โœ… Story is COMPLETE ({{verified_pct}}% verified) +{{else if verified_pct >= 80}} +๐Ÿ”ถ Story is MOSTLY COMPLETE ({{verified_pct}}% verified, {{total_missing}} gaps) +{{else if verified_pct >= 50}} +โš ๏ธ Story is PARTIALLY COMPLETE ({{verified_pct}}% verified, {{total_missing}} gaps) +{{else}} +โŒ Story is INCOMPLETE ({{verified_pct}}% verified, significant work missing) +{{/if}} + +**Before Revalidation:** {{total_checked_before}}/{{total_items}} checked ({{pct_before}}%) +**After Revalidation:** {{total_verified}}/{{total_items}} verified ({{verified_pct}}%) +**Accuracy:** {{#if pct_before == verified_pct}}Perfect match{{else if pct_before > verified_pct}}{{pct_before - verified_pct}}% over-reported{{else}}{{verified_pct - pct_before}}% under-reported{{/if}} + +{{#if total_missing > 0}} +--- +**Gaps Found ({{total_missing}}):** +{{#each gaps_list}} +{{@index + 1}}. {{item_type}} - {{item_description}} + Status: {{status}} + Missing: {{what_is_missing}} + {{#if evidence}}Evidence checked: {{evidence}}{{/if}} +{{/each}} +--- +{{/if}} +โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ” + + + + Write detailed report to: {sprint_artifacts}/revalidation-{{story_key}}-{{timestamp}}.md + Include: verification results, gaps list, evidence for each item, recommendations + ๐Ÿ“„ Detailed report: {{report_path}} + + + + + + +โœ… Verification complete (verify-only mode) + +{{#if total_missing > 0}} +**To fill the {{total_missing}} gaps, run:** +/revalidate-story story_file={{story_file}} fill_gaps=true +{{else}} +No gaps found - story is complete! +{{/if}} + + Exit workflow + + + + โœ… No gaps to fill - story is already complete! + Exit workflow + + + + + +โš ๏ธ TOO MANY GAPS: {{total_missing}} gaps found (max: {{max_gaps_to_fill}}) + +This story has too many missing items for automatic gap filling. +Consider: +1. Re-implementing the story from scratch with /dev-story +2. Manually implementing the gaps +3. Increasing max_gaps_to_fill in workflow.yaml (use cautiously) + +Gap filling HALTED for safety. + + HALT + + + +โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ” +๐Ÿ”ง GAP FILLING MODE ({{total_missing}} gaps to fill) +โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ” + + + Continue to Step 8 + + + + + For each gap in gaps_list: + + + + +Fill this gap? + +**Item:** {{item_description}} +**Type:** {{item_type}} ({{section}}) +**Missing:** {{what_is_missing}} + +[Y] Yes - Implement this item +[A] Auto-fill - Implement this and all remaining gaps without asking +[S] Skip - Leave this gap unfilled +[H] Halt - Stop gap filling + +Your choice: + + + + Set require_confirmation = false (auto-fill remaining) + + + + Continue to next gap + + + + Exit gap filling loop + Jump to Step 9 (Summary) + + + + + + ๐Ÿ”ง Implementing: {{item_description}} + + Load story context (Technical Requirements, Architecture Compliance, Dev Notes) + Implement missing item following story specifications + Write tests if required + Run tests to verify implementation + Verify linting/type checking passes + + + Check box [x] for this item in story file + Update File List with new/modified files + Add to Dev Agent Record: "Gap filled: {{item_description}}" + โœ… Implemented and verified + + + Stage files for this gap + Commit: "fix({{story_key}}): fill gap - {{item_description}}" + โœ… Committed + + + + + โŒ Failed to implement: {{error_message}} + Leave box unchecked + Record failure in gaps_list + Add to failed_gaps + + + + After all gaps processed: + +โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ” +Gap Filling Complete +โœ… Filled: {{gaps_filled}} +โŒ Failed: {{gaps_failed}} +โญ๏ธ Skipped: {{gaps_skipped}} +โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ” + + + + + + ๐Ÿ” Re-verifying filled gaps... + + For each filled gap: + Re-run verification for that item + Ensure still VERIFIED after all changes + + โœ… All filled gaps re-verified + + + Calculate final completion: + + final_verified = count of [x] across all sections + final_partial = count of [~] across all sections + final_missing = count of [ ] across all sections + final_pct = (final_verified / total_items) ร— 100 + + + + Stage all changed files + Commit: "fix({{story_key}}): fill {{gaps_filled}} gaps from revalidation" + โœ… All gaps committed + + + + Load {sprint_status} file + Update entry with current progress: + Format: {{story_key}}: {{current_status}} # Revalidated: {{final_verified}}/{{total_items}} ({{final_pct}}%) verified + Save sprint-status.yaml + โœ… Sprint status updated with revalidation results + + + + Add to Dev Agent Record in story file: + +## Revalidation Record ({{timestamp}}) + +**Revalidation Mode:** {{#if fill_gaps}}Verify & Fill{{else}}Verify Only{{/if}} + +**Results:** +- Verified: {{final_verified}}/{{total_items}} ({{final_pct}}%) +- Gaps Found: {{total_missing}} +- Gaps Filled: {{gaps_filled}} + +**Evidence:** +{{#each verification_evidence}} +- {{item}}: {{evidence}} +{{/each}} + +{{#if gaps_filled > 0}} +**Gaps Filled:** +{{#each filled_gaps}} +- {{item}}: {{what_was_implemented}} +{{/each}} +{{/if}} + +{{#if failed_gaps.length > 0}} +**Failed to Fill:** +{{#each failed_gaps}} +- {{item}}: {{error}} +{{/each}} +{{/if}} + + Save story file + + + + + +โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ” +โœ… REVALIDATION COMPLETE +โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ” +**Story:** {{story_key}} + +**Final Status:** +- โœ… Verified Complete: {{final_verified}}/{{total_items}} ({{final_pct}}%) +- ๐Ÿ”ถ Partially Complete: {{final_partial}}/{{total_items}} +- โŒ Missing/Incomplete: {{final_missing}}/{{total_items}} + +{{#if fill_gaps}} +**Gap Filling Results:** +- Filled: {{gaps_filled}} +- Failed: {{gaps_failed}} +- Skipped: {{gaps_skipped}} +{{/if}} + +**Accuracy Check:** +- Before revalidation: {{pct_before}}% checked +- After revalidation: {{final_pct}}% verified +- Checkbox accuracy: {{#if pct_before == final_pct}}โœ… Perfect (0% discrepancy){{else if pct_before > final_pct}}โš ๏ธ {{pct_before - final_pct}}% over-reported (checkboxes were optimistic){{else}}๐Ÿ”ถ {{final_pct - pct_before}}% under-reported (work done but not checked){{/if}} + +{{#if final_pct >= 95}} +**Recommendation:** Story is COMPLETE - mark as "done" or "review" +{{else if final_pct >= 80}} +**Recommendation:** Story is mostly complete - finish remaining {{final_missing}} items then mark "review" +{{else if final_pct >= 50}} +**Recommendation:** Story has significant gaps - continue development with /dev-story +{{else}} +**Recommendation:** Story is mostly incomplete - consider re-implementing with /dev-story or /super-dev-pipeline +{{/if}} + +{{#if failed_gaps.length > 0}} +**โš ๏ธ Manual attention needed for {{failed_gaps.length}} items that failed to fill automatically** +{{/if}} + +{{#if create_report}} +**Detailed Report:** {sprint_artifacts}/revalidation-{{story_key}}-{{timestamp}}.md +{{/if}} +โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ” + + + + diff --git a/src/modules/bmm/workflows/4-implementation/revalidate-story/workflow.yaml b/src/modules/bmm/workflows/4-implementation/revalidate-story/workflow.yaml new file mode 100644 index 00000000..ecc23f56 --- /dev/null +++ b/src/modules/bmm/workflows/4-implementation/revalidate-story/workflow.yaml @@ -0,0 +1,37 @@ +name: revalidate-story +description: "Clear checkboxes and re-verify story against actual codebase implementation. Identifies gaps and optionally fills them." +author: "BMad" +version: "1.0.0" + +# Critical variables from config +config_source: "{project-root}/_bmad/bmm/config.yaml" +output_folder: "{config_source}:output_folder" +sprint_artifacts: "{output_folder}/sprint-artifacts" + +# Input parameters +story_file: "{story_file}" # Required: Full path to story file +fill_gaps: false # Optional: Fill missing items after verification (default: verify-only) +auto_commit: false # Optional: Auto-commit filled gaps (default: prompt) + +# Verification settings +verification: + verify_acceptance_criteria: true + verify_tasks: true + verify_definition_of_done: true + check_for_stubs: true # Reject stub implementations (TODO, Not implemented, etc.) + require_tests: true # Require tests for code items + +# Gap filling settings (only used if fill_gaps=true) +gap_filling: + max_gaps_to_fill: 10 # Safety limit - HALT if more gaps than this + require_confirmation: true # Ask before filling each gap (false = auto-fill all) + run_tests_after_each: true # Verify each filled gap works + commit_strategy: "per_gap" # "per_gap" | "all_at_once" | "none" + +# Output settings +output: + create_report: true # Generate revalidation-report.md + update_dev_agent_record: true # Add revalidation notes to story + update_sprint_status: true # Update progress in sprint-status.yaml + +standalone: false