Repository navigation
fix(extract): match dedup text across Unicode normalization forms - #2533
Merged
Merged
Conversation
Fold payee and narration to NFC (decompose, lowercase, recompose) before dedup compares them, so an NFC and an NFD spelling of the same text are one transaction rather than a re-imported duplicate. Compatibility forms (NFKC) are deliberately not folded: they are not always the same text, and a false match drops a row silently. Adds unicode-normalization, covered by Mozilla's imported cargo-vet audit. Closes #2507 Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]> Claude-Session: https://claude.ai/code/session_012nNGPA44Dt32NyxWem26xr
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
Contributor
📊 Benchmark Results
vs base, measured in this run
A difference counts only when it clears the combined spread of the two measurements, per shape (2σ: What do these numbers mean?
|
Contributor
✅ Compatibility Test Results
What's tested
Full results available in workflow artifacts |
This was referenced Oct 8, 2026
Member
Author
Review (adversarial pass): the lockfile
Cross-PR integration (applies to #2524, #2526, #2527, #2531, #2532, #2533)All six PRs were merged onto
|
…code-normalization # Conflicts: # CHANGELOG.md
Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]> Claude-Session: https://claude.ai/code/session_012nNGPA44Dt32NyxWem26xr
…code-normalization # Conflicts: # CHANGELOG.md
…code-normalization # Conflicts: # CHANGELOG.md
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What changed
extract --existingdedup now folds payee + narration to NFC before comparing, inrustledger_ops::dedup::txn_text. The text is decomposed, lowercased, then recomposed: Unicode's canonical caseless match (D145), withto_lowercasestanding in for full case folding. Soéstored as U+00E9 andéstored ase+ U+0301 compare equal, in either case, whichever side uses which form.NFC, deliberately not NFKC
Canonical equivalents are the same characters by definition. Compatibility equivalents are not always the same text:
²/2,½/1⁄2,fi/fi, full-width/ASCII. The two failure modes are not symmetric:So only the folding that can never merge different text is done. Whitespace variants need no folding, because matching already splits on
char::is_whitespace, which covers a no-break space. This reasoning is written attxn_text, indocs/commands/extract.md(Duplicate Detection) and in the CHANGELOG, and pinned by a test.New dependency
unicode-normalization0.1.25 (MIT/Apache-2.0; its one dependency,tinyvec, is already in the tree).audits.mozilla.wildcard-audits.unicode-normalization, safe-to-deploy). Importing it added 16 lines tosupply-chain/imports.lock(the publisher row and the imported audit). No exemption was needed.cargo vet --lockedpasses.cargo deny --locked checkgivesadvisories ok, bans ok, licenses ok, sources ok.rustledger-ops(+10 lines).cargowanted to re-resolve unrelated Windows-only deps (windows-sys,getrandom) while adding it, so the lock change was kept minimal by hand and verified withcargo metadata --locked.How tested
nfc_and_nfd_spellings_of_the_same_text_match: NFD new vs NFC existing, NFC vs NFD, and upper-case NFD vs NFC are each recognized as one duplicate, by text and not by amount alone.compatibility_forms_are_not_folded:fish/fishandUnit²/Unit2are not matched.to_lowercase, the NFC/NFD test fails. With NFKC folding instead of NFC, the compatibility test fails. So the second test pins the decision, and is not decoration.cargo test -p rustledger-ops -p rustledger --all-features, workspace clippy (-D warnings) and rustdoc (-D warnings) are clean.Closes #2507
🤖 Generated with Claude Code
https://claude.ai/code/session_012nNGPA44Dt32NyxWem26xr