Repository navigation
fix(analysis): normalize probe paths before test association - #3471
EffortlessSteven wants to merge 3 commits into
Conversation
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: ASSERTIVE Plan: Pro Plus Run ID: 📒 Files selected for processing (1)
Included review availability: Your plan provides up to 1 included review per hour; 0 remain after this review. Summary by CodeRabbit
WalkthroughThe related-test classifier now normalizes probe path separators before extracting file stems. It rejects empty stems and adds coverage for Windows separators, assertion preservation, and dotfile matching. ChangesRelated-test matching
Estimated code review effort: 2 (Simple) | ~10 minutes Merge Risk: ⚪ Minimal · up to The PR normalizes probe paths and preserves fail-closed and dotfile matching behavior in the internal test-association logic. No actionable merge-blocking risk remains beyond normal checks and review. Poem
🚥 Pre-merge checks | ✅ 3 | ❌ 2❌ Failed checks (2 warnings)
✅ Passed checks (3 passed)
Full details: Linked Issues checkExplanation The changes address the path-normalization portion of issue Full details: Description checkExplanation The description explains the change, scope boundary, linked issue, and targeted proof. It omits most required template sections, including Swarm / Source Boundary, Scope Classification, Support-tier Impact, Policy Impact, Claim Boundary, Rollback, Spec-Test-Code Traceability, Static Language Check, CI Economics, Engineering Check, and Gates. Resolution Complete the required template sections. Mark non-applicable sections as
✨ Finishing Touches 💡 2📝 Generate docstrings 💡
⚔️ Resolve merge conflicts 💡
🧪 Generate unit tests (beta)
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. Comment |
There was a problem hiding this comment.
Code Review
This pull request introduces a new helper function normalized_file_stem to extract a source-file stem after normalizing path separators, ensuring cross-platform compatibility. It also updates find_related_tests to use this helper and adds a unit test verifying the stability of associations with mixed path separators. The review feedback suggests improving the robustness of normalized_file_stem by leveraging the standard library's Path::file_stem to correctly handle edge cases like dotfiles, and addresses a minor formatting issue with the new test's opening brace.
| normalize_path(path) | ||
| .rsplit('/') | ||
| .next() | ||
| .and_then(|file| file.rsplit_once('.').map(|(stem, _)| stem).or(Some(file))) | ||
| .unwrap_or_default() | ||
| .to_string() |
There was a problem hiding this comment.
The custom logic to extract the file stem differs from std::path::Path::file_stem's behavior for dotfiles (e.g., for a file like .config, it would produce an empty stem instead of "config").
To ensure correctness and improve maintainability, it's better to reuse the standard library's well-tested logic. You can do this by applying Path::file_stem to the filename component after normalizing the path separators.
normalize_path(path)
.rsplit('/')
.next()
.and_then(|filename| Path::new(filename).file_stem())
.and_then(|stem| stem.to_str())
.unwrap_or_default()
.to_string()| fn given_mixed_path_separators_when_same_file_probe_is_repeated_then_association_and_assertion_text_are_stable() | ||
| { |
There was a problem hiding this comment.
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: c30bc58cc1
ℹ️ 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".
| #[test] | ||
| fn given_mixed_path_separators_when_same_file_probe_is_repeated_then_association_and_assertion_text_are_stable() | ||
| { | ||
| let assertion_text = "assert_eq!(config.retry_limit, 3);"; |
There was a problem hiding this comment.
Isolate the path-normalization signal in the regression test
This test still passes if the separator fix is reverted: retry_limit is at least five characters and appears in the assertion's observed tokens, so assertions_reference_owner selects both probes independently of file_path_matches. Use an unrelated or short probe token and an unrelated test name/assertion, then assert RelationReason::SameTestFile, so the old host-dependent Path::file_stem behavior actually fails the test. This is especially important for an analysis/** behavior change, where the repository requires challenging the test oracle rather than relying on a green test.
AGENTS.md reference: AGENTS.md:L540-L544
Useful? React with 👍 / 👎.
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
EffortlessSteven
left a comment
There was a problem hiding this comment.
Review — exact head dc1807d3
Disposition: REVIEW_INCOMPLETE. The diff is sound hardening, but the issue linkage overclaims and required local validation is missing.
Inspected: the complete diff (1 file, +53/-7), the semantic owner (analysis/classify/related_tests.rs), both probe-path producers, and the premise of #3469.
Finding 1 (blocking the Closes #3469 claim) — this patch cannot change the Linux verdict
Probe file paths are built host-natively:
crates/ripr/src/analysis/probes/diff.rs:330—SourceLocation::new(context.root.join(&context.changed.path), new_line, 1)crates/ripr/src/analysis/probes/repo.rs:39—SourceLocation::new(root.join(path), shape.start_line, 1)
Path::join produces the host's own separators. So on the ubuntu-24.04 runner the probe path is /…/crates/…/src/foo.rs, and on Windows it is C:\…\crates\…\src\foo.rs. Path::file_stem() resolves each correctly on its own host — \ is a separator only under std::path on Windows. Both platforms already derived foo before this change.
The only behavior this patch alters is the mixed case: a backslash-bearing path parsed on a Unix host. That is exactly what the new test constructs synthetically (struct_field_probe("crates\\ripr\\src\\config.rs", …) evaluated on Linux). In #3469's repro each platform analyzed its own checkout, so that case never arises there.
Consequence: merging as-is auto-closes #3469 while the reported divergence (Windows unsuppressed_exposure_gaps = 0 vs Linux new_unsuppressed = 51) remains unexplained — a false-confidence surface of the kind the repository contract calls out.
Ask: retarget the body to Refs #3469 and leave #3469 open. I checked the two mechanisms #3469 hypothesizes and can rule both out, which may help narrow the search:
- Corpus discovery order — ruled out. Both
discover_rust_files(analysis/workspace/discover.rs:18) anddiscover_preview_language_files(:34) sort before returning. - Association/assertion ordering — ruled out.
find_related_testssorts and dedups before returning, and theobservation_unverifiedfold inclassify/reveal.rs:255-262is order-independent (it resolves to "no matching assertion was confirmed" regardless of iteration order).
Worth noting the repro also confounds two variables besides OS: Windows ran a local working tree in --mode draft, Linux ran a merge ref under the gate. Those two modes are worth eliminating before attributing the delta to the platform.
Finding 2 — the genuine fix in this diff is unnamed and unproven
!file_name.is_empty() && normalize_path(&test.file).contains(&file_name) is a real fail-closed correction that is independent of separators: with the previous unwrap_or(""), an empty stem made .contains("") universally true, associating every test file with the probe. That is the load-bearing change here, and it is neither in the summary nor covered by a regression. It deserves its own named negative test.
Finding 3 — normalized_file_stem diverges from Path::file_stem() on dotfiles
rsplit_once('.') on .gitignore yields ("", "gitignore") → stem "", where Path::file_stem() returns .gitignore. Harmless today only because Finding 2's is_empty() guard catches it. gemini-code-assist raised this on c30bc58c and it is still unaddressed at dc1807d3. Normalizing separators first and then delegating to Path::file_stem() keeps one authority and removes the edge case.
Review currentness
Both existing bot reviews are bound to c30bc58c, not the current head dc1807d3. CodeRabbit returned a quota notice rather than a review, which under the repository contract means review is missing, not clean.
Local validation
The PR body states the xtask gates "were attempted but blocked by a Cargo artifact-directory lock and are not claimed as passing." cargo xtask precommit is the authoritative pre-publication gate, so that remains outstanding. I verified independently on this head's base that cargo build --workspace --all-targets is clean; that is not a substitute for the gate.
Generated by Claude Code
EffortlessSteven
left a comment
There was a problem hiding this comment.
REPAIR_REQUIRED - exact head dc1807d. normalized_file_stem manually splitting on dots can lose valid dotfile semantics such as .config; add a positive dotfile proof using Path::file_stem semantics. Also add a discriminating regression for the empty-stem guard, and narrow the Closes #3469 claim because the native-host reproduction remains unproven. Hosted checks are green, but these semantic and oracle gaps remain. A proposed repair is preserved in a named stash and must be validated and committed on this same candidate.
EffortlessSteven
left a comment
There was a problem hiding this comment.
Review — exact head 6b48b55a7942ee3ae721c3c52197a5f4defd5636
Disposition: REVIEW_INCOMPLETE. The repaired candidate is semantically narrow and addresses the prior dotfile/oracle findings, but hosted checks are still pending and GitHub reports the PR conflicting with current main; merge is not authorized.
Inspected the complete exact-head diff and semantic owner in crates/ripr/src/analysis/classify/related_tests.rs, including normalized_file_stem, the empty-stem guard, mixed-separator association, assertion-text preservation, and dotfile association. The new dotfile test distinguishes .config from config and checks both slash forms; the existing mixed-separator test remains covered. The standard-library Path::file_stem() call is applied only after separator normalization.
Proof observed in this run: cargo fmt --all --check; the existing foreign-separator association test passed; the new dotfile association test passed. These establish the targeted association behavior and do not establish the native Windows/Linux reproduction or explain issue #3469's broader divergence.
The current Gemini dotfile finding is addressed by this head. The two other unresolved threads are outdated and their concerns are covered by the committed repair and formatting proof; they still require explicit thread reconciliation before merge. Current hosted evidence is incomplete: GitGuardian and CodeRabbit are pending, and prior-head checks are stale for this SHA. Required branch protection remains Ripr Rust Small Result; the active main ruleset also requires review-thread resolution. Mergeability is currently CONFLICTING/DIRTY.
Claim boundary remains Refs #3469; no native-platform proof or issue closure is claimed.
|
Superseded by #3545, which carries the same bounded analysis fix on current |
|
Superseded by #3545 (current-main reconciliation). |
Summary
Path::file_stem()so dotfiles retain their native stem semanticsRefs #3469
This PR narrows the association behavior relevant to #3469. It does not claim native-platform proof, explain the reported Windows/Linux divergence, or close #3469; that issue remains open for the remaining platform-reproduction investigation.
Proof
cargo fmt --all --checkcargo test --manifest-path E:/Code/Rust/ripr-swarm-3471-candidate/Cargo.toml -p ripr --lib analysis::classify::related_tests::tests::given_foreign_separator_file_stem_when_associated_then_assertion_text_is_preservedcargo test --manifest-path E:/Code/Rust/ripr-swarm-3471-candidate/Cargo.toml -p ripr --lib analysis::classify::related_tests::tests::given_dotfile_probe_when_associated_then_only_matching_companion_is_relatedThe candidate is the fast-forward commit
6b48b55a7942ee3ae721c3c52197a5f4defd5636, parented directly on the previously reviewed PR headdc1807d3eab61a1d24dbdf88ed9332936848511e. The broader xtask gates are not claimed as passing here.