Skip to content

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

Description

@JSONbored

New REES github-light analyzer (the #1499 epic 'Enum/literal-union exhaustiveness drift' idea) that detects when a PR adds a new member to a TS enum or string-literal union type but does not update a switch/mapping that previously handled all members — a classic missed-case bug. Fetches the changed type file + candidate consumer files at headSha; conservative and fail-safe.

Deliverables

  • Add ExhaustivenessFinding ({ file, line, unionName: string, addedMember: string, consumerFile?: string }) + exhaustiveness? key to review-enrichment/src/types.ts
  • Create review-enrichment/src/analyzers/exhaustiveness-drift.ts: detect added enum/union members from the diff, fetch the full type file at headSha (injected fetch), find switch/record consumers that don't cover the new member; strict maxFiles + maxFetches caps; only report high-confidence misses
  • Register a descriptor (category 'quality', cost 'github-light', requires ['files','github-token','head-sha']) in review-enrichment/src/analyzers/registry.ts with inline render()
  • Add review-enrichment/test/exhaustiveness-drift.test.ts covering an uncovered added member flagged, a fully-covered switch not flagged, the fetch cap, and the token-absent skip

References

  • review-enrichment/src/analyzers/doc-comment-drift.ts (github-light 'fetch changed file at headSha then parse' template)
  • review-enrichment/src/analyzers/registry.ts:373-392 (docCommentDrift descriptor)
  • gh issue 1499 lists 'Enum/literal-union exhaustiveness drift' as a later idea

Part of #1499.


size: S · gittensor:feature

Metadata

Metadata

Assignees

No one assigned

    Labels

    gittensor:featureGittensor-scored feature linked to a feature issue — scores a 0.25x multiplier.help wantedExtra attention is needed

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions