Skip to content

fix(rust): relate a sibling-crate test calling Type::method() on an imported type (#4558) - #4897

Merged
EffortlessSteven merged 7 commits into
mainfrom
claude/project-thread-4ws691
Sep 29, 2026
Merged

EffortlessSteven merged 7 commits into
mainfrom
claude/project-thread-4ws691

Conversation

@EffortlessSteven

@EffortlessSteven EffortlessSteven commented Sep 29, 2026 •

Copy link
Copy Markdown
Member

Requested by Steven · project thread

Summary

Before: in tokio-rs/tracing, changing LevelFilter::current in tracing-core never related the tracing-subscriber test that asserts LevelFilter::current(), even with use tracing_core::LevelFilter;. The cross-crate admit (#2972) keys competitors on the bare name current, and tracing-subscriber defines its own SpanStack::current, so it read as a local shadow. The test's oracle was never considered.

After: a call spelled T::name( relates across crates when T is the owner's impl self type and is imported from the owner's crate through its declared dependency name (or spelled dep::T::name(). Only definitions such a call could reach compete: methods of an impl of a type named T, and definitions whose context is not established (trait default methods, blanket or non-path impls, lexical-fallback files). Free functions and other types' same-named methods no longer refuse it. In tracing with --mode deep/ready, the test now relates as direct_owner_call.

How: parser-backed FunctionFacts carry a new impl_context (Free, Impl { self_type }, Unknown), set from the nearest enclosing fn/impl/trait. The ambiguity scan keeps the same-named definitions themselves, and dependency_edge_admits_owner_call tries the type-path rule before the #2972 shadow checks. Declared dependency names are Cargo.toml keys, so - is folded to _ before matching use paths (tracing-core → tracing_core); without that no hyphenated path dependency could ever match an import.

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: #4558
Acceptance delta (one sentence): A sibling-crate test calling Type::method() on the owner's type imported from the owner's crate relates to the changed method unless another definition that call could reach exists.

Candidate Relationships

Candidate branch: claude/project-thread-4ws691 (restarted from main after #4611 merged). Open PRs searched: #4885 (same-method-name on another type, same crate) edits classify/related_tests.rs too but narrows a different relation and does not touch the dependency-edge admit; no equivalent PR. Not module-graph seeding (#4435).

Scope

Non-goals:

  • When the owner's crate imports a same-named type from another crate, or globs in another crate (std/core/alloc and local module globs excepted), the admit refuses rather than resolving which T the path names.
  • Types reached through a re-export (use tracing_subscriber::filter::LevelFilter, the original tracing test): which T a re-export names is not resolved, so that spelling stays refused.
  • --mode draft (default) indexes only the changed packages, so no cross-crate test is visible there; unchanged.
  • In the test's file: type aliases, use … as T, glob imports, turbofish or whitespace spellings: refused.

Support-tier Impact

  • changes a README, release, docs, CLI, JSON, editor, CI, or package claim: CHANGELOG only.

Policy Impact

  • none

Proof

cargo test -p ripr --lib                            # 6692 passed (before the glob-root fix; the 4 type_path_call tests pass after it); 3 unwritable-dir tests fail only because this container runs as root (unrelated to the diff)
cargo clippy -p ripr --all-targets -- -D warnings   # clean
cargo xtask precommit                               # exit 0 (also on the main merge 88a132a; lib tests there: 6908 passed, same 3 root-only failures)

New tests:

  • type_path_call_imported_from_owner_crate_admits_across_crates (import form and crate_a::LevelFilter::current(); declared name crate-a)
  • type_path_call_fails_closed_without_owner_identity: no import, renamed import, glob import, type imported from an unrelated crate, another impl of a same-named type, an Unknown definition, a call on another type, an Unknown owner
  • type_path_call_refuses_foreign_type_names_and_quoted_paths: external same-named re-export, aliased brace import, pub use external::*, use ::external::*, use external::num; use num::*, and a quoted "LevelFilter::current()" beside a real other.current()
  • type_path_call_admits_past_local_and_standard_globs: use core::{num} + use num::* (tracing-core's own shape), mod inner; use inner::*, use std::collections::*
  • impl_context_names_the_self_type_only_for_plain_named_impls (free, module, function-local, fn in a const, inherent, trait impl with qualified self type, generic args, blanket, reference self type, trait default)
  • the admit row also covers let current = LevelFilter::current() and a self:: re-export inside the owner crate

Negative experiments: Unknown treated as unreachable fails the unknown-definition row; ignoring the self type fails the same-named-impl row; unmasked call text fails the quoted row; disabling the owner-crate import scan fails the foreign re-export rows; treating every glob as foreign fails the local-glob rows; dropping the const/static/block arms fails in_const.

Re-walk (tracing d9d4c54 + LevelFilter::current change, head 4c60168). The first review-fix cut over-refused here on tracing-core's use num::*, which is what the glob-root rule fixes:

Test import Mode Before After
use tracing_core::LevelFilter; deep, ready not related (issue repro) direct_owner_call
use tracing_core::LevelFilter; draft not related not related (draft indexes changed packages only)
use tracing_subscriber::filter::LevelFilter (original) deep not related not related (re-export, non-goal)

Claim Boundary

May claim: sibling-crate T::name() calls on a type imported from the owner's crate relate when no other reachable definition exists; hyphenated dependency names match their _ spelling.

Must not claim: re-exported types, aliases, draft-mode cross-crate discovery, or any change to exposure class rules.

Rollback

Revert the squash commit. The cache schema bumps make any cache written by this version rebuild on the reverted one.

Static Language Check

  • Static output avoids killed, survived, untested, proven, and adequate.

CI Economics

n/a

Engineering Check

  • No new panic, unwrap, expect, todo, or unimplemented in production code.
  • No new panic, unwrap, expect, todo, or unimplemented in tests.

Review

Gemini, Devin and Codex reviewed; all findings fixed and threads resolved (let-binding shadow, quoted call text, foreign same-named re-export, cache schema bump, traceability, const/static/block context). CodeRabbit: rate-limited, review missing.

Gates

  • cargo fmt --check
  • cargo xtask precommit

🤖 Generated with Claude Code

https://claude.ai/code/session_01EqbiiuYkC94scgE9rZ5K8W

…mported type (#4558)

A type-path call T::name( can only reach a definition inside an impl of a
type named T, or one whose context is unknown (trait default, blanket
impl, lexical fallback). Record that context on parser-backed
FunctionFacts and, for such a call with T imported from a declared path
dependency of the owner's crate (or spelled dep::T::name), count only
those definitions as competitors. Free functions and other types'
same-named methods no longer refuse the call.

Declared dependency names are Cargo.toml keys; fold '-' to '_' before
matching use paths (tracing-core is use tracing_core::...).

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01EqbiiuYkC94scgE9rZ5K8W
…type-path rule

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01EqbiiuYkC94scgE9rZ5K8W
@EffortlessSteven
EffortlessSteven marked this pull request as ready for review September 29, 2026 07:59
@coderabbitai

coderabbitai Bot commented Sep 29, 2026 •

Copy link
Copy Markdown

Warning

Review limit reached

Next included review available in 49 minutes.

Check out review usage here.

View limit details

Limit details: You’ve used the included review currently available.

You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository.

Learn how review limits work.

Review configuration:

⚙️ Run configuration

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Advanced

Run ID: c6e257b7-3ecc-489a-ad51-89f2e43473c0

📥 Commits

Reviewing files that changed from the base of the PR and between 5e62dac and 88a132a.

📒 Files selected for processing (33)
  • .ripr/traceability.toml
  • CHANGELOG.md
  • crates/ripr/src/analysis/classifier.rs
  • crates/ripr/src/analysis/classifier/evidence.rs
  • crates/ripr/src/analysis/classifier/owner.rs
  • crates/ripr/src/analysis/classify/activation.rs
  • crates/ripr/src/analysis/classify/flow.rs
  • crates/ripr/src/analysis/classify/helper_transfer.rs
  • crates/ripr/src/analysis/classify/match_transfer.rs
  • crates/ripr/src/analysis/classify/owner_shape.rs
  • crates/ripr/src/analysis/classify/propagation_witness.rs
  • crates/ripr/src/analysis/classify/reach.rs
  • crates/ripr/src/analysis/classify/related_tests.rs
  • crates/ripr/src/analysis/classify/scanner_transfer.rs
  • crates/ripr/src/analysis/classify/transitive_reach.rs
  • crates/ripr/src/analysis/facts/harness_registry/tests.rs
  • crates/ripr/src/analysis/facts/includes.rs
  • crates/ripr/src/analysis/facts/mod.rs
  • crates/ripr/src/analysis/facts/model.rs
  • crates/ripr/src/analysis/facts/test_styles/tests.rs
  • crates/ripr/src/analysis/language/rust/mod.rs
  • crates/ripr/src/analysis/language/rust/oracles.rs
  • crates/ripr/src/analysis/language/rust/probes.rs
  • crates/ripr/src/analysis/probes/diff.rs
  • crates/ripr/src/analysis/probes/repo.rs
  • crates/ripr/src/analysis/seam_cache.rs
  • crates/ripr/src/analysis/seam_inventory.rs
  • crates/ripr/src/analysis/syntax/lexical.rs
  • crates/ripr/src/analysis/syntax/ra.rs
  • crates/ripr/src/analysis/test_grip_evidence/related_tests/context.rs
  • crates/ripr/src/analysis/test_grip_evidence/tests.rs
  • docs/OUTPUT_SCHEMA.md
  • docs/specs/RIPR-SPEC-0172-cross-crate-dependency-edge-relation.md

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

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

@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-29T08:04:20.276582Z ac752a4 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.

@gemini-code-assist gemini-code-assist 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.

Code Review

This pull request introduces a mechanism to resolve ambiguity for type-path calls (e.g., T::name()) across Rust workspace crates by tracking the implementation context of functions (FunctionImplContext). It updates the AST parser to extract this context and refactors dependency edge checks to utilize it, preventing false positives when common method names are used. The feedback suggests a robust improvement in ra.rs to ensure that local functions defined inside associated constants, statics, or block expressions within an impl or trait block are correctly treated as free functions rather than being incorrectly associated with the enclosing type.

Comment thread crates/ripr/src/analysis/syntax/ra.rs Resolved

@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 4 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: ac752a47a3

ℹ️ 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".

Comment thread crates/ripr/src/analysis/facts/model.rs Resolved
…l is free (#4558 review)

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01EqbiiuYkC94scgE9rZ5K8W
- admit before the let-binding shadow check so `let current = LevelFilter::current()` relates
- match call sites on comment/string-masked text so quoted paths do not admit
- refuse when the owner crate imports a same-named type or glob from another crate
- bump seam and file-fact cache schema versions for the new impl_context fact
- add spec and traceability rows for the new tests

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01EqbiiuYkC94scgE9rZ5K8W
…pe-path admit (#4558)

The tracing re-walk showed tracing-core's `use core::{num}` then `use num::*;`
refusing the admit. A glob now counts only when its root is not std/core/alloc,
a module the file declares, or a name imported through a local or std path.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01EqbiiuYkC94scgE9rZ5K8W
…th admit (#4558)

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01EqbiiuYkC94scgE9rZ5K8W
…-4ws691

# Conflicts:
#	crates/ripr/src/analysis/seam_cache.rs

@EffortlessSteven EffortlessSteven left a comment

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Exact-head review of 88a132a: clean. CI is still running, so this records the source and oracle pass only.

What I inspected:

  • The admit path in related_tests.rs, and the order of its checks. The type-path admit runs before the let-binding, unattributed, local-shadow and competing-edge checks.
    • Those checks guard bare calls. A T::name( call is guarded by its own competitor scan: any same-named definition whose context may be impl T, or is Unknown, refuses.
    • An unattributed definition that is Free cannot be reached by T::name(, so it does not refuse. Anything in an impl of T, or Unknown, does.
  • The owner-crate import scan.
    • It runs only after a dependency-spelled T::name( call has been captured, so it does not scan every candidate pair.
    • A statement that names T from a non-local root refuses. That includes std::, which is conservative.
    • A glob refuses unless its root is std/core/alloc, a mod in the same file, or a name that file imports through a local or std path.
    • A chained re-export from another crate is still seen, because every file of the crate is scanned.
  • The producer (function_impl_context in ra.rs).
    • Fn, BlockExpr, Const and Static ancestors give Free; a trait gives Unknown.
    • An impl gives Impl only for a plain path self type that is not a generic parameter; any other impl gives Unknown.
    • Lexical fallback gives Unknown.
  • The cache. The merge with main moved every bump one step past main's #4576 and impl_attrs generations. The asserts and the OUTPUT_SCHEMA.md example were updated to match.
  • Oracle grip. Every rule has a discriminating negative experiment, listed in the PR body. The local-glob rule was added after the tracing re-walk exposed an over-refusal, and that rule's own negative experiment fails as expected.
  • Public claim. The claims in the CHANGELOG, RIPR-SPEC-0172 and the PR body match the behaviour. The re-export and draft-mode non-claims are stated.

Missing: CodeRabbit is rate-limited, so its review is missing, not clean. Gemini, Devin and Codex reviewed earlier heads, and all of their threads are fixed and resolved.


Generated by Claude Code

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