fix(signals): classify .mjs/.cjs/.mts/.cts as code and test files#2665
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #2665 +/- ##
==========================================
- Coverage 96.10% 96.10% -0.01%
==========================================
Files 237 237
Lines 26540 26539 -1
Branches 9625 9624 -1
==========================================
- Hits 25507 25506 -1
Misses 424 424
Partials 609 609
🚀 New features to boost your workflow:
|
|
Warning 🟨🟨🟨🟨🟨🟨🟨🟨🟨🟨🟨🟨 ⏸️ Gittensory review result - manual review recommendedReview updated: 2026-07-03 02:36:23 UTC
⏸️ Suggested Action - Manual Review Review summary Nits — 4 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.
|
isCodeFile omitted the Node/TypeScript ESM + CommonJS module extensions (.mjs/.cjs/.mts/.cts), even though the codebase's own rag.ts JS_TS_RE already recognizes .mjs/.cjs as JS/TS. A PR changing only `.mjs`/`.mts` source was therefore counted as having no code files, skewing the "code changed without tests" slop signal, the codeFileCount/source-line inputs, and the AI-review code-path grounding. Add the four module extensions to isCodeFile (both src copies — signals/ local-branch.ts and signals/engine.ts — plus the MCP client copy) and, consistently, to BOTH test-file extension groups (`.test`/`.spec` AND the Cypress/Playwright `.cy`/`.e2e` group) in isTestPath / the MCP isTestFile, so a `foo.test.mts` or `checkout.cy.mts` still classifies as a test rather than as source. engine.ts's private isTestFile — a stale partial copy that also lacked `.cy`/`.e2e` and `__snapshots__` — now delegates to the canonical isTestPath (mirroring local-branch.ts), so the classifiers can't drift again. Adds regression assertions across the file-classifier, test-evidence, and MCP tests. No issue because issue creation is restricted on this repo; this aligns the code/ test-file classifiers with the module extensions the codebase already uses, no schema or API change.
537f051 to
f3c6f0e
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.
… 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.
… 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.
… conventions (#2822) 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 (#2666), the Cypress/Playwright `*.cy.*`/`*.e2e.*` convention and `__snapshots__` dirs (#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. (#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.
Summary
isCodeFileomitted the Node/TypeScript ESM + CommonJS module extensions —.mjs/.cjs/.mts/.cts— even though the codebase's ownsrc/review/rag.ts(JS_TS_RE = /\.(ts|tsx|js|jsx|mjs|cjs)$/i) already recognizes.mjs/.cjsas JS/TS. So a PR that changes only.mjs/.mtssource was counted as having no code files, skewing:signals/engine.ts),codeFileCount/ source-line inputs, andservices/ai-review.ts→local-branchisCodeFile).Fix: add the four module extensions to
isCodeFilein both src copies (signals/local-branch.tsand the private one insignals/engine.ts) and the MCP client copy — and, consistently, to the.test/.specgroup inisTestPath(signals/test-evidence.ts) and the MCPisTestFile, so afoo.test.mtsstill classifies as a test rather than as source (verified). Pure classifiers — no schema or API change.No issue because issue creation is restricted on this repo for outside accounts; this aligns the code/test-file classifiers with the module extensions the codebase already uses.
Scope
Validation
git diff --checknpm run typechecknpm run build:mcp(node --checkclean)npm run test:coverage(scoped:test-evidence.test.ts+local-branch-file-classifiers.test.ts+local-branch.test.ts— 75 pass; the changed regex lines add extension alternatives, not new branches, and are exercised by these tests and the engine slop tests —engine.tsisCodeFilestatement confirmed hit.)npm run test:workers/ui:*— N/A (no UI/worker change)npm audit --audit-level=moderateIf any required check was skipped, explain why:
src/signals/**plus the MCP client copy (plain JS, outside Codecov'ssrc/**/*.tsinclude).typecheck+build:mcpclean; regression assertions added in the file-classifier, test-evidence, and MCP-lib tests (.mjs/.cjs/.mts/.ctsare code;.test.mts/.spec.cjsare tests). I did not run the UI/workers steps (unrelated), and the local Windows tree has pre-existing unrelated failures (CRLF, missing CLI binaries, Node 24 vs pinned 22). CI runs the full matrix on a clean checkout.Safety
Notes
.test/.specgroup is extended in lockstep withisCodeFileso afoo.test.mtsis still a test, not source — a regression test pins this.isCodeFilecopies (local-branch.tsexported +engine.tsprivate) and the MCP client copy are updated together so the classifier can't drift by extension.Update (addressing review): also extended the Cypress/Playwright
.cy/.e2etest-file group to the module extensions (socheckout.cy.mts/flow.e2e.mjsstay tests, not source), and replacedengine.ts's stale privateisTestFile(which lacked.cy/.e2eand__snapshots__) with a delegation to the canonicalisTestPath, mirroringlocal-branch.ts— so all test/code classifiers are single-sourced and cannot drift by extension. Regression assertions added for the.cy.mts/.e2e.mjscases;engine.tsdelegation line confirmed covered.