Skip to content

registry: packages, first name and aliases per source - #217

Merged
adssib merged 1 commit into
mainfrom
pl2-packages
Nov 21, 2026
Merged

adssib merged 1 commit into
mainfrom
pl2-packages

Conversation

@adssib

@adssib adssib commented Nov 20, 2026 •

Copy link
Copy Markdown
Contributor

Stacked on #216

Part of #171 (prepares for patch-it-dev/patch-it#58)

What this changes

The registry exposes per source what the contract change (patch-it#58) and the client need, without adopting the contract yet:

  • plugin.Source.Packages: the published packages a source covers, ecosystem:name (pypi:stripe, npm:@vercel/sdk), checked by RegisterProvider (plugin.Ecosystems()). plugin.ForPackage("pypi:stripe") finds a package's sources, so a lockfile maps to sources without a table.
  • SourceInfo.Aliases(); the list (plugins.json, schema updated) prints each source's packages, first_name (the old slug, which fingerprints keep hashing) and aliases, next to id, alias, kind, layer, category.
  • Packages filled in where I could check them: the package itself for the six package/SDK sources (anthropic, numpy, posthog, newrelic, textual, urllib3), the official SDKs for API sources (Stripe, Datadog, Vercel, Elasticsearch, Neon, Appwrite, Algolia, OpenAI and Anthropic models, Cloudflare). None for the others (GitHub, GitLab, Sentry, Supabase, Convex, PlanetScale, Flagsmith, MongoDB Atlas, Redis, Salesforce, Vertex AI, GitHub Actions).

No event changes; goldens untouched.

Calls I made (please check)

  • Which SDK packages map to an API source is a judgment per provider (precision over recall): please read the list in the registrations.

Checks

  • make check passes (tidy, build, gofmt, vet, import allowlist, net/http guard, go test -race, no TODO(new-plugin), leak guard); make contract against patch-it's main fixtures passes (11 files).
  • Goldens: no golden changed

Related PRs

🤖 Generated with Claude Code

Each source lists the packages it covers (ecosystem:name) and
plugin.ForPackage finds a package's sources; the list prints them with
each source's first name and aliases, for the contract switch to source
ids.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: adssib <[email protected]>
@claude

claude Bot commented Nov 20, 2026 •

Copy link
Copy Markdown

Claude finished @adssib's task in 1m 14s —— View job


✅ Ready to merge. This PR adds metadata to the registry and to the list (packages, first_name, aliases). It is checked by RegisterProvider and the schema test, and it doesn't change any events or goldens.

Rules

Rule Status Evidence
Plugin list (Rule 1) ✅ Packages lives only in each plugin.Source registration. check() refuses a malformed ecosystem:name, and a new "bad package" case tests that. No hand-kept list was added. AGENTS.md and docs/writing-a-plugin.md now name the new field.
Provider page ✅ n/a No new provider. The sources only gain a metadata field, so what they read and emit is unchanged.
Golden test and quote ✅ n/a No golden or testdata changed.
Drop test ✅ n/a No plugin logic changed.
Fetch only via env ✅ No fetch code touched.
Nothing private (Rule 2) ✅ Diff, commit and PR body are clean. The leak guard passes.

Package mapping (I read all of them): each one matches the provider's official package. These are pypi:stripe/npm:stripe, pypi:datadog-api-client/npm:@datadog/datadog-api-client, npm:@vercel/sdk, pypi:algoliasearch/npm:algoliasearch, pypi:elasticsearch/npm:@elastic/elasticsearch, npm:@neondatabase/api-client and pypi:appwrite/npm:node-appwrite (server SDKs, which fits the Appwrite source's "operations a server SDK calls"). The others are openai, anthropic/@anthropic-ai/sdk, cloudflare, and the six package or SDK sources. Leaving out GitHub, GitLab, Sentry and the rest fits "precision over recall".

Bugs

None found.

Verified

  • go build ./...: passed
  • go vet ./...: passed
  • gofmt -l .: printed nothing
  • go test -race ./...: every package passed. That includes core/plugin (the new TestForPackage and the "bad package" case) and internal/pluginlist (TestTheListMatchesTheSchema, which checks the new required first_name/aliases/packages and the package pattern against real output).
  • python3 scripts/leak_guard.py --all: "no banned terms (8 hashed terms checked)"
  • I couldn't run go run ./cmd/list-plugins (it needs approval in this runner), so I relied on the schema test for the output.

Non-blocking (optional)

  • PyPI name normalization (inline note on core/plugin/provider.go:311): ForPackage matches strings exactly. A lockfile that writes datadog_api_client or Datadog-API-Client won't find the source. You could normalize PEP 503 names, or require the normalized form in check().
  • Schema drift: the ecosystem list appears twice, in plugin.Ecosystems() and in the packages pattern in docs/plugins.schema.json. TestSchemaEnumsMatchTheRegistry checks categories and layers against the registry but not ecosystems, so a new ecosystem added in Go only would fail later in the schema test rather than here. You could add a small check that the pattern's alternatives equal Ecosystems().
  • Test isolation (already there before this PR): TestForPackage adds one more acme-test source to the global registry. TestRegisterProviderResolvesBothIDs expects acme-test's sources to be exactly api,sdk, so that test depends on running first. It already did because of TestRegisterProviderRefusesConflictingProvider. Using a separate provider id here (e.g. acme-pkg-test) would keep it from making that worse.

Comment thread core/plugin/provider.go
func ForPackage(pkg string) []SourceInfo {
var out []SourceInfo
for _, s := range Sources() {
if slices.Contains(s.Source.Packages, pkg) {

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Non-blocking: this is an exact string match, but lockfiles don't always write a PyPI name the way the registration does. PEP 503 treats Datadog_API_Client, datadog.api.client and datadog-api-client as the same name, so ForPackage("pypi:datadog_api_client") from a poetry.lock or requirements.txt would find nothing. Two ways to fix it:

  • normalize PyPI names on both sides (lowercase, and collapse runs of -, _ and . into -), or
  • have check() accept only the normalized form and say in the doc comment that callers must normalize.

npm names are already lowercase, so npm doesn't need this.

Base automatically changed from pl2-versions to main November 21, 2026 00:57
@adssib
adssib merged commit 04190eb into main Nov 21, 2026
7 checks passed
@adssib
adssib deleted the pl2-packages branch November 21, 2026 00:58
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