Skip to content

Fix: [for cherry-picking] Made nested baseline directory traversal dete - #208

Closed
qodo-code-review[bot] wants to merge 1 commit into
fix/types-sampler-nested-baselinesfrom
fix/remediation-066dc91c-2f9fe3
Closed

qodo-code-review[bot] wants to merge 1 commit into
fix/types-sampler-nested-baselinesfrom
fix/remediation-066dc91c-2f9fe3

Conversation

@qodo-code-review

@qodo-code-review qodo-code-review Bot commented Sep 8, 2026 •

Copy link
Copy Markdown

Fixed Findings

  • Deduplicate baseline variants by directory precedence

Automated fix from agentic review of #207

Qodo Logo

Summary by Sourcery

Deduplicate baseline variants according to deterministic directory precedence during filesystem resolution.

Bug Fixes:

  • Make baseline directory traversal deterministic and prevent duplicate nested variants from creating ambiguous matches.

Enhancements:

  • Preserve flat baseline files as authoritative while applying deterministic precedence to nested directories.

Summary by cubic

Makes baseline directory traversal deterministic so duplicate nested variants no longer create ambiguous matches.

  • Sorts nested directories during filesystem resolution.
  • Deduplicates variant suffixes by keeping the first occurrence.
  • Preserves flat baseline files as authoritative over nested copies.

Written for commit 1afe0b4. Summary will update on new commits.

Review in cubic

@codeant-ai

codeant-ai Bot commented Sep 8, 2026

Copy link
Copy Markdown

Skipping PR review because a bot author is detected.

If you want to trigger CodeAnt AI, comment @codeant-ai review to trigger a manual review.

@sourcery-ai

sourcery-ai Bot commented Sep 8, 2026

Copy link
Copy Markdown

Reviewer's Guide

Baseline filesystem resolution now scans directories deterministically, prioritizes flat references over nested ones, and deduplicates variant files by configuration suffix.

File-Level Changes

Change Details Files
Make baseline directory traversal deterministic and enforce directory precedence when resolving baseline files.
  • Sort nested baseline directories before scanning, while retaining the flat directory as highest priority.
  • Keep the first plain baseline found according to directory order.
  • Deduplicate variant baselines by suffix so nested copies cannot create ambiguous matches.
crates/bamts-verification/tests/types_facet_sampler.rs

Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

@qodo-code-review qodo-code-review Bot closed this Sep 8, 2026
@codeant-ai

codeant-ai Bot commented Sep 8, 2026 •

Copy link
Copy Markdown

🏁 CodeAnt Quality Gate Results

Commit: 1afe0b4b
Scan Time: 2026-09-08 06:10:41 UTC

✅ Overall Status: PASSED

Quality Gate Details

Quality Gate Status Details
Secrets ✅ PASSED 0 secrets found
Duplicate Code ✅ PASSED 4.5% duplicated
SAST ✅ PASSED No security issues
Bugs ✅ PASSED Rating S: No bugs
IAC ✅ PASSED No IAC issues

View Full Results

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

Hey - I've found 1 issue

Prompt for AI Agents
Please address the comments from this code review:

## Individual Comments

### Comment 1
<location path="crates/bamts-verification/tests/types_facet_sampler.rs" line_range="188-190" />
<code_context>
-                variants.push((suffix.to_owned(), entry.path()));
+                // A suffix identifies one configuration; retain the first
+                // occurrence so nested copies cannot make matching ambiguous.
+                if seen_variants.insert(suffix.to_owned()) {
+                    variants.push((suffix.to_owned(), entry.path()));
+                }
             }
</code_context>
<issue_to_address>
**issue (bug_risk):** `seen_variants` deduplicates only the raw suffix text, while `suffix_matches_options` treats option names, values, and option ordering case-insensitively. Equivalent variants such as `foo(target=ES5,module=commonjs).types` and `foo(module=commonjs,target=es5).types` therefore remain as two matches, causing the resolver to skip the intended match and fall back to an arbitrary lexicographic variant.

**Triggers:** When flat and nested baseline directories contain the same configuration encoded with different casing or option ordering.

**Suggested fix:** Canonicalize each suffix into a normalized option map before inserting it into `seen_variants`, or deduplicate the matching variants using the same normalization as `suffix_matches_options`.

```suggestion
                let normalized_suffix: BTreeMap<String, String> = suffix
                    .split(',')
                    .filter_map(|part| {
                        let (key, value) = part.trim().split_once('=')?;
                        Some((
                            key.trim().to_ascii_lowercase(),
                            value.trim().to_ascii_lowercase(),
                        ))
                    })
                    .collect();
                if seen_variants.insert(normalized_suffix) {
                    variants.push((suffix.to_owned(), entry.path()));
                }
```
</issue_to_address>

Sourcery assessment

Approval pending. 1 finding to address first.

Blocking findings: crates/bamts-verification/tests/types_facet_sampler.rs:190


Sourcery is free for open source - if you like our reviews please consider sharing them ✨

Comment on lines +188 to +190
if seen_variants.insert(suffix.to_owned()) {
variants.push((suffix.to_owned(), entry.path()));
}

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

issue (bug_risk): seen_variants deduplicates only the raw suffix text, while suffix_matches_options treats option names, values, and option ordering case-insensitively. Equivalent variants such as foo(target=ES5,module=commonjs).types and foo(module=commonjs,target=es5).types therefore remain as two matches, causing the resolver to skip the intended match and fall back to an arbitrary lexicographic variant.

Triggers: When flat and nested baseline directories contain the same configuration encoded with different casing or option ordering.

Suggested fix: Canonicalize each suffix into a normalized option map before inserting it into seen_variants, or deduplicate the matching variants using the same normalization as suffix_matches_options.

Suggested change
if seen_variants.insert(suffix.to_owned()) {
variants.push((suffix.to_owned(), entry.path()));
}
let normalized_suffix: BTreeMap<String, String> = suffix
.split(',')
.filter_map(|part| {
let (key, value) = part.trim().split_once('=')?;
Some((
key.trim().to_ascii_lowercase(),
value.trim().to_ascii_lowercase(),
))
})
.collect();
if seen_variants.insert(normalized_suffix) {
variants.push((suffix.to_owned(), entry.path()));
}

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.

0 participants