feat: add generated-code leakage detector - #340
Open
AAH20 wants to merge 1 commit into
Open
Conversation
Flags production source files that import from generated, mock, fixture, or test directories (__generated__, __mocks__, __fixtures__, fixtures/, test-utils/, .mock.ts, .generated.ts) and files with @generated headers. - Path-based detection (high confidence 0.85) for known generated/test directory patterns and file suffixes - Content-based detection (confidence 0.75) for @generated markers in the first 500 chars of resolved import targets - Excludes test files (.test, .spec, .stories, __tests__/) from flagging - Added to core and ai-assisted-maintainer packs - 12 test cases covering positive detections and false-positive guards Closes ColumbusLabs#313 Co-authored-by: Cursor <cursoragent@cursor.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Implements the generated-code leakage detector requested in #313.
Flags production source files that import from generated, mock, fixture, or test directories — the defining failure mode of AI-scaffolded codebases where a mock or fixture import leaks into the production bundle.
Detection strategy
__generated__/,__mocks__/,__tests__/,__snapshots__/,__fixtures__/,fixtures/,test-utils/,testing/,.fixtures/,.mocks/, and file suffixes.mock.*,.generated.*.@generatedorAUTO-GENERATEDmarkers in the first 500 characters..test.*,.spec.*,.stories.*and files inside test directories) are never flagged — these are expected to consume fixtures.Pack membership
Added to
coreandai-assisted-maintainerpacks, since this debt pattern is common in all TS/JS codebases and especially prevalent in AI-assisted development.Rule ID
generated-code-leakageTests
12 test cases covering:
__generated__,__mocks__,__fixtures__,fixtures/,.mock.ts,@generatedheaderValidation
Existing detector tests (
storyOnlyComponent,deadAbstraction) pass unchanged.Closes #313
Made with Cursor