Skip to content

feat(contract): migrate every remote MCP tool contract to @loopover/contract (#9518) - #9559

Merged
loopover-orb[bot] merged 2 commits into
mainfrom
feat/remote-mcp-contract-9518
Jul 28, 2026
Merged

feat(contract): migrate every remote MCP tool contract to @loopover/contract (#9518)#9559
loopover-orb[bot] merged 2 commits into
mainfrom
feat/remote-mcp-contract-9518

Conversation

@JSONbored

Copy link
Copy Markdown
Owner

Closes #9518.

What changed

Every tool the remote MCP server registers now takes its input and output schema from @loopover/contract instead of a declaration local to src/mcp/server.ts. All seven categories are done — admin, maintainer, review, branch, discovery, utility, agent — which makes the remote server the second of the three to be migrated to completion, after the AMS miner (#9542). ~120 shape/output-schema declarations and their supporting sub-schemas are deleted from the server; what remains there is the handler logic and the auth checks.

New contract families: maintainer.ts (27 tools), review.ts (12), branch.ts (13), discovery-utility.ts (22), agent.ts (29), plus the admin additions.

What deliberately did not move

A shared contract describes the wire shape a caller may send; the emitted JSON Schema cannot round-trip a runtime coercion. So these inputs stay server-side and only their outputs migrate:

  • Anything embedding callerBranchEligibilitySchema — a .transform() that downgrades a caller-claimed eligible to unknown. Relocating it would have advertised the post-transform shape and silently dropped the downgrade, letting a caller assert its own eligibility into its own score. That is explain_score_breakdown, get_eligibility_plan, and eleven branch tools.
  • watch_issues, whose input carries .default("list").
  • simulate_open_pr_pressure, whose input is exported and reused verbatim by POST /v1/lint/open-pr-pressure (REST + CLI mirror for loopover_simulate_open_pr_pressure #6751) and is built from .passthrough() sub-schemas.
  • find_opportunities, retrieve_issue_context and mark_notifications_read, bounded by constants owned by modules a zod-only leaf package cannot import.

Tool descriptions are relocated verbatim — a description is part of the surface an agent selects on, so rewording one would be a behaviour change wearing a refactor's clothes.

Two bugs fixed on the way

The no-upload boundary had been quietly disabled. The changed-file and validation-entry schemas behind loopover_run_local_scorer / loopover_preflight_local_diff, and both nested schemas behind loopover_suggest_boundary_tests, lost their .strict() in an earlier batch of this same migration. That strictness is the boundary: with it, a caller that smuggles a patch/content field gets a rejected call; without it, zod v4 strips the field and returns success, so an agent uploading source text is told it worked. Restored on all four, with regression tests on both surfaces. test/unit/mcp-suggest-boundary-tests.test.ts's existing case is what caught it.

PLAN_STEP_STATUSES named a state that does not exist. It said in_progress where both real surfaces — the remote plan DAG and the miner's plan store — say running. Nothing consumed it yet, so nothing broke, but the first consumer would have rejected every running step the store has ever persisted. Corrected, aliased from the miner contract so there is exactly one vocabulary, and pinned by a test that also asserts the plan-level statuses are a subset.

Validation

  • npx vitest run test/unit test/contract — 23361 passed, 6 skipped, 0 failed.
  • npx tsc --noEmit clean across the workspace.
  • ui:openapi:check, docs:drift-check, manifest:drift-check, engine-parity:drift-check, build:mcp all green. openapi.json regenerates byte-identical, which is the intended result: this is a relocation, not a surface change.
  • New pins in test/unit/contract-registry.test.ts for SCENARIO_LIMITS (against the server's live values) and the plan-step vocabulary.
  • The REST↔MCP parity guards in test/unit/openapi.test.ts now read the contract instead of server-local exports that no longer exist; their assertions are unchanged.

…ontract

Completes #9518. All seven remote-server categories -- admin, maintainer,
review, branch, discovery, utility and agent -- now take their input and output
schemas from the contract package instead of ~120 declarations local to
src/mcp/server.ts. The remote server is the second of the three to be migrated
to completion, after the AMS miner (#9542).

A handful of inputs deliberately stay server-side, each for a stated reason:
schemas carrying a .transform() or .default() (a caller must not be able to
assert its own branch eligibility into its own score), one input shared verbatim
with a REST route, and three bounded by constants a zod-only leaf package cannot
import. Their outputs migrate either way.

Two fixes fall out of the move:

- The changed-file and validation-entry schemas behind loopover_run_local_scorer
  and loopover_preflight_local_diff, and both nested schemas behind
  loopover_suggest_boundary_tests, lost their .strict() in an earlier batch of
  this migration. That strictness is the no-upload boundary: without it a caller
  that smuggles a patch/content field gets a silently-stripped call instead of a
  rejected one, and believes the upload succeeded. Restored, with regression
  tests on both surfaces.

- PLAN_STEP_STATUSES said 'in_progress' where both real surfaces -- the remote
  plan DAG and the miner's plan store -- say 'running'. Nothing consumed it yet,
  so nothing broke, but the first consumer would have rejected every running step
  the store has ever persisted. Corrected, aliased from the miner contract so
  there is one vocabulary, and pinned by a test.

The REST<->MCP parity guards now read the contract rather than server-local
declarations that no longer exist. Tool descriptions are relocated verbatim.
@JSONbored JSONbored self-assigned this Jul 28, 2026
@loopover-orb

loopover-orb Bot commented Jul 28, 2026

Copy link
Copy Markdown
Contributor

Tip

✅ LoopOver review result - approve/merge recommended

Review updated: 2026-07-28 09:26:21 UTC

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

✅ Suggested Action - Approve/Merge

  • safe to merge

Review summary
This PR relocates ~110 remote MCP tool contracts (maintainer, review, branch, discovery, utility, agent, admin categories) from src/mcp/server.ts into the shared @​loopover/contract package, following the pattern established by #9517's pilot batch. The description carefully documents which inputs deliberately stay server-side (transforms, defaults, passthrough schemas, and constants owned by modules the leaf package can't import) with concrete reasoning tied to specific tools, and the code shows the same discipline (verbatim descriptions, unknown() fields left alone rather than tightened). CI is green across build/typecheck/tests/coverage on this large mechanical migration, and the tool registry (test/unit/contract-registry.test.ts) presumably pins the full 1:1 mapping.

Nits — 6 non-blocking
  • The size smells flagged (agent.ts at 741 lines, maintainer.ts at 714, discovery-utility.ts at 504) are inherent to a schema-relocation PR and not a real maintainability concern given the one-file-per-category convention documented in the README.
  • The low test-to-code ratio (0.03) is expected for a schema-relocation PR since most value comes from the meta-test asserting parity with the original server declarations rather than new per-field tests — worth confirming test/unit/contract-registry.test.ts (not shown) actually asserts field-for-field equality against src/mcp/server.ts's original shapes rather than just checking tool names are registered.
  • Several magic numbers (400, 60_000, 255, etc. in limits.ts and the tool files) lack named constants, though the PR's comments do explain the reasoning behind most of the specific bounds (e.g. WRITE_TOOL_LIMITS.bodyChars matching GitHub's comment ceiling).
  • Confirm test/unit/contract-registry.test.ts asserts each migrated output schema is structurally equal to (or a safe superset of) the original src/mcp/server.ts declaration it replaces, not just that the tool count/names match.
  • Since src/mcp/server.ts's diff wasn't shown in full, verify the wiring at each call site actually imports these new contracts rather than leaving a duplicate local declaration behind (dead code).
  • 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.

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 #9518
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: 14 registered-repo PR(s), 13 merged, 317 issue(s).
Contributor context ✅ Confirmed Gittensor contributor JSONbored; Gittensor profile; 14 PR(s), 317 issue(s).
Improvement ✅ Minor risk: clean · value: minor · LLM: moderate
Linked issue satisfaction

Partially addressed
The PR adds real, non-placeholder output schemas and typed contract-derived registrations for the remote server's admin/maintainer/review/branch/discovery/utility/agent categories (~120 tools), directly fulfilling requirement 1 and much of requirement 2, and documents deliberate exceptions (transform-bearing inputs, shared-constant inputs) with rationale rather than silently skipping them. However

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, Ruby, Go, MDX, Shell, Solidity, JavaScript
  • Official Gittensor activity: 14 PR(s), 317 issue(s).
  • PR-specific overlap: none found.
Contributor next steps
  • Start here: 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.
🧪 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

@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
loopover-ui dde50d1 Commit Preview URL

Branch Preview URL
Jul 28 2026, 09:07 AM

@superagent-security

Copy link
Copy Markdown
Contributor

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

@codecov

codecov Bot commented Jul 28, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 89.62%. Comparing base (9713f26) to head (dde50d1).
⚠️ Report is 3 commits behind head on main.
✅ All tests successful. No failed tests found.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #9559      +/-   ##
==========================================
+ Coverage   89.60%   89.62%   +0.01%     
==========================================
  Files         861      866       +5     
  Lines      110629   110784     +155     
  Branches    26334    26334              
==========================================
+ Hits        99133    99288     +155     
  Misses      10231    10231              
  Partials     1265     1265              
Flag Coverage Δ
backend 95.32% <100.00%> (+0.01%) ⬆️
engine 65.80% <100.00%> (ø)

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

Files with missing lines Coverage Δ
packages/loopover-contract/src/enums.ts 100.00% <100.00%> (ø)
packages/loopover-contract/src/limits.ts 100.00% <100.00%> (ø)
...ckages/loopover-contract/src/tools/admin-config.ts 100.00% <100.00%> (ø)
packages/loopover-contract/src/tools/agent.ts 100.00% <100.00%> (ø)
packages/loopover-contract/src/tools/branch.ts 100.00% <100.00%> (ø)
...s/loopover-contract/src/tools/discovery-utility.ts 100.00% <100.00%> (ø)
packages/loopover-contract/src/tools/index.ts 100.00% <ø> (ø)
packages/loopover-contract/src/tools/maintainer.ts 100.00% <100.00%> (ø)
packages/loopover-contract/src/tools/miner.ts 100.00% <100.00%> (ø)
packages/loopover-contract/src/tools/review.ts 100.00% <100.00%> (ø)
... and 6 more

@codecov

codecov Bot commented Jul 28, 2026

Copy link
Copy Markdown

Bundle Report

Bundle size has no change ✅

@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 968c731 into main Jul 28, 2026
9 checks passed
@loopover-orb
loopover-orb Bot deleted the feat/remote-mcp-contract-9518 branch July 28, 2026 09:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

contract(remote): migrate the remote MCP server's tools to @loopover/contract — typed handlers, real output schemas

1 participant