Skip to content

fix: ignore Rust target/ build directory during file collection (#2374) - #2511

Open
carlos-alm wants to merge 1 commit into
mainfrom
fix/issue-2374-ignore-dirs-target
Open

fix: ignore Rust target/ build directory during file collection (#2374)#2511
carlos-alm wants to merge 1 commit into
mainfrom
fix/issue-2374-ignore-dirs-target

Conversation

@carlos-alm

Copy link
Copy Markdown
Contributor

Summary

Neither IGNORE_DIRS (TypeScript, src/shared/constants.ts) nor its mirror DEFAULT_IGNORE_DIRS (Rust, crates/codegraph-core/src/domain/graph/builder/stages/collect_files.rs) skipped Cargo's target/ build output directory. For any non-trivial Rust project this directory can be enormous, and codegen tools (bindgen, prost, tonic-build, etc.) emit real, syntactically valid .rs files into OUT_DIR under target/ — codegraph's file walk was parsing these as hand-written project source, polluting the graph and adding real walk-time cost.

Added "target" to both lists, keeping the dual-engine mirroring convention intact.

Verification

  • lint: pass
  • tests: pass (full JS suite: 328 files / 5287 tests; full Rust suite: 1024 tests)
  • Added unit coverage: shouldIgnore('target') + IGNORE_DIRS membership (TS), an end-to-end collectFiles() walk test with a target/debug/build.rs fixture (TS), and a collect_skips_target_dir test mirroring the existing collect_skips_ignored_dirs pattern (Rust)

Closes #2374

docs check acknowledged: small ignore-list addition, no doc updates needed.
@greptile-apps

greptile-apps Bot commented Aug 15, 2026

Copy link
Copy Markdown
Contributor

Greptile Summary

Adds Cargo’s target/ directory to the default ignore sets for both collection engines.

  • Keeps the TypeScript and Rust file collectors behaviorally aligned.
  • Adds TypeScript and Rust coverage confirming generated files beneath target/ are excluded from full collection.

Confidence Score: 5/5

The PR appears safe to merge.

No blocking failure remains.

Important Files Changed

Filename Overview
crates/codegraph-core/src/domain/graph/builder/stages/collect_files.rs Adds target to the Rust collector’s mirrored default ignore list and verifies full collection skips that directory.
src/shared/constants.ts Adds target to the TypeScript default ignore set, matching the Rust engine.
tests/unit/builder.test.ts Extends the collection fixture and verifies files beneath target/ are excluded.
tests/unit/constants.test.ts Verifies target belongs to the ignore set and is recognized by shouldIgnore.

Reviews (2): Last reviewed commit: "fix: ignore Rust target/ build directory..." | Re-trigger Greptile

Comment thread src/shared/constants.ts
'venv',
'env',
'.env',
'target',

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Incremental collection retains target files

When an existing graph contains files under target/ and the next build uses incremental collection, the fast path reconstructs its file set without applying this new default ignore, causing generated Rust files to remain in the graph until a full rebuild invalidates them.

Knowledge Base Used:

Fix in Claude Code

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Confirmed — this is real, but it's a general characteristic of the incremental fast path (tryFastCollect/try_fast_collect), not something specific to target: neither engine's fast path re-applies IGNORE_DIRS/DEFAULT_IGNORE_DIRS at all, so any file already in file_hashes from a prior build survives incremental rebuilds regardless of which ignore-dir entry would now exclude it. Fixing that means changing the fast path for every ignore-dir entry, which is out of scope for this PR. Filed as #2512 to track separately. Existing graphs self-heal via the documented --no-incremental full rebuild in the meantime.

@carlos-alm

Copy link
Copy Markdown
Contributor Author

@greptileai

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.

IGNORE_DIRS / DEFAULT_IGNORE_DIRS never skip Rust's target/ build directory

1 participant