Skip to content

feat(enrichment): unused-export / dead-on-arrival detector analyzer - #3582

Merged
loopover-orb[bot] merged 2 commits into
JSONbored:mainfrom
bohdansolovie:feat/enrichment-unused-export-2025-v3
Jul 5, 2026
Merged

feat(enrichment): unused-export / dead-on-arrival detector analyzer#3582
loopover-orb[bot] merged 2 commits into
JSONbored:mainfrom
bohdansolovie:feat/enrichment-unused-export-2025-v3

Conversation

@bohdansolovie

Copy link
Copy Markdown
Contributor

Summary

  • Adds unusedExport github-light analyzer that flags net-new direct exports with no non-declaration references.
  • Parses added exports from the diff, checks same-file uses in the headSha file, then queries default-branch GitHub Code Search (total_count: 0 for brand-new PR exports is treated as dead-on-arrival).
  • Reuses parseAddedExports; bounded symbol/search/file-fetch caps; fail-safe on missing token, fetch/search errors, or incomplete results.

Fixes #2025

Test plan

  • cd review-enrichment && npm run build && npm run metadata
  • node --test review-enrichment/test/unused-export.test.ts review-enrichment/test/analyzer-registry.test.ts
  • CI green + Gittensory Orb approval

Made with Cursor

Detect net-new exports with zero repo references via bounded GitHub Code Search so reviewers catch dead public surface early.

Fixes JSONbored#2025
Check headSha same-file references before Code Search and flag exports absent from the default-branch index.
@bohdansolovie
bohdansolovie requested a review from JSONbored as a code owner July 5, 2026 17:49
@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 5, 2026
@loopover-orb

loopover-orb Bot commented Jul 5, 2026

Copy link
Copy Markdown
Contributor

Warning

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

⏸️ Gittensory review result - manual review recommended

Review updated: 2026-07-05 18:09:31 UTC

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

⏸️ Suggested Action - Manual Review

Review summary
This adds a new `unusedExport` github-light analyzer that parses added direct exports from the diff (via the existing `parseAddedExports`/`exportedSymbols` helpers), rules out same-file references in the headSha file, and falls back to a bounded, repo-scoped GitHub Code Search to detect exports with zero external references (total_count 0, or a single hit confined to the declaring file). The implementation is well-bounded (symbol/search/file-fetch/finding caps), fails safe on missing token/headSha/search errors, and is wired consistently across registry.ts, analyzer-metadata.json, rees-analyzers.ts, enrichment-analyzer-names.ts, render.ts, types.ts, and .env.example with no drift between the four descriptor copies. Tests cover the dead/alive/incomplete-results branches of `isDeadOnArrivalFromSearch`, same-file reference detection, the max-searches cap, and the no-token fail-safe path, and CI (including codecov/patch) is green. Fixes the linked issue #2025 and stays narrowly scoped to the stated feature with no unrelated changes.

Nits — 5 non-blocking
  • review-enrichment/src/analyzers/unused-export.ts: the `limits` values (10/10/25) are duplicated as literals in registry.ts, analyzer-metadata.json, and rees-analyzers.ts instead of being derived from the MAX_SYMBOLS/MAX_SEARCHES/MAX_FINDINGS constants, so a future tweak to the constants silently desyncs the docs/metadata.
  • review-enrichment/src/analyzers/unused-export.ts:117 nests to depth 5 in the main scan loop (per the size-smell scan); consider extracting the per-candidate body into a helper for readability.
  • isDeadOnArrivalFromSearch treats `total_count === 1` with an empty `items` array as dead-on-arrival (same as a same-file-only hit) — worth a comment noting that's an intentional fail-safe assumption rather than an oversight.
  • The GitHub Code Search query only matches an exact quoted substring of the symbol name; common/short-ish names could still get false 'alive' hits from unrelated identical substrings in comments/strings — acceptable given MIN_SYMBOL_LEN=3, but worth a doc note since findings are reported as fact ('no references found').
  • review-enrichment/src/analyzers/registry.ts / analyzer-metadata.json / rees-analyzers.ts: export the limits from unused-export.ts's constants (or a shared config object) so registry/docs can't drift from the analyzer's actual caps.
Signal Result Evidence
Code review ✅ No blockers 1 reviewer
Linked issue ✅ Linked #2025
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 (1 linked issue).
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: 330 registered-repo PR(s), 191 merged, 9 issue(s).
Contributor context ✅ Confirmed Gittensor contributor bohdansolovie; Gittensor profile; 330 PR(s), 9 issue(s).
Gate result ✅ Passing No configured blocker found.
Review context
  • Author: bohdansolovie
  • Role context: outside_contributor
  • Public audience mode: oss maintainer
  • Lane context: Repository registration is not available in the local Gittensory cache.
  • Public profile languages: Python, C++, JavaScript
  • Official Gittensor activity: 330 PR(s), 9 issue(s).
  • PR-specific overlap: none found.
Contributor next steps
  • Await review-lane availability.
  • Refresh registry data or choose a registered active repo.
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

@codecov

codecov Bot commented Jul 5, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 93.16%. Comparing base (7d0e2c4) to head (295dd8c).

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #3582   +/-   ##
=======================================
  Coverage   93.16%   93.16%           
=======================================
  Files         311      311           
  Lines       31750    31750           
  Branches    11612    11612           
=======================================
  Hits        29581    29581           
  Misses       1517     1517           
  Partials      652      652           
Files with missing lines Coverage Δ
src/review/enrichment-analyzer-names.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.

@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 b98229d into JSONbored:main Jul 5, 2026
9 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.

feat(enrichment): unused-export / dead-on-arrival detector analyzer

1 participant