RFC 0025 — Generic file mirror in local and hybrid mode
| Field | Value |
|---|---|
| Status | In review |
| Short | Generic publish |
| Settles | Publishing arbitrary files under {name}/{version}/{filename} to a generic registry — the equivalent of GitLab's generic packages — on the shared local-registry machinery |
| Author | Max Batleforc maxleriche.60@gmail.com |
| Co-author | Claude Fable 5.1 noreply@anthropic.com, Claude Opus 5.5 noreply@anthropic.com |
| Created | 2026-09-11 |
| Supersedes | — |
| Touches | crates/core (entities/registry_kind.rs, services/local_registry/, ports/registry/local_registry.rs, services/blocking/, a new services/generic.rs), crates/adapters (the in-memory and Postgres LocalRegistryBackend), crates/config (schema/mod.rs), crates/web (handlers/proxy/generic.rs, lib.rs), cli, ui (config/registryTypes.ts, locales, openapi.json, client), tests/heavy, docs (registries/generic.md, use/publishing.md, registries/index.md and the French twins) |
| Risk | medium — §7 (a new authenticated write surface; a publisher-chosen Content-Type served from this origin is open, §15 q8) |
1. Summary
A generic registry mirrors any plain HTTP file tree, and only mirrors it: validate_registry_mode refuses mode = "local" and "hybrid" on the kind with "no local publish model", and the roadmap has carried "the equivalent of GitLab's generic packages" as the missing half since the kind shipped. This RFC adds that half. A file is published with one PUT to {name}/{version}/{filename} and read back from the same path; a version is a set of files, listed at a reserved -/ prefix; and everything between the request and the bytes — role and grant checks, namespace visibility, ownership, the immutable-coordinate tombstone, quota, size limit, signing policy, SBOM, first-sight scanning, dedup, retention, yank and delete — is the machinery every other local kind already runs through, reached by the same two calls Maven's multi-file publish makes today.
Nothing about mode = "proxy" changes. hybrid is a mirror with a private overlay: a held file answers first, an unheld one falls through to the upstream path under the same path_allow as before.
Before / after
# today — private blobs live on the forge, everything else lives here
[[registries]]
name = "gl"
type = "gitlab" # passthrough of /api/v4/projects/…/packages/generic/…
# published with PRIVATE-TOKEN to GitLab; cached here as `_packages`/`_`, no version, no policy
# with this RFC — the same curl, against this instance, on a coordinate
[[registries]]
name = "blobs"
type = "generic"
mode = "local" # or "hybrid" with upstreams + path_allow
$ curl -fsS -H "Authorization: Bearer $BATLEHUB_TOKEN" \
--upload-file installer-1.4.0.run \
https://batlehub.example.com/proxy/blobs/generic/installer/1.4.0/installer-1.4.0.run
{"message":"published installer 1.4.0 installer-1.4.0.run"}
$ curl -fsSO https://batlehub.example.com/proxy/blobs/generic/installer/1.4.0/installer-1.4.0.run
$ batlehub-cli package yank blobs installer 1.4.0 # the shared lifecycle, unchangedThe same curl on both sides. What changes is that the path now parses into a coordinate before anything is written, which is what every line of §4.4 is about.
There is no upstream protocol to describe for this one: the shape is this instance's own, and §4.2 is its specification.
2. Motivation
The demand is served today by a different server.
gl_packagesincrates/web/src/handlers/proxy/gitlab.rsexists to cache GitLab's generic package registry — its own doc comment calls that endpoint "ideal for the generic package registry (immutable file downloads)". A team that has moved npm, Maven and PyPI onto this instance still publishes its installers, CI blobs and vendored binaries to the forge, then proxies them back through here as the synthetic_packages/_coordinate: no version, no owner, no quota, no tombstone, no retention. The proxy is the second copy of a file whose first copy is governed elsewhere.The mode a private file needs is the one the kind refuses.
AppConfig::validate_registry_mode(crates/config/src/schema/mod.rs) fails agenericregistry inlocal/hybridwith "mode 'local'/'hybrid' is not supported for generic registries (no local publish model)", becauseRegistryKind::Generic::supports_local_mode()answersfalsebeside the three forges,jetbrainsand the six toolchain kinds (nodedist,godist,mise-java,sdkman,rustup,mise-versions;entities/registry_kind.rs:400-415). The refusal is correct for the code as it stands and is the whole gap.The publish path is shared machinery, and it already accepts a per-file key.
LocalRegistryService::publishrunsenforce_publish_policy(name and version validation, the RFC 0015 versioning andimmutablepolicy, the signing pair check, namespace membership, ownership, the size limit, the quota reservation and the RFC 0016 tombstone), thenexecute_publish_transaction,first_sight_after_publish(RFC 0018),run_publish_sbomandregister_initial_owner. Maven's non-POM files go through the same gate withPublishPolicyRequest::artifact_keyset tomaven_artifact_storage_key(registry, name, version, filename)and are stored under it (handlers/proxy/maven/proxy.rs). Nix's local mode is the second precedent and states the reason sharper: a version holds many store paths, so every later one would read as a replacement unless the decision is taken on the NAR's own key (services/local_registry/eco_nix.rs:440-457). A generic version is the Maven shape with no.pom: several files, one coordinate, each file its own key. Nothing new has to be invented to govern it.The proxy coordinate cannot be reused, because it has no version. The
generichandler addresses everything asPackageId::new(registry, "repo", "_").with_artifact(path). That is right for a mirror — an upstream path has no version to speak of — and useless for a publish: there is nothing to yank, nothing for retention to count, nothing a tombstone could burn. The coordinate is the design; the handlers follow from it.A mirror and its private overlay are one registry, or two URLs. A fleet that mirrors
get.helm.shand also ships an in-househelmbuild today configures two registries and every consumer chooses between two base URLs.hybridon this kind is what the mode was built for: the held file answers, the rest falls through.
3. Goals / non-goals
Goals
- A file can be published to a
genericregistry inlocalorhybridmode with a singlePUTof its bytes, and read back from the same path. - A version is a set of files under one coordinate, and the shared lifecycle (yank, unlist, deprecate, delete, retention, tombstone) applies to the version as a whole.
- Every gate a NuGet or npm publish passes applies here unchanged, including the signing policy, quota headers, SBOM, first-sight scanning and dedup.
- A
hybridregistry serves held files first and falls through to upstream for the rest, under the existingpath_allow. - The versions of a name, and the files of a version, are listable from the protocol so a CI job can ask "what is the newest installer" without the admin API.
batlehub-cli publishand the console's setup snippet cover the kind.
Non-goals
- Changing
mode = "proxy". Every existinggenericregistry keeps its routes, its synthetic coordinate and its mandatorypath_allow. - Paths inside a version. A file name is one segment. A nested tree under a version is a second addressing scheme on the same coordinate, and the three-segment key is what every policy is written against.
- Per-file delete. The version is the unit of immutability (RFC 0016); removing one file from a published set is the same thing as republishing the set, which
immutablegoverns. - Emulating GitLab's URL (
/api/v4/projects/:id/packages/generic/…) so unmodified pipelines point here. The forge passthrough already proxies that shape; this kind has its own prefix like every other, and the curl is one line either way. - Scanning every file of a version. Scanning and SBOM attach to the version through its first file, the limitation Maven's jars already have; §15 q2 says where that is fixed.
- Release imports into a generic registry (RFC 0021). An import reads its coordinate off the asset's file name, and a generic file name carries none; the tag-as-version import is a bis of 0021 (§15 q4).
- A checksum or signature side-car protocol (
.sha256,.sigserved beside the file). The signature is a header on download as everywhere else; a consumer that wants a side-car publishes one as a second file.
4. User-facing design
4.1 Configuration
[[registries]]
name = "blobs"
type = "generic"
mode = "local" # no upstream; every file is published here
[[registries]]
name = "helm-bin"
type = "generic"
mode = "hybrid" # held files first, then the mirror
upstreams = ["https://get.helm.sh"]
path_allow = ["helm-v*"] # governs the fall-through only
[registries.rbac]
anonymous = ["releases:read", "releases:list"]
# publishers hold releases:publish through a grant (RFC 0015); nothing new
[registries.quota] # the existing block, unchanged
max_storage_bytes_per_user = 10737418240mode = "local"needs noupstreamsand nopath_allow; both are refused (§4.5), because in local mode there is nothing for either to govern.mode = "hybrid"needs both, exactly asproxydoes today.path_allowapplies to the fall-through and never to a held file: a published file is reachable at its coordinate whatever the allowlist says, since the allowlist is a statement about the upstream host, not about what this instance holds.- No new registry option. The kind gains a mode, not a knob.
4.2 The protocol
Under /proxy/{registry}/generic/:
| Method and path | Meaning | Action |
|---|---|---|
PUT {name}/{version}/{filename} | Publish one file. Body is the bytes; Content-Type is recorded and served back. | releases:publish (releases:overwrite to replace a held file) |
GET {name}/{version}/{filename} | The file. Hybrid falls through to {upstream}/{name}/{version}/{filename}. | releases:read |
DELETE {name}/{version} | Delete the version: every file, and the coordinate is burned. | releases:delete |
GET -/{name} | Versions of a name, newest first, with latest. | releases:list |
GET -/{name}/{version} | Files of a version: name, size, SHA-256, content type, publisher, signed or not. | releases:list |
GET {path} (anything else) | Proxy mode: the mirror, as today. Hybrid: the fall-through for a path that is not a coordinate. Local: 404. | releases:read |
# publish, with the optional detached signature the signing policy may require
curl -fsS -H "Authorization: Bearer $BATLEHUB_TOKEN" \
-H "Content-Type: application/octet-stream" \
-H "X-Artifact-Signature: $(base64 -w0 installer.sig)" -H "X-Signature-Type: ed25519" \
--upload-file installer-1.4.0.run \
"$REG/installer/1.4.0/installer-1.4.0.run"
# the CLI form — --type is mandatory, a file name carries no coordinate
batlehub-cli publish --type generic --name installer --version 1.4.0 installer-1.4.0.run
# what is the newest installer?
curl -fsS "$REG/-/installer" | jq -r .latestYank, unyank, deprecate and unlist are the existing admin API and batlehub-cli package … commands; the version is a version like any other.
4.3 Coordinates
| Request | PackageId | Storage key |
|---|---|---|
installer/1.4.0/installer-1.4.0.run (local) | installer / 1.4.0 / installer-1.4.0.run | local:blobs/installer/1.4.0/installer-1.4.0.run |
installer/1.4.0/installer-1.4.0.run.sha256 (local) | installer / 1.4.0 / …run.sha256 | local:blobs/installer/1.4.0/…run.sha256 |
helm-v3.16.0-linux-amd64.tar.gz (hybrid miss) | repo / _ / helm-v3.16.0-linux-amd64.tar.gz | the proxy key, as today |
-/installer | installer, version unused | not stored: rendered from the version rows |
The storage key is maven_artifact_storage_key's shape — local:{registry}/{name}/{version}/{filename} — used for every file, including the first. There is no primary artifact at local:{registry}/{name}/{version}, because a generic version has no .pom: no file is more the version than another. PublishRequest gains an optional storage key for this (§6.1); the version row's checksum is the first file's, which is what require_signed_release and the download audit already read.
name is one segment, validate_package_name; version is one segment, validate_path_safe, and is not required to parse as semver — an installer called 2024.09 is a version. Ordering in -/{name} uses version_order, which already tolerates the unparseable by falling back to lexical order, and latest is best_latest over what is held and not yanked, so a pre-release never becomes latest while a release exists. filename is one segment, validate_path_safe, with GitLab's character set (A-Za-z0-9._-+~@, no leading or trailing ~/@) — the same rules a pipeline already obeys.
4.4 Behaviour rules
The uninteresting case. A PUT of a new file name to a version that does not exist creates the version and stores the file; a PUT of a new file name to a version that exists adds the file (GitLab's default, "the new files are added to the existing package"). Both need releases:publish. A PUT of a file name the version already holds is a replacement, and RFC 0015 §4.5 decides it: releases:overwrite and the namespace's immutable setting must both allow, evaluated on this file's key exactly as Maven's jar is — otherwise 409. That is the existing artifact_key branch of enforce_publish_policy, not a new rule.
A deleted coordinate is burned, whatever the file name. RFC 0016 §4.4's tombstone is on {name}/{version}; after a delete, a PUT of any file to that version is 409 with the tombstone message. The name may be published to again at a new version. This is the property that makes a generic registry a place a lockfile can pin a checksum to, and it is why the unit is the version and not the file.
Every file passes the whole gate. Name and version validation, the versioning policy, the signing pair check, namespace membership, ownership, limits.max_artifact_size_bytes, the quota reservation and the tombstone — enforce_publish_policy, called once per PUT. A second file that fails the quota leaves the first in place; the version is still valid with one file, which is what the listing says.
The signing policy is per file. X-Artifact-Signature and X-Signature-Type are checked on every PUT against [registries.signing] (required, allowed_types), and a stored signature is verified on download when verify_on_download is set — over the raw bytes of that file, which is what signature::verify_ed25519 defines. The version row carries the first file's signature in its existing columns; every file's signature lives in the version's file list (§6.1) and is what append_signature_headers reads for that file. A version is "published signed" for require_signed_release when its first file was, matching the column's existing meaning rather than inventing an all-files rule the columns cannot hold.
Dedup is free. The storage router stores by content hash (blob/<sha256>, artifact_dedup_index): the same installer published under two names, or the same LICENSE beside every version, is one blob and two references. Nothing in this RFC touches it; it is listed because it is the first kind where publishing the same bytes twice is normal rather than a mistake.
Hybrid is a two-step read. A GET of a coordinate-shaped path asks the local store first; on a miss it becomes the mirror request {upstream}/{name}/{version}/{filename}, checked against path_allow and cached under the proxy key as today. A path that is not coordinate-shaped (one or two segments, or a reserved -/) never consults the local store in hybrid — it is the mirror's. local mode has no upstream: a miss is 404.
Listings are rendered, not stored. -/{name} is the version rows for the name — not yanked, not unlisted, not tombstoned, visible to the caller under RFC 0015 — and -/{name}/{version} is that row's file list. Both are Filtered listings in listing_filter(), so a version an administrator blocked is absent from them the way it is absent from every other kind's (blocking::strip gains a Generic arm; the JSON is this instance's, so the filter is a plain array drop). In proxy mode the routes are 404: a mirror has no listing, and RFC 0008-bis §4.3's "the path-proxy family has no listing this instance can compose" stays true of the mirror and stops being true of what is published (§6.6).
The response shape.
// GET -/installer
{ "name": "installer", "latest": "1.4.0",
"versions": [ { "version": "1.4.0", "published_at": "2026-09-11T10:02:00Z",
"files": 2, "yanked": false } ] }
// GET -/installer/1.4.0
{ "name": "installer", "version": "1.4.0", "published_by": "user:ci-release",
"files": [ { "name": "installer-1.4.0.run", "size": 48210944,
"sha256": "…", "content_type": "application/octet-stream",
"signed": "ed25519" },
{ "name": "installer-1.4.0.run.sha256", "size": 84,
"sha256": "…", "content_type": "text/plain", "signed": null } ] }Two DTOs with ToSchema, serialised from named structs — the openapi_contract rule — so the generated TypeScript client and the console read the same shape.
4.5 Validation
AppConfig::validate() rejects:
| Condition | Rationale |
|---|---|
type = "generic", mode = "local", with upstreams or path_allow set | Neither governs anything in local mode; an operator who set them believes a mirror exists. Refused, not warned, for the same reason path_allow is refused on a non-path kind. |
type = "generic", mode = "hybrid", with empty path_allow | The existing mandatory-allowlist rule, now conditioned on "there is an upstream" rather than on the kind alone. ["**"] remains the explicit opt-out. |
type = "generic", mode = "hybrid", with empty upstreams | The existing hybrid rule, unchanged. |
Warnings (logged and surfaced to the admin):
| Condition | Behaviour |
|---|---|
A generic registry in local/hybrid under [registries.sbom] required = true | Served; warned at reload that an SBOM of an opaque file is generated from what the tool can identify in it, which for a compiled installer is usually nothing, so required will refuse publishes the operator meant to allow. |
[air_gap] with a generic registry in local/hybrid | The existing AIR_GAP_LISTING_NOT_SYNTHESISED warning is not emitted for this mode (§6.6); it stays for proxy. |
4.6 Mocks
The visible surface is the protocol's answers, the CLI's output and one tab of the console's setup guide. Each mock is a proposal; the error bodies are the shape AppError::error_response (crates/web/src/error.rs) already renders, and the two refusal sentences are the existing ones, quoted from the tree.
curl --upload-file — nominal
$ curl -fsS -H "Authorization: Bearer $BATLEHUB_TOKEN" \
--upload-file installer-1.4.0.run "$REG/installer/1.4.0/installer-1.4.0.run"
{"message":"published installer 1.4.0 installer-1.4.0.run"}One line naming the coordinate and the file, so a CI log shows what was written without a second request.
curl --upload-file — the same file name again (refusal, 409)
$ curl -sS -w '%{http_code}\n' -H "Authorization: Bearer $BATLEHUB_TOKEN" \
--upload-file installer-1.4.0.run "$REG/installer/1.4.0/installer-1.4.0.run"
{"error":"Conflict","message":"installer@1.4.0 already exists and this node is immutable = \"always\". Publish a new version; no permission grants a replacement here."}
409The message is enforce_publish_policy's (services/local_registry/publish.rs:538), unchanged: the file key is what was judged, and the sentence names the version because the version is the unit a reader pins.
curl --upload-file — a deleted version (refusal, 409)
$ curl -sS -w '%{http_code}\n' -H "Authorization: Bearer $BATLEHUB_TOKEN" \
--upload-file notes.txt "$REG/installer/1.3.0/notes.txt"
{"error":"Conflict","message":"installer@1.3.0 was published and deleted on 2026-09-11 in registry 'blobs'; a published version coordinate is never reused — publish under a new version"}
409Tombstone::burned_coordinate_message (entities/local_package.rs:185), unchanged: a new file name does not reopen a burned version.
curl — the listings, nominal and empty
$ curl -fsS "$REG/-/installer" | jq -c '{latest, n: (.versions | length)}'
{"latest":"1.4.0","n":3}
$ curl -sS -w '%{http_code}\n' "$REG/-/never-published"
{"error":"Not Found","message":"no versions of 'never-published' in registry 'blobs'"}
404An unknown name is a 404, not an empty list, so a typo in a CI job fails loudly instead of finding "no newer version".
batlehub-cli publish --type generic — nominal and usage error
$ batlehub-cli publish --type generic --name installer --version 1.4.0 installer-1.4.0.run
published installer 1.4.0 installer-1.4.0.run to blobs (48.2 MB)
$ batlehub-cli publish --type generic installer-1.4.0.run
error: --type generic needs --name and --version: a generic file name carries no coordinateThe usage error says why the flags are needed, so the reader does not go looking for a file-name convention that does not exist.
Console setup guide — generic registry in local mode
┌ Setup · blobs (generic · local) ───────────────────────────────┐
│ [ Download ] [ Publish ] [ Server config ] │
│ │
│ Publish a file │
│ curl -fsS -H "Authorization: Bearer $BATLEHUB_TOKEN" \ │
│ --upload-file <file> \ │
│ https://batlehub.example.com/proxy/blobs/generic/<name>/<version>/<file> │
│ │
│ A published version is immutable; a deleted one is never │
│ reused. │
└────────────────────────────────────────────────────────────────┘The Publish tab appears only in local/hybrid; a proxy registry keeps today's single Download snippet. The immutability sentence sits under the command because it is what a first publisher needs to know before the second.
5. Architecture
5.1 One PUT, the shared gate, one key
The invariant: there is no path to storage that does not pass enforce_publish_policy with the file's own key. The first file and every later one call the same function with artifact_key set, so immutable, quota and the tombstone are decided per file and never on a row that a previous file created — the trap RFC 0015 §4.5 names for Maven, and the reason this design reuses Maven's branch rather than publish() alone.
5.2 A read, by mode
The invariant: a held file is read through get_artifact_at_key and nothing else, the lesson of RFC 0009's survey finding 6, where Maven's jar read local_svc.storage directly and skipped both the rule chain and the visibility check that maven-metadata.xml beside it applied. The handler never touches storage on a read.
5.3 What the version is
| Thing | Where it lives | Unit |
|---|---|---|
| The coordinate, its checksum, publisher, signature, visibility, yank/unlist/deprecate flags, tombstone | the version row (PublishedPackage) | version |
| The file list — name, size, SHA-256, content type, signature | index_metadata.files[] on that row | file |
| The bytes | local:{registry}/{name}/{version}/{filename} | file |
| Quota, dedup refs, retention accounting | as today | bytes / version |
The version row is the unit of every policy; the file list is the unit of every read. Keeping the file list in index_metadata rather than a new table is deliberate: every other kind already puts its ecosystem document there (CargoIndexEntry, the npm version object), the retention compaction of RFC 0016 §4.5 already knows to strip it after the window, and the air-gap export already carries it.
6. Detailed design
6.1 crates/core
RegistryKind::Generic::supports_local_mode()→true. The exhaustive matches that key on it (validate_registry_mode, the UI's mode picker through the generated client) follow.listing_filter()forGeneric→Filtered("versions (-/{name})", ["versions"]),Filtered("files (-/{name}/{version})", ["files"]), withDocumentKind::FILES = Secondary("files").blocking::stripgains aGenericarm dropping array entries byversionand, forFILES, refusing the whole document when the version is blocked.every_advertised_filter_is_reachable_from_dispatchenforces the pair.readme_support()staysNone;fetchable_by_version()staysNonewith its reason extended: a version is a set of files with no canonical one.PublishRequestgainsstorage_key: Option<String>—Nonekeepsartifact_storage_key(every existing caller),Somestores the bytes there instead.execute_publish_transactionreads it; nothing else changes.LocalRegistryBackendgains one method,put_generic_file(registry, name, version, file: GenericFile) -> bool, so a later file can be added to the row's file list under the same transaction disciplinecommit_publishuses. It inserts the entry ofindex_metadata.files[]whosenameisfile.name, or replaces that one entry, and touches nothing else on the row — not the checksum, not the signature columns, not another file's entry. It is called only afterenforce_publish_policypassed for that file's key, so a replacement it performs is onereleases:overwriteandimmutablealready allowed. It is required, not defaulted, likeset_channel, so a backend that has not implemented it is a compile error rather than a silent no-op. The reason it is a method rather than a re-publish is that a re-publish would run the tombstone and versioning checks against a row that legitimately exists; the reason it is this method rather than a generalset_index_metadatais decision 6.services/generic.rs— the file-list document:GenericFile { name, size, sha256, content_type, signature_type, signature_b64 },files_of(row),push_file(row, file), the filename character rule, and the two rendered DTOs.version_orderandblocking::best_latestare reused forlatest.
6.2 crates/config
validate_registry_modeno longer refuses the kind; the §4.5 rejections are added besidevalidate_registry_path_allow, whosegenericbranch becomes "mandatory when the registry has an upstream".CURRENT_CONFIG_VERSIONdoes not move: no field is added or renamed.
6.3 crates/web — handlers/proxy/generic.rs
The one file grows four handlers and keeps generic_get's route last:
| Route | Handler |
|---|---|
PUT /proxy/{registry}/generic/{name}/{version}/{filename} | generic_put — require_local_mode; validate the three segments; collect_payload (bounded by max_artifact_size_bytes); signature headers via extract_signature_headers; then the §5.1 branch: publish_and_respond with storage_key set when the row is absent, enforce_publish_policy + storage.store + put_generic_file when present. 201 with MessageResponse and the X-Quota-* headers publish_and_respond already sets. |
DELETE /proxy/{registry}/generic/{name}/{version} | generic_delete — delete_version_audited (the version and every file key; the tombstone is the backend's, RFC 0016 §5.2). |
GET /proxy/{registry}/generic/-/{name} | generic_versions — rendered from get_index-style rows through check_visibility; releases:list. |
GET /proxy/{registry}/generic/-/{name}/{version} | generic_files — the file list; releases:list. |
GET /proxy/{registry}/generic/{path:.*} | generic_get, as today, plus: in local/hybrid, a three-segment path first tries get_artifact_at_key with the file key and the PackageId name/version + with_artifact(filename) — the handle_maven_artifact shape — and only on a hybrid miss builds today's repo/_ request. |
Obligations from the existing rules: validate every segment at the edge (validate_package_name, validate_path_safe twice, the filename character set) for a clean 400; body = T on every success (MessageResponse, ArtifactBytes, the two new DTOs), or openapi_contract fails. Route ordering: -/{name} and -/{name}/{version} register before {path:.*}, and PUT/DELETE are distinct methods so they never shadow the read. The conformance fixture asserts the matched pattern for each.
serve_local_or_proxy_artifact is not used: its local branch calls get_artifact with the primary key, which this kind does not have. The Maven pair (get_artifact_at_key then proxy_stream) is the right shape and is followed literally.
6.4 cli
batlehub-cli publish --type generic --name <n> --version <v> <file> → Api::publish_generic, one PUT with the file's bytes and Content-Type guessed from the extension. --type generic without --name and --version is a usage error: FilenameCoordinates refuses the kind on purpose, as it refuses Maven and Composer (RFC 0021 §13.3), because the name carries no coordinate and guessing one would publish under the wrong one. batlehub-cli download gains nothing: a generic file is a URL.
6.5 ui and docs
ui/src/config/registryTypes.ts— thegenericentry gains a Publish snippet (the curl of §4.2) shown when the registry's mode is local or hybrid, and its server block gains the local form. The description drops "Proxy-only: there is no publish or index model".docs/registries/generic.md— a Publishing section, the coordinate table, the listing routes, theimmutable/tombstone sentence, and the SBOM warning; its support table is regenerated (task docs:listing-coverage).docs/use/publishing.mdgains the generic row. The "Private publish" cell ofdocs/registries/index.mdflips.ROADMAP.md— the entry moves to done when phase 4 lands.
6.6 Air gap (RFC 0008-bis)
A generic registry in local/hybrid has a listing this instance can compose, because it is this instance's own: -/{name} and -/{name}/{version} render from the bundle's inventory and the held index_metadata, with no external document to sign. The 0008-bis table gains a row, the config warning of §4.5 is narrowed to proxy, and the registry page's air-gap cell says "held versions and their files are listed; a mirror path is served if held". The mirror half keeps its 503-on-listing behaviour because a mirror still has no listing.
6.P Proof against a real client
Not yet observed. Everything below is the plan, to be run before phase 2 is called done (§16); nothing in it has crossed a wire yet. There is no package manager for this kind; the real clients are curl (the runner image's, pinned by the image digest, its curl --version line recorded in the transcript) and this project's own batlehub-cli, built from the same commit. Both are driven through the tap, with every download written into the run's temp directory so no step reads another's file. The suite is tests/heavy/generic.sh, with config.generic-local.toml beside it, task test:generic-local-heavy and a row in the heavy-client matrix.
curl --upload-filepublishes two files to one version — both201, theX-Quota-Usedheader grows by their sizes, and-/{name}/{version}lists both with the SHA-256sha256sumcomputes locally.- Refusal. A second
--upload-fileof the same file name is409with theimmutablesentence of §4.6, and the listing'ssha256for that file is unchanged. With areleases:overwritegrant on animmutable = "never"namespace the same request is201and the listing'ssha256changes. batlehub-cli publish --type genericpublishes a third version;-/{name}names it aslatest.batlehub-cli package yankremoves it fromlatestand from the listing; the file still downloads by exact coordinate.- Refusal.
DELETEthe version; aPUTof a different file name to it is409with the tombstone message of §4.6, and-/{name}no longer lists it. - A
hybridregistry overhttps://get.helm.shwithpath_allow = ["helm-v*"]: the published file answers from local,helm-v3.16.0-linux-amd64.tar.gzfalls through and its cache-miss counter moves; refusal: a path outside the allowlist is403and the tap shows no request toget.helm.shfor it, while the held coordinate stays200whatever the allowlist says. Fetching the same fall-through path again movesbatlehub_artifact_cache_hits_total. - The same bytes published under two names:
artifact_dedup_refsgrows by one and the blob count does not. - Refusal. An anonymous
PUTis401and a token holding onlyreleases:readis403; in both cases-/{name}is unchanged and the storage backend holds no new key. - Refusal.
curl --path-as-iswith..as the version and with a/encoded into the file name are both400before any storage call — the tap shows the request, the storage backend shows no write.
Deliberately untouched, so reviewers do not go looking:
crates/adapters/src/registry/path_proxy.rs— the mirror client is not consulted on a local read and needs no change; hybrid reaches it through the sameproxy_streamas today.crates/core/src/services/local_registry/publish.rsbeyond thestorage_keyplumb — the gate is reused, not extended; no policy is specific to this kind.crates/core/src/services/retention.rsand the RFC 0016 tombstone — a version with several file keys is what Maven already is; delete and compaction handle it.- The dedup router — content-addressed already; this RFC only points out that the kind exercises it.
gl_packages— the forge passthrough keeps working for anyone who stays on GitLab; this kind is an alternative, not a replacement.
7. Security
Rating: medium — a new authenticated write surface on a kind whose mirror half is often anonymous-readable; every gate it passes already exists, and the one new port method is narrow by design (decision 6). The highest residual risk is T8: a publisher-chosen Content-Type served from this instance's origin (§15 q8).
7.1 Threat model
Assets: the bytes of a published file and the promise that a pinned {name}/{version}/{filename} never changes; the version rows and their file lists; the quota; the publisher identity on each row. Actors: an anonymous reader, an authenticated publisher, a publisher holding releases:overwrite, an administrator, and — in hybrid — the upstream mirror host.
Attacker-controlled inputs are the three path segments, the body, the Content-Type header and the two signature headers (B1), the path of a read (B2), and the bytes the upstream returns on a fall-through (B3).
| # | Threat (STRIDE) | Where | Mitigation | Residual risk |
|---|---|---|---|---|
| T1 | Spoofing — publish under a name the caller does not own | B1 | auth middleware, the releases:publish grant, ownership and namespace membership in enforce_publish_policy, register_initial_owner on the first file; §14 Security | a stolen token publishes as its holder — as for every kind |
| T2 | Tampering — replace the bytes of a pinned file | B1 | the artifact_key branch of enforce_publish_policy (publish.rs:525): releases:overwrite and immutable on the file key; §6.P case 2 | none beyond a granted overwrite on an immutable = "never" namespace |
| T3 | Tampering — reoccupy a deleted version under a new file name | B1 | the RFC 0016 tombstone on {name}/{version}, checked on every PUT (publish.rs:341); §6.P case 5 | none known |
| T4 | Tampering — a segment escapes its storage key (traversal, encoded /) | B1, B2 | validate_package_name, validate_path_safe ×2, the filename character set at the edge; validate_coordinate in get_artifact_at_key; ensure_safe_key in the backends; §6.P case 9 | none known |
| T5 | Tampering — the file-list write used to rewrite a version's checksum or signature | B1 → S | put_generic_file writes one entry of index_metadata.files[] and nothing else, and is called only after enforce_publish_policy passed for that file's key (decision 6) | none known |
| T6 | Information disclosure — a team-visible version's file or listing read by a non-member | B2 | get_artifact_at_key and check_visibility on the file and on both listings (§5.2) | none known |
| T7 | Information disclosure — a blocked version advertised by -/{name} | B2 | the Generic arm of blocking::strip, checked by every_advertised_filter_is_reachable_from_dispatch | none known |
| T8 | Tampering / elevation — a published text/html or image/svg+xml file runs script in this instance's origin when a browser opens its URL | B1 → B2 | X-Content-Type-Options: nosniff (stops sniffing, not rendering of a declared type) | open: a publisher can plant same-origin active content; §15 q8 recommends serving active types as an attachment |
| T9 | Spoofing — a held file in hybrid shadows the upstream file of the same path | B1 | only a releases:publish holder on that name can hold it; the registry page states it | accepted by the operator who chooses hybrid |
| T10 | Denial of service — one caller fills storage, or a version's file list grows without bound | B1 | limits.max_artifact_size_bytes per file, the quota reservation per file | no cap on the number of files per version; quota bounds bytes, not entries (§10.3) — accepted for phase 2 |
| T11 | Repudiation — a later file of a version has no trace of who wrote it | B1 | every PUT writes the publish audit event, the second-file branch included (§10.1) | none once the branch is tested |
| T12 | Elevation — SSRF through the fall-through | B3 | the upstream comes from configuration only; path_allow; the segments are validated before the path is joined; the path_proxy client's existing redirect guard | as for proxy mode today |
7.2 Authentication and authorisation
- Trust boundary. A publish is authenticated (
releases:publishthrough RFC 0015 grants) and every byte it writes is under a coordinate the publisher may write to. The reader's side is unchanged:releases:read, namespace visibility, pre-release access, the rule chain, the download audit — all applied byget_artifact_at_key, never bypassed by a direct storage read (§5.2). - A hybrid overlay cannot shadow the mirror by accident. A held file wins over the upstream path of the same name — that is the feature — and it can only be held by someone with
releases:publishon that name. The registry page states it, because "our helm is not the upstream helm" is a sentence an operator should read before choosing hybrid. - What an attacker gains from a bypassed check is nothing new: every gate here is the one npm, NuGet and Maven publishes already stand behind. Adding a kind adds no new authority.
7.3 Input handling and injection
- Attacker-controlled inputs are the three path segments, the body and the two signature headers. Segments are validated before they touch a key;
ensure_safe_keyin the storage backends is the deeper guard; the body is opaque and bounded bymax_artifact_size_bytesbefore it is buffered; the signature pair is refused when incoherent (check_signing_policy), and a zero-byte signature is not a signature. - Content type is data, not a directive. The
Content-Typea publisher sends is recorded and served back verbatim withX-Content-Type-Options: nosniff, as the mirror already does for upstream types. A generic registry can hold an HTML file;nosniffdoes not stop a browser rendering a type that is declaredtext/html, so this is T8 and §15 q8, not a solved case.
7.4 Secrets and cryptography
No new secret and no new primitive. The bearer token is the existing one, read by the existing auth middleware; signatures are Ed25519 through signature::verify_ed25519, the code every signed publish already uses.
7.5 Abuse and resource exhaustion
The body is bounded by limits.max_artifact_size_bytes and the quota is reserved per file before the write (T10). An unauthenticated caller can do nothing here but read and list, at the cost of a storage read or a rendered row; the listings render from rows already loaded for visibility, with no upstream call in local.
7.6 Existing defences that still hold
- Immutability is the supply-chain property. A pinned
{name}/{version}/{filename}never changes bytes without areleases:overwritegrant and animmutablepolicy that allows it; a deleted version can never be reoccupied. This is what makes the registry usable as a lockfile target, and it is inherited, not built here. path_allowand the mandatory upstream for the mirror half; thepath_proxyclient's redirect handling;ensure_safe_key; the download audit.
8. Supply chain
No new dependency, image, action or tool: the handlers reuse actix-web, serde and the existing storage and backend ports, and the heavy suite drives the runner image's curl and this repository's CLI. task audit is unchanged.
9. Data and privacy
| Data | Personal? | Where stored | Retention | Who can read it | Leaves the instance? |
|---|---|---|---|---|---|
The file's bytes and Content-Type | not by this instance's design; a publisher can upload anything | storage, at the file key (deduplicated) | RFC 0016 retention and delete | releases:read holders | on download only |
published_by in -/{name}/{version} | yes — a user or service-account identity (user:ci-release) | the version row's publisher column, which exists today | kept: RFC 0036 decision 5 exempts publication rows from erasure under legitimate interest; gdpr export lists them | today the admin API; with this RFC every releases:list holder, anonymous included when the registry grants it | in the listing response only |
| The file list — name, size, SHA-256, content type, signature type | no | index_metadata.files[] | compacted with the row (RFC 0016 §4.5) | releases:list holders | in the listing response only |
The publish audit event per PUT | yes — the actor | the audit trail | the RFC 0036 retention class of publish events; pseudonymised on erasure | administrators | no |
| A hybrid fall-through request | no | — | — | — | yes, to the configured upstream, carrying no caller identity |
- The new exposure is the
published_byfield: the console and the admin API show it to administrators today, and a protocol listing would show it to anyone who may list. Whether an anonymous caller should see it is §15 q9. - No identity, token or IP is forwarded upstream; logs and metric labels gain no personal field (§10.1).
10. Operability
10.1 Observability
- Metrics: none new. Publishes, downloads and fall-throughs are counted by the existing per-registry counters (
batlehub_artifact_cache_hits_totaland its siblings); no label carries a package or file name. - Logs and audit trail: every
PUTwrites the publish audit event — the second-file branch, which does not go throughpublish(), calls the same audit writer, and the integration suite asserts one event per file. An overwrite and a version delete write theirs as for every kind. - Alerts: none new; the quota and storage alerts already cover the failure that matters (a full backend).
10.2 Failure modes
| Failure | Detected by | Behaviour (fail open / closed) | Recovery |
|---|---|---|---|
| Storage write fails after the policy passed | the store error | closed: 5xx, no files[] entry, quota reservation released | the client retries the PUT |
| Database write of the file entry fails after the bytes were stored | the put_generic_file error | closed: 5xx; the bytes sit at their key unreferenced | a retry overwrites the same key with the same bytes; the dedup sweep reclaims an abandoned one |
Upstream down in hybrid | the path_proxy error | held files served; a miss is the mirror's existing 502 | none needed |
| Invalid mode/upstream combination | AppConfig::validate() | the configuration is refused at startup and on reload | fix the file (§4.5) |
10.3 Performance and capacity
- One storage object per distinct file (deduplicated) and one
files[]entry of roughly 200 bytes per file. A version with 1 000 files is a 200 KB JSONB value rewritten on every append — quadratic in the file count, and the trigger the files table alternative (§12) names. collect_payloadbuffers the body: a 1 GB installer is 1 GB of memory per concurrentPUT, bounded bymax_artifact_size_bytes. That is today's behaviour for every publish; a streaming publish is out of scope.
11. Other concerns
- Accessibility: the console change is one more tab in the existing setup guide component, which already has keyboard tab navigation and focus styles; no new widget.
- Internationalisation: the Publish tab's label and its sentence are added to every locale under
ui/src/locales; the CLI output is English, like every CLI message. - Compliance: no control changes; the publish audit events feed the RFC 0036 trail as every other publish does, and an immutable, pinned file is evidence a CRA-style SBOM can reference.
- Licensing: unchanged; published files are the publisher's.
- Documentation:
docs/registries/generic.md,docs/use/publishing.mdand the registries index (§6.5), in English and the French twins.
12. Alternatives considered
| Alternative | Why rejected |
|---|---|
| Keep the forge passthrough as the answer | It governs nothing: the cached copy is _packages/_, so no owner, quota, tombstone, retention or listing. The demand exists (§2.1), and the machinery to meet it is idle. |
A new kind (type = "files") instead of a mode on generic | Two kinds for one file tree, and a fleet that wants a mirror with a private overlay would need both. hybrid is the mode built for exactly that, and it costs one validator change. |
Publish through publish() for every file, storing the primary at the plain key | The second file's publish() would hit the tombstone and versioning checks on a row that legitimately exists, and would double-store the first file. Maven already answers this with artifact_key; following it is one branch, not a rule. |
A files table instead of index_metadata.files[] | A migration, a new port surface, a retention rule and an air-gap export path for a list that every other kind keeps in the same JSON column. Revisit if a version ever needs thousands of files. |
| Nested paths inside a version | A second addressing scheme on one coordinate; every policy is written against three segments; and GitLab, the reference, is flat too. |
Emulate /api/v4/projects/:id/packages/generic/… so pipelines need no change | The forge passthrough already serves that URL for the forge's content; a second server answering it for different content is the kind of ambiguity that ends in a wrong artifact. Each kind has its own prefix here. |
Serve .sha256/.sig side-cars computed by this instance | The signature is a header on download everywhere else; generating a second representation of it invents a protocol no client reads. Publish the side-car as a file if a consumer wants one. |
13. Rollout and compatibility
- Default behaviour when not configured: none. No
genericregistry changes mode by itself;proxyis untouched. - Config migration: none;
CURRENT_CONFIG_VERSIONstays. The only validator change is that a combination that was refused is now accepted, and alocalregistry with an idleupstreams/path_allowis now refused — which cannot hit an existing file, sincelocalwas refused outright. - Operator prerequisites: none beyond what a local registry of any kind needs (Postgres, a storage backend, tokens).
max_artifact_size_bytesbounds each file; the page says so beside the mirror's identical note. - Rollback: set the registry back to
proxy(or remove it). Published rows and files stay in the database and storage underlocal:keys until retention or delete takes them; nothing else references the mode.
14. Test plan
- Unit (
crates/core/src/services/generic.rs): the filename rule accepts GitLab's set and rejects a leading~, a space, a/;push_fileon a row with no list creates it;latestskips a yanked and a pre-release version;blocking::strip'sGenericarm drops a blocked version from the versions document and refuses a blocked version's file document. - Unit (
crates/config/src/schema/tests.rs):localwithupstreamsis refused;localwithpath_allowis refused;hybridwithoutpath_allowis refused;proxyis unchanged (the existing tests). - Integration (
crates/web/tests/local_generic_registry.rs): the five routes;generic_publish_traversal_version_returns_400and itsnameandfilenametwins; second file adds, same file409, overwrite grant withimmutable = "never"replaces; delete thenPUTis409tombstone; hybrid held-first then fall-through throughFixedRegistry; listing hides a blocked version;openapi_contractseesbody = Ton every success; team-visibility coordinate is refused on the file and on both listings. - Conformance (
crates/web/tests/protocol_conformance.rs): aGENERICfixture — the threecurllines of §4.2 and the CLI'sPUT— asserting route ordering between-/{name},{name}/{version}/{filename}and{path:.*}. - CLI (
cli/tests/integration.rs):publish --type genericwithout--nameis a usage error; with both it publishes and the listing names it. - Proof: §6.P (
tests/heavy/generic.sh). - Security (
crates/web/tests/local_generic_registry.rsunless named): T1 — aPUTto a name owned by another user is403; T2 — same-filePUTwithoutreleases:overwriteis409and the stored bytes are unchanged; T3 — delete thenPUTof a new file name is409; T4 —.., an encoded/and a leading~in each of the three segments are400with no storage call; T5 — a unit test in the backend suites thatput_generic_fileleaves the row's checksum and signature columns and every otherfiles[]entry byte-identical; T6 — the team-visibility case above; T7 — the blocked-version case above; T8 — once §15 q8 is decided, a publishedtext/htmlfile is served with the decided headers; T11 — one publish audit event per file, the second file included; T12 — a hybrid fall-through outsidepath_allowis403with no upstream call. - Audit:
task auditunchanged — no new dependency (§8). - Existing suites that must pass unchanged:
local_maven_registry.rs(theartifact_keygate this reuses),tests/heavy/pathproxy.shand thegenericmirror tests (proxymode is untouched),every_advertised_filter_is_reachable_from_dispatch.
15. Decisions and open questions
Resolved
| # | Question | Decision |
|---|---|---|
| 1 | A mode on generic, or a new kind? | A mode. hybrid is the mirror-plus-overlay case, and it already exists. |
| 3 | Where does the file list live? | index_metadata.files[] on the version row. Every other kind's ecosystem document lives there; retention compaction and the air-gap export already handle it. |
| 5 | Listing routes under a reserved prefix or a trailing slash? | -/{name} and -/{name}/{version}. A trailing slash is a legitimate upstream path on a mirror; a reserved segment is the convention npm (/-/) and RFC 0019's raw scheme already use. |
| 6 | How does a later file reach the row's file list? | A narrow, purpose-named port method, put_generic_file, not a general set_index_metadata. The first draft proposed set_index_metadata(registry, name, version, value), which contradicts a decision already written on the port: "a narrow, purpose-named method rather than a general set_index_metadata. The generic one would be a way to mutate anything on a published version — including the checksum — behind a verb that names one field, which is the shape immutable exists to prevent" (ports/registry/local_registry.rs:113-116, beside set_channel). put_generic_file writes one files[] entry and nothing else (§6.1, T5). Corrected in review, 2026-11-15. |
Still open
- Scanning and SBOM cover the first file only. RFC 0018's
FirstSeenjob andrun_publish_sbomattach to the version, and Maven's jars have the same gap today. Recommendation: land as-is with the limitation on the page, and open a 0018-bis for multi-file versions, since the fix is in the worker's notion of "the artifact", not here. - Release imports into a generic registry (RFC 0021). An import cannot read a coordinate off a generic asset name; a tag-as-version rule (
name = <repo>,version = <tag>, every asset a file) is small and useful. Recommendation: a bis of 0021 after this lands, not scope here. - Land phases 1–4 first; split
hybridand the air gap out. Review finding (2026-11-15): the demand that §2 names is a private file store (local);hybridadds the two-step read of §5.2, the path-shape rule and the T9 shadowing risk, and the air gap (phase 5) adds a 0008-bis row — each separable, and nothing inlocaldepends on them. No user is named in §2 asking for an overlay on a mirror. Recommendation: phases 1–4 deliverlocalonly (validation refuseshybridon this kind until a later phase);hybridbecomes its own phase after the heavy suite of §6.P is green, and the air gap stays phase 5 on its own. - A publisher-chosen
Content-Typeis served from this instance's origin. Review finding (T8):X-Content-Type-Options: nosniffstops sniffing, not the rendering of a declaredtext/htmlorimage/svg+xml, so a publisher can plant script that runs in the console's origin when someone opens the file's URL. Recommendation: record the type but serve every active type (text/html,application/xhtml+xml,image/svg+xml,text/xml,application/xml) asapplication/octet-streamwithContent-Disposition: attachment, and addContent-Security-Policy: sandboxon every generic download. published_byin a protocol listing. §9:-/{name}/{version}shows a user identity to everyreleases:listholder, anonymous included when the registry grants it, where today only administrators see it. Recommendation: renderpublished_byonly to an authenticated caller, and omit the field for an anonymous one.
16. Implementation phases
| Phase | Content |
|---|---|
| 1 | crates/core: supports_local_mode, listing_filter and the Generic strip arm, PublishRequest::storage_key, LocalRegistryBackend::put_generic_file (in-memory and Postgres), services/generic.rs. crates/config: the §4.5 validator changes. Tree green; nothing routable yet, so phases 1 and 2 land together. |
| 2 | crates/web: the four handlers and the local branch of generic_get, the two DTOs, local_generic_registry.rs, the conformance fixture. Useful on its own: publish, read, list, delete, hybrid overlay. |
| 3 | tests/heavy/generic.sh and its task and matrix row. Runs before phase 2 is called done. |
| 4 | cli publish --type generic; ui snippet; docs/registries/generic.md, docs/use/publishing.md, the registries index; ROADMAP.md ticked; the §17 note. |
| 5 | Air gap: the composed listings and the 0008-bis table row, proven in tests/heavy/airgap.sh. Ships on its own. |