Skip to content

Prevent automerge from racing ahead of comment-driven iterations#339

Merged
nicobistolfi merged 2 commits intomainfrom
vigilante/issue-338-prevent-automerge-completion-from-racing-ahead-of-comment-driven-iterations
Mar 30, 2026
Merged

Prevent automerge from racing ahead of comment-driven iterations#339
nicobistolfi merged 2 commits intomainfrom
vigilante/issue-338-prevent-automerge-completion-from-racing-ahead-of-comment-driven-iterations

Conversation

@nicobistolfi
Copy link
Copy Markdown
Collaborator

Summary

  • Adds an explicit pending-iteration gate in tryAutoSquashMerge that blocks automerge when a session has IterationInProgress set or when there are unclaimed @vigilanteai iteration comments on the issue.
  • The new iterationBlocksAutomerge method fetches issue comments before each merge attempt and uses the existing FindIterationComment function with the session's monotonic claim cursor to detect pending iteration requests.
  • Covers both the short window after a qualifying comment is observed but before the iteration session starts, and the active iteration window after vigilante:iterating is set.

Test plan

  • TestScanOnceAutomergeBlockedByPendingIterationComment — verifies automerge is blocked when an unclaimed iteration comment exists
  • TestScanOnceAutomergeBlockedByIterationInProgress — verifies automerge is blocked when IterationInProgress is true
  • TestScanOnceAutomergeProceedsWithNoIterationComments — verifies automerge proceeds normally with no iteration comments
  • TestScanOnceAutomergeProceedsWhenIterationAlreadyClaimed — verifies automerge proceeds when the iteration comment has already been claimed
  • All existing automerge and iteration tests continue to pass
  • Full test suite passes (go test ./...)

Closes #338

When an assignee posts a follow-up @vigilanteai iteration request and
vigilante:automerge is added immediately after, the PR maintenance path
could merge the PR before the iteration was processed. This introduces
an explicit pending-iteration gate in tryAutoSquashMerge that:

1. Blocks automerge when IterationInProgress is set on the session.
2. Fetches issue comments and checks for unclaimed iteration comments
   before allowing the merge to proceed.

The gate covers both the window after a qualifying comment is observed
but before the iteration session starts, and the active iteration
window. Once the iteration completes and no further comments are
pending, automerge proceeds normally.

Closes #338
@nicobistolfi nicobistolfi merged commit 8c997e9 into main Mar 30, 2026
1 check passed
@nicobistolfi nicobistolfi deleted the vigilante/issue-338-prevent-automerge-completion-from-racing-ahead-of-comment-driven-iterations branch March 30, 2026 16:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Prevent automerge/completion from racing ahead of comment-driven iterations

1 participant