fix: add main.rs driver to rust dynamic tracer fixture#1877
Conversation
The rust fixture had no main.rs, so trace_rust() failed immediately trying to inject `mod trace_support;` into a nonexistent file. This silently skipped the rust same-file recall assertion in tracer-validation.test.ts as "toolchain not available" even when cargo was installed, masking the fact that the rust dynamic tracer had never actually been exercised. Adds main.rs exercising the full models/repository/service/validator call chain through build_service()/add_user()/get_user()/remove_user() plus a direct_repo_access() helper, and documents the edges it introduces in expected-edges.json (mirroring how the swift/dart/zig fixtures already catalog every call sourced from their own main driver) — precision stays at 100%, recall is 58.3% against a larger, more complete manifest (24 edges vs. 14). Getting the tracer to actually run past the missing file surfaced three more bugs in the same trace_rust() code path that had never been reached before, since compilation was never previously attempted: - The dump_trace() injection used a GNU-only inline `i\text` sed form that BSD sed (macOS) rejects; switched to the portable `i\` + newline form. - The impl-block context regex captured the trait name instead of the concrete type for `impl Trait for Type` blocks, mislabeling e.g. EmailValidator.validate as Validator.validate in the trace output. - trace_support.rs's trace_call() held an immutable borrow from t.stack.last() across mutations of t.seen/t.edges, which doesn't compile under the borrow checker; clones the needed fields out first instead. The fixture itself also never compiled as a real crate: User didn't derive Clone (needed by find_by_id's .cloned()), and service.rs called Repository trait methods on self.repo without importing the trait. Both fixed. Verified end-to-end: native-tracer.sh now compiles and runs, producing 23/24 expected edges (the only miss, User.display_name, is legitimately unreachable since the repo stub's save() never persists into its HashMap). tracer-validation.test.ts's rust case now actually runs (rather than skipping) at 100% same-file recall (7/7) against the 50% threshold. Filed #1876 for the pre-existing static-resolution gap this also confirmed (receiver-typed/trait-dispatch calls through locally-typed variables aren't resolved by either engine). Fixes #1759 Impact: 1 functions changed, 1 affected Impact: 3 functions changed, 2 affected
Greptile SummaryThis PR unblocks the Rust dynamic tracer path by adding the missing
Confidence Score: 4/5Safe to merge; all changes are scoped to test fixtures and the tracer shell script, with the full suite confirmed green. The Rust tracer path is now correctly exercised. The one remaining concern is that the Swift, Dart, Zig, and C# tracer sections still carry the GNU-only i ext inline sed form that was just patched for Rust — on macOS, this silently breaks dump injection for Dart/Zig and would abort the Swift tracer outright (no 2>/dev/null || true guard). This is a pre-existing gap made more visible by the fix landing here. tests/benchmarks/resolution/tracer/native-tracer.sh — the Swift, Dart, Zig, and C# dump-injection sedi calls should receive the same BSD-portable i\ treatment applied to Rust in this PR. Important Files Changed
Sequence Diagram%%{init: {'theme': 'neutral'}}%%
sequenceDiagram
participant main
participant build_service as build_service (service.rs)
participant UserService as UserService (service.rs)
participant UserRepository as UserRepository (repository.rs)
participant create_user as create_user (models.rs)
participant validate_all as validate_all (validator.rs)
participant User as User (models.rs)
participant direct_repo_access as direct_repo_access (main.rs)
main->>build_service: build_service()
build_service-->>main: UserService
main->>UserService: add_user(1, "Alice", ...)
UserService->>create_user: create_user(...)
UserService->>validate_all: "validate_all(&user)"
UserService->>UserRepository: "save(&user)"
UserService-->>main: Ok(())
main->>UserService: get_user(1)
UserService->>UserRepository: find_by_id(1)
UserService-->>main: None (stub never persisted)
Note over main,User: display_name() unreachable at runtime
main->>UserService: remove_user(1)
UserService->>UserRepository: delete(1)
UserService-->>main: bool
main->>direct_repo_access: direct_repo_access()
direct_repo_access->>UserRepository: new()
direct_repo_access->>create_user: create_user(2, "Bob", ...)
direct_repo_access->>validate_all: "validate_all(&user)"
direct_repo_access->>UserRepository: "save(&user)"
%%{init: {'theme': 'base', 'themeVariables': {"darkMode": true, "background": "#0d1117", "primaryColor": "#21262d", "primaryTextColor": "#e6edf3", "primaryBorderColor": "#8b949e", "lineColor": "#8b949e", "textColor": "#e6edf3", "edgeLabelBackground": "#161b22", "actorBkg": "#21262d", "actorBorder": "#8b949e", "actorTextColor": "#e6edf3", "actorLineColor": "#8b949e", "signalColor": "#8b949e", "signalTextColor": "#e6edf3", "noteBkgColor": "#373320", "noteBorderColor": "#d4a72c", "noteTextColor": "#f0e6c0", "labelBoxBkgColor": "#21262d", "labelBoxBorderColor": "#8b949e", "labelTextColor": "#e6edf3", "loopTextColor": "#e6edf3", "activationBkgColor": "#30363d", "activationBorderColor": "#8b949e"}}}%%
sequenceDiagram
participant main
participant build_service as build_service (service.rs)
participant UserService as UserService (service.rs)
participant UserRepository as UserRepository (repository.rs)
participant create_user as create_user (models.rs)
participant validate_all as validate_all (validator.rs)
participant User as User (models.rs)
participant direct_repo_access as direct_repo_access (main.rs)
main->>build_service: build_service()
build_service-->>main: UserService
main->>UserService: add_user(1, "Alice", ...)
UserService->>create_user: create_user(...)
UserService->>validate_all: "validate_all(&user)"
UserService->>UserRepository: "save(&user)"
UserService-->>main: Ok(())
main->>UserService: get_user(1)
UserService->>UserRepository: find_by_id(1)
UserService-->>main: None (stub never persisted)
Note over main,User: display_name() unreachable at runtime
main->>UserService: remove_user(1)
UserService->>UserRepository: delete(1)
UserService-->>main: bool
main->>direct_repo_access: direct_repo_access()
direct_repo_access->>UserRepository: new()
direct_repo_access->>create_user: create_user(2, "Bob", ...)
direct_repo_access->>validate_all: "validate_all(&user)"
direct_repo_access->>UserRepository: "save(&user)"
|
Codegraph Impact Analysis3 functions changed → 2 callers affected across 2 files
|
Summary
tests/benchmarks/resolution/fixtures/rust/had nomain.rs, sonative-tracer.sh'strace_rust()failed immediately on the injection step, before ever reaching compile/run — silently skipped as "toolchain not available" by the consuming test, masking the fact this tracer path had never actually been exercised.main.rsexercising the full models/repository/service/validator chain. Getting it to actually run end-to-end (the issue's real impact concern) surfaced 3 more latent bugs in the same never-exercised path, all fixed as necessary prerequisites: a GNU-only sed form innative-tracer.shthat BSD sed (macOS) rejects, an impl-block context regex that captured the trait name instead of the concrete type forimpl Trait for Type, and the fixture itself never compiling as a real crate (missingClonederive, missing trait import).Closes #1759
Test plan
npm test— full suite green (3519 passed, 0 failed)npm run lint— clean (.rs/.shoutside Biome's scope, no other format gate applies)native-tracer.shnow compiles and runs end-to-end, producing 23/24 expected edges (the one miss is legitimately unreachable at runtime — a repo stub'ssave()never persists into itsHashMap, pre-existing fixture behavior)tracer-validation.test.ts's rust case now actually runs (not skipped) at 100% same-file recall against the 0.5 thresholdresolution-benchmark.test.ts's rust suite: 100% precision, 58.3% recall, both above thresholdsFiled #1876 for a genuinely separate finding surfaced by this work: both engines miss receiver-typed calls on locally-typed variables and trait-dispatch through local variables — confirmed as a real resolution gap, not an engine-parity divergence.
Stacked on #1875 (base branch
fix/issue-1757-token-benchmark-dedupe-persist) — only the rust fixture/tracer diff is this issue's change.