feat(maven): composition-root mount of slug-anchored formats (Step 10b)

What

Step 10b of the Maven hosted plan: mount the slug-anchored formats (npm and Maven) on the production application mux behind a shared root dispatcher, so a resolved Maven route is reachable end-to-end instead of a registration-time panic or a 404 at the mux.

npm and Maven both want the root / pattern, which cannot coexist with OCI's /v2/ on a single net/http.ServeMux (/v2/acme/maven/x matches both /v2/ and the slug wildcard, neither more specific). A shared root dispatcher (buildRootDispatcher in wire_root_dispatcher.go) mounts the slug-anchored routes at / while OCI keeps /v2/ and management keeps /api/v1/ on the application mux, preserving reserved-prefix precedence over the slug wildcard.

Changes

  • cmd/artifact-registry/wire_root_dispatcher.go (new): buildRootDispatcher mounting the npm + Maven slug-anchored routes.
  • cmd/artifact-registry/wire.go: construct the shared dispatcher and mount it at /; call the npm + Maven wire seams.
  • cmd/artifact-registry/wire_maven.go: production buildMavenDispatcher + mavenNamespaceFinderAdapter.
  • Tests: wire_root_dispatcher_test.go (mux coexistence + reserved-prefix precedence), wire_root_dispatcher_boot_integration_test.go (boots the slug-anchored formats against a real DB, asserts each route reaches its handler), and a mavenNamespaceFinderAdapter error-translation unit test in wire_maven_test.go.

Acceptance

  • npm, Maven, and OCI coexist on the shared mux without a ServeMux overlap panic.
  • A live Maven route resolves end-to-end (a hosted PUT reaches its handler, not a 404 at the mux).
  • Reserved-prefix precedence (/v2/, /api/v1/) holds over the slug wildcard.
  • Unblocks Step 11 (the first step that needs a live mounted route).

Reviewer notes

  • Diff size: the diff is over the 500-LOC review guideline, but ~75% is table-driven routing tests. Production code is ~182 LOC; buildRootDispatcher itself is 67 LOC. The large surface is the coexistence + reserved-prefix precedence matrix, not production complexity.
  • Out of scope (tracked separately): some handler.go comments are stale after this step (the maven dispatcher now handles all methods, not just GET/PUT). Reconciling those comments and the 405 Allow header is deferred to a dedicated maven-package MR. (The dead wireMavenWithResolver seam, originally listed here, was removed in this MR instead.)

Related to #21 (closed)

Edited by Sylvia Shen

Merge request reports

Loading
Loading