🔤 fix: Stabilize Truncated Workspace Search Results - #109
Merged
Conversation
…ministic `list_files` passes `--sort path`; the search candidate listing did not, so ripgrep's parallel directory walk decided the order. Two consequences: search results came back in filesystem-dependent order, and - the part that matters - when the candidate limit or maxResults truncates, *which* files get searched was arbitrary, so a bounded search could silently return different matches on identical input. `search decodes BOM-marked UTF-16 text` asserts a fixed order and fails 12/12 on ext4 with ripgrep 13.0.0; it passes only where the walk happens to emit sorted order. Sorting the candidates matches list_files and makes the bound reproducible: 0/10 failures after. Sorting disables ripgrep's parallel walk, but the cost is immaterial against the 10s search budget: 16ms versus 8ms over a 4,856-file tree, the same tradeoff list_files already makes.
Collaborator
Author
|
@codex review |
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
|
Codex Review: Didn't find any major issues. More of your lovely PRs please. Reviewed commit: ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
If Codex has suggestions, it will comment; otherwise it will react with 👍. Codex can also answer questions or update the PR. Try commenting "@codex address that feedback". |
dustinhealy
approved these changes
Sep 4, 2026
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.
Problem
Found while standing up CI for
packages/code.list_filespasses--sort pathto ripgrep; thesearch_textcandidate listing does not. Ripgrep's parallel directory walk therefore decides the order — and, more importantly, which files survive truncation whenMAX_SEARCH_CANDIDATESormaxResultsbites. A bounded search can silently return different matches for identical input.The existing test
search decodes BOM-marked UTF-16 textasserts a fixed result order and fails 12/12 on ext4 with ripgrep 13.0.0:It passes only where the walk happens to emit sorted order, which is why this went unnoticed on macOS.
Fix
Sort the candidate listing, exactly as
list_filesalready does.Verification
main(61 tests, 60 pass, 1 skipped).list_filesalready makes.Sorting after collection was considered and rejected: truncation happens during collection, so it would fix result order while leaving which files get searched arbitrary — the actual defect.
Scope
One flag. No protocol change, no new dependencies.