Skip to content

fix(analysis): normalize probe paths before test association - #3471

Closed
EffortlessSteven wants to merge 3 commits into
mainfrom
agent/3469-platform-association
Closed

EffortlessSteven wants to merge 3 commits into
mainfrom
agent/3469-platform-association

Conversation

@EffortlessSteven

@EffortlessSteven EffortlessSteven commented Aug 27, 2026 •

Copy link
Copy Markdown
Member

Summary

  • normalize foreign path separators before deriving probe file stems
  • keep empty-stem matching fail-closed
  • delegate normalized filename stem extraction to Path::file_stem() so dotfiles retain their native stem semantics
  • cover mixed separators and dotfile association with discriminating regressions

Refs #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 --check
  • cargo 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_preserved
  • cargo 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_related

The candidate is the fast-forward commit 6b48b55a7942ee3ae721c3c52197a5f4defd5636, parented directly on the previously reviewed PR head dc1807d3eab61a1d24dbdf88ed9332936848511e. The broader xtask gates are not claimed as passing here.

@coderabbitai

coderabbitai Bot commented Aug 27, 2026 •

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Pro Plus

Run ID: 7de6a073-7ed5-4bb3-965f-427a3d51634d

📥 Commits

Reviewing files that changed from the base of the PR and between 8c45bac and 6b48b55.

📒 Files selected for processing (1)
  • crates/ripr/src/analysis/classify/related_tests.rs

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


Summary by CodeRabbit

  • Bug Fixes
    • Improved related-test detection for file paths using Windows-style separators.
    • Correctly preserves assertion text when matching related tests.
    • Fixed matching for dotfiles so they associate only with tests sharing the same dotfile name.
    • Prevented empty file names from producing incorrect test matches.

Walkthrough

The 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.

Changes

Related-test matching

Layer / File(s) Summary
Normalize probe stems and validate associations
crates/ripr/src/analysis/classify/related_tests.rs
Probe stems now use normalized separators. Empty stems do not match test paths. Tests cover Windows separators, preserved assertion text, and distinct .config.rs versus config.rs matching.

Estimated code review effort: 2 (Simple) | ~10 minutes

Merge Risk: ⚪ Minimal · up to 6b48b

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

A rabbit hops through paths made bright
Backslashes turn to slashes right
Dotfiles keep their proper name
Empty stems leave out the game
Tests guard each matching flight

🚥 Pre-merge checks | ✅ 3 | ❌ 2

❌ Failed checks (2 warnings)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 66.67% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 6 functions across 1 files. Write docstrings for the functions missing them to satisfy the coverage threshold.
Description check ⚠️ Warning 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 I… Complete the required template sections. Mark non-applicable sections as none or n/a, document scope and rollback, provide traceability, record engineering and static-language checks, and list the status of the required gates. Preserve …
✅ Passed checks (3 passed)
Check name Status Explanation
Linked Issues check ✅ Passed The changes address the path-normalization portion of issue #3469 by normalizing foreign separators, preserving assertion text, and adding regression coverage for mixed separators and dotfiles. The de…
Out of Scope Changes check ✅ Passed The changes are narrowly limited to probe-to-test path normalization and related regression tests. They are directly related to issue #3469 and introduce no unrelated production or repository changes.
Title check ✅ Passed The title clearly and concisely describes the main change: normalizing probe paths before associating related tests.
Full details: Linked Issues check

Explanation

The changes address the path-normalization portion of issue #3469 by normalizing foreign separators, preserving assertion text, and adding regression coverage for mixed separators and dotfiles. The description correctly states that the broader platform-reproduction investigation remains open.

Full details: Description check

Explanation

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 none or n/a, document scope and rollback, provide traceability, record engineering and static-language checks, and list the status of the required gates. Preserve the existing statement that native-platform proof and issue closure are not claimed.

  • Fix all pre-merge checks with AI
✨ Finishing Touches 💡 2
📝 Generate docstrings 💡
  • Create stacked PR
  • Commit on current branch
⚔️ Resolve merge conflicts 💡
  • Resolve merge conflict in branch agent/3469-platform-association
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch agent/3469-platform-association

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.

@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 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.

Comment on lines +215 to +220
normalize_path(path)
.rsplit('/')
.next()
.and_then(|file| file.rsplit_once('.').map(|(stem, _)| stem).or(Some(file)))
.unwrap_or_default()
.to_string()

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

medium

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()

Comment on lines +750 to +751
fn given_mixed_path_separators_when_same_file_probe_is_repeated_then_association_and_assertion_text_are_stable()
{

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

low

This is a minor style issue. For consistency with the rest of the file and standard Rust formatting (rustfmt), the opening brace should be on the same line as the function signature.

    fn given_mixed_path_separators_when_same_file_probe_is_repeated_then_association_and_assertion_text_are_stable() {

@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: 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);";

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P1 Badge 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

codecov Bot commented Aug 27, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

@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.

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) and discover_preview_language_files (:34) sort before returning.
  • Association/assertion ordering — ruled out. find_related_tests sorts and dedups before returning, and the observation_unverified fold in classify/reveal.rs:255-262 is 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 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.

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 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.

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.

@EffortlessSteven

Copy link
Copy Markdown
Member Author

Superseded by #3545, which carries the same bounded analysis fix on current main with the merge conflict resolved and the current test suite passing. Closing this stale head so only the reconciled candidate remains active.

@EffortlessSteven

Copy link
Copy Markdown
Member Author

Superseded by #3545 (current-main reconciliation).

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.

fix(analysis): exposure classification diverges across platforms on identical committed trees

1 participant