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
Load {bugs_yaml} if it existsSet bugs_updated = [], features_updated = [], features_pending = []Return early - no bug tracking to syncInitialize: 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 method2. 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 unambiguousFor 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 listFor 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 story3. Only proceed if ALL stories in sprint_stories have status "done" in sprint-status.yaml4. 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 listSave updated bugs.yaml, preserving all structure and commentsLoad {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 presentSave updated bugs.md