Files
codebase-memory-mcp/tests
Martin Vogel 52ca6b7e19 fix(k8s): link a Service to the pods its whole selector selects
Service -> workload INFRA_MAPS edges came from a value-only guess:
- any one selector VALUE matched, ignoring keys and the other pairs
  (`{app: web, tier: front}` selected `tier: back` pods; `component: web`
  selected `app: web`),
- any `labels:` block counted, including the workload's own
  metadata.labels rather than its pod template's,
- a workload whose NAME equalled a selector value was selected,
- namespaces were ignored,
- only the first 512 manifests took part (deckhouse has 2,003), and the
  match was Services x workloads.

Now a Service selects a workload when every `key=value` of its
spec.selector is a pod-template label (a bare Pod's metadata.labels) and
their namespaces do not conflict -- how Kubernetes resolves endpoints.
Records grow without a cap; an inverted index from "key=value" to
workloads makes each Service scan only the workloads carrying its rarest
pair. Records stay in file order, so the edge set is deterministic.

On real input against main: gardener 12 -> 11 (the removed edge joined a
Service to a Helm template only through the Deployment's name; its pod
labels come from `.Values.labels`), k8s.io 11 -> 12, cluster-api
0 -> 1, eight other corpora unchanged. Most Services still sit in the
second document of their file, which only the first document is read
from.

probe_k8s_infra_maps_edge passed only through the name guess (its
Deployment had no pod labels); the fixture now carries the label.
Six new probes, one per defect above, fail on the old matcher.

Signed-off-by: Martin Vogel <martin.vogel.tech@gmail.com>
2026-10-10 12:45:52 +02:00
..