fix(engine): add cross-process merge guard to prevent concurrent merges

Multiple engine processes (dashboard + serve) share the same SQLite database
but each has its own in-memory merge queue. Without a cross-process check,
two processes can start merging different tasks simultaneously.

Added store.getActiveMergingTask() as a DB-level check before any merge
starts. The drainMergeQueue defers with pollIntervalMs delay, and both
aiMergeTask and processPullRequestMergeTask have safety-net checks.
Also moved stale merge status cleanup to run regardless of autoMerge setting.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
gsxdsm
2026-04-13 20:21:58 -07:00
parent 827c0370c3
commit f9f7aff3ec
7 changed files with 70 additions and 3 deletions

View File

@@ -65,6 +65,7 @@ const mocks = vi.hoisted(() => {
emitter.off(event, handler);
}),
emit: emitter.emit.bind(emitter),
getActiveMergingTask: vi.fn().mockReturnValue(undefined),
};
}