Skip to content

fix(runtime): prune heavy directories in grep_search - #3388

Open
b84330808 wants to merge 1 commit into
ultraworkers:mainfrom
b84330808:fix-grep-skip-heavy-dirs
Open

b84330808 wants to merge 1 commit into
ultraworkers:mainfrom
b84330808:fix-grep-skip-heavy-dirs

Conversation

@b84330808

Copy link
Copy Markdown

Summary

  • grep_search walks and reads every file under its root, including .git, node_modules and target. glob_search already prunes these directories (runtime: prune heavy directories during glob searches #2986), and docs/g002-security-verification-map.md says both search tools do.
  • In a Rust checkout that has been built, one grep_search call spends nearly all its time reading target/.
  • Fix: grep_search now uses the same pruning as glob_search. The search root itself is never pruned, so a search the caller points into node_modules or target still works. That also fixes glob_search, which currently returns nothing when its walk root is one of these directories.

Measured on Windows 11 with a release build calling grep_search_in_workspace (pattern fn edit_file, files_with_matches) at the root of a claw-code checkout whose rust/target holds 2.5 GB / 4,327 files from cargo test -p runtime -p tools. There were 568 other files. Base and patched binaries ran alternately for 6 rounds of 3 calls each, with a warm file cache:

median range files found
base 2262 ms 2141 to 3278 ms 1
patched 126 ms 111 to 138 ms 1

Anti-slop triage

  • Classification: actionable-fix
  • Evidence: new test grep_search_skips_common_heavy_directories and a new assertion in glob_search_skips_common_heavy_directories. Before the fix grep returns 4 files (.git, node_modules, target and src) where 1 is expected, and a glob rooted in node_modules returns 0 files where 1 is expected. Both pass after the fix.
  • Non-destructive review result: merge candidate

Verification

  • Targeted tests/docs checks ran, or the gap is explicitly recorded. (cargo test -p runtime, cargo clippy -p runtime --all-targets -- -D warnings, cargo fmt --all --check, on Windows 11; the full workspace suite was not run locally)
  • git diff --check passes.
  • No live secrets, tokens, private logs, or unrelated generated churn are included.

Resolution gate

  • If this PR resolves an issue, the issue number and fix evidence are linked. (no issue filed)
  • If this PR should not merge, the rejection/defer rationale is evidence-backed and does not rely on vibes.
  • I did not merge/close remote PRs or issues from an automation lane without owner approval.

Compatibility: a grep_search from a parent directory no longer reports matches inside .git, node_modules, .build, target, dist or coverage. This matches glob_search.

grep_search walked and read every file under its root, including .git,
node_modules and target. glob_search already prunes these directories
(ultraworkers#2986), and docs/g002-security-verification-map.md says both search tools
do. In a Rust checkout with a 2.5 GB target/ directory, one grep_search
call took about 2.3 s instead of about 0.13 s, with the same results.

Use the same pruning for grep_search, and never prune the search root
itself, so a search the caller points into node_modules or target still
works for both tools.
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.

1 participant