story-kit: create 205_bug_mergemaster_marks_stories_as_done_without_squash_merging_code

This commit is contained in:
Dave
2026-02-26 13:48:50 +00:00
parent c24301d60c
commit 181e49e0ec

View File

@@ -8,9 +8,28 @@ name: "Mergemaster marks stories as done without squash-merging code"
The mergemaster agent consistently moves stories from 4_merge to 5_done without actually squash-merging the feature branch code onto master. This was observed across stories #199, #200, #201, #202, #203, #204 — all marked done with unmerged commits still on their feature branches. The mergemaster agent consistently moves stories from 4_merge to 5_done without actually squash-merging the feature branch code onto master. This was observed across stories #199, #200, #201, #202, #203, #204 — all marked done with unmerged commits still on their feature branches.
The issue appears to be triggered when multiple stories are developed in parallel from different base points on master. The feature branches carry conflicting views of the codebase (e.g. one story adds watcher config, another removes it). The mergemaster either encounters conflicts/empty diffs and silently skips the merge, or the merge_agent_work pipeline doesn't actually perform the squash merge step before moving the story file. ## Root Cause
Additionally, the stale .story_kit/merge_workspace directory from a failed merge blocks subsequent merge_agent_work calls with a "directory already exists" error. The new merge-queue worktree approach (introduced ~24 hours ago) has a race condition with the filesystem watcher:
1. `run_squash_merge()` creates a `merge-queue/{story_id}` branch at master's current HEAD
2. It creates a temporary worktree, runs `git merge --squash`, commits, and runs quality gates — all in the merge-queue worktree
3. Meanwhile, the **filesystem watcher auto-commits pipeline file moves** to master (e.g. "story-kit: queue X for merge", "story-kit: done Y")
4. By the time step 7 tries `git merge --ff-only merge-queue/{story_id}` on master, master has diverged and the fast-forward fails
5. `run_squash_merge()` returns `success: false` (correctly) but `gates_passed: true` (misleading)
6. The `merge_agent_work` caller correctly reports failure — but the mergemaster is a Claude Code agent, not the Rust pipeline. The agent sees the failure, gives up on the squash merge, and instead manually moves the story file to done without the code
The old approach (direct squash-merge on master) didn't have this problem because it was atomic — no separate branch/worktree and no fast-forward step that could be foiled by concurrent master commits.
## Key code locations
- `server/src/agents.rs:2561``run_squash_merge()` function
- `server/src/agents.rs:2837-2865` — fast-forward step that fails when master diverges
- `server/src/agents.rs:2694-2708` — "nothing to commit" early return also skips fast-forward
## Additional issue
The stale `.story_kit/merge_workspace` directory from failed merges blocks subsequent `merge_agent_work` calls with a "directory already exists" error, though there is cleanup code at line 2572-2573 that should handle this.
## How to Reproduce ## How to Reproduce