Module proxy and its self-check, observe-only (MQ-11 step 5a) #51

Merged
merge-queue merged 1 commit from mq-11-goproxy into main 2026-12-01 02:13:22 -08:00
Owner

Step 5a of stage 6b of the anvil build: https://openproject.home.romaine.life/wp/MQ-11 (the design's "Module proxy" section; cutover step "merge-queue proxy (observe)").

Added

  • goproxy.go: a GOPROXY-protocol handler at /goproxy/<plan>/.... A plan (in memory) maps module@version to repository, commit and folder. For a registered version: list, .info (committer time), .mod (byte for byte) and .zip, which is x/mod/zip.CreateFromVCS run on a scratch repo whose objects are the bare clone's, with the blobs it needs fetched by id first, cached on the volume (DATA_DIR/goproxy/zips) by module, version and tree. @latest and anything unregistered: 404. Unknown plan: 410. Paths and versions are case-escaped.
  • CreateFromVCS runs with export-ignore and export-subst turned off, because cmd/go turns them off before its own git archive (ensureGitAttributes). Without that, a file marked export-ignore is in Go's zip but not anvil's, and the h1: differs. A test caught this.
  • Auth: a Forgejo token as basic auth (the password, or the user name when there's no password). It is accepted if it can GET /api/v1/repos/<plan's library repo>, and the verdict is cached 10 minutes, keyed by the token's sha256 and the repo. No token gets 401, a refused one 403, and Forgejo down 502 (not cached). No token is logged.
  • Self-check: for each library module with users, the h1: of anvil's zip and go.mod for its newest real tag, compared with what users' go.sum files on their default branches record. It runs at warm-up, whole after a fetch of the library's repository, and for one user's go.sum after a fetch of that user. Results are ok / mismatch (both hashes) / unknown. Shown in GET /selfcheck JSON, the gauge merge_queue_goproxy_selfcheck_modules{result}, and one warn line per new mismatch. Also the counter merge_queue_goproxy_requests_total{answer}.
  • register (test-only until step 5b plans landings).
  • Tests: protocol answers from a real git origin (nested module excluded, the root LICENSE in a folder module's zip, an export-ignore file kept, escaping, 404/410), auth (401/403, verdict cache and expiry), the self-check (Go's real sums give ok, a bogus go.sum gives a mismatch with both hashes, a user's fix and fetch turn it ok, an older recorded version gives unknown), and the end-to-end: go mod download through the proxy, then the same commit tagged and fetched with GOPROXY=direct. The h1: sums are equal for a root module and a module in a folder. On Linux (CI) the proxy run uses https with the token in the GOPROXY URL, since Go sends URL credentials over https only; elsewhere a forwarder adds the same basic auth.

Changed

  • k8s/route.yaml: a PathPrefix /goproxy match beside /health on merge-queue.home.romaine.life.
  • main.go, keep.go: wiring. The self-check runs after clones ready and after each fetch.
  • selftest.go: the image's self-test also checks the 410 for an unknown plan and /selfcheck.
  • README: a "Module proxy" section, Observability, and DATA_DIR.

Removed

Nothing.

Left alone

No plan is ever registered, so nothing outside the tests is served yet (step 5b does that). queue.go, groups.go and lines.go are untouched (held mq-10-lines). The metrics are registered from goproxy.go rather than in metrics.go, so they don't collide with that branch.

Differs from the brief

The self-check page is GET /selfcheck, not /goproxy/selfcheck: the route's /goproxy prefix would have published it.

🤖 Generated with Claude Code

Step 5a of stage 6b of the anvil build: https://openproject.home.romaine.life/wp/MQ-11 (the design's "Module proxy" section; cutover step "merge-queue proxy (observe)"). ## Added - `goproxy.go`: a GOPROXY-protocol handler at `/goproxy/<plan>/...`. A plan (in memory) maps module@version to repository, commit and folder. For a registered version: `list`, `.info` (committer time), `.mod` (byte for byte) and `.zip`, which is `x/mod/zip.CreateFromVCS` run on a scratch repo whose objects are the bare clone's, with the blobs it needs fetched by id first, cached on the volume (`DATA_DIR/goproxy/zips`) by module, version and tree. `@latest` and anything unregistered: 404. Unknown plan: 410. Paths and versions are case-escaped. - `CreateFromVCS` runs with `export-ignore` and `export-subst` turned off, because cmd/go turns them off before its own `git archive` (`ensureGitAttributes`). Without that, a file marked `export-ignore` is in Go's zip but not anvil's, and the `h1:` differs. A test caught this. - Auth: a Forgejo token as basic auth (the password, or the user name when there's no password). It is accepted if it can `GET /api/v1/repos/<plan's library repo>`, and the verdict is cached 10 minutes, keyed by the token's sha256 and the repo. No token gets 401, a refused one 403, and Forgejo down 502 (not cached). No token is logged. - Self-check: for each library module with users, the `h1:` of anvil's zip and go.mod for its newest real tag, compared with what users' go.sum files on their default branches record. It runs at warm-up, whole after a fetch of the library's repository, and for one user's go.sum after a fetch of that user. Results are ok / mismatch (both hashes) / unknown. Shown in `GET /selfcheck` JSON, the gauge `merge_queue_goproxy_selfcheck_modules{result}`, and one warn line per new mismatch. Also the counter `merge_queue_goproxy_requests_total{answer}`. - `register` (test-only until step 5b plans landings). - Tests: protocol answers from a real git origin (nested module excluded, the root LICENSE in a folder module's zip, an export-ignore file kept, escaping, 404/410), auth (401/403, verdict cache and expiry), the self-check (Go's real sums give ok, a bogus go.sum gives a mismatch with both hashes, a user's fix and fetch turn it ok, an older recorded version gives unknown), and the end-to-end: `go mod download` through the proxy, then the same commit tagged and fetched with `GOPROXY=direct`. The `h1:` sums are equal for a root module and a module in a folder. On Linux (CI) the proxy run uses https with the token in the GOPROXY URL, since Go sends URL credentials over https only; elsewhere a forwarder adds the same basic auth. ## Changed - `k8s/route.yaml`: a `PathPrefix /goproxy` match beside `/health` on merge-queue.home.romaine.life. - `main.go`, `keep.go`: wiring. The self-check runs after `clones ready` and after each fetch. - `selftest.go`: the image's self-test also checks the 410 for an unknown plan and `/selfcheck`. - README: a "Module proxy" section, Observability, and `DATA_DIR`. ## Removed Nothing. ## Left alone No plan is ever registered, so nothing outside the tests is served yet (step 5b does that). queue.go, groups.go and lines.go are untouched (held mq-10-lines). The metrics are registered from goproxy.go rather than in metrics.go, so they don't collide with that branch. ## Differs from the brief The self-check page is `GET /selfcheck`, not `/goproxy/selfcheck`: the route's `/goproxy` prefix would have published it. 🤖 Generated with [Claude Code](https://claude.com/claude-code)
Module proxy and its self-check, observe-only (MQ-11 step 5a)
All checks were successful
Suite default / reused-checks (pull_request) Successful in 31s
Suite default / check-fetches (pull_request) Has been skipped
Suite go / check-services (pull_request) Has been skipped
Suite default / check-rules (pull_request) Successful in 16s
Suite default / check-logs (pull_request) Successful in 16s
Suite go / check-test-windows (pull_request) Has been skipped
Suite cluster-service / check-smoke (pull_request) Has been skipped
Suite cluster-service / check-manifests (push) Has been skipped
Suite cluster-service / check-image (push) Has been skipped
Suite cluster-service / scope (push) Has been skipped
Suite cluster-service / check-smoke (push) Has been skipped
Suite cluster-service / publish (push) Has been skipped
Suite cluster-service / reused-checks (push) Has been skipped
Suite default / scope (pull_request) Successful in 17s
Suite cluster-service / scope (pull_request) Successful in 20s
Suite go / scope (pull_request) Successful in 19s
Suite cluster-service / publish (pull_request) Has been skipped
Suite cluster-service / check-manifests (pull_request) Successful in 18s
Suite go / check-format (pull_request) Successful in 30s
Suite cluster-service / check-image (pull_request) Successful in 2m0s
Suite go / check-test-linux (pull_request) Successful in 1m54s
Suite cluster-service / reused-checks (pull_request) Successful in 31s
Suite go / reused-checks (pull_request) Successful in 36s
merge-queue landed on main
9b28240153
goproxy.go serves a plan's predicted module versions at /goproxy/<plan>
(Go's GOPROXY protocol; .zip from x/mod's CreateFromVCS with export-ignore
and export-subst off as Go has them, cached on the volume by tree), checks
a Forgejo token that can read the plan's library repository, and self-checks
each library's newest tag's h1: against its users' go.sum. Nothing registers
a plan yet. The route carries /goproxy; /selfcheck stays in the cluster.
merge-queue deleted branch mq-11-goproxy 2026-12-01 02:13:22 -08:00
Sign in to join this conversation.
No reviewers
No labels
queue
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
romaine-life/merge-queue!51
No description provided.