Refuse turns, discard and subtasks while a merge is finalizing

This commit is contained in:
Ian Gulliver
2026-10-16 12:46:28 -07:00
parent 0e52253d07
commit ecfae97d97
11 changed files with 287 additions and 233 deletions
-2
View File
@@ -1,7 +1,5 @@
# Bugs
- Task accepts new turns while its merge is being finalized
`EndTurn` clears `merging_by` (`internal/agents/manager.go:899`, `:926–930`) before `finishMerge` snapshots the live worktree, pushes and runs `RemoveTask` (`internal/agents/mergein.go:238–318`), and `transitionSession` blocks only discard (`internal/store/store.go:1389`). A message sent during the push can put half-done edits into the pushed squash, or be killed when the worktree is force-removed. Add a persisted `finalizing` marker set in the same EndTurn transaction; turns, discard and subtask creation refuse while it is set, and the UI shows it as Merging.
- Merge finalization keeps no durable progress; cleanup runs before the task is closed
`internal/agents/mergein.go:303–324` runs push → notes → fast-forward → `RemoveTask` → `MergeTask`. A crash or error after the push leaves an active task with no worktree; a retried Merge fails in `Snapshot`, or squashes to no change and closes with an empty `merge_commit`. Have the `finalizing` marker record the squash commit; on startup, a recorded commit that is an ancestor of origin/<default> finishes notes, fast-forward, removal and MergeTask idempotently, otherwise the marker is cleared and an error is filed.
- A failed auto-commit still advances the workflow from the old HEAD