Repository navigation
Description
Why
After #764 (DynamoDB removal) and the upgrade stack, go.mod/go.sum carry residue that go mod tidy would normally clear. But go mod tidy is structurally unusable here (verified 2026-09-13): the generated proto packages aethermesh.dev/api/aether/{cni,config,registry,registrar,agent}/v1 exist only as Bazel outputs, so the Go tool fails with "no matching versions for query latest" on every import of them, and go mod tidy -e strips modules only generated code needs and breaks the gazelle_overrides (bazel mod tidy then fails). The cleanup therefore has to be driven from the module graph and the Bazel graph, not from go mod tidy.
Measured state (main @ e871c26)
| what | value |
|---|---|
go.mod requires |
103 (75 direct, 28 indirect) |
module build list (bazel run @rules_go//go -- list -m all, works from go.mod alone) |
318 modules |
go.sum |
1,458 lines / 277 modules |
go.sum modules not in the build list (stale) |
27 modules / 243 lines — the whole AWS SDK tree, smithy-go, protoc-gen-dynamo, protoc-gen-star, jennifer, testcontainers dynamodb, … |
| direct requires with zero Go imports anywhere in the repo | 24: golang.org/x/crypto, golang.org/x/time, github.com/go-jose/go-jose/v4, github.com/go-openapi/swag + its 11 sub-modules, github.com/moby/spdystream, github.com/mxk/go-flowrate, github.com/zeebo/errs, github.com/blang/semver/v4, k8s.io/component-base, github.com/vladimirvivien/gexe, go.etcd.io/etcd/server/v3 |
unused modules (no import in any .go, no BUILD/.bzl reference) |
go.etcd.io/etcd/server/v3 and go.etcd.io/raft/v3 (added with the original etcd backend #20, the embed server was never used; both still have gazelle_override blocks in MODULE.bazel). They drag ~23 indirect requires that nothing else needs: bbolt, etcd/pkg/v3, cmux, probing, grpc-websocket-proxy, golang-jwt/v5, groupcache, btree, go-humanize, gogo/protobuf, clockwork, afero, go-strcase, vtprotobuf, morikuni/aec, pkg/errors, cel-go (google), go-cmp, easyjson, intern, go-grpc-middleware v1 + providers/prometheus |
| Bazel-only direct requires (referenced from BUILD/.bzl, never imported) | github.com/pseudomuto/protoc-gen-doc, github.com/pseudomuto/protokit (//website API docs), github.com/uudashr/gocognit (lint aspect), buf.build/gen/go/bufbuild/protovalidate/protocolbuffers/go (proto compiler dep) — must stay direct |
| Dependabot open | github.com/moby/go-archive high (indirect via testcontainers-go), pymdown-extensions high+medium (website/requirements_lock.txt) |
Note //test/e2e:e2e_test is manual (run by ci.yaml directly), so sigs.k8s.io/e2e-framework and its deps (gexe, spdystream, go-flowrate, component-base) are legitimately used even though deps(//...) does not see them — any "unused" analysis must include manual targets.
Plan (one PR for Go deps, one for the website lock)
0. Repeatable audit first — scripts/go-deps-audit.sh + make deps-audit:
- build list:
bazel run @rules_go//go -- list -m all(needsGOPROXY=https://proxy.golang.org,directin the environment;--repo_envdoes not reach the go subprocess); - stale go.sum = go.sum modules ∉ build list (print module + line count);
- direct requires with zero
.goimports (grep"<module>(/|")"over the repo minusbazel-*) and zero BUILD/.bzl references; - Bazel-reachable module set from
bazel query 'deps(//... + //test/e2e:e2e_test + //website:all)'(include manual targets) for the unused check.
Exit non-zero on stale go.sum or unused requires; wire it as adeps-auditjob inci.yaml(cheap: no build).
1. go.sum prune — delete every line whose module is not in the build list (−243 lines). Verify: bazel build //... //test/e2e:e2e_test (gazelle's go_deps verifies every module it fetches against go.sum, so a wrongly removed h1: fails loudly; add back with go mod download <mod> if so), bazel mod tidy idempotent, //website:site_test.
2. Remove the unused modules — bazel run @rules_go//go -- get go.etcd.io/etcd/server/v3@none go.etcd.io/raft/v3@none, delete their two go_deps.gazelle_override blocks in MODULE.bazel, make tidy, make gazelle. Expect the ~23 indirects above to disappear and use_repo(go_deps, …) to shrink (io_etcd_go_etcd_server_v3). registry/internal/etcd and the testcontainers etcd module use only client/v3 + api/v3 — the etcd integration test must still pass. Re-run step 1 afterwards (the pruned modules leave go.sum lines behind).
3. Reclassify, don't drop, the pinned-but-unimported direct requires — x/crypto, x/time, go-jose/v4, swag ×12, spdystream, go-flowrate, zeebo/errs, blang/semver/v4, component-base, gexe become // indirect (they exist to force CVE-clean versions through MVS; the pin survives, only the directness changes). bazel mod tidy then drops their use_repo entries. Keep the four Bazel-only tools direct and mark them with a // bazel-only: referenced from BUILD/.bzl comment in go.mod so the next audit (and the next human) knows why go mod tidy -e must never be trusted on them. (A //go:build tools anchor file was considered and rejected: it would make Gazelle generate a target for it and adds nothing Bazel needs.)
4. Dependabot — moby/go-archive high: bump testcontainers-go to the first release that lifts it, else go get github.com/moby/go-archive@<fixed>; pymdown-extensions: bump in website/requirements.in and regenerate the lock with the uv pip compile line from its header (separate PR, //website:site_test is the gate).
5. Docs — runbook: why go mod tidy is forbidden (generated packages), the audit command, and the "reclassify, don't drop" rule for version pins.
Verification bar for the Go PR: build + full test (incl. //test/e2e:e2e_test build, the etcd testcontainers test, and the website targets), make format-check, make lint, make gazelle no churn, bazel mod tidy idempotent, scripts/go-deps-audit.sh clean, and the audit job green in CI. Expected outcome: go.mod ≈ 75–80 requires (from 103), go.sum ≈ 1,100 lines (from 1,458), two gazelle_overrides fewer.
🤖 Generated with Claude Code
Activity
chore(website): bump pymdown-extensions past GHSA advisories (#767) (#…
chore(deps): Go dependency audit, go.sum prune, and unused-module rem…
bpalermo commentedon Sep 13, 2026
Done in two PRs:
make deps-audit+deps-auditCI job; go.sum 1,458 → 1,193 lines (27 stale modules pruned, 18 more after the etcd removal); our requires on etcd/server/v3 + raft/v3 and 22 indirects dropped with their two gazelle_overrides; 21 pinned-but-unimported requires reclassified to indirect with no version moved; moby/go-archive → v0.3.3 (GHSA-hfg8-hc9c-6c3h); runbook section on whygo mod tidyis forbidden.Net: go.mod 207 → 183 requires (75 → 53 direct), use_repo 75 → 53, gazelle_overrides 6 → 4. Two corrections to the plan recorded in #769:
go get @nonedowngrades dependants (usedgo mod edit -droprequire), and protoc-gen-doc/protokit are real Go imports via bazel/protodoc, not Bazel-only.