Skip to content

Plugin contract 0.2: mounts, asset names, kinds, ranged downloads and NuGet's queries - #156

Merged
schmitch merged 1 commit into
mainfrom
claude/plugin-contract-0-2
Oct 21, 2026
Merged

schmitch merged 1 commit into
mainfrom
claude/plugin-contract-0-2

Conversation

@schmitch

@schmitch schmitch commented Oct 21, 2026 •

Copy link
Copy Markdown
Member

Plugin contract 0.2: what NuGet needs, for every plugin

First of the follow-ups to #146, toward NuGet as a built-in plugin in plugins/nuget with the same architecture as Helm. This PR grows the plugin contract by the parts the NuGet protocol needs that the contract lacked. Each one is generic, so Helm and future plugins get it too. Helm's behavior is unchanged.

Rebased onto main with the Docker / OCI registry (#149). Plugin mounts sit next to the /v2 registry routes. A plugin's kinds feed FormatRegistry::kinds, and GET /admin/formats lists NuGet, Docker and then the plugins.

What changes

Declared in plugin.toml

  • mount: where the format's repositories are served, {mount}/{repo}/…. The default is /repository. NuGet will declare /v3, which stays reserved until then.
    • The server registers a route for every plugin mount.
    • A repository is served under its own format's mount only. Anywhere else it answers 404 "repository is not served here".
    • Mounts are one lowercase segment. The server's own paths (/v2 included) and the web UI's pages are reserved; so are the ids nuget and docker.
  • kinds: the repository kinds the format serves. The default is hosted and group; proxy is refused until proxies come to the contract. The admin API and /admin/formats follow it, through FormatRegistry::kinds.
  • [assets]: the names and content types a version's package and manifest are stored under. NuGet keeps its existing package.nupkg / package.nuspec rows this way.

Host behavior

  • Ranged downloads: a download answers a single Range (206/416, Accept-Ranges) when the blob source serves ranges (the local blob cache), exactly as NuGet's .nupkg downloads do. The range parser is NuGet's, made public.
  • Selector 404s: unlist, relist and delete of a package outside the caller's selector answer 404, like an unknown package, as NuGet does. Before this PR they answered 403 from the write path.
  • Offline proxies keep serving what they cached (offline_serves_nothing, as on /v3).

Contract forge:format@0.2.0 (WIT and FormatPlugin types)

  • packages-of(id, versions): the metadata of some versions, ascending. NuGet uses it for registration pages.
  • search-query gains semver2 and upstream. take is passed through to the read ops, so 0 is the default page as for NuGet (it used to be clamped to 1). search-hit gains total-downloads.
  • upload::first-part: the first multipart part, whatever its name (NuGet push).
  • Publish times are RFC 3339 in UTC with milliseconds (…T12:00:00.000+00:00), NuGet's format.
  • A version stored before manifest summaries were gets its summary from its stored manifest, through the plugin's manifest_summary.
  • 0.1.0 shipped in no release, so the host implements 0.2.0 only.

forge-plugin-api helpers

  • Request::segments() (percent-decoded path segments), query_pairs() and query_param() (form-decoded), and Response::text().

Testing

  • New crates/server/tests/plugin_contract.rs: a small native test plugin, probe, installed through a new ServerOpts::extra_plugins hook, with its own mount, kinds and asset names. It covers:
    • mounts (served under /probe only; a Helm repository under /probe answers 404);
    • kinds (a group of probe is refused) and /admin/formats;
    • first-part uploads, and the asset rows' names and content type;
    • ranged downloads (206, 416, several ranges answered in full) with [blob_cache], which the test server now honors as main does;
    • packages-of (ascending; unknown and malformed versions left out);
    • publish-time format, summaries and size/SHA-256 in package info;
    • search with and without semver2, take=0, and download totals;
    • a role with a content selector: delete outside it answers 404, inside it 204.
  • tests/plugins.rs: the Helm component is installed under the mount /charts and served there only.
  • forge-plugin: manifest tests for mounts, kinds and assets (including the reserved /v2 and docker); the component tests run against Helm built for 0.2.0.
  • Locally after the rebase (Postgres, versitygw and Redis; no Docker here): the full forge-server suite on a fresh database, including the new registry tests, plus the forge-plugin, forge-plugin-api and forge-format-helm tests. All passed except workers, which passed when run on its own. It counts every pending outbox row in the database, and locally all test binaries share one database, so it fails after the registry tests (CI gives each binary its own).
  • Also clean: cargo fmt --check, clippy -D warnings, cargo check --all-features, and cargo xtask plugins-check.

Next in the series

  1. NuGet becomes a built-in plugin (plugins/nuget, mount = "/v3"; NuGet as a built-in format plugin (plugins/nuget), served at /v3 by the plugin dispatcher #157): its protocol behind FormatPlugin, and the separate /v3 dispatcher removed. Proxies keep the host's NuGet upstream code for now.
  2. Proxy repositories through the contract: the upstream side moves into the plugin, and Helm gets proxies too.

Generated by Claude Code

…NuGet's queries

What a format like NuGet needs from the plugin contract, added for every
plugin (Helm's behavior is unchanged):

- plugin.toml names the format's mount (`/repository` by default), the
  repository kinds it serves (hosted and group; proxies come later) and
  its `[assets]` names and content types. The server routes every mount,
  serves a repository under its own format's mount only, and the admin API
  and /admin/formats follow the declared kinds and mount.
- Downloads answer a single `Range` (206/416) when the blob source serves
  ranges, as NuGet's do.
- New query `packages-of(id, versions)` for a page of a long listing;
  search takes `semver2` and `upstream`, passes `take` through (0 is the
  default page) and its hits carry the download total.
- Publish times are RFC 3339 with milliseconds; a version stored before
  manifest summaries were gets its summary from its stored manifest.
- Uploads can be the first multipart part, whatever its name (NuGet push).
- Unlist, relist and delete of a package outside the caller's selector
  answer 404, as for NuGet; an offline proxy keeps serving.
- Request helpers in forge-plugin-api: decoded path segments and query
  parameters, plain-text responses.

The contract becomes forge:format@0.2.0 (0.1.0 shipped in no release).
Tests: a native test plugin covers mounts, kinds, asset names, first-part
uploads, ranges, the queries and selector 404s; the Helm component is
installed under a mount of its own; the test server honors [blob_cache].

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01PVwHnFCgGPRzXcChXeCHFx
@schmitch
schmitch force-pushed the claude/plugin-contract-0-2 branch from da0e6e7 to 75733ce Compare October 21, 2026 17:09
@schmitch
schmitch merged commit 3baf597 into main Oct 21, 2026
11 checks passed
@schmitch
schmitch deleted the claude/plugin-contract-0-2 branch October 21, 2026 17:37
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.

2 participants