{
  "repo": "tidbcloud/infra-api",
  "binary": "config-manager",
  "binary_path": "cmd/config-manager/main.go",
  "dependencies": {
    "Runtime ConfigManagerLifecycle.LoadFlagsAndLogger": {
      "infrastructure": {
        "runtime_flags": [
          {
            "operation": "PARSE FLAGS",
            "target": "metrics-bind-address, health-probe-bind-address, leader-elect, gc-period, config-revision-ttl",
            "conditions": [
              "Always at process start"
            ],
            "implementation": "cmd/config-manager/main.go:48-65"
          }
        ]
      },
      "services": []
    },
    "Runtime ConfigManagerLifecycle.CreateManager": {
      "infrastructure": {
        "kubernetes_api": [
          {
            "operation": "BUILD MANAGER CLIENTS",
            "target": "controller-runtime cached client, direct API reader, webhook server, metrics server, and probe server",
            "conditions": [
              "Always after flags are parsed"
            ],
            "implementation": "cmd/config-manager/main.go:69-82"
          }
        ]
      },
      "services": []
    },
    "Runtime ConfigManagerLifecycle.RegisterClusterConfigController": {
      "infrastructure": {},
      "services": []
    },
    "Runtime ConfigManagerLifecycle.RegisterGarbageCollector": {
      "infrastructure": {},
      "services": []
    },
    "Runtime ConfigManagerLifecycle.RegisterClusterRevisionWebhook": {
      "infrastructure": {},
      "services": []
    },
    "Runtime ConfigManagerLifecycle.RegisterHealthChecks": {
      "infrastructure": {},
      "services": []
    },
    "Runtime ConfigManagerLifecycle.StartManager": {
      "infrastructure": {
        "kubernetes_api": [
          {
            "operation": "LIST/WATCH/GET/UPDATE",
            "target": "Cluster, ClusterConfig, and ConfigRevision resources served through the manager cache and client",
            "conditions": [
              "Always after controller and webhook registration"
            ],
            "implementation": "cmd/config-manager/main.go:105-109"
          },
          {
            "operation": "LEADER ELECTION",
            "target": "controller-runtime leader-election lock",
            "conditions": [
              "Only when --leader-elect=true"
            ],
            "implementation": "cmd/config-manager/main.go:56-81"
          }
        ]
      },
      "services": []
    },
    "Runtime ClusterConfigController.Reconcile": {
      "infrastructure": {
        "kubernetes_api": [
          {
            "operation": "GET",
            "target": "Cluster named by the reconcile request",
            "conditions": [
              "Always when Reconcile is invoked"
            ],
            "implementation": "controllers/clusterconfig/clusterconfig_controller.go:62-70"
          },
          {
            "operation": "LIST",
            "target": "ConfigRevision objects matching the overlaid ClusterConfig labels",
            "conditions": [
              "Cluster exists, is not deleting, and the calculated ClusterConfig is not dry-run"
            ],
            "implementation": "controllers/clusterconfig/clusterconfig_controller.go:105-126"
          },
          {
            "operation": "CREATE/UPDATE",
            "target": "ConfigRevision and Cluster.spec.configRevisionRef",
            "conditions": [
              "No equivalent ConfigRevision exists or the current Cluster points at a different revision"
            ],
            "implementation": "controllers/clusterconfig/clusterconfig_controller.go:79-101"
          }
        ]
      },
      "services": [
        {
          "name": "gitops-v2",
          "target_interface": "Gitops.DescribeClusterConfiguration",
          "operation_type": "internal_kubernetes_reader",
          "target_repo": "tidbcloud/infra-api",
          "conditions": [
            "Cluster exists and is not deleting"
          ],
          "operations": [
            {
              "operation": "DESCRIBE CLUSTER CONFIGURATION",
              "trigger": "Calculate the layered ClusterConfig before deriving a ConfigRevision",
              "conditions": [
                "Always before GetClusterRevision(...)"
              ],
              "implementation": "controllers/clusterconfig/clusterconfig_controller.go:76-83"
            }
          ]
        }
      ]
    },
    "Runtime ConfigRevisionGarbageCollector.RunGarbageCollection": {
      "infrastructure": {
        "kubernetes_api": [
          {
            "operation": "LIST",
            "target": "all ConfigRevision resources",
            "conditions": [
              "Each gc-period tick on the elected leader"
            ],
            "implementation": "controllers/clusterconfig/garbage_collector.go:44-49"
          },
          {
            "operation": "LIST",
            "target": "Cluster objects indexed by .spec.configRevisionRef.name",
            "conditions": [
              "For each ConfigRevision candidate"
            ],
            "implementation": "controllers/clusterconfig/garbage_collector.go:51-56"
          },
          {
            "operation": "DELETE",
            "target": "expired ConfigRevision resources with zero referencing Clusters",
            "conditions": [
              "No Cluster references the revision and activeAt + configRevisionTTL is before now"
            ],
            "implementation": "controllers/clusterconfig/garbage_collector.go:57-69"
          }
        ]
      },
      "services": []
    },
    "HTTP POST /mutate-cloud-pingcap-com-v1-cluster-revision": {
      "infrastructure": {
        "kubernetes_api": [
          {
            "operation": "LIST/CREATE/UPDATE",
            "target": "ConfigRevision objects needed to resolve or mint the revision reference",
            "conditions": [
              "Admission object decodes as Cluster and cluster.spec.configRevisionRef is nil"
            ],
            "implementation": "cmd/config-manager/webhooks/cluster_webhook.go:37-61"
          }
        ]
      },
      "services": [
        {
          "name": "gitops-v2",
          "target_interface": "Gitops.DescribeClusterConfiguration",
          "operation_type": "internal_kubernetes_reader",
          "target_repo": "tidbcloud/infra-api",
          "conditions": [
            "Admission object decodes successfully",
            "cluster.spec.configRevisionRef is nil"
          ],
          "operations": [
            {
              "operation": "DESCRIBE CLUSTER CONFIGURATION",
              "trigger": "Compute the effective ClusterConfig for the new Cluster admission request",
              "conditions": [
                "Always before clusterconfig.GetClusterRevision(...)"
              ],
              "implementation": "cmd/config-manager/webhooks/cluster_webhook.go:48-55"
            }
          ]
        }
      ]
    },
    "HTTP GET /metrics": {
      "infrastructure": {},
      "services": []
    },
    "HTTP GET /healthz": {
      "infrastructure": {},
      "services": []
    },
    "HTTP GET /readyz": {
      "infrastructure": {},
      "services": []
    }
  },
  "notes": [
    "The webhook is a Cluster create mutator even though the path suffix says cluster-revision.",
    "The garbage collector's real work happens in performGC on a periodic timer; representing it as a background worker avoids losing the TTL condition.",
    "gitops-v2 here is an internal in-repo Kubernetes-backed configuration reader, not an external network RPC."
  ]
}
