Skip to content

Backfill missed PR comments on worker startup (closes #794)#797

Merged
FidoCanCode merged 1 commit into
mainfrom
fix-794-backfill-missed-comments
Apr 18, 2026
Merged

Backfill missed PR comments on worker startup (closes #794)#797
FidoCanCode merged 1 commit into
mainfrom
fix-794-backfill-missed-comments

Conversation

@FidoCanCode
Copy link
Copy Markdown
Owner

Closes #794.

Summary

When kennel is down (vet-mode stop, crash, deploy), GitHub eventually stops retrying webhook delivery for the missed events. Top-level PR comments from that window are then invisible to the worker loop on restart — fido never sees them, never replies.

This PR adds a one-shot backfill pass that runs on the first iteration of each `WorkerThread` lifetime:

  • For the active PR, fetch `gh.get_issue_comments(repo, pr)` and enqueue thread tasks for any not already tasked.
  • `create_task` dedups on `comment_id` regardless of task status, so replays are idempotent.
  • Zero steady-state cost: runs exactly once per thread, then the flag flips.

Scope

Top-level PR comments only. Inline review comments and review threads are already scanned every iteration by `Worker.handle_threads` — only issue-comments (`issue_comment` webhooks) are invisible to the loop.

Fresh PRs skip the scan (no history to backfill).

Test plan

  • `uv run ruff format . && uv run ruff check .`
  • `uv run pytest --cov --cov-fail-under=100` — 2397 passed, 100% coverage
  • `TestBackfillMissedPrComments` (9 cases): allowed collaborators, fido self-skip, case-insensitive gh_user, non-allowed users, allowed bots, bot/human prompt markers, missing fields, empty list, fido literal-name defense
  • Worker integration: backfill fires once per WorkerThread; skipped for fresh PRs

When kennel is down, GitHub eventually gives up redelivering webhook
events.  Top-level PR comments landing during the downtime are then
invisible to the worker loop on restart — fido never sees them, never
replies.

Add Worker.first_iteration mode: on the first iteration of each
WorkerThread lifetime (i.e. after kennel restart), scan the active PR's
issue_comments and enqueue thread tasks for any we haven't already
tasked.  create_task dedups by comment_id so replays are idempotent, and
the scan runs exactly once per thread — zero steady-state cost.

Scope is deliberately narrow: inline review comments and review threads
are already scanned every iteration by handle_threads, so the gap is
only top-level PR comments.  Fresh PRs skip the scan since they have no
history to backfill.
@FidoCanCode FidoCanCode marked this pull request as ready for review April 18, 2026 14:36
@FidoCanCode FidoCanCode requested a review from rhencke April 18, 2026 14:36
@FidoCanCode FidoCanCode merged commit 2f383d1 into main Apr 18, 2026
3 checks passed
@FidoCanCode FidoCanCode deleted the fix-794-backfill-missed-comments branch April 18, 2026 14:37
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.

Fido misses comments that land while kennel/webhook is down — no backfill on restart

2 participants