refactor(natives): split grep and fs_cache into responsibility modules - #2206
Merged
Conversation
…submodules Replace the mechanical include!(part_NN.rs) splicing in grep.rs and fs_cache.rs with real mod submodules wired through use/pub use, matching the subagent_control convention. grep keeps every #[napi] item plus shared vocabulary (OutputMode, SearchParams, GrepConfig, DEFAULT_NATIVE_GREP_MAX_COUNT, empty_search_result) in the parent and delegates to: - pattern: regex hygiene + matcher construction (with sanitization tests) - engine: per-buffer search engine + match collection - fs: file reading + candidate filtering - walk: directory traversal orchestration - output: result shaping + aggregation - run: sync entry points + option resolution (with integration tests) fs_cache keeps its #[napi] items and shared ScanDetail/ScanOptions in the parent, re-exports the existing public surface unchanged, and delegates to: - policy: env-tunable cache/worker policy - paths: path resolution + metadata classification - walker: parallel walk + entry collection - cache: TTL cache, epochs, invalidation - test_util: shared TempDirGuard/make_fifo test helpers Item visibility widens only where the new module boundaries require (pub(super)); function bodies are moved, not rewritten. cache.rs now calls the already-public cache_ttl_ms()/max_cache_entries() accessors instead of dereferencing the policy statics across the module boundary. The generated N-API surface (packages/natives/native/index.d.ts, index.js) is verified byte-identical. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Promote build_matcher to pub in grep::pattern and re-export it with pub use from grep.rs, matching the fs_cache and subagent_control module convention. grep_sync/search_sync stay module-private because their signatures carry the private GrepConfig type. No N-API surface or runtime behavior change.
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.
Splits the
grepandfs_cachenative modules into responsibility-named submodules, matching thesubagent_controlconvention already used incrates/atomic-natives.The mechanical
part_NN.rsline-count splits and theirinclude!(...)splicing are replaced with realmodsubmodules plus explicituse/pub usewiring.Pure reorganization: the generated N-API surface in
packages/natives/native/is unchanged, verified withgit diff --exit-codeafter a native rebuild.Commits:
f899beb refactor(natives): re-export grep submodule surface from grep.rs
5c1700d refactor(natives): split grep and fs_cache into responsibility-named submodules
Need help on this PR? Tag
@codesmith-botwith what you need. Autofix is disabled.Greptile Summary
This change replaces generated source-fragment inclusion with named Rust submodules for native grep and filesystem-cache behavior while retaining the existing crate and N-API interfaces.
The compiled native addon was built from both the pre-change and updated revisions. The same runtime checks exercised
search,hasMatch, filesystemgrep, andinvalidateFsScanCache; both revisions returned identical normalized results. The observed filesystem search totals changed from1to2only after explicit cache invalidation, as expected.Confidence Score: 5/5
What T-Rex did
Reviews (1): Last reviewed commit: "refactor(natives): re-export grep submod..." | Re-trigger Greptile