Skip to content

feat(enrichment): enum / literal-union exhaustiveness-drift analyzer - #3594

Merged
loopover-orb[bot] merged 1 commit into
JSONbored:mainfrom
bohdansolovie:feat/enrichment-exhaustiveness-drift-2028
Jul 5, 2026
Merged

feat(enrichment): enum / literal-union exhaustiveness-drift analyzer#3594
loopover-orb[bot] merged 1 commit into
JSONbored:mainfrom
bohdansolovie:feat/enrichment-exhaustiveness-drift-2028

Conversation

@bohdansolovie

Copy link
Copy Markdown
Contributor

Summary

  • Adds exhaustiveness github-light analyzer that flags when a PR adds a new enum member or string-literal union variant but a previously exhaustive switch still omits it.
  • Parses added members from the diff, reconstructs the pre-PR member set via patch reverse-apply, fetches changed files at headSha, and scans explicit enum/union case labels (skips switches with default).
  • Bounded file-fetch caps; fail-safe on missing token, fetch errors, or ambiguous type parsing.

Fixes #2028

Test plan

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

Made with Cursor

Detect switches that covered every old enum or union member but omit a variant newly added by the PR.

Fixes JSONbored#2028
@bohdansolovie
bohdansolovie requested a review from JSONbored as a code owner July 5, 2026 18:18
@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:24:29 UTC

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

⏸️ Suggested Action - Manual Review

Review summary
Adds a new github-light analyzer that detects enum/literal-union members added by a PR while a previously-exhaustive switch (no default) still omits them, reusing the existing patch-reverse-apply helper from doc-comment-drift and wiring into registry/metadata/render/UI/analyzer-names consistently with other analyzers. The parsing is heuristic (regex-based enum/union/case extraction) but appropriately conservative — it bails on ambiguous parses, skips switches with a default, and bounds file count/fetches/findings — and the accompanying unit tests exercise the added-member parser, gap detection, end-to-end scan, the same-file fix case, the fetch cap, and the no-token fail-safe. I did not have access to `doc-comment-drift.ts`'s `reconstructOldContent` in this environment to independently verify its contract, but the diff's usage (guarding on a null return) is defensive regardless.

Nits — 5 non-blocking
  • review-enrichment/src/analyzers/exhaustiveness-drift.ts: in the `else` (non-added-line) branch of `parseAddedTypeMembers`, `enumDepth` is only closed out when the closing `}` appears as a context/deleted line — if a whole enum block (including its closing brace) is added within the same hunk, `enumName` never resets and could bleed into a later declaration in the same hunk until the next `@​@​` header.
  • review-enrichment/src/analyzers/exhaustiveness-drift.ts: `collectEnumCases`'s bare `case Active:` fallback (no `Status.` qualifier) can false-positive on an unrelated case label from a different enum/type sharing a member name — worth calling out in the docs.notes alongside the existing conservatism caveats.
  • review-enrichment/src/analyzers/registry.ts: the new `exhaustiveness` import is appended after `unused-export.js` rather than kept in the existing alphabetical import ordering used by the surrounding block.
  • review-enrichment/src/analyzers/exhaustiveness-drift.ts:98 `fetchFileAtHead`'s catch-all `return null` is an intentional fail-safe per the docstring, but consider logging/diagnostics on unexpected (non-network) errors so silent parsing failures aren't indistinguishable from expected fetch failures.
  • review-enrichment/src/types.ts: the `(feat(enrichment): enum / literal-union exhaustiveness-drift analyzer #2028)` issue reference embedded in the JSDoc comment will rot if the issue is renumbered/closed elsewhere — fine for now, just flagging per the magic-number scan.
Signal Result Evidence
Code review ✅ No blockers 1 reviewer
Linked issue ✅ Linked #2028
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.19%. Comparing base (b98229d) to head (d9f13ce).

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #3594   +/-   ##
=======================================
  Coverage   93.19%   93.19%           
=======================================
  Files         313      313           
  Lines       31874    31874           
  Branches    11666    11666           
=======================================
  Hits        29705    29705           
  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 e0a5e54 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): enum / literal-union exhaustiveness-drift analyzer

1 participant