Sync bugs.yaml and bugs.md when a story is marked done, updating related bugs to "fixed" and features to "implemented" This task is invoked by workflows (story-done, code-review) after a story is marked done. It searches bugs.yaml for bugs/features linked to the completed story and updates their status. For multi-story features, it only marks "implemented" when ALL linked stories are done. The story key (e.g., "3-7-checkout-from-club-detail-page") The story ID (e.g., "3.7") - used for related_story matching Path to bugs.yaml file Path to bugs.md file Path to sprint-status.yaml file Current date for timestamps List of bug IDs marked as fixed List of feature IDs marked as implemented List of feature IDs with incomplete stories Load {bugs_yaml} if it exists Set bugs_updated = [], features_updated = [], features_pending = [] Return early - no bug tracking to sync Initialize: bugs_updated = [], features_updated = [], features_pending = [] Search for entries matching this story using ALL THREE methods: 1. Check sprint-status.yaml for comment "# Source: bugs.yaml/feature-XXX" or "# Source: bugs.yaml/bug-XXX" on the {story_key} line - this is the MOST RELIABLE method 2. Check related_story field in bugs.yaml matching {story_id} or {story_key} 3. Check sprint_stories arrays in feature_requests for entries containing {story_key} PRIORITY: Use sprint-status comment source if present - it's explicit and unambiguous For each matching bug: - Update status: "triaged" or "routed" or "in-progress" → "fixed" - Set fixed_date: {date} - Set assigned_to: "dev-agent" (if not already set) - Append to notes: "Auto-closed via sync-bug-tracking. Story {story_key} marked done on {date}." - Add bug ID to bugs_updated list For each matching feature (via related_story OR sprint_stories): MULTI-STORY FEATURE CHECK: If feature has sprint_stories array with multiple entries: 1. Extract all story keys from sprint_stories (format: "story-key: status") 2. Load sprint-status.yaml and check development_status for EACH story 3. Only proceed if ALL stories in sprint_stories have status "done" in sprint-status.yaml 4. If any story is NOT done, add feature to features_pending and log: "Feature {feature_id} has incomplete stories: {incomplete_list}" - Update status: "backlog" or "triaged" or "routed" or "in-progress" → "implemented" - Set implemented_date: {date} - Update sprint_stories entries to reflect done status - Append to notes: "Auto-closed via sync-bug-tracking. Story {story_key} marked done on {date}." - Add feature ID to features_updated list Save updated bugs.yaml, preserving all structure and comments Load {bugs_md} For each bug in bugs_updated: - Find the bug entry in "# Tracked Bugs" section - Move it to "# Fixed Bugs" section - Add [IMPLEMENTED] tag prefix with date: "[IMPLEMENTED] bug-XXX: Title [Fixed: {date}, Verified: pending]" For each feature in features_updated: - Find the feature entry in "# Tracked Feature Requests" section - Move it to "# Implemented Features" section - Add [IMPLEMENTED] tag prefix with date: "[IMPLEMENTED] feature-XXX: Title [Implemented: {date}, Verified: pending]" Update statistics section if present Save updated bugs.md Bug/Feature Sync Results: {{#if bugs_updated}} - Bugs marked fixed: {{bugs_updated}} {{/if}} {{#if features_updated}} - Features marked implemented: {{features_updated}} {{/if}} {{#if features_pending}} - Features with incomplete stories (not yet implemented): {{features_pending}} {{/if}} {{#if no_matches}} - No related bugs/features found for story {story_key} {{/if}}