Skip to content

fix(signals): detect pytest test_*.py prefix as test evidence - #2666

Merged
JSONbored merged 1 commit into
JSONbored:mainfrom
ultrahighsuper:fix/pytest-test-prefix-detection
Jul 3, 2026
Merged

fix(signals): detect pytest test_*.py prefix as test evidence#2666
JSONbored merged 1 commit into
JSONbored:mainfrom
ultrahighsuper:fix/pytest-test-prefix-detection

Conversation

@ultrahighsuper

Copy link
Copy Markdown
Contributor

isTestPath recognized the *_test.py suffix but not pytests default and more common test_*.py**prefix**. A Python PR that adds test files next to source (e.g.mypackage/test_utils.py, src/app/test_auth.py) matched no branch of isTestPathand was scored as shipping **no** test evidence — tripping the missing-test slop finding and undercountingclassifyTestCoverage` / the local scorer.

test_*.py is the default python_files pattern for pytest (and matches unittest discovery), so this is the primary Python test convention, not an edge case. The existing dir-based branch only catches files that live under a test/, tests/, spec/, or __tests__/ directory, which the flat pytest layout does not.

Fix

Add one path-segment-anchored matcher next to the existing suffix rule:

/(^|\/)test_[^/]*\.py$/i.test(file)

The (^|\/) anchor keeps it precise: latest_config.py and testing.py remain non-tests (no test_ at a segment boundary), while the pre-existing *_test.py suffix form is untouched.

Tests

Adds a regression case covering the prefix form, the still-working suffix form, and both non-test negatives. Verified the new case FAILS on current main and PASSES with the fix; the full test-evidence, slop, and path-matchers suites stay green.

No linked issue: issue creation is unavailable for this account.

isTestPath recognized the *_test.py suffix but not pytest`s default and
more common test_*.py prefix, so a Python PR adding test files next to
source (mypackage/test_utils.py) was scored as having no test evidence —
tripping the missing-test slop finding and undercounting test coverage.
Add a path-segment-anchored test_*.py matcher; latest_config.py and
testing.py stay non-tests.
@ultrahighsuper
ultrahighsuper requested a review from JSONbored as a code owner July 3, 2026 02:16
@dosubot dosubot Bot added the size:XS 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 02:36:39 UTC

2 files · 1 AI reviewer · no blockers · readiness 80/100 · CI green · clean

⏸️ Suggested Action - Manual Review

Review summary
The change correctly extends the shared test-path classifier to recognize pytest's default `test_*.py` segment convention while preserving the existing `*_test.py` suffix and avoiding mid-segment false positives like `latest_config.py`. The regression test drives the production helper directly and covers root-level, nested, suffix-preservation, and negative cases, so the visible diff is safe enough to proceed.

Nits — 4 non-blocking
  • nit: `src/signals/test-evidence.ts:6` is now a long matcher/comment line; moving the explanation above the regex would keep the matcher list easier to scan.
  • nit: `test/unit/local-branch-file-classifiers.test.ts` could add a `test_utils.py` case so the local-branch classifier tests document this convention too, since that path delegates to `isTestPath`.
  • In `src/signals/test-evidence.ts:6`, prefer a preceding comment such as `// pytest's default test_*.py prefix convention.` followed by the regex on its own line.
  • In `test/unit/local-branch-file-classifiers.test.ts`, add `test_utils.py` or `pkg/test_utils.py` to the `isTestFile` positive cases and, if `isCodeFile` delegates through it, to the code-file exclusion cases.
Signal Result Evidence
Code review ✅ No blockers 1 reviewer
Linked issue ✅ No-issue rationale PR body explains why no issue is linked.
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 (size label size:XS; 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: 41 registered-repo PR(s), 25 merged, 5 issue(s).
Contributor context ✅ Confirmed Gittensor contributor ultrahighsuper; Gittensor profile; 41 PR(s), 5 issue(s).
Gate result ✅ Passing No configured blocker found.
Review context
  • Author: ultrahighsuper
  • 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: 41 PR(s), 5 issue(s).
  • PR-specific overlap: none found.
Contributor next steps
  • 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

@loopover-orb loopover-orb Bot added gittensor gittensor:bug Gittensor-scored bug fix — scores a 0.05x multiplier. labels Jul 3, 2026
@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.10%. Comparing base (cfbdc9f) to head (999a5db).
⚠️ Report is 25 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #2666   +/-   ##
=======================================
  Coverage   96.10%   96.10%           
=======================================
  Files         237      237           
  Lines       26540    26540           
  Branches     9625     9625           
=======================================
  Hits        25507    25507           
  Misses        424      424           
  Partials      609      609           
Files with missing lines Coverage Δ
src/signals/test-evidence.ts 100.00% <ø> (ø)
🚀 New features to boost your workflow:
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@dosubot dosubot Bot added the lgtm label Jul 3, 2026
@JSONbored
JSONbored merged commit a1173eb into JSONbored:main Jul 3, 2026
9 checks passed
loopover-orb Bot pushed a commit that referenced this pull request Jul 3, 2026
…x + JVM/C#/Swift) (#2753)

The MCP local-branch isTestFile is a standalone inlined copy of the server's
canonical isTestPath (packages/gittensory-mcp ships as a Node bin package, so it
cannot import from src/). Two conventions added to isTestPath were never mirrored
here: the pytest `test_*.py` prefix (#2666) and the JVM/C#/Swift
`SomethingTest(s)`/`Spec` class-suffix (#2743). So the local pre-submit predictor
counted Java/Kotlin/Scala/C#/Swift test classes and pytest-prefixed files as
SOURCE, disagreeing with the server gate's own test-coverage classification and
misleading contributors in those ecosystems about readiness.

Add both rules verbatim from isTestPath (same order, same case-sensitive JVM
suffix so `Latest.java`/`Contest.cs`/`manifest.scala` stay source). Adds
regressions to the MCP-copy classifier test.
glorydavid03023 added a commit to glorydavid03023/gittensory that referenced this pull request Jul 3, 2026
… 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.
glorydavid03023 added a commit to glorydavid03023/gittensory that referenced this pull request Jul 3, 2026
… 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.
glorydavid03023 added a commit to glorydavid03023/gittensory that referenced this pull request Jul 3, 2026
… 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 Bot pushed a commit that referenced this pull request Jul 3, 2026
… 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.
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.

2 participants