Skip to content

refactor(constants): split common/constants into domain packages (#542) - #552

Merged
bpalermo merged 1 commit into
mainfrom
refactor/542-constants-split
Jul 19, 2026
Merged

bpalermo merged 1 commit into
mainfrom
refactor/542-constants-split

Conversation

@bpalermo

Copy link
Copy Markdown
Owner

Fixes #542.

Splits common/constants (zero deps but maximal fan-in — ~21 importers, most using a small slice) into domain sub-packages so each tree links only the constants it actually uses. Purely mechanical: consts moved, imports fixed, make gazelle + make format. No exported names or values changed — these are wire/annotation contracts (aether.io/ prefixes, ports).

Final layout (per-package constant counts)

Package Consts Contents
common/constants (base) 7 DefaultEndpointPort, DefaultEndpointWeight, DefaultDynamoDBServiceTableName, DefaultEtcdKeyPrefix, CNIDefaultRegistryPath, IgnoredNamespaces, IsIgnoredNamespace
common/constants/annotations 15 endpoint / capture / topology annotation keys + value enums (HealthCheckMode*, Protocol*)
common/constants/labels 10 label + mesh-service/clusterset label & annotation domain
common/constants/mesh 6 ProxyOutboundPort, ProxyCapturePort, ProxyDNSResolverPort, ProxyReadinessPath, CapturePassthroughFwMark, DefaultMeshDomain
agent/internal/xds/xdsconst 3 AnnotationConfigUpstreams, AnnotationSpiffeID, AnnotationEndpointHealthPath (agent xDS-only)
agent/internal/edge/gatewayapi 1 AnnotationGatewayHTTPRedirect (moved into its sole consumer)

Importer narrowing (before → after)

Before, all ~21 importer packages linked the single common/constants blob. After, each package's group touch is:

  • mesh: 17 importers, labels: 15, annotations: 12, base: 9, xdsconst: 7, edge-const: 1.
  • Most importers now touch exactly one group (e.g. every registrar/internal/{mcs,services} file → labels only; every cni/internal/plugin dns/capture file → mesh only; agent xDS test files → xdsconst only).
  • Only 4 files still link 3+ groups (registry/internal/k8s/*, agent/internal/xds/proxy/{cluster,listener}.go), which genuinely span domains.
  • The 7 agent xDS files that only needed proxy annotations no longer link common/constants at all — they link the agent-internal xdsconst (visibility scoped to //agent:__subpackages__).

Dead constants found (NOT deleted per task)

  • DefaultEtcdKeyPrefix — zero references anywhere in the tree (kept in common/constants/registry.go).

(IgnoredNamespaces has no external constants.IgnoredNamespaces refs but is consumed internally by IsIgnoredNamespace, so it is not dead.)

Tests

  • bazel build //... — success (264 targets)
  • bazel test --test_output=errors //... — 74/74 pass
  • make format-check — clean

🤖 Generated with Claude Code

https://claude.ai/code/session_01EioJVuoepwStjHoRLB52WR

Split common/constants (maximal fan-in, ~21 importers, most using a small
slice) into domain sub-packages to narrow what each tree links:

- common/constants/annotations  — cross-tree pod/service/node annotation keys
  and their accepted values (endpoint, capture, topology, health-check-mode,
  protocol).
- common/constants/labels       — cross-tree label + mesh-service/clusterset
  label/annotation domain.
- common/constants/mesh          — cross-tree data-plane ports, paths, mesh
  domain, and netfilter mark.
- common/constants               — genuinely basic cross-tree scalars only
  (endpoint defaults, registry defaults, CNI registry path, ignored
  namespaces).
- agent/internal/xds/xdsconst    — annotations consumed only by the agent's
  xDS proxy config generation (AnnotationConfigUpstreams, AnnotationSpiffeID,
  AnnotationEndpointHealthPath).
- AnnotationGatewayHTTPRedirect moved into agent/internal/edge/gatewayapi
  (its sole consumer).

Purely mechanical: exported identifier names and values are unchanged (wire /
annotation contracts); importers change only their import path/prefix.

Co-Authored-By: Claude Fable 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01EioJVuoepwStjHoRLB52WR
@bpalermo
bpalermo merged commit fbec08e into main Jul 19, 2026
10 checks passed
@bpalermo
bpalermo deleted the refactor/542-constants-split branch July 19, 2026 18:01
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.

refactor(constants): split common/constants into domain-focused sub-packages

1 participant