feat(managementapi): serve statistics for remote Maven repositories (S17 repository statistics on remote repositories plan: 5/8)

Summary

  • Problem: the repository statistics route answers 404 for a remote Maven repository, as if it did not exist. So the monolith cannot show cache counts for remote repositories.
  • Impact: callers of GET /api/v1/:slug/repositories/:repository_name/statistics on a remote Maven repository. Hosted and virtual repositories, and remote npm, Docker, and OCI, answer as before.
  • Change: a remote Maven repository answers 200 with the Maven shape. artifacts_count, size_bytes, and downloads_count come from its repositories row. packages_count, versions_count, and files_count count its cache: the same rows the remote lists return.
  • Downsides: the OpenAPI and Bruno text still say remote answers 404. Step 8 updates them after every format serves remote.

The count starts from the maven_remote_repositories row. A remote repository also has a maven_repositories row, but no cache rows sit under it, so counting through that row would answer zeros. The unit tests check that the hosted lookup is never called, and the integration test fails if it is.

Checklist

  • Ran it: no local run of the service. The integration tests drive the route through the real stores on PostgreSQL 17, with a remote cache filled through the production cache write. The e2e row is in the manual test:e2e:caproni:functional job, which has not run yet.
  • Interfaces and data: the route now answers 200 instead of 404 for remote Maven. The body is the existing Maven shape, so the schema does not change. S17 already specs this (criterion 115). No config, schema, or storage change.
  • Failure: a missing maven_remote_repositories row, or a failed count, gives a logged 500, as on hosted. A cancelled request writes nothing and logs nothing.
  • Rollout: no schema or config change. During the deploy an old pod answers 404 and a new pod 200.
  • Hot path: one lookup and one count statement per request, the same as hosted.
  • Database: no new query or migration. This MR is the first caller of AggregateMavenRemoteRepositoryEntityCounts, added in !3543 (merged).
  • Security: no new route, input, or permission. The route keeps read_repository. The answer is counts only, with no artifact names.
  • ADRs: ./scripts/adr-freshness.sh says the mirror is current. ADR-009 (the route has no kind limit), ADR-021 (read_repository on repository statistics, unchanged), and ADR-007 (the remote cache tables the count reads) all hold.
  • E2E: changes e2e.maven.setup.repository-statistics. Its remote part now fetches one artifact through a mirror and expects the counts to equal the mirror's package, version, and file lists, not 404. It runs as a subtest, so a rig with no stub upstream skips only that part.
  • Simplicity: I rejected one write path shared by hosted and remote. It changes more of Step 4's code, and Step 7 writes a different type. Step 6 (!3588 (merged)) writes the same MavenRepositoryStatistics literal, so a small constructor goes in whichever of the two merges second.

Also:

  • docs/user/: none. No page says which kinds the route serves.
  • Conformance: not affected. No package-client protocol path changes.
  • Merge order: none needed. Steps 6 and 7 change their own format handlers. Step 3 (!3542 (merged)) also edits the plan's Status table, on a different row, and git merge-tree merges the two cleanly.

Closes #1671 (closed)

Edited by Dzmitry (Dima) Meshcharakou

Merge request reports

Loading
Loading