Skip to content

fix(scanner): Track Rust embedded file dependencies - #142

Merged
JordanCoin merged 2 commits into
JordanCoin:mainfrom
reneleonhardt:fix/rust-embedded-file-dependencies
Aug 27, 2026
Merged

fix(scanner): Track Rust embedded file dependencies#142
JordanCoin merged 2 commits into
JordanCoin:mainfrom
reneleonhardt:fix/rust-embedded-file-dependencies

Conversation

@reneleonhardt

Copy link
Copy Markdown
Contributor

What does this PR do?

Record dependencies from literal Rust include_str! and include_bytes! calls. Resolve relative paths only when the exact target is uniquely indexed in the repository; leave dynamic, missing, external, excluded, ambiguous, self, and include! targets unresolved.

Type of change

  • Bug fix

Verification

  • Focused tests cover literal and raw strings, dynamic, missing, external, excluded, ambiguous, and self targets.
  • go vet ./...
  • go test ./...

Resolve literal include_str! and include_bytes! targets through the configured exact-file index while preserving conservative include! behavior.

Co-Authored-By: GPT-5.6 Sol <codex@openai.com>

Copy link
Copy Markdown
Owner

Reviewed in depth (adversarial pass with end-to-end probes on the PR head). The rule scoping is solid — concat!/env! args correctly yield nothing, raw strings parse right, traversal/self-includes are guarded, suite is green. Two blocking items before this lands, both small:

1. BLOCKING — phantom edge: the resolver's uniqueness check accepts extension-stripped index keys

resolveRustEmbeddedFile uses a bare len(idx.byExact[target]) != 1, but buildFileIndexContext also indexes every file under its extension-stripped key. Demonstrated end-to-end: a repo with src/shader.wgsl.tmpl (checked in) and no src/shader.wgslinclude_str!("shader.wgsl") resolves and the graph gains src/lib.rs → src/shader.wgsl, a file that doesn't exist on disk. Same pattern for .license, .in, .orig siblings.

Fix is the idiom your own sibling functions already use (resolveRustInclude documents this exact hazard): count entries equal to target and require exactly 1. That also fixes the inverse miss (real data.txt unresolvable because data.txt.license exists). Please also restore the TestResolveRustIncludeRequiresRealIndexedFile regression test this PR removed — it was the guard for precisely this class — and add the embedded-file analog.

2. BLOCKING — rust-embedded-file-imports missing from the Imports-append exclusion list

scanner/astgrep.go excludes rust-path-imports, rust-askama-template-imports, and rust-cargo-rerun-imports from the raw imports array, but not the new kind — so asset paths like data.txt land in the versioned payload and feed --diff's basename fuzzy matching (a change to unrelated docs/data.md would falsely count the including file as impacted). Same invariant #127 settled. Add the exclusion and drop the two asset entries from the test's imports expectation (the test currently asserts the leak).

Nits (non-blocking)

Rebase note

#143 and #144 just merged; this branch auto-merges cleanly with the new main (verified with real three-way merges — your astgrep.go/rustgraph.go hunks don't overlap #143's), so a plain rebase or merge of main should be conflict-free. Re-run the suite after; with the two fixes above this is ready to land.


Generated by Claude Code

@reneleonhardt

Copy link
Copy Markdown
Contributor Author

Complied

  • Require an exact indexed path, preventing phantom embedded-file edges.
  • Restored the real-file include regression and added the embedded-file equivalent.
  • Excluded rust-embedded-file-imports from raw imports.
  • Updated expectations and closed the actual scanner instance.

Not fully complied

@JordanCoin
JordanCoin merged commit df06ce0 into JordanCoin:main Aug 27, 2026
12 checks passed
@reneleonhardt
reneleonhardt deleted the fix/rust-embedded-file-dependencies branch August 27, 2026 05:58
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.

2 participants