chadtmiller.com/knotless
git that lives in your Atmosphere account
knotless-serve answers Maven's repository layout for a repository's artifacts
MergedThis adds a per-repository Maven repository to knotless-serve, with an optional maven object on dev.knotless.release. File PUTs are uploaded to the PDS and staged in memory. The artifact's maven-metadata.xml PUT then makes the releases.
I read the lexicon, maven.rs, the route and App wiring, the record and release changes, the docs and the change file. I did not read tests/web.rs, swift.rs or docs/design/packages.md. swift.rs belongs to the stacked pull, and I judged the layout and publish logic from maven.rs itself. I found nothing that must change.
The lexicon and Record types agree. The auth path checks session.did == did, so a cached session can't be used on another account's repository. A republish gets 409, because versions() counts yanked releases as published.
Two notes, neither blocking:
Writing::publishtakes every staged version of the artifact out ofStaging(versions(&of, true)) before it makes any release. A failure partway through, such as a PDS error on the second version, loses the rest of the staged files, and the client has to re-upload them. Taking each version only after its release is made would avoid that.publishalso releases staged versions that the uploaded XML doesn't name. It only checks the other direction, that every named version is known. This is harmless for Gradle and Maven, which always send the version they just uploaded, but it differs from whatdocs/reference/api.mdsays ("each version … kept").
crates/knotless-serve/src/web/maven.rsline 574Outdated
return Err(bad(says)); | |
} | |
let package = asked.package(); | |
for (version, files) in app.maven.versions(&of, true) { |
versions(&of, true) removes every staged version up front. If Target::open or create fails for one, the versions after it are already gone from Staging, and the client must re-upload them. Remove each version only once its release is made.
I read what changed since my approval at 004f018. The Maven file limit drops from 256 MiB to 64 MiB. The docs and a new test for the oversize refusal agree with it. refused_publish becomes refused_as(status), a curried closure, in both maven.rs and swift.rs. It behaves the same and is used the same way at each call site. The rest is small swift.rs cleanups (Link, Digest and Content-Disposition headers set through extend) plus a few extra unit assertions. None of it breaks what I approved. My two earlier notes (taking staged versions out before making their releases, and releasing staged versions the XML doesn't name) were non-blocking, and this round doesn't touch them.
Its head ebc01370501b on main at 6a6130767443 conflicts with main in docs/design/packages.md, where both sides changed the same lines, so it is left as it is. Merge main into it, then queue it again.
The head is the same tree as the commit I approved (ebc0137), so the code hasn't changed. Only the title or body changed. I read them again, and they match what I approved. My two earlier non-blocking notes still stand: staged versions are taken out before their releases are made, and staged versions the XML doesn't name are released too. Approving.
10 passed, 1 skipped
knotless-serve now runs a Maven repository for each repository. Gradle's
maven-publishpublishes an Android or Java library tohttps://knotless.dev/maven/<did>/<repo key>/with a handle and an app password, and any build that names that URL can resolve it. HUD's hudkit is the first user. This pull is stacked on knotless-serve answers the Swift Package Registry for a repository's packages (Swift), so until that lands its diff includes that pull's commit. Two things need a look: themavenobject indev.knotless.release, and how a publish is held between requests (Staging).Claude Opus 5.5 · high
What changes
knotless-serve runs a Maven repository for each repository at
/maven/<did>/<repo key>/, in Maven's layout:GET/HEADof<group path>/<artifact>/maven-metadata.xml: built from the releases. It lists the versions that aren't yanked, the highest aslatest, the latest without a pre-release asrelease, andlastUpdated. It is sentno-cachewith an ETag.GET/HEADof each file,<group path>/<artifact>/<version>/<file>..sha1,.sha256and.sha512beside each file and beside the metadata. MD5 is answered 404.PUTof each of those, as Gradle and Maven publish.Errors are plain text. A write without credentials gets
401with aBasicchallenge, which Gradle needs before it sends its credentials.A publish is many requests, and a release is made once. Each file
PUTis uploaded to the owner's PDS as it lands and kept in memory (StaginginApp). The checksumPUTthat follows each file is checked against it; MD5 is not computed, so it goes unchecked. The artifact'smaven-metadata.xml, which Gradle and Maven send last, makes the release of each version kept, with every file.Credentials log in to the owner's PDS once per publish. The session is kept by the credentials' SHA-256 for ten minutes, so a publish of some twenty requests isn't twenty
createSessioncalls.A version is published once: a file
PUTto a published version gets409. Snapshots get400.A release gains an optional
mavenobject: itsgroup, itsartifact, and each file's SHA-1 and SHA-512. The release'spackageis<group>.<artifact>.docs/design/packages.mdhas a new Maven artifacts section.docs/reference/api.mdlists the routes. There is a change file.Why
HUD's Android half, hudkit, has to be a versioned Gradle dependency that Grain can use, instead of a copied
vendor/hud. It follows the other registries: one repository's own registry, an address holding a DID and a key, reads served from the index, and a yank keeping a version out of what is offered (here, out ofmaven-metadata.xml) while its files stay.oci.rsstages its blobs in the same way. The cost is that a restart mid-publish loses the files. The metadataPUTthen names a version neither published nor kept, and is refused with "publish it again", rather than answering 201 with nothing released. The blobs already uploaded are never referenced and the PDS drops them.maven-metadata.xmlis mutable shared state; npm's packument and Cargo's index are built from releases for the same reason.<group>.<artifact>as the package name keeps it within a release's name rules. A<group>:<artifact>name would have needed the lexicon's rule widened. The price is thatcom.example+libandcom+example.libcollide; whichever comes second is refused as published already.1.2.0and1.0.0-alpha01are SemVer.How it was checked
a_maven_repositoryintests/web.rspublishes as Gradle does, against a served repository and the PDS:.aar,.pom,.moduleand-sources.jar: the file, then its four hashes;It then reads everything back: the metadata, its SHA-1, each file and its hashes, and
HEAD. It also covers:Unit tests cover the layout parser, the metadata XML, the staging bounds (files per version, versions kept, sessions kept), the hashes and the credentials. Run locally: those tests, clippy and fmt for knotless-serve and knotless, and
harness/lexicons.mjs.End to end, against a local knotless-serve over the harness PDS, with Gradle 9.7.1, AGP 9.3.1 and JDK 17:
place.hud:tinylib:0.1.0(withmaven-publish,singleVariant("release") { withSourcesJar() }, credentials of a handle and an app password) published with./gradlew publish;.aar,.pom,-sources.jarand.module;place.hud:tinylib:0.1.0, with only the repository's URL added, built with./gradlew assembleDebug --refresh-dependencies;0.2.0-SNAPSHOTgot 400, and a wrong app password got 403, each from Gradle.Over plain http (
isAllowInsecureProtocol).Shortcomings
commitorcheckon a release, and the app password sits in the build's credentials.Review
The lexicon first, then
crates/knotless-serve/src/web/maven.rs:Writing::file,Writing::publishandStaging.