Skip to content

feat: add generated-code leakage detector - #340

Open
AAH20 wants to merge 1 commit into
ColumbusLabs:mainfrom
AAH20:feat/generated-code-leakage-detector
Open

feat: add generated-code leakage detector#340
AAH20 wants to merge 1 commit into
ColumbusLabs:mainfrom
AAH20:feat/generated-code-leakage-detector

Conversation

@AAH20

@AAH20 AAH20 commented Aug 18, 2026

Copy link
Copy Markdown

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

  • Path-based detection (confidence 0.85): catches imports whose specifier contains known generated/test path segments: __generated__/, __mocks__/, __tests__/, __snapshots__/, __fixtures__/, fixtures/, test-utils/, testing/, .fixtures/, .mocks/, and file suffixes .mock.*, .generated.*.
  • Content-based detection (confidence 0.75): resolves the import target and checks for @generated or AUTO-GENERATED markers in the first 500 characters.
  • Exclusion guard: test files (.test.*, .spec.*, .stories.* and files inside test directories) are never flagged — these are expected to consume fixtures.

Pack membership

Added to core and ai-assisted-maintainer packs, since this debt pattern is common in all TS/JS codebases and especially prevalent in AI-assisted development.

Rule ID

generated-code-leakage

Tests

12 test cases covering:

  • Positive: __generated__, __mocks__, __fixtures__, fixtures/, .mock.ts, @generated header
  • Negative: test files importing fixtures, normal imports, bare (non-relative) imports, files without markers

Validation

npx tsx --test tests/detectors/generatedCodeLeakage.test.ts
# 12 pass, 0 fail

Existing detector tests (storyOnlyComponent, deadAbstraction) pass unchanged.

Closes #313

Made with Cursor

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>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Generated-code leakage detector (production importing generated/test fixtures)

1 participant