Skip to content

feat(commands): shared PR-comment command-handler preamble helper (bot/action/missing-target skip recording) #2161

Description

@JSONbored

maybeProcessGateOverrideCommand (src/queue/processors.ts:5977) and maybeProcessPlanCommand (:6204) each hand-roll the SAME guard preamble: reject payload.action !== "created", reject Bot/[bot] authors, reject missing repo/PR/installation/actor, and record a skip audit event for each. The #1960 command surface will add 6+ more handlers that need the identical preamble. Extract a PURE classifier (mirroring classifyPlanCommandRequest at src/review/planner.ts:39) that takes the webhook payload + installationId and returns either {ok:true, repoFullName, installationId, actor, pr-or-issue} or {ok:false, reason, ...targetKey} so every new command handler carries a single ok branch. Contributor scope = the pure classifier + its exhaustive tests; wiring it into the (maintainer-owned) handlers is a follow-up.

Deliverables

  • Add a pure classifyPrCommandRequest(payload, installationId) helper (new module under src/review/ or src/github/, mirroring classifyPlanCommandRequest) returning a discriminated ok/skip union with a stable reason string per skip cause
  • Cover the four skip causes independently: unsupported_comment_action, bot_author, missing_repo_pr_installation_or_actor, and the ok path — matching the reason strings already used at src/queue/processors.ts:5992-6027
  • Do NOT change the existing handlers in this PR (pure add + tests only; the refactor to consume it is separate to keep the diff small)
  • Unit tests exhaustively covering each skip branch + the ok branch (both sides of every guard for branch-counted 97% coverage)

References

  • src/queue/processors.ts:5977 (maybeProcessGateOverrideCommand preamble)
  • src/queue/processors.ts:6204 (maybeProcessPlanCommand)
  • src/review/planner.ts:39 (classifyPlanCommandRequest — the pattern to mirror)
  • #1960

Part of #1960.


size: S · held for later release (gittensor:feature once activated)

Metadata

Metadata

Assignees

No one assigned

    Labels

    gittensor:featureGittensor-scored feature linked to a feature issue — scores a 0.25x multiplier.

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions