fix(engine): scope Ruby test globs to spec/ and test/ directories - #80
Merged
Conversation
`**/*_spec.rb` and `**/*_test.rb` sat in both config.Default().Ignore and .TestGlobs, matching on the basename alone. Any production file ending in the token `_test` or `_spec` -- an A/B-test job, a load-test harness -- was excluded from indexing AND routed to reference-only test-ref extraction, so the class it declared never became a symbol fact. The failure was silent and asymmetric: enola removed a right fact rather than adding a wrong one, so no downstream finding looked suspicious, and dead-code, impact and performance analysis were all quietly wrong for that file. A file is now a Ruby test iff its basename ends `_spec.rb`/`_test.rb` AND some directory segment is exactly `spec` or `test`. No filename-only rule works: `foo_test.rb` (a test) and `ab_test.rb` (production) both end in the token `test`. Ruby settles it by convention -- RSpec requires spec/, Minitest defaults to test/. Expressing that needed a pattern form the matcher lacked, so matchAnyGlob gained `<prefix>/**/<fileglob>` via matchDirScopedGlob. It fires only on a literal "/**/" in the pattern, which no shipped pattern contains, so existing globs are untouched. isIgnored was a token-identical copy of matchAnyGlob and now delegates to it -- one matcher is what keeps Ignore and TestGlobs from disagreeing about a file, which is the drift that caused this bug. Both lists change together: narrowing one alone leaves the file either still ignored or still misrouted. Go and TypeScript keep their filename patterns; those languages genuinely co-locate tests. The bundled mcp-arch.yaml and examples/*.yaml ignore blocks are updated in step, since a YAML `ignore:` replaces the default wholesale and none of them declares `test_globs:`. cacheVersion v96 -> v97: the file set reaching the extractor changes, so cached snapshots must re-extract.
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.
**/*_spec.rband**/*_test.rbsat in both config.Default().Ignore and .TestGlobs, matching on the basename alone. Any production file ending in the token_testor_spec-- an A/B-test job, a load-test harness -- was excluded from indexing AND routed to reference-only test-ref extraction, so the class it declared never became a symbol fact. The failure was silent and asymmetric: enola removed a right fact rather than adding a wrong one, so no downstream finding looked suspicious, and dead-code, impact and performance analysis were all quietly wrong for that file.A file is now a Ruby test iff its basename ends
_spec.rb/_test.rbAND some directory segment is exactlyspecortest. No filename-only rule works:foo_test.rb(a test) andab_test.rb(production) both end in the tokentest. Ruby settles it by convention -- RSpec requires spec/, Minitest defaults to test/.Expressing that needed a pattern form the matcher lacked, so matchAnyGlob gained
<prefix>/**/<fileglob>via matchDirScopedGlob. It fires only on a literal "/**/" in the pattern, which no shipped pattern contains, so existing globs are untouched. isIgnored was a token-identical copy of matchAnyGlob and now delegates to it -- one matcher is what keeps Ignore and TestGlobs from disagreeing about a file, which is the drift that caused this bug. Both lists change together: narrowing one alone leaves the file either still ignored or still misrouted.Go and TypeScript keep their filename patterns; those languages genuinely co-locate tests. The bundled mcp-arch.yaml and examples/*.yaml ignore blocks are updated in step, since a YAML
ignore:replaces the default wholesale and none of them declarestest_globs:.cacheVersion v96 -> v97: the file set reaching the extractor changes, so cached snapshots must re-extract.