Skip to content

fix(signals): exclude generated Dart part files from code scoring - #3724

Merged
JSONbored merged 1 commit into
mainfrom
codex/fix-issue-with-generated-dart-files-classification
Jul 6, 2026
Merged

fix(signals): exclude generated Dart part files from code scoring#3724
JSONbored merged 1 commit into
mainfrom
codex/fix-issue-with-generated-dart-files-classification

Conversation

@JSONbored

Copy link
Copy Markdown
Owner

Motivation

  • A recent change added .dart to the broad code-extension classifier but did not exclude generated Dart part files, causing .g.dart/.freezed.dart/.gr.dart to be counted as source in local scoring and preview scripts.
  • Generated Dart parts are already recognized by the repository's generated-file matcher and should be treated as non-code to avoid inflating sourceTokenScore/sourceLines.

Description

  • Update the server-side classifier isCodeFile to use a CODE_FILE_RE and explicitly exclude generated Dart parts via GENERATED_CODE_FILE_RE so hand-authored .dart remains source while .g.dart/.freezed.dart/.gr.dart are non-code (src/signals/local-branch.ts).
  • Mirror the same exclusion in the packaged MCP helper and metadata-preview fallbacks by adding isGeneratedCodeFile / is_generated_code_file guards in packages/gittensory-mcp/lib/local-branch.js, packages/gittensory-mcp/scripts/gittensor-score-preview.mjs, and packages/gittensory-mcp/scripts/gittensor-score-preview.py.
  • Add regression tests covering: server classifier parity, deterministic local scorer behavior, and JS/Python local score-preview parity to ensure generated Dart parts are classified as non-code (test/unit/local-branch-file-classifiers.test.ts, test/unit/local-scorer.test.ts, test/unit/score-preview-script.test.ts, and updates in test/unit/local-branch.test.ts).

Testing

  • Ran the unit test subset with npx vitest run test/unit/local-branch-file-classifiers.test.ts test/unit/local-scorer.test.ts test/unit/score-preview-script.test.ts test/unit/local-branch.test.ts, and all tests in those files passed.
  • Verified git diff --check returned clean results and npm run build:mcp completed successfully to validate the packaged MCP scripts.
  • Attempted the full gate npm run test:ci, but the run in this environment encountered long-running queue-test activity and transient actionlint / network DNS issues that prevented completion; this is unrelated to the classifier change.
  • Attempted npm audit --audit-level=moderate, but the environment returned a 403 from the npm audit endpoint so the dependency-review step could not be exercised here.

Codex Task

@cloudflare-workers-and-pages

cloudflare-workers-and-pages Bot commented Jul 6, 2026

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 Preview URL Updated (UTC)
✅ Deployment successful!
View logs
gittensory-ui 870e906 Commit Preview URL

Branch Preview URL
Jul 06 2026, 09:34 AM

@superagent-security

Copy link
Copy Markdown
Contributor

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

@loopover-orb loopover-orb Bot added the gittensor:bug Gittensor-scored bug fix — scores a 0.05x multiplier. label Jul 6, 2026
@loopover-orb

loopover-orb Bot commented Jul 6, 2026

Copy link
Copy Markdown
Contributor

Warning

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

⏸️ Gittensory review result - manual review recommended

Review updated: 2026-07-06 08:02:43 UTC

8 files · 1 AI reviewer · 2 blockers · readiness 93/100 · CI pending · dirty

⏸️ Suggested Action - Manual Review

  • No linked issue detected — If this PR is intended to solve an issue, link it explicitly in the PR body.
  • Maintainer requires a linked issue — Link the relevant issue (for example Closes #123) before opening the PR.

Review summary
This PR closes a real classification gap: isCodeFile previously counted generated Dart part files (.g.dart/.freezed.dart/.gr.dart) as source across four independently-maintained classifiers (TS, two JS mirrors, one Python fallback), inflating sourceTokenScore. The fix is mechanically consistent across all four implementations, and each gets a matching regression test with the same expected token totals (source=3, non-code=15), which line up correctly with the added test fixtures. The only soft spot is that the TS version introduces a new inline GENERATED_CODE_FILE_RE even though the removed comment it edits references an existing 'generated-file matcher' (isGeneratedFile) used elsewhere in the codebase for the same purpose, suggesting duplicated logic rather than reuse.

Nits — 5 non-blocking
  • src/signals/local-branch.ts:1277-1284 — the old comment referenced an existing isGeneratedFile matcher for excluding generated Dart parts; this diff instead duplicates the exclusion as a new local GENERATED_CODE_FILE_RE rather than reusing that matcher, which risks the two definitions drifting apart over time.
  • The same `/\.(g|freezed|gr)\.dart$/i` pattern is now copied verbatim into four files (local-branch.ts, local-branch.js, gittensor-score-preview.mjs, gittensor-score-preview.py); consider a shared constant/helper for the JS-side copies at least, since local-branch.js and gittensor-score-preview.mjs are both JS and already duplicate isTestFile similarly.
  • The `.gr.dart`/`.freezed.dart` exclusion would also silently swallow a hand-authored file that happens to match that suffix pattern (e.g. a non-generated `foo.gr.dart`); worth a one-line comment noting this is an accepted tradeoff mirroring the repo's existing generated-file convention.
  • Factor the generated-Dart-part regex into a single shared constant imported by local-branch.js and gittensor-score-preview.mjs to guarantee they can't drift the way isCodeFile itself just did.
  • Consider having src/signals/local-branch.ts delegate to the existing isGeneratedFile matcher referenced in the old comment rather than re-implementing the pattern locally, if that matcher already covers this case.

Concerns raised — review before merging

  • No linked issue detected — If this PR is intended to solve an issue, link it explicitly in the PR body.
  • Maintainer requires a linked issue — Link the relevant issue (for example Closes #123) before opening the PR.
Signal Result Evidence
Code review ❌ 2 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 ✅ 25/25 PR body includes validation/test evidence.
Contributor workload ✅ 10/10 Author activity: 54 registered-repo PR(s), 46 merged, 413 issue(s).
Contributor context ✅ Confirmed Gittensor contributor JSONbored; Gittensor profile; 54 PR(s), 413 issue(s).
Gate result ❌ Blocking Repo-configured hard blocker found.
Review context
  • Author: JSONbored
  • Role context: owner (maintainer lane)
  • Public audience mode: oss maintainer
  • Lane context: Repository registration is not available in the local Gittensory cache.
  • Public profile languages: Python, TypeScript, JavaScript, Ruby, Go, Kotlin, MDX, Shell
  • Official Gittensor activity: 54 PR(s), 413 issue(s).
  • PR-specific overlap: none found.
Contributor next steps
  • Treat this as maintainer-lane context rather than normal contributor-lane activity.
  • Explain no-issue PR.
  • 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

Dart build_runner/freezed/retrofit part files (*.g.dart, *.freezed.dart,
*.gr.dart) were being classified as hand-authored source across every
independent code-file classifier -- the TS engine (now centralized in
path-matchers.ts's isCodeFile), the MCP package's standalone JS copy,
and both the .mjs and Python gittensor-score-preview scripts -- so a
PR that's mostly generated Dart boilerplate scored as if it were real
work.

Excludes the three generated-part-file suffixes from isCodeFile in
each of the four classifiers, matching the existing pattern already
used for other codegen (protobuf, C# designer partials, source maps).
@JSONbored
JSONbored force-pushed the codex/fix-issue-with-generated-dart-files-classification branch from f8bfe00 to 870e906 Compare July 6, 2026 09:33
@codecov

codecov Bot commented Jul 6, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 93.30%. Comparing base (8398615) to head (870e906).
✅ All tests successful. No failed tests found.

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #3724   +/-   ##
=======================================
  Coverage   93.30%   93.30%           
=======================================
  Files         317      317           
  Lines       32384    32384           
  Branches    11876    11876           
=======================================
  Hits        30215    30215           
  Misses       1537     1537           
  Partials      632      632           
Files with missing lines Coverage Δ
src/signals/local-branch.ts 97.18% <ø> (ø)
src/signals/path-matchers.ts 89.09% <ø> (ø)
🚀 New features to boost your workflow:
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@JSONbored
JSONbored merged commit 1abcd71 into main Jul 6, 2026
12 checks passed
@JSONbored
JSONbored deleted the codex/fix-issue-with-generated-dart-files-classification branch July 6, 2026 09:44
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.

Development

Successfully merging this pull request may close these issues.

1 participant