Skip to content

Make iteration comment claiming monotonic to stop replay loops on historical comments #332

@nicobistolfi

Description

@nicobistolfi

Summary

Vigilante can get stuck replaying historical @vigilanteai ... iteration comments on open issues, causing repeated Iteration Ignored comments and unnecessary redispatch attempts. The comment-claim cursor for iteration requests needs monotonic semantics so older comments are treated as already consumed once a newer comment has been claimed.

Problem

  • FindIterationComment currently skips only the exact last claimed comment ID, then returns the next older matching iteration comment.
  • On the next scan, Vigilante can reprocess a historical iteration comment instead of stopping at the claimed cursor.
  • When the issue has no current assignees, each replayed historical comment fails the assignee check and produces a fresh Iteration Ignored comment.
  • This creates sustained GitHub issue noise and can trigger unnecessary follow-up session starts after the relevant work already completed.

Context

Desired Outcome

Implementation Notes

  • Update iteration comment selection so comments at or before the stored claim cursor are considered consumed.
  • Use a monotonic comparison based on comment timestamp and ID, rather than exact-ID equality only.
  • A reasonable implementation is to consider only comments newer than LastIterationCommentAt, with ID as a tie-breaker if needed.
  • Preserve the ability to detect genuinely new iteration comments that arrive after the stored cursor.
  • Audit any similar command-claim helpers for resume, cleanup, or recreate to confirm they do not have the same replay behavior.
  • Keep the fix narrow: the primary problem is historical iteration comment replay, not the broader session lifecycle.

Acceptance Criteria

Testing Expectations

  • Add regression tests for a session with multiple historical iteration comments where only the newest unclaimed comment should be considered.
  • Add coverage for repeated scans after an ignored iteration request to verify that older comments are not replayed.
  • Add coverage for the positive case where a new iteration comment arrives after the stored cursor and is correctly detected.
  • Verify the assignee-mismatch path does not produce repeated Iteration Ignored comments for older history.

Operational / UX Considerations

  • The fix should reduce GitHub issue noise and avoid confusing operators with repeated rejection comments for stale history.
  • Preserve compatibility with existing persisted session state that already contains last_iteration_comment_id and last_iteration_comment_at.
  • If the implementation changes cursor semantics, make the behavior explicit in logs so future comment-processing bugs are easier to diagnose.

Metadata

Metadata

Assignees

Labels

vigilante:doneVigilante completed its work on the issue and no further automation is expected.

Type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions