# Sprint Status Helper
**Purpose:** Utility workflow for reading and updating `sprint-status.yaml` tracking file used across Phase 4 implementation workflows.
**Location:** `src/modules/bmm/workflows/helpers/sprint-status/`
**Status File:** `{output_folder}/sprint-status.yaml` (created by sprint-planning workflow)
---
## Quick Reference
### Usage Pattern
```xml
action: ACTION_NAME
PARAM_NAME: value
Do something with {{result_*}} variables
```
---
## Available Actions
### Read Operations
| Action | Purpose | Key Parameters | Key Returns |
| --------------------- | ---------------------------- | --------------------------------------- | ----------------------------------------------------------------------------- |
| `get_next_story` | Find first story by status | `filter_status`, `epic_filter` | `result_found`, `result_story_key`, `result_epic_id`, `result_story_id` |
| `list_stories` | Get all matching stories | `filter_status`, `epic_filter`, `limit` | `result_count`, `result_stories`, `result_story_list` |
| `get_story_status` | Check story's current status | `story_key` | `result_found`, `result_status` |
| `get_epic_status` | Check epic status + stats | `epic_id` | `result_status`, `result_story_count`, `result_done_count`, `result_complete` |
| `check_epic_complete` | Verify all stories done | `epic_id` | `result_complete`, `result_pending_stories` |
| `get_metadata` | Get project info from file | none | `result_project`, `result_story_location`, `result_generated_date` |
| `get_file_path` | Get file location | none | `result_file_path`, `result_exists` |
### Write Operations
| Action | Purpose | Key Parameters | Key Returns |
| ------------------------ | ---------------------- | ------------------------------------- | ---------------------------------------------------------- |
| `update_story_status` | Change story status | `story_key`, `new_status`, `validate` | `result_success`, `result_old_status`, `result_new_status` |
| `update_epic_status` | Mark epic as contexted | `epic_id`, `new_status` | `result_success`, `result_old_status`, `result_new_status` |
| `complete_retrospective` | Mark epic retro done | `epic_id` | `result_success`, `result_retro_key` |
### Utility Operations
| Action | Purpose | Key Parameters | Key Returns |
| --------------------- | ------------------------------- | -------------------------- | --------------------------------------------------------- |
| `validate_transition` | Check if status change is legal | `from_status`, `to_status` | `result_valid`, `result_message`, `result_suggested_path` |
---
## Status Flow Reference
**Epic Status:**
```
backlog → contexted
```
**Story Status:**
```
backlog → drafted → ready-for-dev → in-progress → review → done
↑_________ Corrections allowed (backward movement) ________↑
```
**Retrospective Status:**
```
optional ↔ completed
```
---
## Common Patterns
### Pattern 1: Find and Update Next Story
```xml
action: get_next_story
filter_status: backlog
Work on story: {{result_story_key}}
action: update_story_status
story_key: {{result_story_key}}
new_status: drafted
```
### Pattern 2: List Stories for User Selection
```xml
action: list_stories
filter_status: drafted
limit: 10
Select a story to work on:
```
### Pattern 3: Check Epic Completion Before Retrospective
```xml
action: check_epic_complete
epic_id: 1
action: complete_retrospective
epic_id: 1
```
### Pattern 4: Validate Before Update
```xml
action: validate_transition
from_status: drafted
to_status: in-progress
HALT
```
### Pattern 5: Mark Epic Contexted
```xml
action: update_epic_status
epic_id: {{epic_num}}
new_status: contexted
```
---
## Return Variables
**All actions return:**
- `result_success`: `true` | `false`
- `result_error`: Error message (if `result_success == false`)
**Common additional returns:**
- `result_found`: `true` | `false` (for query operations)
- `result_status`: Current status value
- `result_old_status`: Previous status (for updates)
- `result_new_status`: Updated status (for updates)
- `result_story_key`: Story key like "1-1-story-name"
- `result_epic_id`: Epic number extracted from key
- `result_story_id`: Story number extracted from key
---
## Error Handling
**File Not Found:**
```xml
HALT
```
**Story Not Found:**
```xml
```
**Invalid Transition:**
```xml
```
---
## Options
| Parameter | Default | Description |
| ------------- | ------- | ---------------------------------------------------------- |
| `validate` | `true` | Enforce legal status transitions for `update_story_status` |
| `dry_run` | `false` | Test update without saving (for debugging) |
| `show_output` | `true` | Helper displays status messages (✅/❌/📋) |
---
## Integration Checklist
When adding sprint-status helper to a workflow:
- [ ] Add `sprint_status_file` variable to workflow.yaml if needed
- [ ] Use `invoke-workflow` with correct action parameter
- [ ] Check `result_success` and `result_found` before proceeding
- [ ] Handle `result_error == 'file_not_found'` case
- [ ] Use returned `result_*` variables in workflow logic
- [ ] Update status at appropriate workflow steps
---
## Workflow Integration Map
| Workflow | Actions Used | When |
| --------------------- | ------------------------------------------------- | ------------------------------------------- |
| **epic-tech-context** | `get_epic_status`
`update_epic_status` | Check epic exists → Mark contexted |
| **create-story** | `get_next_story`
`update_story_status` | Find backlog → Mark drafted |
| **story-ready** | `list_stories`
`update_story_status` | List drafted → Mark ready-for-dev |
| **story-context** | `get_next_story` | Find drafted (read-only) |
| **dev-story** | `get_next_story`
`update_story_status` (2x) | Find ready → Mark in-progress → Mark review |
| **review-story** | `list_stories`
`update_story_status` | List review → Update based on outcome |
| **story-done** | `list_stories`
`update_story_status` | List review → Mark done |
| **retrospective** | `check_epic_complete`
`complete_retrospective` | Verify complete → Mark retro done |
---
## Notes
- **Source of Truth:** File system is authoritative. Sprint-planning regenerates from epics + file detection.
- **Refresh Strategy:** Re-run sprint-planning anytime to resync tracking with actual files.
- **Concurrency:** Not designed for concurrent access. Single-user CLI workflow execution.
- **Alpha Status:** No backward compatibility. Re-run sprint-planning with latest version before using.
---
## Examples in Context
See individual workflow instructions in `src/modules/bmm/workflows/4-implementation/` for integration examples.
**Helper Files:**
- `workflow.yaml` - Interface definition
- `instructions.md` - Action implementation logic
- `README.md` - This file