Skip to content

feat(review): interactive generate-tests checkbox in ORB's PR comment, maintainer-only - #4600

Merged
JSONbored merged 1 commit into
mainfrom
feat/e2e-testgen-panel-checkbox
Jul 10, 2026
Merged

feat(review): interactive generate-tests checkbox in ORB's PR comment, maintainer-only#4600
JSONbored merged 1 commit into
mainfrom
feat/e2e-testgen-panel-checkbox

Conversation

@JSONbored

Copy link
Copy Markdown
Owner

Summary

Follow-up to #4583 (text-only inline CTA), upgrading it to a real, clickable checkbox per direct
maintainer request — mirroring both CodeRabbit's own "Generate unit tests" walkthrough checkbox and
gittensory's own pre-existing "Re-run Gittensory review" checkbox.

The security question this had to answer first: a GitHub markdown task-list checkbox can be
toggled by anyone who can comment on the PR — that's GitHub's own permission model, not
gittensory's. So the checkbox itself proves nothing about who clicked it; a raw checkbox would
actually be less safe than the existing text command, not more, since a contributor (or a miner, on
their own PR) could just check it themselves. The fix mirrors the pre-existing "Re-run Gittensory
review" checkbox's own already-proven pattern exactly:

  • PR_PANEL_GENERATE_TESTS_MARKER (a sibling of PR_PANEL_RETRIGGER_MARKER) identifies the checkbox
    in the bot's own comment body.
  • maybeProcessPrPanelGenerateTests (a sibling of maybeProcessPrPanelRetrigger) listens for
    issue_comment.edited, confirms the marker is checked in the bot's own comment (not a spoofed
    comment from someone else), resolves payload.sender — who actually clicked, not who authored the
    comment — and re-authorizes through the exact same authorizePrActionActor pipeline every other
    @gittensory action command uses.
  • Hardcoded to commandAuthorization: PR_PANEL_GENERATE_TESTS_COMMAND_AUTHORIZATION
    (["maintainer"] only) regardless of what a repo's own .gittensory.yml might configure for the
    text-command version of generate-tests (which can be widened to collaborator/confirmed_miner) — a
    one-click checkbox gets a hard floor that can't be misconfigured wider.
  • An unauthorized click is a silent no-op — no comment fetch, no patch, no revert, no explanation
    — audit-logged only (github_app.e2e_tests_generation_denied), exactly matching the retrigger
    checkbox's own denial behavior (verified via its own test: zero GitHub writes beyond the permission
    check).
  • Authorized clicks dispatch through the same shared runE2eTestGenerationAndDeliver core the
    @gittensory generate-tests command (feat(commands): wire @gittensory generate-tests PR-comment command #4195) and the manifest_missing_tests auto-trigger (feat(review): auto-trigger E2E test generation on the manifest_missing_tests signal #4196)
    already use, with a new trigger: "checkbox" value — behaves like "command" for delivery-mode
    purposes (NOT forced comment-only, since a checkbox click carries a real re-verified maintainer
    invoker), kept as its own literal purely so audit metadata can distinguish "typed the command" from
    "clicked the checkbox."

Where the checkbox lives: a new "Test coverage" collapsible (buildPublicSafeCollapsibles in
src/signals/engine.ts), appended right after "Signal definitions," carrying the missing-coverage
detail and a pointer to the checkbox — reusing the already-computed manifest_missing_tests finding
rather than a second detection pass, and only rendering (non-empty) when there's an actual gap and
e2eTests is enabled for the repo, matching #4583's own "never mention a command that would bounce"
principle. The checkbox itself renders as a top-level line outside the alert blockquote, alongside
the re-run checkbox — GitHub disables interactive task-list checkboxes inside a blockquote (the same
constraint the pre-existing re-run checkbox's own code comment documents), so it can't live inside the
collapsible with the context text; the collapsible points at it instead.

A real bug caught while writing the end-to-end test: unified-comment-bridge.ts's
buildUnifiedCommentBody explicitly allowlists which fields get forwarded into the renderer's
context (reRunLabel was already there) — my new generateTestsLabel field was silently dropped
until I added it there too. Every pure-function unit test I wrote first (testing
renderUnifiedReviewComment/buildPublicSafeCollapsibles directly) passed despite this, because none
of them went through the bridge layer — only the full webhook-integration test caught it. Now pinned
with a dedicated bridge-layer regression test.

Fixes #4589

Test plan

  • New describe("PR-panel generate-tests checkbox (#4589)", ...) in test/unit/queue.test.ts (14
    tests): authorized happy path, unauthorized silent no-op (zero comment writes), bot-sender
    guard, non-bot-comment guard, feature-disabled skip, wrong/unchecked-marker no-op, malformed/
    sparse-payload skip, cached-PR-missing skip, agentPaused/agentDryRun skips, commit-delivery-mode
    respected via the checkbox (unlike the auto-trigger), a [bot]-suffixed non-Bot-typed sender
    (spoofing guard), and a full end-to-end render proving the checkbox + collapsible actually appear
    in a real webhook-triggered comment (the test that caught the bridge-layer bug above)
  • test/unit/unified-comment-parity.test.ts: 3 new cases for testCoverageBody's gating (gap +
    available → CTA; gap without availability → empty; availability without a gap → empty), plus the
    pre-existing collapsible-title-array assertion updated for the new 4th entry
  • test/unit/unified-comment.test.ts: 3 new cases for the dual-checkbox composition (both present,
    generate-tests alone, generate-tests omitted) plus the outside-the-blockquote placement check
  • test/unit/unified-comment-bridge.test.ts: new case pinning the field-forwarding fix
  • Verified via lcov branch data across all 4 changed source files (processors.ts, engine.ts,
    unified-comment.ts, unified-comment-bridge.ts): zero uncovered lines or branches in this
    diff
  • npx tsc --noEmit clean on this diff (the one remaining error is a pre-existing, unrelated
    failure in test/unit/miner-attempt-log.test.ts, confirmed via git diff origin/main showing
    zero changes to that file — another in-flight fix, not part of this PR)
  • Full relevant test suite run clean: 951/951 across queue.test.ts +
    unified-comment{,-bridge,-parity}.test.ts + public-safe-manifest-finding.test.ts
  • Rebased onto latest origin/main at push time; git diff --check clean

…, maintainer-only (#4589)

Adds a real, clickable "Generate an AI Playwright test for this PR" checkbox
alongside the existing "Re-run Gittensory review" one -- same
issue_comment.edited detection shell, same payload.sender re-authorization
(a GitHub task-list checkbox can be toggled by anyone who can comment, so
the checkbox itself proves nothing), hardcoded to maintainer-only regardless
of what a repo's own .gittensory.yml configures for the text-command
version. Unauthorized clicks are a silent no-op, mirroring the pre-existing
retrigger checkbox's own denial behavior exactly.

Also adds a "Test coverage" collapsible (after Signal definitions) with the
missing-coverage detail and a pointer to the checkbox -- the checkbox
itself has to render outside the alert blockquote (GitHub disables
interactive checkboxes inside one), so the collapsible carries the context
and the checkbox carries the action.

Fixes #4589
@superagent-security

Copy link
Copy Markdown
Contributor

Superagent didn't find any vulnerabilities or security issues in this PR.

@codecov

codecov Bot commented Jul 10, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 94.13%. Comparing base (63d5a0f) to head (95b3830).
⚠️ Report is 8 commits behind head on main.
✅ All tests successful. No failed tests found.

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #4600   +/-   ##
=======================================
  Coverage   94.12%   94.13%           
=======================================
  Files         430      430           
  Lines       38181    38239   +58     
  Branches    13922    13947   +25     
=======================================
+ Hits        35939    35997   +58     
  Misses       1585     1585           
  Partials      657      657           
Files with missing lines Coverage Δ
src/queue/processors.ts 95.38% <100.00%> (+0.06%) ⬆️
src/review/unified-comment-bridge.ts 99.57% <100.00%> (+<0.01%) ⬆️
src/review/unified-comment.ts 99.57% <100.00%> (+<0.01%) ⬆️
src/signals/engine.ts 97.46% <100.00%> (+<0.01%) ⬆️
🚀 New features to boost your workflow:
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@loopover-orb loopover-orb Bot added the gittensor:bug Gittensor-scored bug fix — scores a 0.05x multiplier. label Jul 10, 2026
@loopover-orb

loopover-orb Bot commented Jul 10, 2026

Copy link
Copy Markdown
Contributor

Warning

🟨🟨🟨🟨🟨🟨🟨🟨🟨🟨🟨🟨

⏸️ Gittensory review result - manual review recommended

Review updated: 2026-07-10 07:33:45 UTC

8 files · 1 AI reviewer · no blockers · readiness 100/100 · CI green · clean

⏸️ Suggested Action - Manual Review

  • Touches a guarded path — held for manual review: This PR changes guardrail-protected path(s): src/queue/processors.ts (matched src/queue/**).

Review summary
Adds a maintainer-only 'Generate an AI Playwright test' checkbox to the PR panel, mirroring the existing retrigger checkbox's marker-detection, bot's-own-comment, and re-authorization pattern, then dispatches through the same runE2eTestGenerationAndDeliver core already used by the text command and auto-trigger. The authorization is hardcoded to maintainer-only via PR_PANEL_GENERATE_TESTS_COMMAND_AUTHORIZATION regardless of repo config, correctly reflecting that GitHub checkboxes are toggleable by any commenter and must not inherit a widened text-command policy. A defense-in-depth re-check of the e2eTests feature flag at click time (not just render time) guards against a TOCTOU gap, and the test suite (queue.test.ts) exercises maintainer-allow, non-maintainer-deny, bot-author skip, spoofed '[bot]'-suffix login, disabled-feature skip, paused/dry-run skip, commit-vs-comment delivery mode, and the full rendered-panel path.

Nits — 7 non-blocking
  • Non-null assertion `actor!` in maybeProcessPrPanelGenerateTests (processors.ts, near the runE2eTestGenerationAndDeliver call) relies on an invariant proven several lines above by the `authorization.authorized` check; a narrow local guard would be more self-evident than the `!` even though the current logic is correct.
  • The new `PR-panel generate-tests checkbox` describe block in test/unit/queue.test.ts adds ~500 lines to an already ~27k-line file — consider a dedicated test file for future checkbox-style features.
  • Deep nesting flagged at processors.ts:12708 (depth 5) inside maybeProcessPrPanelGenerateTests — the skip/authorize/mode-check chain could be flattened with early returns extracted into small helpers.
  • Comment-embedded issue numbers (feat(commands): wire @gittensory generate-tests PR-comment command #4195, feat(review): auto-trigger E2E test generation on the manifest_missing_tests signal #4196, feat(review): interactive generate-tests checkbox in ORB's PR comment, maintainer-only #4589, feat(review): resolver gate for e2eTests — src/review/e2e-test-gen.ts #4192) scattered through processors.ts read like magic numbers to static scanners; harmless here since they're just historical references in prose, not logic constants.
  • The three 'generic_secret_assignment' flags in queue.test.ts (~26713/26944/27034) are synthetic test private keys from generatePrivateKeyPem(), not real secrets — false positives, but a shared fixture helper would make that obvious to scanners at a glance.
  • PR author also opened the linked issue — Link an issue that was opened by a different contributor, or provide a rationale for why this self-authored issue represents genuine discovery work.
  • Touches a guarded path — held for manual review — A maintainer must review and merge this change.
Signal Result Evidence
Code review ✅ No blockers 1 reviewer
Linked issue ✅ Linked #4589
Related work ✅ No active overlap found No same-issue or scoped active PR overlap found.
Change scope ✅ 20/20 Low review scope from cached public metadata (1 linked issue).
Validation posture ✅ 25/25 PR body includes validation/test evidence.
Contributor workload ✅ 10/10 Author activity: 48 registered-repo PR(s), 40 merged, 334 issue(s).
Contributor context ✅ Confirmed Gittensor contributor JSONbored; Gittensor profile; 48 PR(s), 334 issue(s).
Gate result ⚠️ Not blocking Advisory; not blocking this PR.
Linked issue satisfaction

Addressed
The diff implements every deliverable the issue lists: a 'Test coverage' collapsible appended after 'Signal definitions' reusing the manifest_missing_tests finding, a dedicated PR_PANEL_GENERATE_TESTS_MARKER checkbox rendered only when e2eTests is enabled and a coverage gap exists (placed outside the alert blockquote per the stated technical constraint), a maybeProcessPrPanelGenerateTests handler

Review context
  • Author: JSONbored
  • Role context: owner (maintainer lane)
  • Public audience mode: oss maintainer
  • Lane context: Repository is configured for direct PR review.
  • Public profile languages: Python, TypeScript, JavaScript, Ruby, Go, Kotlin, MDX, Shell
  • Official Gittensor activity: 48 PR(s), 334 issue(s).
  • PR-specific overlap: none found.
Contributor next steps
  • Treat this as maintainer-lane context rather than normal contributor-lane activity.
Signal definitions
  • Related work = same linked issue, overlapping active PRs, or title/path similarity.
  • Change scope = cached public metadata such as size labels, draft state, and review-burden hints.
  • Validation posture = whether the PR provides enough public validation/test evidence for maintainer review.
  • Contributor workload = public contributor activity and cleanup pressure, not a repo-wide quality failure.
  • Contributor context = public GitHub/Gittensor identity context; non-Gittensor status is not a blocker.

🟩 Safe / merged · 🟦 Advisory · 🟨 Held for review · 🟥 Blocked / closed


💰 Earn for open-source contributions like this. Gittensor lets GitHub contributors earn for the work they already do — register to start earning →.

Checked by Gittensory, a quiet PR intelligence layer for OSS maintainers.

  • Re-run Gittensory review

@loopover-orb loopover-orb Bot added the manual-review Gittensor contributor context label Jul 10, 2026
@JSONbored
JSONbored merged commit 4d46357 into main Jul 10, 2026
11 checks passed
@JSONbored
JSONbored deleted the feat/e2e-testgen-panel-checkbox branch July 10, 2026 07:34
JSONbored added a commit that referenced this pull request Jul 10, 2026
…it-delivery test (#4627)

Main-red: PR #4600 added this test before #4359 (merged same day) started
verifying the live PR head/ref/sha inside commitE2eTestToPrBranch before ever
writing. #4600 merged on top of #4359 without picking up the stub every
sibling commit-delivery test already got in #4359's own diff, so this one
test 404s on the live-PR fetch and silently declines the commit -- zero
git-write calls, gitWrites stays empty. Adds the same GET /pulls/{n} stub
the passing sibling tests already use.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

gittensor:bug Gittensor-scored bug fix — scores a 0.05x multiplier. manual-review Gittensor contributor context

Development

Successfully merging this pull request may close these issues.

feat(review): interactive generate-tests checkbox in ORB's PR comment, maintainer-only

1 participant