fix(anthropic): exclude sibling directories from grep search scope - #39681
Merged
ccurme (ccurme) merged 2 commits intoAug 18, 2026
Merged
Conversation
Lingjin (Haaaarry)
requested review from
ccurme (ccurme) and
Mason Daugherty (mdrxy)
as code owners
August 17, 2026 02:34
This comment has been minimized.
This comment has been minimized.
ccurme (ccurme)
approved these changes
Aug 18, 2026
29 tasks
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.
Fixes #39679
StateFileSearchMiddleware._handle_grep_searchscoped a search with a rawstartswithcheck, so a file under a sibling directory that shares the scope prefix (for example/app-secret/creds.txtwhen scoped to/app) was included in the results. This disagreed with_handle_glob_search, which already enforces a segment boundary.The grep lookup now uses the same segment-aware boundary: a file is in scope when the base path is
/, when it is the base path itself, or when it lives directly underbase_path/. Sibling directories that merely share the prefix are excluded, matching_handle_glob_search.Added a unit test covering a sibling directory that shares the scope prefix.
Release note
grep_searchin the Anthropic file-search middleware now respects the directory boundary of itspathargument and no longer returns files from sibling directories that merely share the path prefix.This contribution was prepared with AI assistance.