Skip to content

build(typescript): Phase 2 completion — convert data-api.mjs to .ts - #7856

Merged
JSONbored merged 1 commit into
mainfrom
ts-migration-phase2-dataapi
Jul 24, 2026
Merged

build(typescript): Phase 2 completion — convert data-api.mjs to .ts#7856
JSONbored merged 1 commit into
mainfrom
ts-migration-phase2-dataapi

Conversation

@JSONbored

Copy link
Copy Markdown
Owner

Summary

Part of the TS migration epic (#7510). Completes Phase 2 (#7513, workers/): converts workers/data-api.mjs (8940 lines, the Postgres-serving Worker) and tests/data-api.test.mjs (8570 lines) to .ts, updating the 5 files that import by the .mjs specifier — including workers/data-api.sentry.ts, the live wrangler.data.jsonc deploy entry point, which would have broken on the next deploy exactly like the api.sentry.ts case fixed in #7837.

Every workers/** runtime file is now TypeScript.

postgres.js typing: transaction-scoped helpers (savepoint-calling loaders, the read-route dispatcher, batchedUpsert) take postgres.TransactionSql; raw per-request connections stay postgres.Sql. Ten runtime-only sync-route secrets (NEURONS_SYNC_SECRET, SUBNET_LOCKS_SYNC_SECRET, WALLET_SESSION_SECRET, etc.) are added to workers/env-extra.d.ts — they're set via wrangler secret put and invisible to wrangler types by design.

Root-level type corrections in shared src/ modules

Each verified behavior-preserving against the implementation (not just cast around):

  • src/cursor.ts: encodeCursor now accepts null parts — cursorPart() already normalized them to a null token (no next_cursor); the declared type was narrower than the real contract its callers rely on.
  • src/unkey-client.ts: createUnkeyKey/verifyUnkeyKey returned Row | UnkeyFetchFailure, which cannot discriminate on .ok (Row also admits an ok key) — introduced UnkeyMintSuccess/UnkeyVerifySuccess so callers' existing if (!result.ok) guards actually narrow.
  • src/metagraph-neurons.ts + src/subnet-conviction.ts: widened immunityPeriod/now/unlockRate/maturityRate options to | null — their paired Postgres/RPC loaders return null by design and the builders already coalesce internally.

Test plan

  • npx tsc --noEmit clean (repo-wide)
  • npx eslint + prettier --check clean on all touched files
  • npx vitest run on the 5 directly-affected test files: 665/665 passing (incl. the full 8570-line data-api suite)
  • CI green (full suite runs there per review policy)

Converts workers/data-api.mjs (8940 lines, the Postgres-serving Worker
and the last remaining Phase 2 file) and its test file
tests/data-api.test.mjs (8570 lines) to .ts, updating the 5 files with
data-api.mjs import specifiers (3 route test files,
workers/data-api.sentry.ts — again the live deploy entry point, same
dangling-specifier class #7837 fixed for api.sentry.ts).

postgres.js typing: transaction-scoped helpers (savepoint callers, the
read dispatcher, batchedUpsert) take postgres.TransactionSql; the raw
per-request connections stay postgres.Sql. Ten runtime-only sync-route
secrets (NEURONS_SYNC_SECRET, SUBNET_LOCKS_SYNC_SECRET, etc.) added to
workers/env-extra.d.ts — set via wrangler secret put, invisible to
`wrangler types` by design.

Root-level type corrections in shared src/ modules, each verified
behavior-preserving against the implementation:
- src/cursor.ts: encodeCursor accepts null parts — cursorPart() already
  normalized them to a null token (no next_cursor); the declared type
  was just narrower than the real contract every caller relies on.
- src/unkey-client.ts: createUnkeyKey/verifyUnkeyKey returned
  `Row | UnkeyFetchFailure`, which cannot discriminate on .ok (Row also
  admits an ok key) — introduced UnkeyMintSuccess/UnkeyVerifySuccess so
  callers' existing `if (!result.ok)` guards actually narrow.
- src/metagraph-neurons.ts + src/subnet-conviction.ts: widened
  immunityPeriod/now/unlockRate/maturityRate options to `| null` — their
  paired Postgres/RPC loaders return null by design and the builders
  already coalesce with ?? internally.
@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 Updated (UTC)
✅ Deployment successful!
View logs
metagraphed-registry-sync-api 09167bc Jul 24 2026, 02:05 AM

@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 Updated (UTC)
✅ Deployment successful!
View logs
metagraphed-data-api 09167bc Jul 24 2026, 02:05 AM

@superagent-security

Copy link
Copy Markdown

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

@codecov

codecov Bot commented Jul 24, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 96.39640% with 4 lines in your changes missing coverage. Please review.
✅ Project coverage is 97.57%. Comparing base (0634dc1) to head (09167bc).
✅ All tests successful. No failed tests found.

Files with missing lines Patch % Lines
workers/data-api.ts 97.14% 2 Missing and 1 partial ⚠️
src/unkey-client.ts 75.00% 0 Missing and 1 partial ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #7856      +/-   ##
==========================================
- Coverage   97.58%   97.57%   -0.01%     
==========================================
  Files         203      203              
  Lines       26283    26290       +7     
  Branches    10414    10420       +6     
==========================================
+ Hits        25647    25652       +5     
  Misses        150      150              
- Partials      486      488       +2     
Files with missing lines Coverage Δ
src/cursor.ts 100.00% <ø> (ø)
src/metagraph-neurons.ts 97.21% <100.00%> (ø)
src/subnet-conviction.ts 72.91% <ø> (ø)
src/unkey-client.ts 96.00% <75.00%> (-4.00%) ⬇️
workers/data-api.ts 97.57% <97.14%> (ø)
🚀 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

Caution

🛑 LoopOver review result - fixes required

Review updated: 2026-07-24 11:22:34 UTC

12 files · 2 blockers · CI failing · unstable

🛑 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.

Why this is blocked

  • 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.
📋 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.

CI checks failing

  • codecov/patch — 96.39% of diff hit (target 99.00%)

Decision drivers

  • ❌ Code review — 2 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 ⚠️ 1 scoped overlap 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, 264 issue(s).
Contributor context ✅ Confirmed Gittensor contributor JSONbored; Gittensor profile; 14 PR(s), 264 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: Python, TypeScript, Ruby, Go, MDX, Shell, Solidity, JavaScript
  • Official Gittensor activity: 14 PR(s), 264 issue(s).
  • Related work: Titles/paths share 10 meaningful terms. (PR #7857)
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

@loopover-orb loopover-orb Bot added the manual-review Gittensor contributor context label Jul 24, 2026
@JSONbored
JSONbored merged commit bdd277e into main Jul 24, 2026
15 of 16 checks passed
@JSONbored
JSONbored deleted the ts-migration-phase2-dataapi branch July 24, 2026 15:53
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