Skip to content

queue: generate-tests checkbox and text-command both missing the pr.state !== "open" guard #9020 added to their retrigger sibling #9311

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

maybeProcessPrPanelRetrigger in src/queue/processors.ts (~line 14016) has an explicit
pr.state !== "open" guard, added for #9020 ("panel re-run checkbox on a closed/merged PR
does real work, then silently no-ops"). Its doc comment explains why: the PR-panel comment is
deliberately preserved after merge/close, its checkboxes stay interactive on GitHub forever, and
without the guard a post-merge click would spend a real gate evaluation and live CI reads before
dying deep in the pipeline with no user-visible feedback.

Two structurally identical handlers never got the same guard:

  1. maybeProcessPrPanelGenerateTests (~line 14175, the checkbox handler, #4589) — goes
    straight from authorization → feature-flag check → mode check → runE2eTestGenerationAndDeliver,
    with no PR-state check anywhere in the function. On a merged/closed PR whose checkbox is still
    checkable, this spends a real AI test-generation call, and in commit delivery mode calls
    commitE2eTestToPrBranch (src/github/e2e-test-commit.ts:43), which only declines if the live
    head SHA/ref no longer matches the cached PR — it does not check PR state, so it can
    silently push a new commit onto an already-merged branch.
  2. maybeProcessGenerateTestsCommand (~line 13466, the @loopover generate-tests text-command
    twin) has the identical gap: no pr.state !== "open" check before authorization/generation.

test/unit/queue-5.test.ts's "PR-panel generate-tests checkbox (#4589)" block
(seedCheckboxPr) hardcodes state: "open" in every case — no test exercises a closed/merged PR
for either handler.

Requirements

  • Both maybeProcessPrPanelGenerateTests and maybeProcessGenerateTestsCommand must add a
    pr.state !== "open" guard that skips (records a skip outcome and returns, same shape as
    maybeProcessPrPanelRetrigger's "pr_not_open" skip) before doing any authorization, AI
    generation, or commit work.
  • Place the guard in the same relative position maybeProcessPrPanelRetrigger uses it (after the
    cached-PR-missing check, before authorization) for both functions.
  • Use each function's own existing skip-recording helper (mirror recordGenerateTestsSkip's
    existing call shape for the "cached_pr_missing"/other skip reasons already in that function) with
    a "pr_not_open" reason string, matching maybeProcessPrPanelRetrigger's convention.
  • Do not modify maybeProcessPrPanelRetrigger itself — it is already correct and is the precedent.

Deliverables

  • maybeProcessPrPanelGenerateTests in src/queue/processors.ts gains the
    pr.state !== "open" guard with a "pr_not_open" skip outcome, mirroring
    maybeProcessPrPanelRetrigger's orb(review): panel re-run checkbox on a closed/merged PR does real work, then silently no-ops #9020 fix exactly.
  • maybeProcessGenerateTestsCommand in src/queue/processors.ts gains the identical guard.
  • test/unit/queue-5.test.ts's generate-tests checkbox suite gains a case with a closed/merged
    PR asserting the handler skips with "pr_not_open" and never calls the AI generation path.
  • The equivalent text-command test suite for maybeProcessGenerateTestsCommand gains the same
    closed/merged-PR skip assertion.

All four deliverables 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/**. Both new guards and their two new test cases above must be covered.

Expected Outcome

Checking the generate-tests checkbox, or invoking @loopover generate-tests, on a closed or
merged PR no longer spends a real AI generation call or risks committing a test onto an
already-merged branch — it skips immediately with a "pr_not_open" outcome, matching the fix
already applied to the sibling retrigger checkbox in #9020.

Links & Resources

  • src/queue/processors.ts (maybeProcessPrPanelRetrigger ~line 14016 — precedent; the two
    functions to fix: maybeProcessPrPanelGenerateTests ~14175, maybeProcessGenerateTestsCommand
    ~13466)
  • src/github/e2e-test-commit.ts:43 (commitE2eTestToPrBranch — confirms it doesn't check PR
    state itself, only head SHA/ref)
  • orb(review): panel re-run checkbox on a closed/merged PR does real work, then silently no-ops #9020 (identical bug class, previously fixed on the sibling retrigger checkbox)
  • test/unit/queue-5.test.ts (existing test file to extend)

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