Skip to content

feat(mcp): mirror selftune override audit to remote/stdio tools and cli (#7798) - #7883

Closed
andriypolanski wants to merge 2 commits into
JSONbored:mainfrom
andriypolanski:feat/selftune-override-audit-mcp-cli
Closed

feat(mcp): mirror selftune override audit to remote/stdio tools and cli (#7798)#7883
andriypolanski wants to merge 2 commits into
JSONbored:mainfrom
andriypolanski:feat/selftune-override-audit-mcp-cli

Conversation

@andriypolanski

Copy link
Copy Markdown
Contributor

Summary

  • GET /v1/repos/:owner/:repo/selftune/overrides/audit (listOverrideAudit) exposed the self-tune override audit trail over REST only — no remote MCP tool, no local stdio MCP tool, and no CLI verb, unlike its gate-precision sibling which has all three.
  • This adds the three missing mirror surfaces for loopover_get_selftune_override_audit, following loopover_get_gate_precision's exact shape. listOverrideAudit, the REST route, and its requireRepoMaintainer gate are unchanged.

Closes #7798

Change

  • Remote MCP tool (src/mcp/server.ts): registered loopover_get_selftune_override_audit (owner/repo + optional limit, output { repoFullName, audit }), added it to MCP_TOOL_CATEGORIES as "maintainer", and added the getSelftuneOverrideAudit method — same per-repo requireRepoAccess gate as getGatePrecision, calling the existing listOverrideAudit.
  • Local stdio MCP tool (packages/loopover-mcp/bin/loopover-mcp.ts): registered the same tool, calling GET ${repoBase}/selftune/overrides/audit via apiGet, with a matching STDIO_TOOL_DESCRIPTORS entry.
  • CLI verb: added maintain selftune-audit --repo owner/repo [--limit N], mirroring the precision subcommand's emit/--json structure, plus printMaintainHelp, CLI_COMMAND_SPEC (shell completions), the usage string, and the unknown-subcommand error.

Tests

  • New test/unit/mcp-selftune-override-audit.test.ts: remote tool — happy path (newest-first mapping), limit passthrough, empty trail, and forbidden-identity denial.
  • test/unit/mcp-cli-maintain.test.ts: maintain selftune-audit plain + --json, null-detail filtering, and --limit passthrough.
  • test/unit/mcp-cli-maintain-tools.test.ts: the stdio tool proxies to the audit endpoint, forwards limit, and surfaces an API failure as a tool error.
  • test/unit/support/mcp-cli-harness.ts: fixture handler for the audit endpoint.
  • Updated invariants the new tool shifted: stdio tool count 79 → 80 (mcp-tool-rename-aliases), the PowerShell completer's maintain list (mcp-cli-basics), and the output-schema roster (mcp-output-schemas).

Validation

  • git diff --check clean.
  • npm run typecheck, targeted vitest suites, and command-reference:check / cf-typegen:check pass.
  • npm run test:coverage — every changed line and branch in src/mcp/server.ts is 100% covered (the new method has no untested branches). packages/** / test/** are outside Codecov's src/** scope.
  • No artifact regeneration needed (no REST/OpenAPI/schema/binding/migration changes).

UI Evidence

N/A — backend MCP tool + CLI only; no apps/loopover-ui/** or other visible surface changed.

@superagent-security

Copy link
Copy Markdown
Contributor

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

@codecov

codecov Bot commented Jul 21, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 36.36364% with 14 lines in your changes missing coverage. Please review.
✅ Project coverage is 81.30%. Comparing base (283fb8f) to head (e83654f).
⚠️ Report is 6 commits behind head on main.

Files with missing lines Patch % Lines
packages/loopover-mcp/bin/loopover-mcp.ts 0.00% 14 Missing ⚠️
Additional details and impacted files
@@             Coverage Diff             @@
##             main    #7883       +/-   ##
===========================================
- Coverage   91.40%   81.30%   -10.10%     
===========================================
  Files         730       90      -640     
  Lines       74763    24364    -50399     
  Branches    22815     4689    -18126     
===========================================
- Hits        68335    19810    -48525     
+ Misses       5385     4354     -1031     
+ Partials     1043      200      -843     
Flag Coverage Δ
shard-1 15.17% <13.63%> (-43.40%) ⬇️
shard-2 12.82% <36.36%> (-39.02%) ⬇️
shard-3 24.41% <13.63%> (-25.81%) ⬇️

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

Files with missing lines Coverage Δ
src/mcp/server.ts 96.48% <100.00%> (+0.02%) ⬆️
packages/loopover-mcp/bin/loopover-mcp.ts 0.00% <0.00%> (ø)

... and 640 files with indirect coverage changes

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

loopover-orb Bot commented Jul 21, 2026

Copy link
Copy Markdown
Contributor

Caution

🛑 LoopOver review result - fixes required

Review updated: 2026-07-21 16:07:19 UTC

9 files · 1 AI reviewer · no blockers · CI failing · unknown

🛑 Suggested Action - Fix Blockers

Review summary
This PR mirrors the existing self-tune override audit endpoint into the remote MCP tool, stdio MCP tool, and CLI, closely following the established `loopover_get_gate_precision` pattern with the same `requireRepoAccess`/`requireRepoAccess` gating and shared `listOverrideAudit` call. The implementation is consistent and well-tested across all three surfaces (remote tool happy-path/limit/empty/forbidden tests, CLI plain+json+limit tests, stdio proxy tests), and the tool-count invariant test was correctly bumped from 79 to 80. The PR closes the linked issue #7798 and is narrowly scoped to the stated mirror work with no unrelated changes.

Nits — 5 non-blocking
  • packages/loopover-mcp/bin/loopover-mcp.ts:2620 and :3373 use `any` typed callback params (`async ({ owner, repo, limit }: any)` and in the CLI handler) instead of a typed interface, consistent with existing sibling tools but still worth tightening over time.
  • The codecov/patch check shows only 36.36% of the diff hit, which is surprising given the apparently thorough new test files — worth double-checking that the new server.ts/loopover-mcp.ts branches (e.g., the `limit ? ... : ''` ternaries) are actually exercised by the added tests rather than just the CLI wrapper paths.
  • packages/loopover-mcp.ts's `selftune-audit` CLI branch uses `Number(options.limit)` which yields `NaN` for missing/invalid input; `NaN > 0` is `false` so it safely falls through, but this is implicit rather than explicit and could use a comment or explicit undefined check for clarity.
  • Confirm the codecov/patch shortfall (36.36%) doesn't stem from an untested branch such as the empty vs. non-empty `query` string construction in both `loopover-mcp.ts:2617` and `server.ts`'s CLI equivalent.
  • Consider consolidating the near-identical `selftuneOverrideAuditShape` z.object literal duplicated between `server.ts` and `loopover-mcp.ts` if there's a shared types module, though this may already be the repo's established per-surface convention (as with `gatePrecisionShape`).

CI checks failing

  • validate
  • validate-tests-merge
  • codecov/patch — 36.36% of diff hit (target 99.00%)

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 #7798
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: 177 registered-repo PR(s), 115 merged, 22 issue(s).
Contributor context ✅ Confirmed Gittensor contributor andriypolanski; Gittensor profile; 177 PR(s), 22 issue(s).
Improvement ✅ Minor risk: clean · value: minor · LLM: moderate
Linked issue satisfaction

Addressed
The diff registers loopover_get_selftune_override_audit as a remote MCP tool (with maintainer category and requireRepoAccess gate calling listOverrideAudit), as a local stdio tool via apiGet, and adds a maintain selftune-audit CLI verb mirroring the precision subcommand's emit/--json structure, matching all three required surfaces without altering listOverrideAudit or the REST route's gate.

Review context
  • Author: andriypolanski
  • Role context: outside_contributor
  • Public audience mode: oss maintainer
  • Lane context: Repository is configured for direct PR review.
  • Public profile languages: Python, TypeScript, JavaScript, Rust, Cuda, Kotlin, MDX, Scala
  • Official Gittensor activity: 177 PR(s), 22 issue(s).
  • PR-specific overlap: none found.
Contributor next steps
  • Keep the PR focused and include validation evidence before maintainer review.
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.

🟩 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 commented Jul 21, 2026

Copy link
Copy Markdown
Contributor

LoopOver is closing this pull request on the maintainer's behalf (CI is failing (validate, validate-tests-merge, codecov/patch)). This is an automated maintenance action — to pursue this change, please open a new pull request with the issues resolved. Closed PRs may be analyzed later to improve review accuracy, but they are not automatically reopened or re-reviewed.

@loopover-orb loopover-orb Bot closed this Jul 21, 2026
@JSONbored JSONbored reopened this Jul 21, 2026
@JSONbored

Copy link
Copy Markdown
Owner

Merge conflicts from a PR before yours touching similar files - the previous merged PR fixes the CI issues re: vitest, but merge conflicts prevent merging of this PR.

Closing.

@JSONbored JSONbored closed this Jul 21, 2026
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.

Self-tune override audit trail (selftune/overrides/audit) has no remote MCP tool, local stdio MCP tool, or CLI verb

3 participants