Skip to content

chore(deps): Go dependency audit, go.sum prune, and unused-module removal (#767) - #769

Merged
bpalermo merged 6 commits into
mainfrom
deps/767-go-deps-audit-and-prune
Sep 13, 2026
Merged

bpalermo merged 6 commits into
mainfrom
deps/767-go-deps-audit-and-prune

Conversation

@bpalermo

Copy link
Copy Markdown
Owner

Implements #767 (steps 0–3, the Go half of 4, and 5). The website half landed in #768.

Before → after

metric before after
go.mod requires 207 (75 direct / 132 indirect) 183 (53 direct / 130 indirect)
module build list (go list -m all) 318 295
go.sum 1,458 lines / 277 modules 1,193 lines / 232 modules
use_repo(go_deps, …) entries 75 53
go_deps.gazelle_override blocks 6 4

One commit per step:

  1. Audit — scripts/go-deps-audit.sh + make deps-audit + a deps-audit CI job in the ci fan-in. Computes the module build list from go.mod alone (bazel run @rules_go//go -- list -m all, no source scan, so it works despite the Bazel-only generated proto packages), flags go.sum modules outside the build list and direct requires with no Go import and no BUILD/.bzl reference. Exits 1 on either; informational on unannotated Bazel-only requires. shellcheck/shfmt clean.
  2. go.sum prune — 27 stale modules / 243 lines: the whole aws-sdk-go-v2 tree, smithy-go, protoc-gen-dynamo, protoc-gen-star, jennifer, the dynamodb/localstack testcontainers modules, otelzap, kr/pty. Proof: go mod download over all 295 build-list modules exits 0 and adds nothing back (the same per-module check gazelle's go_deps performs).
  3. Unused modules — our requires on go.etcd.io/etcd/server/v3 and go.etcd.io/raft/v3 (never imported; the embed server was never used) plus 22 indirects that only they pulled, and their two dangling gazelle_override blocks. Deviation from the issue's recipe: go get <mod>@none downgrades every dependant (it took controller-runtime 0.25 → 0.9.7 and apiextensions-apiserver to an alpha), so the requirement was dropped with go mod edit -droprequire instead. etcd/server/v3 therefore remains in the build list as a transitive requirement of k8s.io/[email protected]; what is gone is our requirement, its gazelle repo, and the override.
  4. Reclassify, don't drop — 21 pinned-but-unimported direct requires (x/crypto, x/time, go-jose/v4, swag + 11 sub-modules, spdystream, go-flowrate, gexe, zeebo/errs, blang/semver/v4, component-base) become // indirect; no version moved (module/version pairs diffed before/after). Bazel-only requires are annotated in go.mod: protovalidate gen-go (named by a gazelle:resolve directive) and gocognit (lint aspect / tool directive). protoc-gen-doc and protokit are real Go imports (bazel/protodoc/main.go) and are annotated as build tooling.
  5. Dependabot — github.com/moby/go-archive v0.2.0 → v0.3.3 (GHSA-hfg8-hc9c-6c3h, high; testcontainers-go 0.44.0 still pins 0.2.0 so bumped directly, kept indirect).
  6. Docs — runbook section "Go dependency hygiene": why go mod tidy (even -e) is forbidden here, the audit command, the reclassify-don't-drop rule.

Verification (final tree, --repo_env=GOPROXY=https://proxy.golang.org,direct)

  • bazel build //... //test/e2e:e2e_test — 370 targets OK (the e2e test is manual; included on purpose)
  • bazel test //... --test_output=errors — 98/98, incl. the etcd and replicator testcontainers tests re-executed
  • lint with fail_on_violation, format.check, gazelle no churn, bazel mod tidy idempotent (re-checked after rebasing onto chore(website): bump pymdown-extensions past GHSA advisories (#767) #768)
  • scripts/go-deps-audit.sh — exit 0

🤖 Generated with Claude Code

https://claude.ai/code/session_01NArCRTfMPZkw4Y97U9Gdsr

bpalermo and others added 6 commits September 13, 2026 08:44
`go mod tidy` is structurally unusable in this repository: the generated
proto packages `aethermesh.dev/api/aether/*/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 that
only generated code or a BUILD file needs (which then breaks the
`gazelle_override`s and `bazel mod tidy`).

So drive the audit from the module graph and the Bazel graph instead:

* stale go.sum modules = go.sum modules outside `go list -m all` (fatal);
* direct requires with no Go import, no `@repo//` reference in any
  BUILD/.bzl file and no `tool` directive (fatal);
* direct requires with no Go import that ARE Bazel-referenced and are not
  annotated `// bazel-only:` (warning) — the fix for a version pin is to
  reclassify it as indirect, never to delete it.

`go list -m all` runs as a subprocess of `bazel run`, so `--repo_env` does
not reach it; the script exports GOPROXY itself.

Wired as `make deps-audit` and as a `deps-audit` job in ci.yaml (in the
`ci` fan-in's needs). Deliberately cheap: `go list -m all` plus greps, no
bazel build.

Co-Authored-By: Claude Fable 5.1 <[email protected]>
Claude-Session: https://claude.ai/code/session_01NArCRTfMPZkw4Y97U9Gdsr
Every one of these modules is outside the module build list
(`go list -m all`), i.e. nothing in go.mod can resolve to them any more —
residue left by the DynamoDB removal (#764) and by earlier bumps that
`bazel mod tidy` does not prune and `go mod tidy` cannot be run to prune:
the whole aws-sdk-go-v2 tree, smithy-go, protoc-gen-dynamo,
protoc-gen-star, jennifer, the dynamodb/localstack testcontainers
modules, otelzap and kr/pty.

-243 lines (1,458 -> 1,215), 277 -> 250 modules.

Verified that nothing removed was needed: `go mod download` over all 318
modules of the build list succeeds and adds no line back, `bazel build
//... //test/e2e:e2e_test` is green (gazelle's go_deps verifies every
module it fetches against go.sum), `bazel test //...` is 98/98, and
`bazel mod tidy` is a no-op.

Co-Authored-By: Claude Fable 5.1 <[email protected]>
Claude-Session: https://claude.ai/code/session_01NArCRTfMPZkw4Y97U9Gdsr
`go.etcd.io/etcd/server/v3` and `go.etcd.io/raft/v3` came in with the
original etcd backend (#20) for an embedded etcd server that was never
used: neither is imported by any .go file and neither is reachable from
`deps(//... + //test/e2e:e2e_test + //website:all)`. The registry backend
and the testcontainers etcd module use only `client/v3` + `api/v3`, which
stay.

`go get <mod>@none` is NOT usable here: `@none` downgrades every module
that requires the removed one, and k8s.io/[email protected]
requires etcd/server/v3 — it took controller-runtime 0.25.0 -> 0.9.7,
e2e-framework 0.7.0 -> 0.0.5 and apiextensions-apiserver -> 0.22.0-alpha.3
with it. `go mod edit -droprequire` removes the requirement without
touching anyone's selected version, which is what is wanted.

Also dropped the 22 indirect requires that existed only to satisfy those
two (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, google/cel-go,
go-cmp, easyjson, intern, go-grpc-middleware v1 and its prometheus
provider) — each verified absent from the Bazel build graph first — and
the two now-dangling `go_deps.gazelle_override` blocks plus the
`io_etcd_go_etcd_server_v3` `use_repo` entry, without which the go_deps
extension fails with "Some gazelle_overrides did not target a Go module
with a matching path".

go.mod 207 -> 183 requires (75 -> 74 direct, 132 -> 109 indirect); the
module build list 318 -> 295; go.sum 1,215 -> 1,189 lines after re-running
the stale-module prune (18 more modules fell out of the graph).
etcd/server/v3 itself stays in the build list at v3.7.0 as a transitive
requirement of apiextensions-apiserver — it is simply no longer ours, and
gazelle no longer generates a repository for it.

Verified: `bazel build //... //test/e2e:e2e_test`, `bazel test //...`
98/98 (incl. //registry/internal/etcd:etcd_test and //website:site_test),
`bazel run //:gazelle` no churn, `bazel mod tidy` idempotent, and
`go mod download` over all 295 modules adds nothing back.

Co-Authored-By: Claude Fable 5.1 <[email protected]>
Claude-Session: https://claude.ai/code/session_01NArCRTfMPZkw4Y97U9Gdsr
)

21 direct requires have no Go import anywhere in the repo, no BUILD/.bzl
reference and no `tool` directive. They exist to force a CVE-clean
version through MVS, so the rule is reclassify, never drop: the pin (and
therefore the selected version) survives, only the directness changes.

Moved to the indirect block: golang.org/x/crypto, golang.org/x/time,
github.com/go-jose/go-jose/v4, github.com/go-openapi/swag and its 11
sub-modules, github.com/moby/spdystream, github.com/mxk/go-flowrate,
github.com/vladimirvivien/gexe, github.com/zeebo/errs,
github.com/blang/semver/v4 and k8s.io/component-base. Diffing the
module/version pairs before and after (including after `bazel mod tidy`)
shows the only change is the `// indirect` markers — not one version
moved.

Annotated, and kept direct:
* buf.build/gen/go/bufbuild/protovalidate/protocolbuffers/go —
  `// bazel-only:`, it is only ever named by the `gazelle:resolve`
  directive in //BUILD.bazel;
* github.com/uudashr/gocognit — `// bazel-only:`, the lint aspect's
  binary (//bazel/lint/linters.bzl); it is also a `tool` directive.
The other two "Bazel-only" tools in #767, protoc-gen-doc and protokit,
turn out to be genuine Go imports — //bazel/protodoc/main.go wraps them —
so they are marked `// build tooling:` instead of `// bazel-only:`, which
would have been untrue.

`bazel mod tidy` then dropped the 21 corresponding `use_repo` entries:
75 -> 53. go.mod is 183 requires, 53 direct / 130 indirect.

scripts/go-deps-audit.sh is now clean (exit 0) on the whole tree.
Verified: `bazel build //... //test/e2e:e2e_test`, `bazel test //...`
98/98, `bazel run //:gazelle` no churn, `bazel mod tidy` idempotent,
`make format-check`.

Co-Authored-By: Claude Fable 5.1 <[email protected]>
Claude-Session: https://claude.ai/code/session_01NArCRTfMPZkw4Y97U9Gdsr
Closes the one open Go Dependabot alert: GHSA-hfg8-hc9c-6c3h, high,
`< 0.3.0`, reached indirectly through testcontainers-go. testcontainers-go
v0.44.0 is the newest release and still pins go-archive v0.2.0, so there
is no upstream bump to ride — the floor has to be raised here.

* github.com/moby/go-archive v0.2.0 -> v0.3.3 (>= the 0.3.0 fix)
* github.com/moby/sys/user v0.4.0 -> v0.4.1 (pulled by the above)

`go get` marks what it fetches as a direct require; nothing imports
go-archive, so it is put back in the indirect block — it is a pure MVS
floor, the same shape as the other CVE pins, and leaving it direct would
(rightly) fail scripts/go-deps-audit.sh.

Verified: `bazel build //... //test/e2e:e2e_test`, `bazel test //...`
98/98 with //registry/internal/etcd:etcd_test and
//registrar/internal/replicator:replicator_test actually re-executed (the
testcontainers path changed), `bazel run //:gazelle` no churn, `bazel mod
tidy` idempotent, `scripts/go-deps-audit.sh` exit 0.

Co-Authored-By: Claude Fable 5.1 <[email protected]>
Claude-Session: https://claude.ai/code/session_01NArCRTfMPZkw4Y97U9Gdsr
A "Go dependency hygiene" subsection in the developer runbook: what
`make deps-audit` reports and why it exists, why `go mod tidy` (and
especially `go mod tidy -e`) cannot be trusted in this module, the
reclassify-don't-drop rule for CVE version pins, why `go get` needs its
`// indirect` marker put back by hand, why removals use `go mod edit
-droprequire` rather than `go get <mod>@none`, and what a `// bazel-only:`
annotation means.

AGENTS.md and CLAUDE.md pointed at `make tidy` as the way to "update
go.mod dependencies", which it is not — it syncs MODULE.bazel's use_repo.
Both now say what it does, mention `make deps-audit`, and state the
`go mod tidy` prohibition where an agent will actually read it.

Co-Authored-By: Claude Fable 5.1 <[email protected]>
Claude-Session: https://claude.ai/code/session_01NArCRTfMPZkw4Y97U9Gdsr
@bpalermo
bpalermo merged commit 3c8f9c7 into main Sep 13, 2026
19 checks passed
@bpalermo
bpalermo deleted the deps/767-go-deps-audit-and-prune branch September 13, 2026 11:53
bpalermo added a commit that referenced this pull request Sep 16, 2026
…review (#772) (#787)

Phase E2 of the review: the docs were not wrong here, they were silent. Each
addition below is sourced from the code or chart it describes.

docs/configuration.md
- New § 3 `prober` section (proposal 013, `charts/prober`): the binary's whole
  flag set with defaults from `prober/internal/prober/prober.go`
  DefaultConfig + `prober/internal/cmd/root.go`; the two metrics it exports
  (`aether_probe_requests_total`, `aether_probe_request_duration_seconds`),
  their tier/target/result attributes and the full `result` value set; why
  per-node identity is an OTel *resource* attribute rather than a metric label;
  and the chart's deployment shape (DaemonSet into a mesh-managed namespace,
  derived `config.aether.io/upstreams`, deliberately no CPU limit, #735).
  The prober takes none of the shared manager flags, which the section says.
- `--lame-duck-max` (`10s`, #729) added to the `mesh-dns` flag list, with the
  successor-observation semantics and the derived
  terminationGracePeriodSeconds.
- `--spire-wait-warn-after` (`2m`, #740) added to the agent identity flag list,
  with a paragraph saying it is a logging threshold everywhere except the node
  agent, where it doubles as the readiness dwell.
- Chart values that shipped undocumented: `spire.waitWarnAfter`,
  `agent.meshDnsDaemon.{forwardPoolSize,lameDuckMax,debug}`, and a new
  `edge.config` table covering all 11 keys of the proposal-029 fleet-default
  EdgeConfig (`name`, `useRemoteAddress`, `headersWithUnderscoresAction`,
  `streamIdleTimeout`, `requestTimeout`, `idleTimeout`,
  `perConnectionBufferLimitBytes`, `http2.*` ×3, `http3.enabled`), sourced from
  values.yaml, `edge-defaultconfig.yaml` and `api/aether/config/v1/edge_config.proto`.
  The rest of the review's "28 undocumented keys" turned out to be false
  positives of its dotted-path matcher: `edge.httpsPort`,
  `edge.geoip.database.fileName`, `edge.gateway.tlsSecretNamespace`,
  `edge.admin.*`, `edge.service.*`, `edge.overload.*`,
  `edge.spire.clusterSpiffeID.*`, `registrar.service.*` and
  `proxy.hotRestart.adminUnresponsiveDeadline` are all already documented in
  combined table rows.

CLAUDE.md / AGENTS.md
- Binaries that existed but were listed nowhere: `agent/cmd/proxy-ready` (#673),
  `agent/cmd/mesh-dns-ready` (#683), `prober/cmd/prober` (proposal 013).
- Packages that existed but were described nowhere: `common/spire` (the #740
  identity-wait/readiness model), `agent/internal/identity`,
  `agent/internal/node` + `controller/internal/nodetaint` (proposal 033 taint
  lifecycle, split across its two writers), `agent/internal/cniconflist` (#645),
  `registrar/internal/replicator` (proposal 006 Phase 2).
- The race detector next to the build/test commands, and the
  `scripts/go-deps-audit.sh` "reclassify, don't drop" rule next to
  `make deps-audit`. nogo and the `deps-audit` CI job were added by #773 and are
  not duplicated here.

docs/runbook.md
- New "The race gate" subsection under § 3 Test: the `--config=race` spelling
  from .bazelrc, the scoped and `--runs_per_test=3 --nocache_test_results`
  forms, why a bare `//...` run currently reports failures that are not yours
  (#772 phase A2), and why a clean run is not evidence of absence.
- Cross-reference from the standalone-charts paragraph to the new prober
  section. The § "Go dependency hygiene" cross-reference from #769 was verified
  present and left alone.

No race CI job is claimed: `.bazelrc` ships `--config=race` and the Makefile
ships `make test-race`, but ci.yaml has no `race` job on main (it arrives with
#776), so the docs describe only the commands that exist today.

Verification: `bazel run //:format.check`, `bazel test //website:all` (the docs
feed the site; its link/nav check passes), `bazel build //... //test/e2e:e2e_test`.


Claude-Session: https://claude.ai/code/session_01NArCRTfMPZkw4Y97U9Gdsr

Co-authored-by: Claude Fable 5.1 <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant