Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
schema_version = "2.0"
id = "ripr.slice.cold-target-affinity-index.v1"
generation = 1

source_issue = "issue:3838"
design_reference = "RIPR-SPEC-0005"
change_class = "refactor"

claim_boundary = """
Replaces the per-seam whole-test scan in repo test-grip target-affinity
matching with a deterministic reverse index built once in CompactGripContext.
The index maps each precomputed target-affinity owner-call name to the same test
indexes the old loop would discover, then the matcher applies the unchanged
target-token predicate, package-prefix filter, relation priority, deduplication,
ranking, and evidence construction. Test enumeration order and BTreeSet owner
names keep candidate vectors deterministic. No relation meaning, grip class,
canonical identity, output contract, cache identity, cancellation behavior, or
support claim changes.
"""

non_goals = [
"parallelizing evidence construction",
"changing RefCell or OnceCell memoization",
"semantic-unit caching or exact-base-proof routing",
"changing relation confidence, ranking, activation, oracle, or output semantics",
"changing public schemas, goldens, fixtures, or support tiers",
]

return_conditions = [
"Return to root if any target-affinity evidence, classification, golden, or fixture changes.",
"Return to root if candidate order differs from the previous full-scan order.",
"Return to root if the matcher still scans every CompactGripContext test for each seam.",
]

owned_seams = [
"seam:ripr:analysis:evidence",
]

shared_seams = [
"seam:ripr:analysis:seam-cache",
]

forbidden_seams = [
"seam:ripr:fixtures:goldens",
"seam:ripr:output:check-json-contract",
"seam:ripr:analysis:classification-decision",
]

[[requirement_delta]]
requirement_id = "RIPR-SPEC-0005"
requirement_generation = 1

[implementation_claim]
status = "implemented"

[evidence]
state = "outstanding"

[support_claim]
state = "unchanged"
19 changes: 12 additions & 7 deletions crates/ripr/src/analysis/test_grip_evidence/related_tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -247,19 +247,24 @@ pub(super) fn match_target_affinity_owner_call(
{
return;
}
for (test_index, test) in context.tests.iter().enumerate() {
if !test
.target_affinity_owner_call_names
.contains(owner.name.as_str())
|| !test_assertion_mentions_any_target_token(test, target_tokens)
{
let Some(indices) = context
.tests_by_target_affinity_owner_call_name
.get(&owner.name)
else {
return;
};
for test_index in indices {
let Some(test) = context.tests.get(*test_index) else {
continue;
};
if !test_assertion_mentions_any_target_token(test, target_tokens) {
continue;
}
insert_related_candidate(
candidates,
context,
prefix,
test_index,
*test_index,
RelationReason::HelperOwnerCall,
);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ pub(crate) struct CompactGripContext<'a> {
pub(in crate::analysis::test_grip_evidence) tests_by_call_name: BTreeMap<String, Vec<usize>>,
pub(in crate::analysis::test_grip_evidence) tests_by_helper_owner_call_name:
BTreeMap<String, Vec<usize>>,
pub(in crate::analysis::test_grip_evidence) tests_by_target_affinity_owner_call_name:
BTreeMap<String, Vec<usize>>,
pub(in crate::analysis::test_grip_evidence) tests_by_assertion_token:
BTreeMap<String, Vec<usize>>,
pub(in crate::analysis::test_grip_evidence) tests_by_file_stem: BTreeMap<String, Vec<usize>>,
Expand Down Expand Up @@ -38,6 +40,8 @@ impl<'a> CompactGripContext<'a> {
pub(crate) fn new(index: &'a RustIndex) -> Self {
let mut tests_by_call_name: BTreeMap<String, Vec<usize>> = BTreeMap::new();
let mut tests_by_helper_owner_call_name: BTreeMap<String, Vec<usize>> = BTreeMap::new();
let mut tests_by_target_affinity_owner_call_name: BTreeMap<String, Vec<usize>> =
BTreeMap::new();
let mut tests_by_assertion_token: BTreeMap<String, Vec<usize>> = BTreeMap::new();
let mut tests_by_file_stem: BTreeMap<String, Vec<usize>> = BTreeMap::new();
let mut tests_by_import_token: BTreeMap<String, Vec<usize>> = BTreeMap::new();
Expand Down Expand Up @@ -153,6 +157,12 @@ impl<'a> CompactGripContext<'a> {
.or_default()
.push(test_index);
}
for owner_name in &target_affinity_owner_call_names {
tests_by_target_affinity_owner_call_name
.entry(owner_name.clone())
.or_default()
.push(test_index);
Comment thread
EffortlessSteven marked this conversation as resolved.
Resolved
}
for token in &assertion_tokens {
tests_by_assertion_token
.entry(token.clone())
Expand Down Expand Up @@ -189,6 +199,7 @@ impl<'a> CompactGripContext<'a> {
tests,
tests_by_call_name,
tests_by_helper_owner_call_name,
tests_by_target_affinity_owner_call_name,
tests_by_assertion_token,
tests_by_file_stem,
tests_by_import_token,
Expand Down
Loading