Skip to content

fix(rust): name the unresolved #[path] a changed file is only reached through (#4435) - #4906

Merged
EffortlessSteven merged 4 commits into
mainfrom
claude/rust-module-graph-7ija8k
Oct 1, 2026
Merged

EffortlessSteven merged 4 commits into
mainfrom
claude/rust-module-graph-7ija8k

Conversation

@EffortlessSteven

Copy link
Copy Markdown
Member

Summary

Before: take a changed Rust file whose only route into its crate is a mod with an unresolved #[path] target, such as #[cfg_attr(unix, path = "platform/unix_impl.rs")] mod sys;. That file got no module context. On a fixture where an integration test calls it through the public API, ripr reported three no_static_path findings, and the run still read as complete_with_findings with no limitations. The only trace was the stderr rust_module_unresolved_target note.

After: the run adds one language_scope_unsupported limitation for that file. The limitation names the file and the declaration (the mod at src/lib.rs:3), so the outcome reads partial_with_limitations. The file still seeds, and its findings are not reclassified.

How:

  • The module-tree scan now reports, for an out-of-line mod with an unresolved #[path], the literal path = "..." targets its attributes spell. It also records whether default resolution still applies, which is the case when every path is inside cfg_attr.
  • When no resolved edge reaches a changed file, the owners' exhausted package walks check whether one of those declarations routes to it: directly, through the target's children, or by default resolution (sys.rs).
  • The diff run emits the limitation only for such files that produced a finding.

Swarm / Source Boundary

  • ordinary feature, analyzer, editor, docs, spec, fixture, badge, dependency, or repo-ops development for ripr-swarm

Source-of-truth Links

Governing issue or accepted claim: #4435 (follow-up the UX grind asked for, after #4802)
Acceptance delta (one sentence): A changed file reached only through an unresolved #[path] makes the run partial and names the declaration; runs that change files reached through resolved edges are unchanged.

Candidate Relationships

Candidate branch: claude/rust-module-graph-7ija8k. It was restarted from main 636d353, after #4556 was closed and its content landed as #4802. No other open PR covers this.

Scope

  • One production behavior: Rust diff limitations for changed files routed only through unresolved #[path] declarations.

Production delta:

  • module_tree.rs: new RustModuleTreeEdge::UnresolvedPath { inline, name, line, candidates, default_applies }. The scan stays incomplete, so no orphan verdict changes.
  • module_graph.rs: package walks record unresolved declarations. When a candidate is reached by no resolved edge, a reusable route walk per declaration decides whether it reaches the file. Route walks follow further unresolved targets; package walks never do.
  • source_role.rs: SourceRoleContext::module_graph_unresolved_routes.
  • rust/mod.rs: unresolved_route_limitations, limited to files whose probes became findings. Both limitations bound their paths so the recovery text stays under the 512-character cap.

Evidence/support delta:

  • Scan test: cfg_attr targets, including one nested in another cfg_attr and one written as a raw string; a cfg predicate's feature = "..." is not taken as a target. Also covers duplicate #[path] (no default resolution), concat! (no targets) and an inline-nested declaration.
  • Walk test: the spelled target, its child and the default sys.rs map to src/lib.rs:3. A resolved module, a file never loaded because a plain #[path] always applies, and an unnamed stray file are not routes, and no orphan is recorded.
  • Diff test: src/platform/unix_impl.rs gets the limitation. The resolved src/used.rs does not, nor does the comment-only change to src/sys.rs.
  • A long-path test: the recovery text stays bounded.

Single acceptance criterion:

  • Only changed files whose findings come from a file routed solely through an unresolved #[path] add a limitation.

Non-goals:

  • Resolving cfg_attr paths into module context. That is the index's job, and fixing the underlying no_static_path is separate.
  • Files reached only through cfg_if! or macro-emitted declarations.
  • A fully dynamic #[path = concat!(..)], which spells no target.
  • Declarations in another package that reach across into this one.

Support-tier Impact

  • none

Claim/proof notes:

  • The UX-grind ask was not to degrade unrelated runs; an earlier broad fix was dropped because it flipped receipts, pr-summary and LSP to incomplete. This limitation is per changed file and per finding, not keyed on any Unknown target in the index. It adds no new eprintln, and the LSP partition is unchanged.

  • Real crates from the local cargo registry. I touched every src file with a comment, then made single behaviour changes:

    Crate Change Result
    errno 0.3.14 src/unix.rs behaviour change limitation (routed via lib.rs mod sys;)
    errno 0.3.14 lib.rs behaviour change complete_with_findings, no limitation
    rustix 1.1.5 src/fs/abs.rs complete, no limitation
    rustix 1.1.5 src/backend/linux_raw/fs/dir.rs limitation
    libc, serde, serde_core, icu_provider, icu_collections all-files comment touch no new limitations
  • rustix's whole backend tree enters through one cfg_attr mod backend;. Every backend behaviour change now reads partial, which is accurate because ripr has no module context for those files.

Policy Impact

  • none

Proof

cargo xtask precommit                                   # exit 0
cargo clippy -p ripr  --all-targets -- -D warnings      # exit 0
cargo clippy -p xtask --all-targets -- -D warnings      # exit 0
cargo test -p ripr --lib                                # 6963 passed, 3 failed (see below)

Result, failures, or skipped proof:

  • Discrimination:
    • With route recording disabled, the walk test and the diff test both fail.
    • With the findings-only filter removed, the diff test fails with ["src/platform/unix_impl.rs", "src/sys.rs"].
  • The 3 local failures are unwritable_* output-dir tests. They fail because this sandbox runs as root, so permission bits do not block writes. They are in output/ and cli/commands/pilot, which this PR does not touch; CI decides them.

Claim Boundary

  • May claim: a run that changes a file routed only through an unresolved #[path] (spelled target, its children, or cfg_attr-only default resolution) reports a limitation naming the declaration.
  • Must not claim: that such files have module context, that their findings are right or wrong, or coverage of macro-declared modules.

Rollback

Revert the squash commit. It adds one limitation shape using an existing kind, with no schema, config or output-contract change.

Spec-Test-Code Traceability

  • Tests:
    • analysis/language/rust/mod.rs: diff_analysis_names_the_unresolved_path_a_changed_file_is_reached_through, unresolved_route_limitation_bounds_long_paths
    • analysis/workspace/module_graph.rs: unresolved_path_routes_name_the_declaration_for_files_only_it_reaches
    • analysis/syntax/module_tree.rs: unresolved_path_declarations_report_the_targets_they_spell
  • Code: the files above plus workspace/source_role.rs and syntax/ra.rs (visibility only).
  • Golden outputs: unchanged.

Static Language Check

  • Static output avoids killed, survived, untested, proven, and adequate.
  • Unknowns include stop reasons where applicable.

Engineering Check

  • No new panic, unwrap, expect, todo, or unimplemented in production code or tests.
  • Public JSON/schema changes are documented. (none)

🤖 Generated with Claude Code

https://claude.ai/code/session_011hoZSKinxoMBpo7Js7zymG


Generated by Claude Code

… through (#4435)

A changed Rust file whose only route into its crate is a `mod` with an
unresolved `#[path]` target (`#[cfg_attr(unix, path = "unix.rs")] mod sys;`)
gets no module context, so its findings can miss related tests, yet the run
read as complete with only a stderr note.

The module-tree scan now reports the literal targets such a declaration
spells, and whether default resolution still applies (every path inside
`cfg_attr`). When no resolved edge reaches a changed file, the owners'
exhausted walks ask whether one of those declarations routes to it
(directly, through the target's children, or by default resolution). The
diff run then adds one `language_scope_unsupported` limitation per such
file that produced a finding, naming the declaration. Files reached through
resolved edges, and comment-only changes, are unchanged.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_011hoZSKinxoMBpo7Js7zymG
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_011hoZSKinxoMBpo7Js7zymG
@gemini-code-assist

Copy link
Copy Markdown

Warning

You have reached your daily quota limit. Please wait up to 24 hours and I will start processing your requests again!

@coderabbitai

coderabbitai Bot commented Sep 29, 2026 •

Copy link
Copy Markdown

Review in Change Stack →

Navigate logical layers of code changes, visualize relationships, and explore their blast radius.

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Advanced

Run ID: be4bd40d-350d-400e-99d2-282cdfb28577

📥 Commits

Reviewing files that changed from the base of the PR and between e7ab89c and 2f058fe.

📒 Files selected for processing (8)
  • .ripr/traceability.toml
  • CHANGELOG.md
  • crates/ripr/src/analysis/language/rust/mod.rs
  • crates/ripr/src/analysis/syntax/module_tree.rs
  • crates/ripr/src/analysis/syntax/ra.rs
  • crates/ripr/src/analysis/workspace/module_graph.rs
  • crates/ripr/src/analysis/workspace/source_role.rs
  • docs/specs/RIPR-SPEC-0153-rust-source-role.md

Included review availability: This review used your included allowance. Your plan provides up to 1 included review per hour; 0 remain after this review.


Summary by CodeRabbit

  • Bug Fixes
    • Changed Rust files that are reachable only through an unresolved #[path] declaration are now included in analysis when possible. If they produce findings, the results report a limitation identifying the file and declaration, noting that related tests may be missing and providing recovery guidance.
    • Files reached through a resolved module path remain unaffected, and no limitation is reported when the file produces no findings.

Walkthrough

The Rust module scan now reports unresolved #[path] candidates. Workspace analysis uses those routes to identify changed files that still seed analysis and reports a limitation when they produce findings.

Changes

Unresolved Rust module paths

Layer / File(s) Summary
Extract unresolved module-path candidates
crates/ripr/src/analysis/syntax/module_tree.rs, crates/ripr/src/analysis/syntax/ra.rs
The module-tree scan records unresolved out-of-line #[path] declarations, literal targets from cfg_attr, and whether default resolution applies.
Track candidate reachability and declarations
crates/ripr/src/analysis/workspace/module_graph.rs, crates/ripr/src/analysis/workspace/source_role.rs
Workspace walks follow unresolved candidates and descendants, record declaration locations, and omit unresolved-route results when resolved paths reach a candidate.
Report limitations for changed files with findings
crates/ripr/src/analysis/language/rust/mod.rs, docs/specs/RIPR-SPEC-0153-rust-source-role.md, .ripr/traceability.toml, CHANGELOG.md
Rust analysis adds a bounded-path limitation for changed files with findings and unresolved routes. Tests and supporting records describe the behavior and its cases.

Priority: ⬇️ Low

Estimated code review effort: 3 (Moderate) | ~25 minutes

Change: Bug fix

Sequence Diagram(s)

sequenceDiagram
  participant ModuleTreeScan
  participant PackageWalk
  participant SourceRoleContext
  participant RustAnalysis
  ModuleTreeScan->>PackageWalk: unresolved path candidates
  PackageWalk->>SourceRoleContext: candidate paths and declaration locations
  RustAnalysis->>SourceRoleContext: look up routes for changed files with findings
  SourceRoleContext-->>RustAnalysis: unresolved route and declaration
  RustAnalysis->>RustAnalysis: add language-scope limitation
Loading

Merge Risk: ⚪ Minimal · up to 2f058

The change reports incomplete Rust module-path coverage without reclassifying findings. No concrete merge-blocking issue is established; merge after normal checks pass.

Security Architecture Review

Security architecture risk: 🔵 Low · up to 2f058

The change exposes incomplete Rust analysis without changing its findings. It reads additional candidate files using existing filesystem permissions. No increased privilege or introduced security vulnerability was established, but runtime isolation and coverage edge cases remain uncertain.

Retained concerns
No architecture-level concerns identified.

Security review details

Security Blast Radius

  • inferred — A repository author controlling module attributes can influence speculative reads, including reads outside the workspace under the analyzer process's existing permissions. The maximum filesystem authority already existed through resolved path and include declarations. Isolation from other tenants, credentials or host assets cannot be determined from the supplied deployment evidence.

Security Findings and Attack Paths

  • inferred — The concrete source-to-sink path is attribute literal, candidate target, route traversal, then filesystem read and syntax scan. This expands which inputs are read, but the inspected attribution output carries declaration identity rather than raw source contents. No newly introduced execution, privilege acquisition or secret-exfiltration path was established.

Trust Boundaries and Controls

  • inferred — The new warning is not an authoritative proof of complete module context. Its suppression scan accepts resolved edges from every listed Rust file without proving that the declaring file belongs to a compiled target. A stray file can therefore suppress an unresolved-route warning. This leaves a disclosure gap rather than worsening the base behavior, which emitted no such warning.

Resilience and Maintainability Implications

  • observed — An unreadable listed Rust file aborts the resolved-edge suppression scan, so a valid resolved route elsewhere may not suppress the warning. This is conservative reporting rather than an ownership bypass. The supplied tests cover ordinary unresolved descendants and legitimate sibling-package suppression, but do not establish these partial-error and stray-file cases.

Hardening Proposals

  • proposed — Consider explicit allowed external-source roots and regular-file or byte limits for speculative reads, preserving intentional external modules while documenting the required isolation boundary. This would harden inherited filesystem access, not remediate a verified vulnerability introduced by this PR.
🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly and concisely describes the main change: naming the unresolved #[path] route for affected changed files.
Description check ✅ Passed The description is detailed, relevant, and covers the change, scope, evidence, proof results, claim boundary, rollback, and traceability. It omits some template sections, including Scope Classificatio…
Docstring Coverage ✅ Passed Docstring coverage is 83.87% which is sufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 31 functions across 5 files. (3 skipped: 3 …
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches 💡 1
📝 Generate docstrings
  • Commit to this branch
  • Create a new PR
🧪 Generate unit tests (beta)
  • Commit to this branch
  • Create a new PR
🛠️ Fix failing CI checks 💡
  • Commit to this branch
  • Create a new PR
  • Autopilot · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Autopilot is currently an internal CodeRabbit preview.


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

A rabbit checks each module trail
It finds a path that cannot resolve
It marks the file and line with care
When findings bloom, the note appears
Clear bounded paths complete the tale

Comment @coderabbitai help to get the list of available commands.

@EffortlessSteven
EffortlessSteven marked this pull request as ready for review September 29, 2026 09:54
@gemini-code-assist

Copy link
Copy Markdown

Warning

You have reached your daily quota limit. Please wait up to 24 hours and I will start processing your requests again!

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Sep 29, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-09-29T09:58:54.327531Z 1244494 Draft marked ready
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@devin-ai-integration devin-ai-integration Bot left a comment

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.

Devin Review found 3 potential issues.

Devin Review

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 12444945dd

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

…4435)

- Parse cfg_attr structurally: only attributes it introduces after the
  predicate supply targets, so a custom cfg keyed `path` is not one.
- Keep two declarations on one line distinct (dedupe on name too), and
  merge a second anchor's default targets into the same declaration.
- `cfg_attr` paths under `p` and `not(p)` always apply, so default
  resolution is not a route for them.
- A file another package compiles through a resolved `#[path]` or
  `include!` gets no limitation.
- One tagged route walk per package replaces a walk per declaration, so
  the cost stays linear (400 declarations sharing a subtree: 135 s to 0.7 s).
- Name a declaring file outside the workspace by its file name only.
- Register the behavior in RIPR-SPEC-0153 and the traceability map.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_011hoZSKinxoMBpo7Js7zymG
…aph-7ija8k

# Conflicts:
#	CHANGELOG.md
#	crates/ripr/src/analysis/language/rust/mod.rs
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