Skip to content

Restore prefix-penalty scoring semantics and remove dead scoring allocation - #67

Merged
matt-edmondson merged 2 commits into
mainfrom
copilot/fix-prefix-penalty-scoring
Sep 13, 2026
Merged

Restore prefix-penalty scoring semantics and remove dead scoring allocation#67
matt-edmondson merged 2 commits into
mainfrom
copilot/fix-prefix-penalty-scoring

Conversation

Copilot AI commented Sep 13, 2026

Copy link
Copy Markdown
Contributor

Prefix-penalty logic in Fuzzy had become a permanent no-op (0 multiplier + 0 cap), so late-starting matches were not downgraded versus start-aligned matches. The associated test also derived expectations from those same constants, making it unable to detect regressions.

  • Scoring behavior: make prefix penalty real again

    • Set unmatchedPrefixLetterPenalty to -1 and maxPrefixPenalty to -5 in Fuzzy.
    • Preserves intended behavior: matches that begin deeper in the subject now score lower on prefix positioning.
  • Scoring hot path cleanup

    • Removed unused matchedIndices list and writes in CalculateScore.
    • Eliminates per-call allocation/work that had no effect on outputs.
  • Test hardening: independent expectations + observable ranking

    • Rewrote prefix-penalty unit expectation to fixed values (no recomputation from production constants).
    • Added cap-coverage test for long prefixes.
    • Added end-to-end scoring-order test to assert early match outranks late match.
// Before: no-op
internal const int unmatchedPrefixLetterPenalty = 0;
internal const int maxPrefixPenalty = 0;

// After: effective penalty with cap
internal const int unmatchedPrefixLetterPenalty = -1;
internal const int maxPrefixPenalty = -5;

Co-authored-by: matt-edmondson <19528727+matt-edmondson@users.noreply.github.com>
Copilot AI changed the title [WIP] Fix prefix-penalty scoring to apply correct penalties Restore prefix-penalty scoring semantics and remove dead scoring allocation Sep 13, 2026
@matt-edmondson
matt-edmondson marked this pull request as ready for review September 13, 2026 12:05
@sonarqubecloud

Copy link
Copy Markdown

@matt-edmondson
matt-edmondson merged commit 5d9d4e9 into main Sep 13, 2026
12 checks passed
@matt-edmondson
matt-edmondson deleted the copilot/fix-prefix-penalty-scoring branch September 13, 2026 12:14
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.

Prefix-penalty scoring is a permanent no-op, and its test can't catch that

2 participants