fix(search): bounded, fail-closed search_files fallbacks with shared engine/ordering policy (salvage #97770) - #101714
Merged
kshitijk4poor merged 19 commits intoSep 2, 2026
Conversation
kshitijk4poor
enabled auto-merge (rebase)
September 2, 2026 23:22
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
search_filesgets a bounded, fail-closed fallback path whenrgis unavailable or a probe finds nothing: a sharedagent/search_policy.pydecides engine + ordering, filename walks are serialised per root, heavy trees are pruned from the zero-match probe, and the Windows/findfallback normalises its paths — so no-rghosts stop burning CPU on concurrent unbounded walks.Salvaged from #97770 by @royalaid (all 19 commits cherry-picked, authorship preserved) onto current
main; every conflict was import-line merging against #95160/#95940 which landed first.Who hits this / when / why it matters
Installs without
rg(Windows without Git-for-Windows extras, minimal containers) and any host where a filename search walks a large tree: the previous fallbacks ran unboundedfindwalks concurrently per call and could return partial results silently on error.What changed (19 commits, on-topic per-commit — search ordering / fallback / interrupt)
agent/search_policy.py(new): engine selection + "fast discovery" file ordering, shared by the tool and the code sandbox.tools/file_operations.py: fallback scans unified and fail-closed (partial errors rejected, explicit roots preserved), boundedrgSIGPIPE accepted, root options terminated, dash-prefixed and macOS-glob roots handled, filename walks serialised by root, admission-cancellation race closed.agent/subdirectory_hints.py: heavy trees pruned from the zero-match probe.test_search_files_engine_selection.py,test_search_files_cpu_windows.py(new) + interrupt-publisher hardening.Verification
test_file_ops_single_roundtrip,edge_cases,read_unicode_filename_retry): 370 passed, 8 skipped; ruff clean.main):read_filebench unchanged (2 MB page 1 → 1 exec / 84 ms), native≡shell parity harness 20/20 identical.main): its--max-columnshunks are outside this PR's ranges; both apply.findfallbacks) was not reproducible on macOS in the triage window; the fail-closed/bounded behaviour is verified by the new tests.Provenance
Salvaged from #97770 by @royalaid — 19 commits cherry-picked with authorship preserved (noreply email). My only changes are the import-line conflict resolutions inside the cherry-picks.