Skip to content

refactor(natives): split grep and fs_cache into responsibility modules - #2206

Merged
flora131 merged 2 commits into
mainfrom
refactor/natives-module-split
Aug 5, 2026
Merged

refactor(natives): split grep and fs_cache into responsibility modules#2206
flora131 merged 2 commits into
mainfrom
refactor/natives-module-split

Conversation

@flora131

@flora131 flora131 commented Aug 5, 2026

Copy link
Copy Markdown
Collaborator

Splits the grep and fs_cache native modules into responsibility-named submodules, matching the
subagent_control convention already used in crates/atomic-natives.

The mechanical part_NN.rs line-count splits and their include!(...) splicing are replaced with real
mod submodules plus explicit use/pub use wiring.

Pure reorganization: the generated N-API surface in packages/natives/native/ is unchanged, verified with
git diff --exit-code after 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


View with [code]smith Autofix with [code]smith
Need help on this PR? Tag @codesmith-bot with 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, filesystem grep, and invalidateFsScanCache; both revisions returned identical normalized results. The observed filesystem search totals changed from 1 to 2 only after explicit cache invalidation, as expected.

Confidence Score: 5/5

T-Rex T-Rex Logs

What T-Rex did

  • T-Rex ran the native export runtime-check script on both the base addon (pre-change) and the HEAD addon (updated) to compare their export surfaces.
  • T-Rex observed consistent results across both runs, including search.matchCount of 2, matching positive and negative hasMatch results, and grep totals progressing 1 → 1 → 2 around cache invalidation, with the same first.txt and second.txt paths and identical normalized runtime output.
  • T-Rex validated that the exercised native export surface and behavior were preserved between the base and HEAD addons.
  • T-Rex captured and documented the exact commands, working directories, and exit codes used for the two runs.

View all artifacts

T-Rex Ran code and verified through T-Rex

Reviews (1): Last reviewed commit: "refactor(natives): re-export grep submod..." | Re-trigger Greptile

flora131 and others added 2 commits August 5, 2026 09:11
…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.
@flora131
flora131 merged commit d84fc43 into main Aug 5, 2026
18 checks passed
@flora131
flora131 deleted the refactor/natives-module-split branch August 14, 2026 01:16
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