Skip to content

Fix false-positive card matches in decklist import - #109

Merged
jcserv merged 2 commits into
mainfrom
factory/issue-93-b86d1b26d1b8
Nov 29, 2026
Merged

jcserv merged 2 commits into
mainfrom
factory/issue-93-b86d1b26d1b8

Conversation

@factory-jcs-poc

Copy link
Copy Markdown
Contributor

Summary

When a card name in an imported decklist has no exact match, the importer falls back to a fuzzy match. That fallback scored candidates by name length only, so an unrelated card with the same first four characters and a similar length could be silently substituted (for example "Lightning Bolt" becoming "Lightning Helix").

The fuzzy matcher now:

  • scores candidates by edit distance
  • requires a confidence of at least 0.85, up from 0.7
  • treats a tie between equally close candidates as unmatched
  • fetches 100 prefix candidates instead of 20, so the real match isn't cut off

Names that can't be matched confidently show up in the existing unmatched list.

Verification

  • pnpm vitest run lib/deck app/_actions/deck passed (1107 tests).
  • pnpm tsc --noEmit and pnpm lint passed.
  • With the old card-resolver.ts, the new false-positive and tie tests fail.

Fixes #93

Factory session

Fuzzy fallback scored candidates by name-length delta only, so any card sharing a 4-char prefix and similar length was accepted. Use edit distance, a 0.85 threshold, and reject ties.

Co-Authored-By: mastra-platform[bot] <284800079+mastra-platform[bot]@users.noreply.github.com>
@coderabbitai

coderabbitai Bot commented Nov 29, 2026 •

Copy link
Copy Markdown
Contributor

Important

Review skipped

Bot user detected.

To trigger a single review, invoke the @coderabbitai review command.

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: defaults
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 1c8b8f55-27e4-43ba-8dfb-4bf0f944ef44

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • Trigger review
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

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

@factory-jcs-poc

factory-jcs-poc Bot commented Nov 29, 2026 •

Copy link
Copy Markdown
Contributor Author

Tip

✅ Review complete: approved

Reviewed 1275ca9 · took 1m 22s · Factory session

@factory-jcs-poc

Copy link
Copy Markdown
Contributor Author

Factory test report

✅ All checks passed on 1275ca9

Check Result Tests
vitest run lib/deck/io ✅ Passed 146 passed
Typecheck (tsc --noEmit) ✅ Passed
New tests on base code ✅ Catches the bug 2 of 2 fail on base resolver, pass on head

@factory-jcs-poc

Copy link
Copy Markdown
Contributor Author

Verdict: approve

Reviewed head: 1275ca9

⚠️ Factory misconfiguration: the review token is the PR author, so GitHub cannot record this verdict as a review or count it toward branch protection. Configure a separate reviewer token for Factory reviews.

Fuzzy matching now uses edit distance, a 0.85 threshold and tie rejection, so look-alike cards are no longer substituted; tests cover it.

No findings.

Review notes
  • Tests: ✅ All checks passed on 1275ca9 (Factory test report comment).
  • Why approve: Strongest case against is a legitimate typo being rejected by the stricter 0.85 threshold; such names land in the existing unmatched list, which is the intended safe failure.

Factory session · Review runtime: litellms/anthropic/claude-sonnet-5-5, reasoning setting: medium.

@jcserv
jcserv merged commit dde45dc into main Nov 29, 2026
5 checks passed
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.

[Bug]: Card name import can result in false positives

1 participant