Skip to content

Fold unicode case and ignore inline drift markers - #748

Merged
n33miaz merged 3 commits into
developfrom
fix/589-drift-unicode-markers
Dec 6, 2026
Merged

n33miaz merged 3 commits into
developfrom
fix/589-drift-unicode-markers

Conversation

@n33miaz

@n33miaz n33miaz commented Dec 6, 2026

Copy link
Copy Markdown
Owner

Summary

This PR fixes two issues in the drift detection module (crates/core/src/drift.rs):

  1. Unicode case folding for stale phrase matching: The sweep function previously used to_lowercase() which doesn't handle Unicode case folding correctly. For example, the German sharp S (ß, U+00DF) would not match SS or ss because to_lowercase() leaves ß unchanged while converting SS to ss. The fix adds a custom casefold function that properly handles:

    • ß → ss
    • Greek sigma variants (Σ, σ, ς) → σ
  2. Ignore inline marker examples: The block_of function previously used line.contains("<!-- ads:begin") which would match marker-like text appearing inline in code blocks or documentation (e.g., `<!-- ads:begin123 -->` in a Rust code example). The fix introduces an is_marker_line helper that only recognizes markers on standalone lines (after trimming), ignoring inline examples.

Changes

  • Added casefold function in crates/core/src/drift.rs for proper Unicode case folding
  • Modified sweep function to use casefold instead of to_lowercase()
  • Added is_marker_line helper to detect only standalone marker lines
  • Modified block_of to use is_marker_line instead of substring matching

Regression Tests

The following tests fail without the fix and pass with it:

  • crates/core/tests/drift.rs::stale_phrase_unicode_case_folding_matches_sharp_s_and_ss - verifies ß matches strasse/STRASSE
  • crates/core/tests/drift.rs::stale_phrase_unicode_case_folding_matches_greek_sigma - verifies Greek sigma variants match
  • crates/core/tests/drift.rs::inline_marker_example_in_code_block_is_ignored - verifies inline begin marker in code block is ignored
  • crates/core/tests/drift.rs::inline_end_marker_example_in_code_block_is_ignored - verifies inline end marker in code block is ignored
  • crates/core/tests/drift.rs::inline_marker_example_in_documentation_is_ignored - verifies inline marker in documentation is ignored
  • crates/core/tests/drift.rs::real_standalone_marker_still_detected_after_inline_examples - verifies real markers still work after inline examples

All 19 drift tests pass, including the 6 new regression tests.

How to validate

  • cargo test -p ads-core --test drift (all 19 tests green).

Regression test: crates/core/tests/drift.rs::stale_phrase_unicode_case_folding_matches_sharp_s_and_ss fails without the fix

Refs #589

Signed-off-by: Neemias Cormino Manso <130704790+n33miaz@users.noreply.github.com>
@coderabbitai

coderabbitai Bot commented Dec 6, 2026 •

Copy link
Copy Markdown

Important

  • Trigger review

This repository does not receive automatic reviews because it has fewer than 10 stars.

Run configuration

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

Signed-off-by: Neemias Cormino Manso <130704790+n33miaz@users.noreply.github.com>
Signed-off-by: Neemias Cormino Manso <130704790+n33miaz@users.noreply.github.com>
@n33miaz
n33miaz merged commit 0bfb0ec into develop Dec 6, 2026
17 checks passed
@n33miaz
n33miaz deleted the fix/589-drift-unicode-markers branch December 6, 2026 03:35
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.

1 participant