Fido posts duplicate replies to review thread comments (closes #566)#662
Merged
Conversation
…#566) Replace the module-level set[int] with RepliedComments — a thread-safe class with an atomic claim() that checks-and-adds under a lock in one operation. The claim now happens *before* calling reply_to_comment() / reply_to_issue_comment(), not after: concurrent webhook deliveries for the same comment can no longer both pass the membership check before either adds the ID. On failure, release() clears the claim so a GitHub redelivery can retry. The already_replied parameter on reply_to_review() is removed since that function is a stub that never used it. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
86870e3 to
6ff6942
Compare
Move RepliedComments to kennel/claimed.py as a shared module so both the webhook handler (server.py) and the worker (worker.py) can consult the same process-wide claimed set without a circular import. _filter_threads now skips threads whose first_db_id appears in the webhook-claimed set. The last_author == gh_user filter already handles threads where the reply landed before handle_threads fetches the thread list, but it has an inherent race with GitHub API propagation. The in-process claimed-ID check is deterministic and fires immediately when the webhook handler claims a comment — even when the reply is still in flight. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
rhencke
approved these changes
Apr 17, 2026
This was referenced Apr 17, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #566.
Closes the TOCTOU race on
_replied_commentsby claiming comment IDs atomically before posting, and wires the claimed set intohandle_threadsfiltering so the worker's comments sub-agent won't re-reply to threads the webhook handler already handled.Work queue
Completed (2)