Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
15 commits
Select commit Hold shift + click to select a range
0ea255c
fix(analysis): credit aliased owner imports and fail closed on #[path…
EffortlessSteven Nov 13, 2026
fd720fb
test(corpus): scope RIPR-SPEC-0442 in the verdict coverage ledgers
EffortlessSteven Nov 13, 2026
b92ea64
fix(analysis): clear the clippy -D warnings failures at the reviewed …
EffortlessSteven Nov 13, 2026
32b0455
fix(analysis): resolve a nested mod beside a non-mod.rs file
EffortlessSteven Nov 13, 2026
ca7e65d
fix(analysis): treat only the compilation-unit root as root-like
EffortlessSteven Nov 13, 2026
e51311b
fix(analysis): close the nested-bin and tuple-pattern false credits
EffortlessSteven Nov 14, 2026
2837a33
recompose: move the evidence-promotion honesty corpus to a follow-up
EffortlessSteven Nov 14, 2026
175ebc4
test(analysis): cover nested tuple and slice shadow patterns
EffortlessSteven Nov 14, 2026
1086e7c
fix(analysis): resolve the test crate root for empty-alias credit
EffortlessSteven Nov 14, 2026
d2896b0
fix(analysis): scan every scoped-shadow form and fix the nested-bin f…
EffortlessSteven Nov 14, 2026
bb40f49
fix(analysis): resolve the crate root that declares a mixed-target ch…
EffortlessSteven Nov 14, 2026
7d31633
fix(analysis): close four alias false-credit paths
EffortlessSteven Nov 14, 2026
cd89bfe
fix(analysis): fail closed on aliased owner lookalikes (#14508)
EffortlessSteven Nov 16, 2026
2d8b5f5
fix(analysis): close alias shadowing edge cases
EffortlessSteven Nov 16, 2026
0bd7c1f
Merge remote-tracking branch 'origin/main' into ripr-coding/14513-ali…
EffortlessSteven Nov 16, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
55 changes: 55 additions & 0 deletions .ripr/traceability.d/RIPR-SPEC-0442.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
# Aliased direct import of the owner credits the owner only when the import
# names its module in the same compilation unit (#14508).
[[behavior]]
id = "RIPR-SPEC-0442"
name = "Aliased owner import credit"
spec = "docs/specs/RIPR-SPEC-0442-aliased-owner-import-credit.md"
tests = [
"crates/ripr/src/analysis/test_grip_evidence/tests.rs::given_direct_owner_alias_when_an_integration_test_module_shadows_the_library_module_then_owner_gets_no_related_test",
"crates/ripr/src/analysis/test_grip_evidence/tests.rs::given_direct_owner_alias_when_the_owner_is_a_nested_module_then_owner_keeps_related_test",
"crates/ripr/src/analysis/test_grip_evidence/tests.rs::given_direct_owner_alias_when_the_owner_is_a_mod_rs_then_owner_keeps_related_test",
"crates/ripr/src/analysis/test_grip_evidence/tests.rs::given_direct_owner_alias_when_a_sibling_module_declares_the_alias_name_then_owner_keeps_related_test",
"crates/ripr/src/analysis/test_grip_evidence/tests.rs::given_direct_owner_alias_when_the_test_module_declares_the_alias_name_then_owner_gets_no_related_test",
"crates/ripr/src/analysis/test_grip_evidence/tests.rs::given_direct_owner_alias_when_a_local_function_shadows_it_then_owner_gets_no_related_test",
"crates/ripr/src/analysis/test_grip_evidence/tests.rs::given_direct_owner_alias_when_a_binary_inline_module_shadows_the_library_module_then_owner_gets_no_related_test",
"crates/ripr/src/analysis/test_grip_evidence/tests.rs::given_direct_owner_alias_when_a_binary_root_imports_the_library_root_then_owner_gets_no_related_test",
"crates/ripr/src/analysis/test_grip_evidence/tests.rs::given_direct_owner_alias_when_a_bin_target_imports_a_library_module_then_owner_gets_no_related_test",
Comment thread
EffortlessSteven marked this conversation as resolved.
Resolved
"crates/ripr/src/analysis/test_grip_evidence/tests.rs::given_direct_owner_alias_when_a_bin_only_package_imports_its_own_module_then_owner_keeps_related_test",
"crates/ripr/src/analysis/test_grip_evidence/tests.rs::given_direct_owner_alias_when_the_crate_root_redirects_the_module_with_path_then_owner_gets_no_related_test",
"crates/ripr/src/analysis/test_grip_evidence/tests.rs::given_two_indexed_packages_when_alias_names_a_sibling_package_then_owner_gets_no_related_test",
"crates/ripr/src/analysis/test_grip_evidence/tests.rs::given_integration_test_when_owner_is_imported_under_an_alias_then_owner_keeps_related_test",
"crates/ripr/src/analysis/test_grip_evidence/tests.rs::given_direct_owner_alias_when_a_scoped_binding_shadows_it_then_owner_takes_no_value_from_it",
"crates/ripr/src/analysis/test_grip_evidence/tests.rs::given_direct_owner_alias_when_a_free_and_an_associated_owner_share_the_name_then_associated_takes_no_value",
"crates/ripr/src/analysis/test_grip_evidence/tests.rs::given_direct_owner_alias_when_a_qualified_call_shares_the_alias_then_owner_takes_no_value_from_it",
"crates/ripr/src/analysis/extract/shadow.rs::fact_authority_tests::scoped_shadow_table_covers_each_scanned_form",
"crates/ripr/src/analysis/extract/shadow.rs::fact_authority_tests::scoped_shadow_ignores_a_genuine_call_in_the_last_match_arm",
"crates/ripr/src/analysis/extract/shadow.rs::fact_authority_tests::scoped_shadow_keeps_a_real_match_arm_binding",
"crates/ripr/src/analysis/extract/shadow.rs::fact_authority_tests::scoped_shadow_sees_a_flat_tuple_pattern_binding",
"crates/ripr/src/analysis/extract/shadow.rs::fact_authority_tests::scoped_shadow_sees_a_nested_tuple_pattern_binding",
"crates/ripr/src/analysis/extract/shadow.rs::fact_authority_tests::scoped_shadow_sees_a_slice_pattern_binding",
"crates/ripr/src/analysis/extract/shadow.rs::fact_authority_tests::scoped_shadow_sees_a_binding_in_a_later_loop",
"crates/ripr/src/analysis/test_grip_evidence/tests.rs::given_direct_owner_alias_when_a_library_child_module_imports_the_crate_root_owner_then_owner_keeps_related_test",
"crates/ripr/src/analysis/test_grip_evidence/tests.rs::given_direct_owner_alias_when_a_bin_only_child_module_imports_its_crate_root_owner_then_owner_keeps_related_test",
"crates/ripr/src/analysis/test_grip_evidence/tests.rs::given_direct_owner_alias_when_a_binary_child_module_imports_the_binary_root_then_library_owner_gets_no_related_test",
"crates/ripr/src/analysis/test_grip_evidence/tests.rs::given_direct_owner_alias_when_a_nearer_unsupported_import_shadows_it_then_owner_gets_no_related_test",
"crates/ripr/src/analysis/test_grip_evidence/tests.rs::given_direct_owner_alias_when_a_closure_in_a_macro_token_tree_shadows_it_then_owner_gets_no_related_test",
"crates/ripr/src/analysis/test_grip_evidence/tests.rs::given_direct_owner_alias_when_the_test_function_parameter_shadows_it_then_owner_gets_no_related_test",
"crates/ripr/src/analysis/test_grip_evidence/tests.rs::given_direct_owner_alias_when_a_cfg_gated_module_has_two_paths_then_owner_gets_no_related_test",
]
fixtures = [
"fixtures/evidence-promotion-honesty-corpus/corpus.json",
]
code = [
"crates/ripr/src/analysis/test_grip_evidence/related_tests.rs",
"crates/ripr/src/analysis/test_grip_evidence/related_tests/context.rs",
"crates/ripr/src/analysis/classify/const_flow.rs",
"crates/ripr/src/analysis/extract/shadow.rs",
"crates/ripr/src/analysis/syntax/ra.rs",
]
outputs = [
"docs/specs/RIPR-SPEC-0442-aliased-owner-import-credit.md",
]
metrics = [
"unit_test_pass_rate",
"corpus_case_pass_rate",
]
7 changes: 7 additions & 0 deletions changelog.d/14508-aliased-owner-import.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
<!-- section: Fixed -->
- `ripr pilot` and the repo-exposure grip path credit a test that imports the
changed owner under an alias as a direct owner call when the import names the
owner's module in the same compilation unit (crate root, nested file module,
`mod.rs`, or an integration test's package-qualified import). A `crate::`
import in an integration test or a binary target names that unit's own
module, so it does not credit the library owner (#14508).
1 change: 1 addition & 0 deletions crates/ripr/src/analysis/classifier/evidence.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3970,6 +3970,7 @@ mod tests {
fn owner_local_bindings_exclude_names_the_signature_binds() {
let binding = |name: &str| LetBindingFact {
line: 1,
scope_end: None,
name: name.to_string(),
};
let owner = FunctionSummary {
Expand Down
47 changes: 47 additions & 0 deletions crates/ripr/src/analysis/classify/const_flow.rs
Original file line number Diff line number Diff line change
Expand Up @@ -211,6 +211,53 @@ impl ModuleScopes {
.iter()
.all(|line| self.0.get(line) == Some(declared))
}

/// The chain of inline `mod` names in force at `line`, outermost first,
/// ignoring non-module blocks. `None` when the line is outside the
/// scanned source (#14508 review).
pub(in crate::analysis) fn module_chain_at(&self, line: usize) -> Option<Vec<&str>> {
let chain = self.0.get(&line)?;
Some(chain.iter().filter_map(|name| name.as_deref()).collect())
}

/// Whether the chain of `mod` items in force at `declaration_line` is at
/// least as deep as `use_module_depth` and is a prefix of the chain at
/// `call_line`. That is a declaration in the import's module or a nested
/// module, and in the call's module or an enclosing one. A declaration in
/// an enclosing module than the import is shadowed by the import, so it
/// does not withhold the call (#14508 review).
pub(in crate::analysis) fn declaration_shadows_import(
&self,
declaration_line: usize,
use_module_depth: usize,
call_line: usize,
) -> bool {
let (Some(declared), Some(used)) = (self.0.get(&declaration_line), self.0.get(&call_line))
else {
return false;
};
// A non-module block (`impl`, `fn`, or a bare block) around the
// declaration is not a module scope. Dropping that marker would make
// an associated or block-local function look like a root declaration
// and falsely shadow a genuine import (#14508 review).
if declared.iter().any(Option::is_none) {
return false;
}
let declared = declared
.iter()
.filter_map(|name| name.as_deref())
.collect::<Vec<_>>();
Comment thread
coderabbitai[bot] marked this conversation as resolved.
Resolved
let used = used
.iter()
.filter_map(|name| name.as_deref())
.collect::<Vec<_>>();
declared.len() >= use_module_depth
&& declared.len() <= used.len()
&& declared
.iter()
.zip(used.iter())
.all(|(declared, used)| declared == used)
}
}

/// What evaluating the related tests under the old and new value showed.
Expand Down
14 changes: 14 additions & 0 deletions crates/ripr/src/analysis/classify/const_flow/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -431,6 +431,20 @@ fn modules_with_the_same_chain_share_a_scope() {
assert!(super::shares_module_scope(source, 2, &[3]));
}

#[test]
fn an_associated_function_does_not_shadow_a_module_level_import() {
let source = "use crate::owner as dt;\n\
impl Rival {\n\
fn dt() {}\n\
}\n\
#[test]\n\
fn genuine() { dt(); }\n";
assert!(
!super::module_scopes(source).declaration_shadows_import(3, 0, 6),
"an associated function cannot rebind the module-level `dt` import"
);
}

/// Run the whole decision on a one-file crate: its production functions that
/// name `LIMIT` are the readers and its `#[test]`s the related tests.
fn decide(tests: &str, old: &str, new: &str) -> Result<Option<super::ConstFlow>, String> {
Expand Down
18 changes: 9 additions & 9 deletions crates/ripr/src/analysis/classify/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ pub(in crate::analysis) use caller_loop_selector::withhold_caller_loop_selector_
pub(in crate::analysis) use compile_time_guard::constrained_by_compile_time_assertion;
pub(in crate::analysis) use const_flow::{
ChangedConsts, ConstFlow, associated_const_binding, const_value_changes, evaluate_const_flow,
shares_module_scope,
module_scopes, shares_module_scope,
};
pub(in crate::analysis) use const_readers::{const_reader_returns, same_file_const_readers};
pub(in crate::analysis) use context::ProbeContext;
Expand Down Expand Up @@ -211,14 +211,14 @@ pub(in crate::analysis) use refusal_miss::{
};
pub(in crate::analysis) use related_tests::{
DependencyEdgeContext, RelatedTestCandidateIndex, assertion_pins_display_string,
body_contains_owner_call, call_text_may_call_free_function, changes_only_string_literals,
companion_scope_admits, declared_dependent_package_calls_owner,
find_related_tests_with_candidate_index, free_helper_call_resolves, impl_self_type_name,
inherent_owner_call_resolves, is_display_fmt_owner, is_drop_destructor, is_partial_eq_method,
manifests_with_unindexed_files, method_call_resolves_to_impl, module_stem,
owner_call_is_direct, owner_call_text, owner_dispatch_trait, owner_impl_identity_shadowed,
owner_trait_name, package_prefix, requires_inherent_receiver_identity,
resolves_method_in_prefix, test_calls_free_function,
body_contains_owner_call, call_text_may_call_free_function, call_text_spells_bare_free_call,
changes_only_string_literals, companion_scope_admits, declared_dependent_package_calls_owner,
find_related_tests_with_candidate_index, free_function_call_text, free_helper_call_resolves,
impl_self_type_name, inherent_owner_call_resolves, is_display_fmt_owner, is_drop_destructor,
is_partial_eq_method, manifests_with_unindexed_files, method_call_resolves_to_impl,
module_stem, owner_call_is_direct, owner_call_text, owner_dispatch_trait,
owner_impl_identity_shadowed, owner_trait_name, package_prefix,
requires_inherent_receiver_identity, resolves_method_in_prefix, test_calls_free_function,
};
#[cfg(feature = "lang-rust")]
pub(in crate::analysis) use reveal::RELATED_TESTS_RENDER_CAP;
Expand Down
22 changes: 22 additions & 0 deletions crates/ripr/src/analysis/classify/related_tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8683,6 +8683,28 @@ pub(in crate::analysis) fn free_function_call_text<'text>(
text.get(at..)
}

/// Whether one captured call's raw source text spells the bare free-function
/// call `name(` — the only spelling an imported alias can bind to. A
/// module-qualified path (`rival::name(`) names that module's function, not
/// the alias, even when the module name is lowercase (#14508 review).
pub(in crate::analysis) fn call_text_spells_bare_free_call(text: &str, name: &str) -> bool {
if name.is_empty() {
return false;
}
let masked = mask_comments_and_strings(text);
let mut calls = masked
.match_indices(name)
.map(|(at, _)| at)
.filter(|&at| is_free_function_call_at(&masked, at, name))
.peekable();
calls.peek().is_some()
&& calls.all(|at| {
let qualifier = masked[..at].trim_end();
let qualifier = qualifier.strip_suffix("r#").unwrap_or(qualifier);
!qualifier.trim_end().ends_with("::")
})
}

/// The text a captured call named like `owner` contributes as an owner
/// call: the whole line for an owner that may be reached through a path or
/// receiver, the free-call suffix for a module-level `fn`, `None` when the
Expand Down
Loading