Skip to content

queue: 5 action-command handlers (review/pause/resume/explain/generate-tests) missing the webhook-redelivery guard #8681 added elsewhere #9312

Description

@JSONbored

⚠️ 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.tsmaybeThrottleReviewNagPing (~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)
  • wrangler.jsonc (max_retries: 3 on the job queue)
  • fix(orb): review-nag and monitored-mention throttles never got the webhook-redelivery guard applied to the command rate limiter #8681 (established this exact pattern for the four throttle functions — this issue extends it to
    the five action-command handlers it didn't cover)
  • test/unit/queue-5.test.ts (existing redelivery test for review-nag throttle — pattern to
    mirror for the five new tests)

Metadata

Metadata

Assignees

No one assigned

    Labels

    gittensor:bugGittensor-scored bug fix — scores a 0.05x multiplier.help wantedExtra attention is needed

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions