Skip to content

feat(commands): add the maintainer-only @gittensory generate-tests command - #4211

Merged
JSONbored merged 2 commits into
mainfrom
feat/e2e-test-gen-render-dispatch
Jul 8, 2026
Merged

feat(commands): add the maintainer-only @gittensory generate-tests command#4211
JSONbored merged 2 commits into
mainfrom
feat/e2e-test-gen-render-dispatch

Conversation

@JSONbored

Copy link
Copy Markdown
Owner

Summary

  • Adds the @gittensory generate-tests command — the maintainer-only, on-demand trigger for AI-generated E2E test coverage (Epic: AI-generated E2E test coverage for pull requests #4189 epic): classify → authorize → resolve the e2eTests gate → generate via feat(review): LLM core to turn a PR diff into Playwright E2E test source #4191's LLM core → render → post as a dedicated reply comment.
  • Design pivot from the original feat(review): render + comment-assembly for generated E2E test blocks #4193/feat(review): dispatch wiring for e2eTests in queue/processors.ts #4194 scope, documented here for traceability: the original plan modeled this on fix-handoff (splice a block into the automated review's sticky unified comment via unified-comment-bridge.ts's collapsible chain). Implementation surfaced why that's the wrong model — fix-handoff derives its content for free from data the regular synchronous review pass already computed; E2E test generation needs a new, async, cost-bearing LLM call, which can only make sense as an explicit, on-demand action, not something spliced into every automated review pass. explain/configuration already establish the right precedent: post the on-demand result as its own reply comment, not an edit to the main sticky comment. This PR follows that precedent instead, closing feat(review): render + comment-assembly for generated E2E test blocks #4193 and feat(review): dispatch wiring for e2eTests in queue/processors.ts #4194 as part of the same, more coherent PR rather than shipping now-inapplicable "splice into unified comment" plumbing.
  • Authorization is deliberately the narrowest in the whole command catalog: ["maintainer"] alone — every other command (review, pause, resume, resolve, configuration, explain) allows at least ["maintainer", "collaborator"]. This closes the specific loophole a click-to-generate button must not open: a repo could grant a contributor/miner collaborator-level push access, and that tier must never be able to generate tests for their own scored PR.
  • The PR's own author is denied even if they hold no elevated role — verified explicitly in tests. The existing shared authorization framework (src/settings/command-authorization.ts's maintainer_command_requires_maintainer guard) already handles this generically for any command whose allowed roles are maintainer/collaborator-only; no bespoke pr_author check was needed.
  • Kept the engine package's own duplicated command-authorization.ts (a genuinely separate file packages/gittensory-engine/src/settings/command-authorization.ts imports, not a re-export shim) in sync — a dedicated regression test (test/unit/command-authorization-engine.test.ts, pre-existing) and focus-manifest.test.ts's parity assertion both caught the drift when I first forgot this, confirming the safety net works.
  • Regenerated apps/gittensory-ui/src/lib/command-reference.ts (the auto-generated command reference — now 8 action commands, was 7) and fixed the two hardcoded "7 action commands" counts in test/unit/gen-command-reference-script.test.ts that the regression run caught.

Closes #4193, #4194, #4195.

Scope

Validation

  • git diff --check
  • npm run actionlint
  • npm run typecheck
  • npm run test:coverage (unsharded, full repo) — 100% branch coverage on every new/changed line, confirmed via the raw coverage/lcov.info data for the new handler (maybeProcessGenerateTestsCommand/postGenerateTestsNotEnabledComment/recordGenerateTestsSkip in processors.ts), the new render file (e2e-test-gen-render.ts, 4/4 lines + 4/4 branches), and command-authorization.ts (77/77 lines, 85/85 branches). All 12,160 existing tests still pass (2 pre-existing PG-gated skips).
  • npm run test:workers
  • npm run build:mcp / npm run test:mcp-pack
  • npm run build:miner (part of test:ci) / npm run test:miner-pack
  • npm run rees:test
  • npm run ui:openapi:check / npm run ui:openapi:settings-parity
  • npm run ui:lint / npm run ui:typecheck / npm run ui:test / npm run ui:build
  • npm run ui:version-audit
  • npm run docs:drift-check / npm run manifest:drift-check / npm run command-reference:check
  • npm run db:migrations:check / npm run db:schema-drift:check / npm run selfhost:env-reference:check / npm run selfhost:validate-observability / npm run cf-typegen:check
  • npm audit --audit-level=moderate
  • New or changed behavior has unit/integration tests for new branches, fallback paths, and sanitizer boundaries — 10 integration tests in test/unit/queue.test.ts covering: authorized-maintainer success (free path), collaborator-tier denial, the PR-author-self-denial loophole check, feature-disabled note, malformed-output note, missing-cached-PR skip, non-command decline, bot-author classify-failure skip, BYOK success (with both the "no provider pin" and "provider pin matches" branches), and the no-provider-configured degrade path — plus 4 unit tests for the render function's own branches.

Safety

  • No secrets, wallet details, hotkeys, coldkeys, user PATs, private keys, raw trust scores, private rankings, or private maintainer evidence are exposed.
  • Public GitHub text stays sanitized, low-noise — the posted comment goes through sanitizePublicComment, wrapped in a try/catch (it throws rather than strips on a forbidden term) that degrades to a safe withheld-content note rather than crashing the handler or leaking raw generated text.
  • Auth, cookie, CORS, GitHub App, Cloudflare, or session changes include negative-path tests — the maintainer-only authorization tier is the core safety property of this PR; covered by the collaborator-denial and PR-author-denial tests above.
  • API/OpenAPI/MCP behavior is updated and tested where needed — N/A, no new API/OpenAPI/MCP surface (this is a GitHub PR-comment command, not an API route).
  • UI changes use live API data or real empty/error/loading states — the only UI-adjacent file is the auto-generated command-reference.ts.
  • Visible UI changes include a UI Evidence section — N/A, no hand-authored UI change (generated reference doc only).
  • Public docs/changelogs are updated where needed (the generated command reference); CHANGELOG.md itself is untouched.

Notes

…mmand

Adds the on-demand `@gittensory generate-tests` command: classify -> authorize
(maintainer-only, ["maintainer"] alone -- the first command in the catalog
narrower than every existing default) -> resolve the e2eTests feature gate ->
generate a Playwright test via the #4191 LLM core -> render and post it as a
dedicated reply comment, mirroring maybeProcessExplainCommand's shape.

Deliberately does NOT splice generated content into the automated review's
sticky unified comment: unlike fix-handoff (which derives its blocks for free
from data the regular review pass already computed), this is an explicit,
cost-bearing, maintainer-triggered action, so it gets its own on-demand reply
comment, the same precedent already set by explain/configuration.

The existing maintainer_command_requires_maintainer guard in the shared
authorization framework already denies a PR's own author when they don't
independently hold the maintainer role -- no bespoke pr_author check needed,
closing the exact loophole a click-to-generate button would otherwise open
for a contributor on their own PR.

Keeps the engine package's own duplicated command-authorization.ts copy in
sync (a genuinely separate file the standalone package imports, not a
re-export shim), which a config-templates-style regression test enforces.

Closes #4193, #4194, #4195.
@superagent-security

Copy link
Copy Markdown
Contributor

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

@cloudflare-workers-and-pages

Copy link
Copy Markdown

Deploying with  Cloudflare Workers  Cloudflare Workers

The latest updates on your project. Learn more about integrating Git with Workers.

Status Name Latest Commit Preview URL Updated (UTC)
✅ Deployment successful!
View logs
gittensory-ui ed5beac Commit Preview URL

Branch Preview URL
Jul 08 2026, 12:57 PM

@codecov

codecov Bot commented Jul 8, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 95.83333% with 2 lines in your changes missing coverage. Please review.
✅ Project coverage is 93.76%. Comparing base (24d058a) to head (9bd58d1).
✅ All tests successful. No failed tests found.

Files with missing lines Patch % Lines
src/queue/processors.ts 95.45% 2 Missing ⚠️

❌ Your patch check has failed because the patch coverage (95.83%) is below the target coverage (99.00%). You can increase the patch coverage or adjust the target coverage.

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #4211   +/-   ##
=======================================
  Coverage   93.75%   93.76%           
=======================================
  Files         389      390    +1     
  Lines       36499    36547   +48     
  Branches    13376    13389   +13     
=======================================
+ Hits        34221    34267   +46     
- Misses       1621     1623    +2     
  Partials      657      657           
Files with missing lines Coverage Δ
...nsory-engine/src/settings/command-authorization.ts 100.00% <ø> (ø)
src/github/commands.ts 98.16% <ø> (ø)
src/review/e2e-test-gen-render.ts 100.00% <100.00%> (ø)
src/settings/command-authorization.ts 100.00% <ø> (ø)
src/queue/processors.ts 95.32% <95.45%> (+<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 8, 2026
@loopover-orb

loopover-orb Bot commented Jul 8, 2026

Copy link
Copy Markdown
Contributor

Caution

🟥🟥🟥🟥🟥🟥🟥🟥🟥🟥🟥🟥

🛑 Gittensory review result - fixes required

Review updated: 2026-07-08 13:32:42 UTC

9 files · 1 blocker · readiness 100/100 · CI failing · unstable

🛑 Suggested Action - Manual Review

  • Possible leaked secret in the diff (generic_secret_assignment) — Remove the secret from the diff, rotate the exposed credential, then re-run the gate.
Nits — 1 non-blocking
  • 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.

Why this is blocked

  • Possible leaked secret in the diff (generic_secret_assignment) — Remove the secret from the diff, rotate the exposed credential, then re-run the gate.

CI checks failing

  • codecov/patch — 95.83% of diff hit (target 99.00%)
Signal Result Evidence
Code review ❌ 1 blocker No AI review summary
Linked issue ✅ Linked #4193, #4194, #4195
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 (3 linked issues).
Validation posture ✅ 25/25 PR body includes validation/test evidence.
Contributor workload ✅ 10/10 Author activity: 52 registered-repo PR(s), 43 merged, 532 issue(s).
Contributor context ✅ Confirmed Gittensor contributor JSONbored; Gittensor profile; 52 PR(s), 532 issue(s).
Gate result ❌ Blocking Repo-configured hard blocker found.
Linked issue satisfaction

Not yet addressed
The issue explicitly asks for a new e2e-test-gen-render.ts that splices a collapsible block into unified-comment-bridge.ts's existing chain (args interface, buildE2eTestGenCollapsible, and the chain splice re-basing withX links), but the PR deliberately abandons that splice model in favor of a standalone reply-comment flow and never touches unified-comment-bridge.ts at all.

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: 52 PR(s), 532 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.
Visual preview
Route Viewport Before (production) After (this PR's preview) Diff
/ desktop after /
/ mobile after / (mobile)

Click any thumbnail to open the full-size screenshot. Before = production · After = this PR's preview deploy.

🟩 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 8, 2026
…erate-tests

CI's codecov/patch flagged 2 missing lines in the previous commit that a local
unsharded coverage run (on a newer local Node than CI's pinned .nvmrc version)
didn't surface. Adds the two branches most likely responsible: the
manifest?.review optional-chain when no manifest is published at all (falls
back to the GITTENSORY_REVIEW_REPOS allowlist default, same precedent as
resolveConvergedFeature's own allowlist test), and payload.comment?.body when
the webhook payload carries no comment object.
@JSONbored
JSONbored merged commit e3b83c8 into main Jul 8, 2026
10 of 11 checks passed
@JSONbored
JSONbored deleted the feat/e2e-test-gen-render-dispatch branch July 8, 2026 13:51
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

Projects

None yet

1 participant