fix(mcp): re-sync score-preview classifiers with the server test/code conventions - #2822
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. 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:
|
|
Warning 🟨🟨🟨🟨🟨🟨🟨🟨🟨🟨🟨🟨 ⏸️ Gittensory review result - manual review recommendedReview updated: 2026-07-03 21:15:24 UTC
⏸️ Suggested Action - Manual Review Review summary Nits — 5 non-blocking
Review context
Contributor next steps
Signal definitions
🟩 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.
|
7228583 to
4a084c7
Compare
4a084c7 to
19cd7df
Compare
… 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.
19cd7df to
4c36ade
Compare
What
The MCP's local score-preview scripts (
packages/gittensory-mcp/scripts/gittensor-score-preview.{mjs,py}) inline their ownisTestFile/isCodeFileclassifiers — they ship in the standalone Node bin package and can't import fromsrc/. Both had drifted from the canonicalisTestPath/isCodeFile:.mjsand.pytest detection was missing: the pytesttest_*.pyprefix (#2666), the Cypress/Playwright*.cy.*/*.e2e.*convention, and__snapshots__dirs (#2665)..mjsalso missed the.mts/.cts/.mjs/.cjsmodule extensions — in both its.test/.spectest rule and itsisCodeFilesource-extension list.#2776already 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
.mtssource file was classified as non-code and a Cypress/pytest test as source — so the localsourceTokenScore/testTokenScore/nonCodeTokenScoredisagree 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) →sourceTokenScore8 → 10,testTokenScore7 → 15,nonCodeTokenScore10 → 0.Fix
Bring both scripts'
isTestFile/is_test_fileand the.mjsisCodeFileto parity withisTestPath/isCodeFile(same conventions, same order/anchoring). The.pyderives source by subtraction, so only its test detector needed the conventions.Tests
Adds
test/unit/score-preview-script.test.ts: spawns the real.mjsover module-ext/Cypress/pytest/JVM files and asserts the token classification. Fails on the pre-fix script (sourceTokenScore8 ≠ 10), passes with the fix. Both scripts are node-/py-syntax-checked.