Skip to content

fix(temporal): find a pin by the matcher's folded name (PEP 503, Cargo -/_), not only exact or lowercase - #989

Merged
runyourempire merged 1 commit into
mainfrom
fix/pins-name-fold
Oct 18, 2026
Merged

runyourempire merged 1 commit into
mainfrom
fix/pins-name-fold

Conversation

@runyourempire

Copy link
Copy Markdown
Collaborator

What

This is a follow-up to #974. temporal_versions::pins_by_project looked a package up as package_name IN (name, lower(name)). When a pin was stored under a mixed-case or differently separated name, the lookup missed it, and both the scorer and Preemption Tier 2 then said "version unknown". Examples:

  • a PyPI Foo_Bar pin, when the advisory names foo-bar;
  • a Cargo serde_json pin, when the advisory names serde-json.

Names are now compared the way the matcher compares them (fourda_depengine::matching::pep503_name / package_key):

  • PyPI: PEP 503. Lowercase, and every run of -, _ or . becomes a single -. So Django matches django, and Foo_Bar matches foo-bar and foo.bar.
  • Cargo: - and _ name the same crate.
  • npm: exact match, scopes included.
  • Other ecosystems: lowercase, as before.

The index is still used:

  • The idx_user_deps_package lookup now asks for the exact, lowercase and folded spellings, plus the _ / . forms where separators fold.
  • Only when none of those is stored for a PyPI or Cargo name does a separator-insensitive LIKE scan run. Its rows are kept only if they fold to the same name.

Tests

  • New:
    • PyPI Django vs django, Foo_Bar vs foo-bar, and foo.bar vs Foo_Bar;
    • PyPI foobar does not match foo-bar;
    • Cargo serde_json vs serde-json, in both directions;
    • npm stays exact (JSONStream is not jsonstream, foo_bar is not foo-bar), a scoped name is found, and ecosystem families never mix.
  • cargo test --lib -- temporal scoring:: preemption::: 1124 passed, 0 failed.
  • cargo clippy --lib -D warnings and fmt are clean, and the pre-commit and pre-push hooks passed.

🤖 Generated with Claude Code

https://claude.ai/code/session_018hjX3pEMmC7CHfG41PiPj7

…exact or lowercase spelling

pins_by_project (from #974) asked for `package_name IN (name, lower(name))`,
so a PyPI "Foo_Bar" pin was missed for an advisory on "foo-bar" (and a
Cargo serde_json for serde-json), and the scorer and Preemption Tier 2 read
"version unknown". Names now fold as the matcher folds them
(fourda_depengine::matching): PyPI per PEP 503, Cargo `-` = `_`, npm
exact (scopes included), others lowercase. The name index is asked for
the exact, lowercase and folded spellings (and `_` / `.` forms where
separators fold); only when none is stored for a PyPI or Cargo name does
a separator-insensitive LIKE scan run, its rows kept by the same fold.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_018hjX3pEMmC7CHfG41PiPj7
@runyourempire
runyourempire added this pull request to the merge queue Oct 18, 2026
Merged via the queue into main with commit 811731b Oct 18, 2026
24 checks passed
@runyourempire
runyourempire deleted the fix/pins-name-fold branch October 18, 2026 12:16
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