You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
⚠️ Definition of Done: this issue must be completed in full, in a single PR. Do not split this
work across multiple PRs, and do not defer any Deliverable below to a follow-up issue. A PR that
satisfies only some of the Deliverables, stubs a required test, or leaves a checkbox
partially-done does NOT resolve this issue and will be closed.
Context
Four throttle functions in src/queue/processors.ts — maybeThrottleReviewNagPing (~14582), maybeThrottleMonitoredMentions (~14795), maybeThrottleLoopOverCommand (~14979), and maybeThrottleIntentRouting (~15093) — all guard against GitHub webhook redelivery by calling hasAuditEventForDelivery(...) against a COMMAND_RATE_LIMIT_REDELIVERY_WINDOW_MS window before
doing any counting/throttle work, per #8681. The pattern's own comment explains why: "GitHub
can redeliver the same issue_comment event; without this, a redelivery re-counts this ping toward
the threshold." This is confirmed reachable in production: wrangler.jsonc sets max_retries: 3
on the job queue, and src/queue/dlq.ts re-drives a dead-lettered github-webhook message once
more with the identical deliveryId/payload after that.
Five action-command handlers, dispatched earlier in processGitHubWebhook than the four
throttles above, have no equivalent guard and post via plain createIssueComment (not the
idempotent createOrUpdateAgentCommandComment some other handlers use):
maybeProcessReviewCommand (~13215) — a redelivered review command re-runs reReviewStoredPullRequest a second time (real AI-review spend).
maybeProcessPauseCommand (~13275)
maybeProcessResumeCommand (~13318)
maybeProcessExplainCommand (~13384)
maybeProcessGenerateTestsCommand (~13466) — a redelivery regenerates and re-commits an E2E
test.
Issue #8681 explicitly frames itself as closing "the two remaining gaps in an otherwise-fixed
bug class," but only ever enumerated the four counting/throttle functions above — it never
addressed these five action-command handlers, which sit earlier in the same dispatch chain and
share the identical redelivery exposure. No redelivery test exists for any of these five handlers
(test/unit/queue-5.test.ts only has a redelivery test for the review-nag throttle).
Requirements
Each of the five handlers listed above must add the same hasAuditEventForDelivery(...) + COMMAND_RATE_LIMIT_REDELIVERY_WINDOW_MS short-circuit the four throttle functions already use,
placed before any side-effecting work (comment posting, re-review dispatch, pause/resume state
change, test generation) — mirror maybeThrottleReviewNagPing's exact placement and event-type
key shape (one eventType/targetKey pair per handler, matching that handler's own existing
audit-event type used for its "completed" outcome).
Use each handler's own existing "completed" audit event type as the redelivery-check's eventType argument (e.g. "github_app.review_command_completed" for maybeProcessReviewCommand), so the check looks for "did this exact command already complete
for this delivery," matching the four throttle functions' own convention.
Do not modify the four already-fixed throttle functions (maybeThrottleReviewNagPing, maybeThrottleMonitoredMentions, maybeThrottleLoopOverCommand, maybeThrottleIntentRouting) —
they are the precedent, not the target.
All five handlers must be fixed in this one PR — this is a single mechanical pattern applied
five times, not five separate concerns.
Deliverables
maybeProcessReviewCommand gains the redelivery guard.
maybeProcessPauseCommand gains the redelivery guard.
maybeProcessResumeCommand gains the redelivery guard.
maybeProcessExplainCommand gains the redelivery guard.
maybeProcessGenerateTestsCommand gains the redelivery guard.
A new test per handler (5 total, in test/unit/queue-5.test.ts or the existing test file(s)
already covering each handler) asserting a simulated redelivery (same deliveryId, command
already recorded as completed) short-circuits without repeating the side effect (re-review
dispatch / pause-state change / resume-state change / explain comment / test generation).
All six deliverables (five fixes + their tests) are required in this single PR.
Test Coverage Requirements
This repo enforces 99%+ Codecov patch coverage, branch-counted, on every changed line/branch in src/**. Each of the five new guards and its corresponding new redelivery test must be covered.
Expected Outcome
A GitHub webhook redelivery of an already-completed @loopover review/pause/resume/ explain/generate-tests command short-circuits immediately instead of repeating the underlying
action a second time — matching the redelivery protection the four sibling throttle functions
already have per #8681.
Links & Resources
src/queue/processors.ts (the five handlers to fix, plus the four throttle functions as
precedent — maybeThrottleReviewNagPing ~14582 is the clearest example to mirror)
src/queue/dlq.ts (confirms the redelivery mechanism this guard defends against)
Context
Four throttle functions in
src/queue/processors.ts—maybeThrottleReviewNagPing(~14582),maybeThrottleMonitoredMentions(~14795),maybeThrottleLoopOverCommand(~14979), andmaybeThrottleIntentRouting(~15093) — all guard against GitHub webhook redelivery by callinghasAuditEventForDelivery(...)against aCOMMAND_RATE_LIMIT_REDELIVERY_WINDOW_MSwindow beforedoing any counting/throttle work, per #8681. The pattern's own comment explains why: "GitHub
can redeliver the same issue_comment event; without this, a redelivery re-counts this ping toward
the threshold." This is confirmed reachable in production:
wrangler.jsoncsetsmax_retries: 3on the job queue, and
src/queue/dlq.tsre-drives a dead-letteredgithub-webhookmessage oncemore with the identical
deliveryId/payload after that.Five action-command handlers, dispatched earlier in
processGitHubWebhookthan the fourthrottles above, have no equivalent guard and post via plain
createIssueComment(not theidempotent
createOrUpdateAgentCommandCommentsome other handlers use):maybeProcessReviewCommand(~13215) — a redeliveredreviewcommand re-runsreReviewStoredPullRequesta second time (real AI-review spend).maybeProcessPauseCommand(~13275)maybeProcessResumeCommand(~13318)maybeProcessExplainCommand(~13384)maybeProcessGenerateTestsCommand(~13466) — a redelivery regenerates and re-commits an E2Etest.
Issue #8681 explicitly frames itself as closing "the two remaining gaps in an otherwise-fixed
bug class," but only ever enumerated the four counting/throttle functions above — it never
addressed these five action-command handlers, which sit earlier in the same dispatch chain and
share the identical redelivery exposure. No redelivery test exists for any of these five handlers
(
test/unit/queue-5.test.tsonly has a redelivery test for the review-nag throttle).Requirements
hasAuditEventForDelivery(...)+COMMAND_RATE_LIMIT_REDELIVERY_WINDOW_MSshort-circuit the four throttle functions already use,placed before any side-effecting work (comment posting, re-review dispatch, pause/resume state
change, test generation) — mirror
maybeThrottleReviewNagPing's exact placement and event-typekey shape (one
eventType/targetKeypair per handler, matching that handler's own existingaudit-event type used for its "completed" outcome).
eventTypeargument (e.g."github_app.review_command_completed"formaybeProcessReviewCommand), so the check looks for "did this exact command already completefor this delivery," matching the four throttle functions' own convention.
maybeThrottleReviewNagPing,maybeThrottleMonitoredMentions,maybeThrottleLoopOverCommand,maybeThrottleIntentRouting) —they are the precedent, not the target.
five times, not five separate concerns.
Deliverables
maybeProcessReviewCommandgains the redelivery guard.maybeProcessPauseCommandgains the redelivery guard.maybeProcessResumeCommandgains the redelivery guard.maybeProcessExplainCommandgains the redelivery guard.maybeProcessGenerateTestsCommandgains the redelivery guard.test/unit/queue-5.test.tsor the existing test file(s)already covering each handler) asserting a simulated redelivery (same
deliveryId, commandalready recorded as completed) short-circuits without repeating the side effect (re-review
dispatch / pause-state change / resume-state change / explain comment / test generation).
All six deliverables (five fixes + their tests) are required in this single PR.
Test Coverage Requirements
This repo enforces 99%+ Codecov patch coverage, branch-counted, on every changed line/branch in
src/**. Each of the five new guards and its corresponding new redelivery test must be covered.Expected Outcome
A GitHub webhook redelivery of an already-completed
@loopover review/pause/resume/explain/generate-testscommand short-circuits immediately instead of repeating the underlyingaction a second time — matching the redelivery protection the four sibling throttle functions
already have per #8681.
Links & Resources
src/queue/processors.ts(the five handlers to fix, plus the four throttle functions asprecedent —
maybeThrottleReviewNagPing~14582 is the clearest example to mirror)src/queue/dlq.ts(confirms the redelivery mechanism this guard defends against)wrangler.jsonc(max_retries: 3on the job queue)the five action-command handlers it didn't cover)
test/unit/queue-5.test.ts(existing redelivery test for review-nag throttle — pattern tomirror for the five new tests)