---
name: "Auto-assign assigns mergemaster to coding-stage stories"
---

# Bug 312: Auto-assign assigns mergemaster to coding-stage stories

## Description

Auto-assign picks agents whose configured stage doesn't match the pipeline stage of the story. Observed multiple mismatch types:

- **Mergemaster assigned to coding-stage stories**: Story 310 was in `2_current/` but got mergemaster instead of a coder (2026-03-19)
- **Coders assigned to QA-stage stories**: Coders (stage=coder) have been observed running on stories in `3_qa/`
- **QA agents assigned to merge-stage stories**: QA agents (stage=qa) have been observed running on stories in `4_merge/`

The `auto_assign_available_work` function doesn't enforce that the agent's configured stage matches the pipeline stage of the story it's being assigned to. Story 279 (auto-assign respects agent stage from front matter) was supposed to fix stage matching, but the check may only apply to front-matter preferences, not the fallback assignment path.

## How to Reproduce

1. Move a story to any pipeline stage with no agent front matter preference
2. Wait for auto_assign_available_work to run
3. Observe that agents from the wrong stage get assigned (e.g. mergemaster to coding, coder to QA)

## Actual Result

Agents are assigned to stories in pipeline stages that don't match their configured stage. Mergemaster codes, coders do QA, QA agents attempt merges.

## Expected Result

Only coder-stage agents should be assigned to stories in 2_current/. Mergemaster should only be assigned to stories in 4_merge/.

## Acceptance Criteria

- [ ] auto_assign_available_work checks that the agent's configured stage matches the pipeline stage of the story before assigning
- [ ] Coder agents only assigned to stories in 2_current/
- [ ] QA agents only assigned to stories in 3_qa/
- [ ] Mergemaster only assigned to stories in 4_merge/
- [ ] Fallback assignment path respects stage matching (not just front-matter preference path)
