Skip to content

feat(api): REST + CLI mirror for loopover_explain_review_risk (#6980) - #7026

Merged
loopover-orb[bot] merged 1 commit into
JSONbored:mainfrom
RealDiligent:feat/explain-review-risk-rest-cli-6980
Jul 17, 2026
Merged

feat(api): REST + CLI mirror for loopover_explain_review_risk (#6980)#7026
loopover-orb[bot] merged 1 commit into
JSONbored:mainfrom
RealDiligent:feat/explain-review-risk-rest-cli-6980

Conversation

@RealDiligent

Copy link
Copy Markdown
Contributor

Summary

  • Add POST /v1/preflight/review-risk with shared buildReviewRiskExplanation (MCP parity; optional contributorLogin gated by requireContributorAccess).
  • Add stdio tool loopover_explain_review_risk + shell CLI explain-review-risk (stdio tool count 78 → 79).
  • Cover route/auth/parity, CLI mirrors, and OpenAPI.

Closes #6980

Test plan

  • Local vitest: routes-review-risk, mcp-cli-review-risk
  • CI validate-code + Codecov patch ≥99%

@RealDiligent
RealDiligent requested a review from JSONbored as a code owner July 17, 2026 18:31
@superagent-security

Copy link
Copy Markdown
Contributor

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

…red#6980)

Expose review-risk explanations via POST /v1/preflight/review-risk and stdio/shell CLI so the tool is not MCP-only.

Co-authored-by: Cursor <cursoragent@cursor.com>
@codecov

codecov Bot commented Jul 17, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 93.73%. Comparing base (447ee82) to head (8f6d9a5).
⚠️ Report is 4 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #7026   +/-   ##
=======================================
  Coverage   93.73%   93.73%           
=======================================
  Files         690      691    +1     
  Lines       68580    68595   +15     
  Branches    18746    18750    +4     
=======================================
+ Hits        64281    64296   +15     
  Misses       3302     3302           
  Partials      997      997           
Flag Coverage Δ
shard-1 43.67% <80.95%> (+0.04%) ⬆️
shard-2 36.89% <9.52%> (-0.01%) ⬇️
shard-3 33.15% <19.04%> (+0.07%) ⬆️
shard-4 34.23% <19.04%> (-0.13%) ⬇️
shard-5 32.01% <28.57%> (-0.01%) ⬇️
shard-6 45.80% <61.90%> (+<0.01%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

Files with missing lines Coverage Δ
src/api/routes.ts 94.91% <100.00%> (+0.01%) ⬆️
src/mcp/server.ts 96.25% <100.00%> (-0.02%) ⬇️
src/openapi/schemas.ts 100.00% <100.00%> (ø)
src/openapi/spec.ts 99.47% <100.00%> (+<0.01%) ⬆️
src/signals/review-risk.ts 100.00% <100.00%> (ø)

@loopover-orb loopover-orb Bot added the gittensor:feature Gittensor-scored feature linked to a feature issue — scores a 0.25x multiplier. label Jul 17, 2026
@loopover-orb

loopover-orb Bot commented Jul 17, 2026

Copy link
Copy Markdown
Contributor

Tip

✅ LoopOver review result - approve/merge recommended

Review updated: 2026-07-17 18:44:54 UTC

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

✅ Suggested Action - Approve/Merge

  • safe to merge

Review summary
This PR extracts the existing MCP tool's inline logic in src/mcp/server.ts into a shared buildReviewRiskExplanation function in a new src/signals/review-risk.ts, wires it to a new POST /v1/preflight/review-risk route with the same auth pattern (requireContributorAccess) as the existing /v1/preflight/pr route, adds the OpenAPI schema/path, and adds a CLI/stdio mirror. The refactor of the MCP handler is a faithful extraction (same computation, same recommendation logic, same summary string), and the REST route reuses the identical preflightSchema and contributor-access gate already proven at /v1/preflight/pr. Tests directly assert REST/MCP parity and CLI/stdio parity against the same fixture, which is the right shape for this kind of mirror PR.

Nits — 5 non-blocking
  • The recommendation ternary chain in src/signals/review-risk.ts is copy-pasted from the prior inline version in src/mcp/server.ts; fine as an extraction but worth a short comment explaining the precedence order (duplicate > maintainer lane > needs_author > ready > watch) since it's non-obvious business logic.
  • explainReviewRiskCli in packages/loopover-mcp/bin/loopover-mcp.js has fairly high branching (many optional-field coercions); consider extracting the array-normalization boilerplate (labels/changedFiles/tests) into a small shared helper if this pattern repeats in future CLI mirrors.
  • Magic HTTP status literals (200/400/403) in src/openapi/spec.ts and src/api/routes.ts mirror the existing convention elsewhere in the file, so not worth changing here.
  • Consider a lint or test assertion that the /v1/preflight/review-risk route and the MCP tool call the same buildReviewRiskExplanation instance to prevent future drift, beyond the current fixture-based parity test.
  • docs/README could mention the new `explain-review-risk` CLI command alongside the other preflight-family commands for discoverability.

Decision drivers

  • ✅ Code review — No blockers (1 reviewer)
  • ✅ Gate result — Passing (No configured blocker found.)
Context & advisory signals — never blocks the verdict
Signal Result Evidence
Linked issue ✅ Linked #6980
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: 402 registered-repo PR(s), 201 merged, 34 issue(s).
Contributor context ✅ Confirmed Gittensor contributor RealDiligent; Gittensor profile; 402 PR(s), 34 issue(s).
Improvement ✅ Minor risk: clean · value: minor · LLM: moderate
Linked issue satisfaction

Addressed
The PR adds POST /v1/preflight/review-risk mirroring /v1/preflight/pr's validation pattern with a richer payload (preflight, roleContext, recommendation, summary), a CLI/stdio mirror (explain-review-risk / loopover_explain_review_risk) with optional contributorLogin, and refactors the MCP tool to share the same buildReviewRiskExplanation logic, plus parity tests and OpenAPI documentation.

Review context
  • Author: RealDiligent
  • Role context: outside_contributor
  • Public audience mode: oss maintainer
  • Lane context: Repository is configured for direct PR review.
  • Public profile languages: not available
  • Official Gittensor activity: 402 PR(s), 34 issue(s).
  • PR-specific overlap: none found.
Contributor next steps
  • Start here: Triage stale or unlinked PRs.
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.
🧪 Chat with LoopOver

Ask LoopOver a question about this PR directly in a comment — grounded only in the same cached, public-safe facts shown above, never a new claim.

  • @loopover ask &lt;question&gt; answers contribution-quality Q&A with source citations and freshness.
  • @loopover chat &lt;question&gt; answers in natural prose from cached decision-pack facts via local inference (maintainer/collaborator; read-only).
  • A plain-language @loopover mention with a real question is routed to the closest matching read-only command automatically — no exact syntax required.

Full command reference: https://loopover.ai/docs/loopover-commands

🧪 Experimental — new and may change.

Visual preview
Route Viewport Before (production) After (this PR's preview) Diff
/ desktop before /
before /
after /
after /
/ mobile before / (mobile)
before / (mobile)
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 LoopOver, a quiet PR intelligence layer for OSS maintainers.

  • Re-run LoopOver review

@loopover-orb loopover-orb Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LoopOver approves — the gate is satisfied and CI is green.

@loopover-orb
loopover-orb Bot merged commit 15715dc into JSONbored:main Jul 17, 2026
16 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

REST + CLI mirror for loopover_explain_review_risk

1 participant