Skip to content

fix(check): use crates.io API for O(1) canonical matching#2

Merged
rocketman-code merged 1 commit intomainfrom
fix/canonical-matching-api
Feb 23, 2026
Merged

fix(check): use crates.io API for O(1) canonical matching#2
rocketman-code merged 1 commit intomainfrom
fix/canonical-matching-api

Conversation

@rocketman-code
Copy link
Owner

Summary

Replace the 3-variant sparse index lookup with a single crates.io API call for canonical name matching.

The crates.io API at GET /api/v1/crates/{name} canonicalizes the name before querying -- the same logic used by cargo publish. This means one request covers ALL separator variants (hyphens/underscores), eliminating the documented mixed-separator gap without needing O(2^n) lookups.

Before: 3 sparse index GETs guessing which separator spelling was used, with a documented gap for mixed-separator names like my_cool-crate.

After: 1 API call. O(1). Correct for all variants.

  • Removed index_path() function and its tests (dead code)
  • Removed mixed-separator limitation from README
  • Added canonical_collision_via_api network test
  • Net: +25 -83 lines (simpler AND more correct)

Test plan

  • cargo test -- 35 pass, 0 fail
  • cargo test -- --ignored -- 6 network tests pass (including new canonical_collision_via_api)
  • cargo clippy --all-targets -- -D warnings -- clean

@rocketman-code rocketman-code force-pushed the fix/canonical-matching-api branch from fff6c0a to 42bdf0d Compare February 23, 2026 01:39
Replace 3-variant sparse index lookup with a single crates.io API call.
The API canonicalizes names server-side, covering all separator variants
in one request and eliminating the documented mixed-separator gap.

- Set User-Agent header per crates.io API policy
- Remove dead index_path() function and tests
- Update all docs from "sparse index" to "crates.io API"
@rocketman-code rocketman-code force-pushed the fix/canonical-matching-api branch from 42bdf0d to 5361113 Compare February 23, 2026 01:40
@rocketman-code rocketman-code merged commit 14254d9 into main Feb 23, 2026
7 checks passed
@rocketman-code rocketman-code deleted the fix/canonical-matching-api branch February 23, 2026 01:46
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