Skip to content

build(typescript): Phase 3 completion — convert graphql.mjs + mcp-server.mjs to .ts - #7857

Merged
JSONbored merged 2 commits into
mainfrom
ts-migration-phase3-completion
Jul 24, 2026
Merged

build(typescript): Phase 3 completion — convert graphql.mjs + mcp-server.mjs to .ts#7857
JSONbored merged 2 commits into
mainfrom
ts-migration-phase3-completion

Conversation

@JSONbored

Copy link
Copy Markdown
Owner

Summary

Part of the TS migration epic (#7510). Completes Phase 3 (#7516, src/): converts the last two hand-written .mjs runtime files in the repo's src/ tree — the GraphQL layer and the MCP server — plus their test suites:

  • src/graphql.mjs (10409 lines) + tests/graphql.test.mjs (19999 lines)
  • src/mcp-server.mjs (16877 lines) + tests/mcp-server.test.mjs (20663 lines)

and updates the .mjs import specifier in all ~170 referencing files (the mcp-server importer count is dominated by the per-subnet *-call-subnet-surface-verify test family).

Together with #7856 (data-api, Phase 2 completion), this makes the entire backend/tooling stack TypeScript — zero hand-written .mjs/.js runtime files remain. Phase 7 (#7521: tsconfig lockdown, permanent no-mjs CI gate, doc updates) unblocks once both merge.

Typing approach

Mirrors the earlier conversions: local Row/AnyFn aliases, a per-file context interface (GqlContext for the graphql execute() contextValue; McpCtx for buildMcpContext's tool-handler context), resolver/tool-handler signatures annotated mechanically, and as unknown as bridges only where two already-shipped modules disagree about a shape (e.g. the MCP loaders' ctx interfaces requiring a readArtifact field that the GraphQL call sites supply through the loaders' own deps override instead — never dereferenced through ctx).

Behavior-verified cleanups (not blind casts)

  • Dropped three silently-ignored excess options at call sites rather than widening the callee signatures — checked against each implementation: loadEconomicsTrends/loadGlobalIncidents never read windowDays, buildSubnetOhlc never reads days, loadSubnetUptime never reads minSamples. The .mjs originals passed them as inert extra properties.
  • One real mistype fixed: DataApiMcpContext.clientIp claimed string but the graphql-ws path populates string | null — widened to match reality (only ever interpolated into a rate-limit key).

Test plan

  • npx tsc --noEmit clean (repo-wide)
  • npx eslint + prettier --check clean on all 175 touched files
  • npx vitest run on the converted suites: 2126/2126 passing (graphql + mcp-server + sentry/docs-drift)
  • CI green (full suite runs there per review policy)

@superagent-security

Copy link
Copy Markdown

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

@cloudflare-workers-and-pages

cloudflare-workers-and-pages Bot commented Jul 24, 2026

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 Updated (UTC)
❌ Deployment failed
View logs
metagraphed-data-api 843dfbb Jul 24 2026, 04:02 PM

@cloudflare-workers-and-pages

cloudflare-workers-and-pages Bot commented Jul 24, 2026

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 Updated (UTC)
✅ Deployment successful!
View logs
metagraphed-registry-sync-api 843dfbb Jul 24 2026, 04:02 PM

@codecov

codecov Bot commented Jul 24, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 97.57%. Comparing base (487ef64) to head (843dfbb).
⚠️ Report is 16 commits behind head on main.
✅ All tests successful. No failed tests found.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #7857      +/-   ##
==========================================
- Coverage   97.58%   97.57%   -0.02%     
==========================================
  Files         204      205       +1     
  Lines       26365    26502     +137     
  Branches    10452    10502      +50     
==========================================
+ Hits        25729    25859     +130     
  Misses        150      150              
- Partials      486      493       +7     
Files with missing lines Coverage Δ
src/agent-tool-specs.ts 100.00% <ø> (ø)
src/data-api-mcp.ts 100.00% <ø> (ø)
src/graphql.ts 99.59% <ø> (ø)
src/mcp-server.ts 97.66% <ø> (ø)
workers/api.ts 91.33% <ø> (ø)
workers/chain-firehose-hub.ts 98.96% <ø> (ø)
workers/request-handlers/discovery.ts 100.00% <ø> (ø)

... and 1 file with indirect coverage changes

🚀 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 or unsolicited PR — scores a 0.05x multiplier. label Jul 24, 2026
@loopover-orb

loopover-orb Bot commented Jul 24, 2026

Copy link
Copy Markdown
Contributor

Warning

⏸️ LoopOver review result - manual review recommended

Review updated: 2026-07-24 15:54:25 UTC

175 files · 3 blockers · CI green · dirty

⏸️ Suggested Action - Manual Review

  • AI review could not be completed: The dual-model AI review did not return a usable verdict for this change.

Review summary
AI review could not be completed for this PR head. LoopOver is holding this PR for manual review instead of relying on deterministic signals alone.

Nits — 2 non-blocking
  • AI review could not be completed — The gate is held for a human reviewer rather than passed automatically; it re-evaluates on the next update.
  • Readiness score is below the configured threshold — Use the readiness panel as advisory maintainer context; the score does not block this PR.

Concerns raised — review before merging

  • No linked issue detected: No closing reference or linked issue number was found in the PR metadata/body. — If this PR is intended to solve an issue, link it explicitly in the PR body.
  • Maintainer requires a linked issue: This repo's maintainer focus manifest requires every PR to reference a tracked issue. — Link the relevant issue (for example Closes #123) before opening the PR.
  • Patch-less file(s) could not be fully scanned for secrets (3): GitHub omitted inline diff for: src/mcp-server.ts, tests/graphql.test.ts, tests/mcp-server.test.ts. Fetched content exceeded the 512000-char scan cap or could not be retrieved completely, so leaked-secret verification is incomplete. Shrink the change, split the file, or ensure the diff is reviewable before merge. — Ensure patch-less files are within scan limits or split the change so secrets can be verified.
📋 Copy for AI agents — paste into your coding agent
Fix the following blocker(s) from this PR review:

1. No linked issue detected: No closing reference or linked issue number was found in the PR metadata/body. — If this PR is intended to solve an issue, link it explicitly in the PR body.

2. Maintainer requires a linked issue: This repo's maintainer focus manifest requires every PR to reference a tracked issue. — Link the relevant issue (for example `Closes #123`) before opening the PR.

3. Patch-less file(s) could not be fully scanned for secrets (3): GitHub omitted inline diff for: src/mcp-server.ts, tests/graphql.test.ts, tests/mcp-server.test.ts. Fetched content exceeded the 512000-char scan cap or could not be retrieved completely, so leaked-secret verification is incomplete. Shrink the change, split the file, or ensure the diff is reviewable before merge. — Ensure patch-less files are within scan limits or split the change so secrets can be verified.

Decision drivers

  • ❌ Code review — 3 blockers (no AI review ran — blocker is from a non-AI gate check)
  • ❌ Gate result — Blocking (Repo-configured hard blocker found.)
Context & advisory signals — never blocks the verdict
Signal Result Evidence
Linked issue ⚠️ Missing No linked issue or no-issue rationale found.
Related work ⚠️ 3 scoped overlaps Top overlaps are listed below; lower-confidence bulk is hidden.
Change scope ❌ 8/20 High review scope from cached public metadata (no linked issue context).
Validation posture ✅ 25/25 PR body includes validation/test evidence.
Contributor workload ✅ 10/10 Author activity: 14 registered-repo PR(s), 14 merged, 346 issue(s).
Contributor context ✅ Confirmed Gittensor contributor JSONbored; Gittensor profile; 14 PR(s), 346 issue(s).
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: not available
  • Official Gittensor activity: 14 PR(s), 346 issue(s).
  • Related work: Titles/paths share 6 meaningful terms. (PR #7949, PR #7921)
  • Related work: Titles/paths share 6 meaningful terms. (PR #7949, PR #7918)
  • Related work: Titles/paths share 6 meaningful terms. (PR #7948, PR #7921)
  • Additional title-only matches omitted; title-only overlap does not block.
Contributor next steps
  • Start here: Treat this as maintainer-lane context rather than normal contributor-lane activity.
  • Then work through the remaining 6 steps in the Signals table above.
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

…ver.mjs to .ts

Converts the last two hand-written .mjs runtime files in src/ — the
GraphQL layer and the MCP server — plus their test suites:
- src/graphql.mjs (10409 lines) + tests/graphql.test.mjs (19999 lines)
- src/mcp-server.mjs (16877 lines) + tests/mcp-server.test.mjs (20663
  lines)
and updates the .mjs import specifier in all ~170 referencing files
(the 168 mcp-server importers are dominated by the per-subnet
call-subnet-surface-verify test family).

Typing approach mirrors the earlier conversions: a local
Row/AnyFn + a per-file context interface (GqlContext for the graphql
execute() contextValue; McpCtx for buildMcpContext's tool-handler
context), resolver/tool-handler signatures annotated mechanically, and
`as unknown as` bridges only where two already-shipped modules disagree
about a shape (e.g. the MCP loaders' ctx interfaces requiring a
readArtifact that GraphQL supplies through the loaders' own deps
override instead).

Dropped three silently-ignored excess options at call sites rather than
widening the callee signatures — verified against each implementation:
loadEconomicsTrends/loadGlobalIncidents never read windowDays,
buildSubnetOhlc never reads days, loadSubnetUptime never reads
minSamples. Behavior identical; the .mjs originals passed them as inert
extra properties.

One real mistype fixed in passing: DataApiMcpContext.clientIp claimed
`string` but the graphql-ws path populates it as `string | null` —
widened to match reality (it is only ever interpolated into a rate-limit
key).
@JSONbored
JSONbored force-pushed the ts-migration-phase3-completion branch from 0abea31 to b1ddf65 Compare July 24, 2026 15:57
…api (0s fail, identical bundle builds clean locally)
@cloudflare-workers-and-pages

cloudflare-workers-and-pages Bot commented Jul 24, 2026

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
metagraphed-ui 843dfbb Commit Preview URL

Branch Preview URL
Jul 24 2026, 04:04 PM

@JSONbored
JSONbored merged commit a77a933 into main Jul 24, 2026
5 of 8 checks passed
@JSONbored
JSONbored deleted the ts-migration-phase3-completion branch July 24, 2026 16:02
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 or unsolicited PR — scores a 0.05x multiplier. manual-review Gittensor contributor context

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant