Skip to content

fix(mcp): re-sync score-preview classifiers with the server test/code conventions - #2822

Merged
loopover-orb[bot] merged 1 commit into
JSONbored:mainfrom
glorydavid03023:fix/mcp-score-preview-classifier-parity
Jul 3, 2026
Merged

fix(mcp): re-sync score-preview classifiers with the server test/code conventions#2822
loopover-orb[bot] merged 1 commit into
JSONbored:mainfrom
glorydavid03023:fix/mcp-score-preview-classifier-parity

Conversation

@glorydavid03023

Copy link
Copy Markdown
Contributor

What

The MCP's local score-preview scripts (packages/gittensory-mcp/scripts/gittensor-score-preview.{mjs,py}) inline their own isTestFile/isCodeFile classifiers — they ship in the standalone Node bin package and can't import from src/. Both had drifted from the canonical isTestPath/isCodeFile:

  • .mjs and .py test detection was missing: the pytest test_*.py prefix (#2666), the Cypress/Playwright *.cy.*/*.e2e.* convention, and __snapshots__ dirs (#2665).
  • .mjs also missed the .mts/.cts/.mjs/.cjs module extensions — in both its .test/.spec test rule and its isCodeFile source-extension list.

#2776 already re-synced these scripts' C#/Swift/Groovy code extensions; this closes the older test-convention gaps that were never propagated.

Why it matters

These scripts drive the miner's local score preview. With the drift, a .mts source file was classified as non-code and a Cypress/pytest test as source — so the local sourceTokenScore/testTokenScore/nonCodeTokenScore disagree with the gate's own source/test split, giving contributors in those ecosystems a wrong local preview.

Concrete (real script output before → after this change): for a diff of src/loader.mts (+10), e2e/login.cy.ts (+5), src/test_api.py (+3) → sourceTokenScore 8 → 10, testTokenScore 7 → 15, nonCodeTokenScore 10 → 0.

Fix

Bring both scripts' isTestFile/is_test_file and the .mjs isCodeFile to parity with isTestPath/isCodeFile (same conventions, same order/anchoring). The .py derives source by subtraction, so only its test detector needed the conventions.

Tests

Adds test/unit/score-preview-script.test.ts: spawns the real .mjs over module-ext/Cypress/pytest/JVM files and asserts the token classification. Fails on the pre-fix script (sourceTokenScore 8 ≠ 10), passes with the fix. Both scripts are node-/py-syntax-checked.

@codecov

codecov Bot commented Jul 3, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 96.18%. Comparing base (f72bcf0) to head (4c36ade).
⚠️ Report is 19 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #2822      +/-   ##
==========================================
+ Coverage   96.16%   96.18%   +0.01%     
==========================================
  Files         248      250       +2     
  Lines       27579    27703     +124     
  Branches    10014    10067      +53     
==========================================
+ Hits        26522    26646     +124     
  Misses        434      434              
  Partials      623      623              
🚀 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 — scores a 0.05x multiplier. label Jul 3, 2026
@loopover-orb

loopover-orb Bot commented Jul 3, 2026

Copy link
Copy Markdown
Contributor

Warning

🟨🟨🟨🟨🟨🟨🟨🟨🟨🟨🟨🟨

⏸️ Gittensory review result - manual review recommended

Review updated: 2026-07-03 21:15:24 UTC

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

⏸️ Suggested Action - Manual Review

Review summary
The change re-syncs the standalone score-preview classifiers with the server conventions for module extensions, pytest prefix tests, Cypress/Playwright tests, and snapshot directories. The modified Node and Python fallback paths are consistent with the stated classification goals, and the added tests drive the real preview scripts rather than isolated helper copies. I do not see a reachable correctness defect in the changed lines.

Nits — 5 non-blocking
  • nit: test/unit/score-preview-script.test.ts:45 silently returns when Python is unavailable, which makes the Python parity coverage disappear without an explicit skip signal.
  • nit: packages/gittensory-mcp/scripts/gittensor-score-preview.mjs:7 keeps __snapshots__ as a separate trailing rule while the Python mirror folds it into the directory-convention rule, so future parity checks are slightly harder to audit.
  • test/unit/score-preview-script.test.ts:45 should use an explicit conditional skip or helper naming that makes the Python-unavailable case visible in test output.
  • packages/gittensory-mcp/scripts/gittensor-score-preview.mjs:7 could fold __snapshots__ into the first directory regex to match the Python layout and reduce drift risk between the two inline mirrors.
  • Readiness score is below the configured threshold — Use the readiness panel as advisory maintainer context; the score does not block this PR.
Signal Result Evidence
Code review ✅ No blockers 1 reviewer
Linked issue ⚠️ Missing No linked issue or no-issue rationale found.
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 (no linked issue context).
Validation posture ❌ 5/25 Preflight is holding this PR: the review lane is unavailable, so it is not ready for automated review.
Contributor workload ✅ 10/10 Author activity: 254 registered-repo PR(s), 157 merged, 12 issue(s).
Contributor context ✅ Confirmed Gittensor contributor glorydavid03023; Gittensor profile; 254 PR(s), 12 issue(s).
Gate result ✅ Passing No configured blocker found.
Review context
  • Author: glorydavid03023
  • Role context: outside_contributor
  • Public audience mode: oss maintainer
  • Lane context: Repository registration is not available in the local Gittensory cache.
  • Public profile languages: not available
  • Official Gittensor activity: 254 PR(s), 12 issue(s).
  • PR-specific overlap: none found.
Contributor next steps
  • Explain no-issue PR.
  • Await review-lane availability.
  • Refresh registry data or choose a registered active repo.
  • Link the issue being solved, or explicitly explain why this is a no-issue PR.
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.

🟩 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 Gittensory, a quiet PR intelligence layer for OSS maintainers.

  • Re-run Gittensory review

… conventions

The local score-preview scripts inline their own test/code classifiers (they ship
in the standalone Node bin package and can't import from src/). Both had drifted
from the canonical isTestPath/isCodeFile: the .mjs and .py test detectors missed
the pytest `test_*.py` prefix (JSONbored#2666), the Cypress/Playwright `*.cy.*`/`*.e2e.*`
convention and `__snapshots__` dirs (JSONbored#2665); the `.mjs` isCodeFile and the `.py`
metadata_fallback source-extension tuple both missed the `.mts/.cts/.mjs/.cjs`
module extensions.

So a miner's LOCAL preview classified a `.mts` source file as non-code and a
Cypress/pytest test as source — disagreeing with the gate's own source/test split
and skewing the previewed token scores. (JSONbored#2776 already re-synced these scripts'
C#/Swift/Groovy code extensions; this closes the older test-convention + module-
extension gaps.)

Bring both scripts' classifiers to parity with isTestPath/isCodeFile. Adds a
spawn-based regression running the real .mjs (and the .py metadata_fallback when
python is available) over module-ext/Cypress/pytest files.

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

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

@loopover-orb
loopover-orb Bot merged commit 4bdcc78 into JSONbored:main Jul 3, 2026
10 checks passed
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 — scores a 0.05x multiplier.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant