{
  "repo": "tidbcloud/aws-shared-provider",
  "binary": "manager",
  "binary_path": "cmd/manager/main.go",
  "dependencies": {
    "WebhookService.ValidateDeleteNS": {
      "infrastructure": {},
      "services": []
    },
    "MetricsService.metrics": {
      "infrastructure": {},
      "services": []
    },
    "ManagerLifecycle.LoadFlags": {
      "infrastructure": {},
      "services": []
    },
    "ManagerLifecycle.ParseConfig": {
      "infrastructure": {},
      "services": []
    },
    "ManagerLifecycle.CreateManager": {
      "infrastructure": {
        "kubernetes_api": {
          "conditions": ["Always after ParseConfig"],
          "operations": [
            {
              "operation": "BUILD_MANAGER",
              "trigger": "Create the main controller-runtime manager, infra manager, metrics server, webhook server, and cache layout",
              "conditions": ["Always during newManager(cfg)"],
              "implementation": "manager.New(cfg.Kubeconfig, cfg.InfraKubeconfig, manager.Options{Manager: ctrl.Options{Metrics: metricsserver.Options{BindAddress: cfg.MetricsBindAddress}, WebhookServer: webhook.NewServer(...), LeaderElection: cfg.EnableLeaderElection, ...}, InfraCluster: ctrlcluster.Options{...}})"
            }
          ]
        }
      },
      "services": []
    },
    "ManagerLifecycle.InitInfraRedisTLS": {
      "infrastructure": {
        "filesystem": {
          "conditions": ["cfg.InfraRedisClientCertDir is set"],
          "operations": [
            {
              "operation": "READ",
              "trigger": "Load the CA, certificate, and key used by the infra Redis consumer",
              "conditions": ["Always before creating the Redis consumer"],
              "implementation": "util.NewTLSConfig(util.WithCAPath(filepath.Join(cfg.InfraRedisClientCertDir, \"ca.crt\")), util.WithCertAndKeyPath(filepath.Join(cfg.InfraRedisClientCertDir, \"tls.crt\"), filepath.Join(cfg.InfraRedisClientCertDir, \"tls.key\")))"
            }
          ]
        }
      },
      "services": []
    },
    "ManagerLifecycle.InitClusterTLS": {
      "infrastructure": {
        "filesystem": {
          "conditions": ["cfg.ClusterCAPath, cfg.ClusterCertPath, and cfg.ClusterKeyPath are set"],
          "operations": [
            {
              "operation": "READ",
              "trigger": "Load the TLS bundle used by PD, TiKV API, TiDB worker API, and PD etcd access",
              "conditions": ["Always before creating shared cluster clients"],
              "implementation": "util.NewTLSConfig(util.WithCAPath(cfg.ClusterCAPath), util.WithCertAndKeyPath(cfg.ClusterCertPath, cfg.ClusterKeyPath))"
            }
          ]
        }
      },
      "services": []
    },
    "ManagerLifecycle.InitRegionalInfraClients": {
      "infrastructure": {
        "redis": {
          "conditions": ["cfg.InfraClusterTable and cfg.InfraRedisAddr are set", "cfg.CloudProviderType is AWS or AliCloud free tier"],
          "operations": [
            {
              "operation": "SUBSCRIBE",
              "trigger": "Subscribe to the regional infra change stream and refresh the cache client",
              "conditions": ["Only after the cloud-provider cache client is created"],
              "implementation": "consumerredis.Consumer{Addr: cfg.InfraRedisAddr, TLSConfig: infraRedisClientTLSConfig, Stream: cfg.InfraClusterTable + \"_\" + cfg.KubeClusterName, CacheOperate: infraClusterCo}.Init(...)"
            }
          ]
        },
        "dynamodb": {
          "conditions": ["cfg.CloudProviderType == AWSFreeTier"],
          "operations": [
            {
              "operation": "CONNECT",
              "trigger": "Create the AWS-backed infra cache client",
              "conditions": ["Only in AWS free-tier mode"],
              "implementation": "infracache.NewCacheClient(..., infradynamo.NewDynamoClient(pAwsCfg, cfg.InfraClusterTable, ...), false)"
            }
          ]
        },
        "tablestore": {
          "conditions": ["cfg.CloudProviderType == AliCloudFreeTier", "cfg.OtsInstanceName != \"\""],
          "operations": [
            {
              "operation": "CONNECT",
              "trigger": "Create the AliCloud TableStore-backed infra cache client",
              "conditions": ["Only in AliCloud free-tier mode with an OTS instance configured"],
              "implementation": "infracache.NewCacheClient(..., infraots.NewTableStoreClient(alicloudCred, otsEndpoint, cfg.OtsInstanceName, cfg.InfraClusterTable, ...), false)"
            }
          ]
        },
        "mysql": {
          "conditions": ["cfg.InfraRdsSecretArn != \"\" or cfg.EnableInfraMysqlClient"],
          "operations": [
            {
              "operation": "CONNECT",
              "trigger": "Initialize the optional infra MySQL underlay and cache double-write client",
              "conditions": ["Only when infra RDS is configured"],
              "implementation": "auditlogutil.GetRdsConfig(...); inframysql.NewMySQLClient(...); infracache.NewCacheClientV2(...)"
            }
          ]
        }
      },
      "services": []
    },
    "ManagerLifecycle.InitAuditLogRepo": {
      "infrastructure": {
        "mysql": {
          "conditions": ["!cfg.DisableAuditLog", "cfg.RdsSecretArn != \"\""],
          "operations": [
            {
              "operation": "CONNECT",
              "trigger": "Initialize the audit-log scheduler repository",
              "conditions": ["Only when audit logging is enabled"],
              "implementation": "auditlogutil.GetRdsConfig(...); storage.NewGormDB(...); repo.NewAuditLogScheduleRepo(...)"
            }
          ]
        }
      },
      "services": []
    },
    "ManagerLifecycle.InitSharedClients": {
      "infrastructure": {
        "etcd": {
          "conditions": ["cfg.EtcdEndpoints is not empty"],
          "operations": [
            {
              "operation": "CONNECT",
              "trigger": "Create the shared etcd client used by TiDB managers, managerserver, and controllers",
              "conditions": ["Always before runnable registration"],
              "implementation": "clientv3.New(clientv3.Config{Endpoints: strings.Split(cfg.EtcdEndpoints, \";\"), ...})"
            }
          ]
        }
      },
      "services": [
        {
          "name": "pd-server",
          "target_interface": "serverless PD keyspace and control APIs",
          "operation_type": "client_init",
          "conditions": ["Always after cluster TLS is loaded"],
          "operations": [
            {
              "operation": "CONNECT",
              "trigger": "Create the PD client shared by cluster, branch, keyspace, export, and import flows",
              "conditions": ["Always during Run(cfg, logger)"],
              "implementation": "pd.NewClient(serverlessPDEndpoint, clusterTLSConfig)"
            }
          ]
        },
        {
          "name": "tikv-api",
          "target_interface": "serverless TiKV API",
          "operation_type": "client_init",
          "conditions": ["Always after cluster TLS is loaded"],
          "operations": [
            {
              "operation": "CONNECT",
              "trigger": "Create the TiKV API client used by branch and import flows",
              "conditions": ["Always during Run(cfg, logger)"],
              "implementation": "tikv.NewApi(tikvApiEndpoint, clusterTLSConfig)"
            }
          ]
        },
        {
          "name": "tidb-worker",
          "target_interface": "Scaler gRPC and worker control APIs",
          "operation_type": "client_init",
          "conditions": ["Always after cluster TLS is loaded"],
          "operations": [
            {
              "operation": "CONNECT",
              "trigger": "Create the TiDB worker API client used by cluster and branch flows",
              "conditions": ["Always during Run(cfg, logger)"],
              "implementation": "tidbworker.NewApi(tidbWorkerApiEndpoint, clusterTLSConfig)"
            }
          ]
        },
        {
          "name": "serverless-infra-api",
          "target_interface": "regional infra API",
          "operation_type": "client_init",
          "conditions": ["Always after infra config is derived"],
          "operations": [
            {
              "operation": "CONNECT",
              "trigger": "Create the infra API client shared by managerserver, TiDB managers, and controllers",
              "conditions": ["Always during Run(cfg, logger)"],
              "implementation": "pkginfra.NewInfraAPI(context.Background(), infraConfig)"
            }
          ]
        }
      ]
    },
    "ManagerLifecycle.RegisterPoolRunnables": {
      "infrastructure": {
        "background_runtime": {
          "conditions": ["cfg.TidbPoolNamespaceList is not empty"],
          "operations": [
            {
              "operation": "REGISTER_RUNNABLES",
              "trigger": "Register the per-pool TiDB manager, scaler, upgrader, autoscaling, optional reclaimer, PDB, template controller, and pod cache controller",
              "conditions": ["Repeated for each TiDB pool namespace"],
              "implementation": "for i, tidbPoolNamespace := range cfg.TidbPoolNamespaceList { tidbmanager.New(...); mgr.Add(tManager); mgr.Add(tidbscaler.New(...)); mgr.Add(tidbupgrader.New(...)); mgr.Add(tidbautoscaling.New(...)); mgr.Add(tidbpdb.New(...)); if cfg.TidbPoolGCIntervalList[i] > 0 { mgr.Add(tidbreclaimer.New(...)) }; ... }"
            }
          ]
        }
      },
      "services": []
    },
    "ManagerLifecycle.RegisterManagerServer": {
      "infrastructure": {},
      "services": []
    },
    "ManagerLifecycle.RegisterAuxiliaryLoops": {
      "infrastructure": {
        "background_runtime": {
          "conditions": ["Always after pool runnables are registered"],
          "operations": [
            {
              "operation": "REGISTER_RUNNABLES",
              "trigger": "Register the DM scaler, node scorer, optional node drainer, optional version updater, and optional o11y API client",
              "conditions": ["Some branches are gated by DisableNodeDrainer, EnableVersionUpdater, and O11yAgentEnabled"],
              "implementation": "mgr.Add(dmscaler.New(...)); mgr.Add(nodescorer.New(...)); if !cfg.DisableNodeDrainer { mgr.Add(nodedrainer.New(...)) }; if cfg.EnableVersionUpdater { versionupdater.NewTiDBVersionUpdater(...).Start(context.Background()) }; if cfg.O11yAgentEnabled { infrao11y.InitApi(...) }"
            }
          ]
        }
      },
      "services": [
        {
          "name": "observability-openapi",
          "target_interface": "o11y infra create/delete/get APIs",
          "operation_type": "client_init",
          "conditions": ["cfg.O11yAgentEnabled"],
          "operations": [
            {
              "operation": "CONNECT",
              "trigger": "Initialize the o11y infra API client used by the cluster and branch controllers",
              "conditions": ["Only when the o11y agent feature is enabled"],
              "implementation": "infrao11y.InitApi(cfg.ObservabilityInfraConfig.Auth0GetTokenURL, cfg.ObservabilityInfraConfig.Auth0ClientID, ..., cfg.ObservabilityInfraConfig.OpenAPIAddress, ...)"
            }
          ]
        }
      ]
    },
    "ManagerLifecycle.RegisterCoreControllers": {
      "infrastructure": {
        "kubernetes_api": {
          "conditions": ["Always after all shared clients and caches are initialized"],
          "operations": [
            {
              "operation": "REGISTER_CONTROLLERS",
              "trigger": "Register the core controllers against the manager and, where required, the infra manager",
              "conditions": ["Always; individual controllers may still be gated by per-feature flags"],
              "implementation": "(&cluster.Reconciler{...}).SetupWithManager(...); (&branch.Reconciler{...}).SetupWithManager(...); (&export.Reconciler{...}).SetupWithManager(infraMgr, ...); ...; cimports.NewImportReconciler(...).SetupWithManager(infraMgr, ...)"
            }
          ]
        }
      },
      "services": []
    },
    "ManagerLifecycle.RegisterOptionalRegionalControllers": {
      "infrastructure": {
        "kubernetes_api": {
          "conditions": ["cfg.EnableRegionalCR"],
          "operations": [
            {
              "operation": "REGISTER_CONTROLLERS",
              "trigger": "Register the regional export and import controllers",
              "conditions": ["Only when regional CR support is enabled"],
              "implementation": "(&export.Reconciler{...}).SetupWithManager(mgr, \"export-regional\"); cimports.NewImportReconciler(mgr, ...).SetupWithManager(mgr, \"import-regional\")"
            }
          ]
        }
      },
      "services": []
    },
    "ManagerLifecycle.RegisterIndexers": {
      "infrastructure": {
        "kubernetes_api": {
          "conditions": ["Always after the relevant controller managers exist"],
          "operations": [
            {
              "operation": "INDEX_FIELD",
              "trigger": "Register keyspace, import, and pod field indexers used by controllers and debug APIs",
              "conditions": ["Always; import indexers run on infraMgr and optionally on mgr when regional CR is enabled"],
              "implementation": "addKeyspaceIndexFields(...); addImportIndexFields(...); addPodIndexFields(...)"
            }
          ]
        }
      },
      "services": []
    },
    "ManagerLifecycle.StartManager": {
      "infrastructure": {
        "background_runtime": {
          "conditions": ["Always after webhook registration"],
          "operations": [
            {
              "operation": "START_MANAGER",
              "trigger": "Start the controller manager, which waits for leader election before starting the infra manager",
              "conditions": ["Always unless startup returns an error"],
              "implementation": "mgr.Start(ctrl.SetupSignalHandler()); ControllerManager.Start: go func(){ <-m.Manager.Elected(); return m.infraMgr.Start(errCtx) }()"
            }
          ]
        }
      },
      "services": []
    },
    "ManagerServer.Run": {
      "infrastructure": {
        "filesystem": {
          "conditions": ["cfg.CertDir is set"],
          "operations": [
            {
              "operation": "READ",
              "trigger": "Watch the TLS certificate and key used by the HTTPS and gRPC listener",
              "conditions": ["Always before ListenAndServeTLS"],
              "implementation": "certwatcher.New(filepath.Join(s.certDir, \"tls.crt\"), filepath.Join(s.certDir, \"tls.key\"))"
            }
          ]
        },
        "http_server": {
          "conditions": ["cfg.HttpServerBindAddress is not empty"],
          "operations": [
            {
              "operation": "LISTEN_AND_SERVE",
              "trigger": "Serve HTTPS, pprof, and gRPC on the same HTTP/2 server",
              "conditions": ["Always after the cert watcher and infra API are started"],
              "implementation": "http2.ConfigureServer(server, ...); server.ListenAndServeTLS(\"\", \"\")"
            }
          ]
        },
        "grpc_server": {
          "conditions": ["Always after server startup reaches gRPC registration"],
          "operations": [
            {
              "operation": "REGISTER_AND_SERVE",
              "trigger": "Register and serve the TidbBackend gRPC API, optionally with reflection",
              "conditions": ["Always; reflection only when s.enableGrpcReflection is true"],
              "implementation": "pbm.RegisterTidbBackendServer(gServer, &grpcServer{...}); if s.enableGrpcReflection { reflection.Register(gServer) }"
            }
          ]
        }
      },
      "services": [
        {
          "name": "serverless-infra-api",
          "target_interface": "infra API cache sync",
          "operation_type": "background_start",
          "conditions": ["Always during server startup"],
          "operations": [
            {
              "operation": "START",
              "trigger": "Start the infra API and wait for its cache sync before serving requests",
              "conditions": ["Always before the public listener is started"],
              "implementation": "go s.infraApi.Start(ctx); s.infraApi.WaitForCacheSync(ctx)"
            }
          ]
        }
      ]
    },
    "ManagerServer.Healthz": {
      "infrastructure": {},
      "services": []
    },
    "ManagerServer.Readyz": {
      "infrastructure": {},
      "services": []
    },
    "ManagerServer.AssignTiDB": {
      "infrastructure": {},
      "services": [
        {
          "name": "serverless-infra-api",
          "target_interface": "cluster or branch metadata lookup and conditional patch",
          "operation_type": "metadata_lookup",
          "conditions": ["token query parameter is not empty"],
          "operations": [
            {
              "operation": "GET",
              "trigger": "Resolve the cluster or branch metadata for the provided token before assignment",
              "conditions": ["Always before assignTidb"],
              "implementation": "pkginfra.GetClusterOrBranchMeta(r.Context(), pkginfra.NewRegionalInfraWithClient(s.infraClusterCli, s.cfg.KubeClusterName), s.infraApi, utils.TrimToken(token), s.cfg.KubeClusterName)"
            },
            {
              "operation": "PATCH",
              "trigger": "Patch the resume-etcd-token annotation when assignment failed because the token was missing in etcd",
              "conditions": ["Only when assignTidb returns utils.ErrNotFoundToken and the token is not an export token"],
              "implementation": "s.infraClusterCli.Patch(...)/s.infraApi.PatchBranch(...) inside tryResumeEtcdToken"
            }
          ]
        }
      ]
    },
    "ManagerServer.CheckTiDB": {
      "infrastructure": {},
      "services": []
    },
    "ManagerServer.FreeTiDB": {
      "infrastructure": {
        "etcd": {
          "conditions": ["normal_restart_log query parameter is present and parseable as token:message"],
          "operations": [
            {
              "operation": "PUT_WITH_LEASE",
              "trigger": "Record a short-lived normal-restart marker before freeing the TiDB pod",
              "conditions": ["Only when a normal restart log is provided"],
              "implementation": "s.etcdLease.Grant(...); s.etcdKV.Put(s.ctx, s.etcdCheckConnPrefix+token+\"-\"+podIP, msg, clientv3.WithLease(lease.ID))"
            }
          ]
        }
      },
      "services": []
    },
    "ManagerServer.ReplaceTiDB": {
      "infrastructure": {
        "kubernetes_api": {
          "conditions": ["pod and ns query parameters are not empty"],
          "operations": [
            {
              "operation": "DELETE",
              "trigger": "Delete the original pod after the TiDB manager accepted the replace request",
              "conditions": ["Only when tManager.ReplaceTidb reaches the delete callback"],
              "implementation": "s.manager.GetClient().Delete(ctx, &corev1.Pod{ObjectMeta: metav1.ObjectMeta{Name: podName, Namespace: ns}})"
            }
          ]
        }
      },
      "services": []
    },
    "ManagerServer.CheckConnection": {
      "infrastructure": {
        "etcd": {
          "conditions": ["token, conn_id, and ip query parameters are all set"],
          "operations": [
            {
              "operation": "GET",
              "trigger": "Look up the normal-restart marker when TiDB status did not confirm a normal close",
              "conditions": ["Repeated up to 4 times after the TiDB status check"],
              "implementation": "s.etcdKV.Get(r.Context(), s.etcdCheckConnPrefix+token+\"-\"+ip)"
            }
          ]
        }
      },
      "services": [
        {
          "name": "tidb-status",
          "target_interface": "Check connection state",
          "operation_type": "http_get",
          "conditions": ["token, conn_id, and ip query parameters are all set"],
          "operations": [
            {
              "operation": "GET",
              "trigger": "Ask the TiDB status endpoint whether the connection closed normally",
              "conditions": ["Repeated up to 4 times with a 2-second timeout"],
              "implementation": "s.tidbController.CheckConn(ctx2s, net.JoinHostPort(ip, \"10080\"), utils.TrimToken(token), connID)"
            }
          ]
        }
      ]
    },
    "ManagerServer.UpdateResourceGroup": {
      "infrastructure": {},
      "services": [
        {
          "name": "serverless-infra-api",
          "target_interface": "cluster resource-group metadata lookup and patch",
          "operation_type": "http_patch",
          "conditions": ["token and user query parameters are both set"],
          "operations": [
            {
              "operation": "GET",
              "trigger": "Load the cluster metadata for the token before rewriting user-resource-group bindings",
              "conditions": ["Always before patching"],
              "implementation": "pkginfra.NewRegionalInfraWithClient(s.infraClusterCli, s.cfg.KubeClusterName).GetClusterWithToken(r.Context(), token)"
            },
            {
              "operation": "PATCH",
              "trigger": "Write the updated user_resource_group and resource_groups map back to regional infra",
              "conditions": ["Only when the computed patch set is non-empty"],
              "implementation": "s.infraClusterCli.Patch(r.Context(), set, cluster)"
            }
          ]
        }
      ]
    },
    "ManagerServer.DumpStatus": {
      "infrastructure": {},
      "services": []
    },
    "ManagerServer.GetTiDBOwner": {
      "infrastructure": {
        "etcd": {
          "conditions": ["keyspace_id query parameter is set"],
          "operations": [
            {
              "operation": "CONNECT_AND_GET",
              "trigger": "Connect to PD etcd and load the owner key for the requested keyspace",
              "conditions": ["Always before returning the owner ID"],
              "implementation": "s.getPDETCDClient(); pdEtcdClient.Get(context.Background(), ownerPath, clientv3.WithFirstCreate()...)"
            }
          ]
        }
      },
      "services": []
    },
    "ManagerServer.GetImportStatus": {
      "infrastructure": {
        "kubernetes_api": {
          "conditions": ["task-id query parameter is set"],
          "operations": [
            {
              "operation": "LIST",
              "trigger": "List infra-cluster Import objects by the indexed task ID field",
              "conditions": ["Always after validating task-id"],
              "implementation": "s.manager.InfraCluster().GetClient().List(r.Context(), il, client.MatchingFields{\"status.taskId\": taskID})"
            }
          ]
        }
      },
      "services": []
    },
    "ManagerServer.GetAssignedTiDB": {
      "infrastructure": {},
      "services": []
    },
    "ManagerServer.KillAssignedTiDB": {
      "infrastructure": {},
      "services": []
    },
    "ManagerServer.GetActiveTiDB": {
      "infrastructure": {},
      "services": []
    },
    "ManagerServer.GetImportJobs": {
      "infrastructure": {
        "kubernetes_api": {
          "conditions": ["keyspace-name query parameter is set"],
          "operations": [
            {
              "operation": "LIST",
              "trigger": "List import-job pods that carry the requested keyspace label",
              "conditions": ["Always after validating keyspace-name"],
              "implementation": "s.manager.GetClient().List(r.Context(), podList, client.InNamespace(\"import-jobs\"), client.MatchingLabelsSelector{Selector: labels.SelectorFromSet(labels.Set{types.KeyspaceNameLabel: keyspaceName})})"
            }
          ]
        }
      },
      "services": []
    },
    "ManagerServer.GetExportJobs": {
      "infrastructure": {
        "kubernetes_api": {
          "conditions": ["keyspace-name query parameter is set"],
          "operations": [
            {
              "operation": "LIST",
              "trigger": "List export-job pods that carry the requested keyspace label",
              "conditions": ["Always after validating keyspace-name"],
              "implementation": "s.manager.GetClient().List(r.Context(), podList, client.InNamespace(\"export-job\"), client.MatchingLabelsSelector{Selector: labels.SelectorFromSet(labels.Set{types.KeyspaceNameLabel: keyspaceName})})"
            }
          ]
        }
      },
      "services": []
    },
    "ManagerServer.PprofIndex": {
      "infrastructure": {},
      "services": []
    },
    "ManagerServer.PprofCmdline": {
      "infrastructure": {},
      "services": []
    },
    "ManagerServer.PprofProfile": {
      "infrastructure": {},
      "services": []
    },
    "ManagerServer.PprofSymbol": {
      "infrastructure": {},
      "services": []
    },
    "ManagerServer.PprofTrace": {
      "infrastructure": {},
      "services": []
    },
    "ManagerServer.WatchBackendV2": {
      "infrastructure": {},
      "services": []
    },
    "ManagerServer.GetBackendV2": {
      "infrastructure": {},
      "services": []
    },
    "TidbManager.Run": {
      "infrastructure": {
        "etcd": {
          "conditions": ["Repeated for each TiDB pool namespace"],
          "operations": [
            {
              "operation": "WATCH",
              "trigger": "Watch the token prefix and the to-freecache-again prefix to keep the assign and free caches fresh",
              "conditions": ["Always after the TiDB manager starts"],
              "implementation": "g.Go(func() error { return t.startToFreeCacheAgainWatch() }); g.Go(func() error { return t.startTokenWatch() })"
            },
            {
              "operation": "GET",
              "trigger": "Load the full token state when rebuilding the local cache",
              "conditions": ["Whenever the TiDB manager refreshes cache from etcd"],
              "implementation": "t.etcdKV.Get(context.TODO(), t.etcdTokenPrefix, clientv3.WithPrefix())"
            }
          ]
        }
      },
      "services": []
    },
    "ClusterController.Reconcile": {
      "infrastructure": {
        "etcd": {
          "conditions": ["Always"],
          "operations": [
            {
              "operation": "PUT",
              "trigger": "Store cluster token and metadata",
              "conditions": ["Always"],
              "implementation": "etcdClient.KV.Put(ctx, key, value)"
            },
            {
              "operation": "GET",
              "trigger": "Retrieve cluster info",
              "conditions": ["Always"],
              "implementation": "etcdClient.KV.Get(ctx, key)"
            },
            {
              "operation": "DELETE",
              "trigger": "Clean up cluster data",
              "conditions": ["Cluster deletion"],
              "implementation": "etcdClient.KV.Delete(ctx, key)"
            }
          ]
        },
        "redis": {
          "conditions": ["Always"],
          "operations": [
            {
              "operation": "SUBSCRIBE",
              "trigger": "Consume cluster updates from Redis stream",
              "conditions": ["Always"],
              "implementation": "consumerredis.Consumer"
            }
          ]
        },
        "dynamodb": {
          "conditions": ["CloudProviderType == AWS"],
          "operations": [
            {
              "operation": "PUT",
              "trigger": "Update cluster status in DynamoDB",
              "conditions": ["Always"],
              "implementation": "infradynamo.NewDynamoClient.Put"
            },
            {
              "operation": "GET",
              "trigger": "Get cluster info from DynamoDB",
              "conditions": ["Always"],
              "implementation": "infradynamo.NewDynamoClient.Get"
            }
          ]
        },
        "tablestore": {
          "conditions": ["CloudProviderType == AliCloud"],
          "operations": [
            {
              "operation": "PUT",
              "trigger": "Update cluster status in TableStore",
              "conditions": ["Always"],
              "implementation": "infraots.NewTableStoreClient.Put"
            }
          ]
        },
        "mysql": {
          "conditions": ["EnableInfraMysqlClient == true"],
          "operations": [
            {
              "operation": "SELECT",
              "trigger": "Query cluster metadata",
              "conditions": ["infraRdsSecretArn configured"],
              "implementation": "inframysql.NewMySQLClient"
            },
            {
              "operation": "INSERT",
              "trigger": "Store audit log schedule",
              "conditions": ["!DisableAuditLog"],
              "implementation": "auditLogScheduleRepo.Create"
            }
          ]
        },
        "s3": {
          "conditions": ["S3BucketName configured"],
          "operations": [
            {
              "operation": "PUT",
              "trigger": "Store backup data",
              "conditions": ["Backup operations"],
              "implementation": "s3Client.PutObject"
            }
          ]
        }
      },
      "services": [
        {
          "name": "kubernetes-api",
          "target_interface": "GET /api/v1/namespaces",
          "operation_type": "http_get",
          "conditions": ["Always"],
          "operations": [
            {
              "operation": "Get cluster resources",
              "trigger": "Retrieve cluster resources",
              "conditions": ["Always"],
              "implementation": "mgr.GetClient().Get"
            }
          ]
        },
        {
          "name": "kubernetes-api",
          "target_interface": "POST /api/v1/namespaces",
          "operation_type": "http_post",
          "conditions": ["Always"],
          "operations": [
            {
              "operation": "Create cluster resources",
              "trigger": "Create cluster resources",
              "conditions": ["Always"],
              "implementation": "mgr.GetClient().Create"
            }
          ]
        },
        {
          "name": "kubernetes-api",
          "target_interface": "PUT /api/v1/namespaces",
          "operation_type": "http_put",
          "conditions": ["Always"],
          "operations": [
            {
              "operation": "Update cluster resources",
              "trigger": "Update cluster resources",
              "conditions": ["Always"],
              "implementation": "mgr.GetClient().Update"
            }
          ]
        },
        {
          "name": "kubernetes-api",
          "target_interface": "DELETE /api/v1/namespaces",
          "operation_type": "http_delete",
          "conditions": ["Always"],
          "operations": [
            {
              "operation": "Delete cluster resources",
              "trigger": "Delete cluster resources",
              "conditions": ["Always"],
              "implementation": "mgr.GetClient().Delete"
            }
          ]
        },
        {
          "name": "pd-server",
          "target_interface": "GET /pd/api/v1/cluster",
          "operation_type": "http_get",
          "conditions": ["Always"],
          "operations": [
            {
              "operation": "Get cluster ID",
              "trigger": "Retrieve PD cluster info",
              "conditions": ["Always"],
              "implementation": "pdClient.GetClusterID"
            }
          ]
        },
        {
          "name": "pd-server",
          "target_interface": "POST /pd/api/v2/keyspaces",
          "operation_type": "http_post",
          "conditions": ["Always"],
          "operations": [
            {
              "operation": "Create keyspace",
              "trigger": "Create new keyspace for cluster",
              "conditions": ["Cluster creation"],
              "implementation": "pdClient.CreateKeyspace"
            }
          ]
        },
        {
          "name": "pd-server",
          "target_interface": "PUT /pd/api/v2/keyspaces/{name}/state",
          "operation_type": "http_put",
          "conditions": ["Always"],
          "operations": [
            {
              "operation": "Update keyspace state",
              "trigger": "Change keyspace state",
              "conditions": ["State transition"],
              "implementation": "pdClient.UpdateKeyspaceState"
            }
          ]
        },
        {
          "name": "pd-server",
          "target_interface": "PATCH /pd/api/v2/keyspaces/{name}/config",
          "operation_type": "http_patch",
          "conditions": ["Always"],
          "operations": [
            {
              "operation": "Update keyspace config",
              "trigger": "Modify keyspace configuration",
              "conditions": ["Config update"],
              "implementation": "pdClient.UpdateKeyspaceConfig"
            }
          ]
        },
        {
          "name": "pd-server",
          "target_interface": "POST /resource-manager/api/v1/config/group",
          "operation_type": "http_post",
          "conditions": ["Always"],
          "operations": [
            {
              "operation": "Create resource group",
              "trigger": "Create resource group for cluster",
              "conditions": ["Always"],
              "implementation": "pdClient.PostResourceGroup"
            }
          ]
        },
        {
          "name": "pd-server",
          "target_interface": "DELETE /resource-manager/api/v1/config/group/{name}",
          "operation_type": "http_delete",
          "conditions": ["Always"],
          "operations": [
            {
              "operation": "Delete resource group",
              "trigger": "Remove resource group",
              "conditions": ["Cluster deletion"],
              "implementation": "pdClient.DeleteResourceGroup"
            }
          ]
        },
        {
          "name": "tikv-api",
          "target_interface": "GET /api/v1/restore_keyspace/{id}",
          "operation_type": "http_get",
          "conditions": ["Branch operations"],
          "operations": [
            {
              "operation": "Get restore progress",
              "trigger": "Check branch restore status",
              "conditions": ["Branch restore"],
              "implementation": "tikvApi.GetRestoreProgress"
            }
          ]
        },
        {
          "name": "tikv-api",
          "target_interface": "PUT /api/v1/restore_keyspace/{id}",
          "operation_type": "http_put",
          "conditions": ["Branch operations"],
          "operations": [
            {
              "operation": "Create restore task",
              "trigger": "Start branch restore",
              "conditions": ["Branch creation"],
              "implementation": "tikvApi.CreateRestore"
            }
          ]
        },
        {
          "name": "tikv-api",
          "target_interface": "DELETE /load_data",
          "operation_type": "http_delete",
          "conditions": ["Import cancellation"],
          "operations": [
            {
              "operation": "Cancel load data tasks",
              "trigger": "Cancel import tasks",
              "conditions": ["Import cancellation"],
              "implementation": "tikvApi.CancelLoadDataTasks"
            }
          ]
        },
        {
          "name": "tidb-worker-api",
          "target_interface": "GET /scaler/api/v1/admin/clean",
          "operation_type": "http_get",
          "conditions": ["Always"],
          "operations": [
            {
              "operation": "Clean TiDB worker",
              "trigger": "Clean up TiDB worker resources",
              "conditions": ["Always"],
              "implementation": "tidbWorkerApi.Clean"
            }
          ]
        },
        {
          "name": "observability-api",
          "target_interface": "POST /api/v1/clusters",
          "operation_type": "http_post",
          "conditions": ["O11yAgentEnabled == true"],
          "operations": [
            {
              "operation": "Create o11y infra",
              "trigger": "Setup observability for cluster",
              "conditions": ["O11yAgentEnabled"],
              "implementation": "o11yApi.CreateO11yInfra"
            }
          ]
        }
      ]
    },
    "BranchController.Reconcile": {
      "infrastructure": {
        "etcd": {
          "conditions": ["Always"],
          "operations": [
            {
              "operation": "PUT/GET",
              "trigger": "Store branch metadata",
              "conditions": ["Always"],
              "implementation": "etcdClient.KV"
            }
          ]
        },
        "s3": {
          "conditions": ["S3BucketName configured"],
          "operations": [
            {
              "operation": "PUT",
              "trigger": "Store branch backup data",
              "conditions": ["Branch backup"],
              "implementation": "s3Client.PutObject"
            }
          ]
        }
      },
      "services": [
        {
          "name": "pd-server",
          "target_interface": "GET /pd/api/v2/keyspaces/{name}",
          "operation_type": "http_get",
          "conditions": ["Always"],
          "operations": [
            {
              "operation": "Get keyspace info",
              "trigger": "Query branch keyspace",
              "conditions": ["Always"],
              "implementation": "pdClient.GetKeyspaceByName"
            }
          ]
        },
        {
          "name": "pd-server",
          "target_interface": "POST /pd/api/v2/keyspaces",
          "operation_type": "http_post",
          "conditions": ["Always"],
          "operations": [
            {
              "operation": "Create branch keyspace",
              "trigger": "Create keyspace for branch",
              "conditions": ["Branch creation"],
              "implementation": "pdClient.CreateKeyspace"
            }
          ]
        },
        {
          "name": "tikv-api",
          "target_interface": "GET /api/v1/restore_keyspace/{id}",
          "operation_type": "http_get",
          "conditions": ["Always"],
          "operations": [
            {
              "operation": "Get branch restore progress",
              "trigger": "Check branch restore status",
              "conditions": ["Always"],
              "implementation": "tikvApi.GetRestoreProgress"
            }
          ]
        },
        {
          "name": "tikv-api",
          "target_interface": "PUT /api/v1/restore_keyspace/{id}",
          "operation_type": "http_put",
          "conditions": ["Always"],
          "operations": [
            {
              "operation": "Create branch restore",
              "trigger": "Start branch restore",
              "conditions": ["Always"],
              "implementation": "tikvApi.CreateRestore"
            }
          ]
        },
        {
          "name": "tidb-worker-api",
          "target_interface": "GET /scaler/api/v1/admin/clean",
          "operation_type": "http_get",
          "conditions": ["Always"],
          "operations": [
            {
              "operation": "Clean TiDB worker for branch",
              "trigger": "Clean branch resources",
              "conditions": ["Always"],
              "implementation": "tidbWorkerApi.Clean"
            }
          ]
        },
        {
          "name": "observability-api",
          "target_interface": "POST /api/v1/clusters",
          "operation_type": "http_post",
          "conditions": ["O11yAgentEnabled == true"],
          "operations": [
            {
              "operation": "Create o11y infra for branch",
              "trigger": "Setup observability for branch",
              "conditions": ["O11yAgentEnabled"],
              "implementation": "o11yApi.CreateO11yInfra"
            }
          ]
        }
      ]
    },
    "ExportController.Reconcile": {
      "infrastructure": {
        "etcd": {
          "conditions": ["Always"],
          "operations": [
            {
              "operation": "GET",
              "trigger": "Get cluster token for export",
              "conditions": ["Always"],
              "implementation": "etcdClient.KV.Get"
            }
          ]
        }
      },
      "services": [
        {
          "name": "kubernetes-api",
          "target_interface": "POST /apis/batch/v1/namespaces/{ns}/jobs",
          "operation_type": "http_post",
          "conditions": ["Always"],
          "operations": [
            {
              "operation": "Create export job",
              "trigger": "Start export job",
              "conditions": ["Always"],
              "implementation": "mgr.GetClient().Create"
            }
          ]
        },
        {
          "name": "pd-server",
          "target_interface": "GET /pd/api/v1/cluster",
          "operation_type": "http_get",
          "conditions": ["Always"],
          "operations": [
            {
              "operation": "Get cluster info for export",
              "trigger": "Retrieve cluster metadata",
              "conditions": ["Always"],
              "implementation": "pdClient"
            }
          ]
        }
      ]
    },
    "ImportController.Reconcile": {
      "infrastructure": {},
      "services": [
        {
          "name": "kubernetes-api",
          "target_interface": "POST /apis/batch/v1/namespaces/{ns}/jobs",
          "operation_type": "http_post",
          "conditions": ["Always"],
          "operations": [
            {
              "operation": "Create import job",
              "trigger": "Start import job",
              "conditions": ["Always"],
              "implementation": "mgr.GetClient().Create"
            }
          ]
        },
        {
          "name": "pd-server",
          "target_interface": "GET /pd/api/v1/cluster",
          "operation_type": "http_get",
          "conditions": ["Always"],
          "operations": [
            {
              "operation": "Get cluster info for import",
              "trigger": "Retrieve cluster metadata",
              "conditions": ["Always"],
              "implementation": "pdClient"
            }
          ]
        },
        {
          "name": "tikv-api",
          "target_interface": "DELETE /load_data",
          "operation_type": "http_delete",
          "conditions": ["Import cancellation"],
          "operations": [
            {
              "operation": "Cancel import tasks",
              "trigger": "Cancel running import",
              "conditions": ["Import cancellation"],
              "implementation": "tikvApi.CancelLoadDataTasks"
            }
          ]
        }
      ]
    },
    "KeyspaceController.Reconcile": {
      "infrastructure": {
        "dynamodb": {
          "conditions": ["CloudProviderType == AWS"],
          "operations": [
            {
              "operation": "GET",
              "trigger": "Get cluster info",
              "conditions": ["Always"],
              "implementation": "infraClusterCli.Get"
            }
          ]
        },
        "tablestore": {
          "conditions": ["CloudProviderType == AliCloud"],
          "operations": [
            {
              "operation": "GET",
              "trigger": "Get cluster info",
              "conditions": ["Always"],
              "implementation": "infraClusterCli.Get"
            }
          ]
        }
      },
      "services": [
        {
          "name": "kubernetes-api",
          "target_interface": "GET /apis/serverless.tidbcloud.com/v1alpha1/namespaces/{ns}/keyspaces",
          "operation_type": "http_get",
          "conditions": ["Always"],
          "operations": [
            {
              "operation": "Get keyspace CR",
              "trigger": "Retrieve keyspace",
              "conditions": ["Always"],
              "implementation": "mgr.GetClient().Get"
            }
          ]
        },
        {
          "name": "kubernetes-api",
          "target_interface": "POST /apis/serverless.tidbcloud.com/v1alpha1/namespaces/{ns}/keyspaces",
          "operation_type": "http_post",
          "conditions": ["Always"],
          "operations": [
            {
              "operation": "Create keyspace CR",
              "trigger": "Create keyspace",
              "conditions": ["Always"],
              "implementation": "mgr.GetClient().Create"
            }
          ]
        },
        {
          "name": "pd-server",
          "target_interface": "GET /pd/api/v2/keyspaces/{name}",
          "operation_type": "http_get",
          "conditions": ["Always"],
          "operations": [
            {
              "operation": "Get keyspace info",
              "trigger": "Query keyspace metadata",
              "conditions": ["Always"],
              "implementation": "pdClient.GetKeyspaceByName"
            }
          ]
        },
        {
          "name": "pd-server",
          "target_interface": "POST /pd/api/v2/keyspaces",
          "operation_type": "http_post",
          "conditions": ["Always"],
          "operations": [
            {
              "operation": "Create keyspace",
              "trigger": "Create new keyspace",
              "conditions": ["Keyspace creation"],
              "implementation": "pdClient.CreateKeyspace"
            }
          ]
        },
        {
          "name": "pd-server",
          "target_interface": "PUT /pd/api/v2/keyspaces/{name}/state",
          "operation_type": "http_put",
          "conditions": ["Always"],
          "operations": [
            {
              "operation": "Update keyspace state",
              "trigger": "Activate/deactivate keyspace",
              "conditions": ["Always"],
              "implementation": "pdClient.UpdateKeyspaceState"
            }
          ]
        }
      ]
    },
    "KeyspacePoolConfigController.Reconcile": {
      "infrastructure": {},
      "services": [
        {
          "name": "kubernetes-api",
          "target_interface": "GET /apis/serverless.tidbcloud.com/v1alpha1/namespaces/{ns}/keyspacepoolconfigs",
          "operation_type": "http_get",
          "conditions": ["Always"],
          "operations": [
            {
              "operation": "Get keyspace pool config",
              "trigger": "Retrieve keyspace pool config",
              "conditions": ["Always"],
              "implementation": "mgr.GetClient().Get"
            }
          ]
        },
        {
          "name": "kubernetes-api",
          "target_interface": "POST /apis/serverless.tidbcloud.com/v1alpha1/namespaces/{ns}/keyspacepoolconfigs",
          "operation_type": "http_post",
          "conditions": ["Always"],
          "operations": [
            {
              "operation": "Create keyspace pool config",
              "trigger": "Create keyspace pool config",
              "conditions": ["Always"],
              "implementation": "mgr.GetClient().Create"
            }
          ]
        },
        {
          "name": "kubernetes-api",
          "target_interface": "PUT /apis/serverless.tidbcloud.com/v1alpha1/namespaces/{ns}/keyspacepoolconfigs",
          "operation_type": "http_put",
          "conditions": ["Always"],
          "operations": [
            {
              "operation": "Update keyspace pool config",
              "trigger": "Update keyspace pool config",
              "conditions": ["Always"],
              "implementation": "mgr.GetClient().Update"
            }
          ]
        }
      ]
    },
    "TidbServerTemplateController.Reconcile": {
      "infrastructure": {},
      "services": [
        {
          "name": "kubernetes-api",
          "target_interface": "GET /apis/serverless.tidbcloud.com/v1alpha1/namespaces/{ns}/tidbservertemplates",
          "operation_type": "http_get",
          "conditions": ["Always"],
          "operations": [
            {
              "operation": "Get TiDB server template",
              "trigger": "Retrieve server template",
              "conditions": ["Always"],
              "implementation": "mgr.GetClient().Get"
            }
          ]
        },
        {
          "name": "kubernetes-api",
          "target_interface": "POST /apis/serverless.tidbcloud.com/v1alpha1/namespaces/{ns}/tidbservertemplates",
          "operation_type": "http_post",
          "conditions": ["Always"],
          "operations": [
            {
              "operation": "Create TiDB server template",
              "trigger": "Create server template",
              "conditions": ["Always"],
              "implementation": "mgr.GetClient().Create"
            }
          ]
        },
        {
          "name": "kubernetes-api",
          "target_interface": "PUT /apis/serverless.tidbcloud.com/v1alpha1/namespaces/{ns}/tidbservertemplates",
          "operation_type": "http_put",
          "conditions": ["Always"],
          "operations": [
            {
              "operation": "Update TiDB server template",
              "trigger": "Update server template",
              "conditions": ["Always"],
              "implementation": "mgr.GetClient().Update"
            }
          ]
        }
      ]
    },
    "TidbPodSyncCacheController.Reconcile": {
      "infrastructure": {},
      "services": [
        {
          "name": "kubernetes-api",
          "target_interface": "GET /api/v1/namespaces/{ns}/pods",
          "operation_type": "http_get",
          "conditions": ["Always"],
          "operations": [
            {
              "operation": "Sync pod cache",
              "trigger": "Sync TiDB pod info",
              "conditions": ["Always"],
              "implementation": "mgr.GetClient().List"
            }
          ]
        }
      ]
    },
    "TidbPodCleanController.Reconcile": {
      "infrastructure": {},
      "services": [
        {
          "name": "kubernetes-api",
          "target_interface": "DELETE /api/v1/namespaces/{ns}/pods/{name}",
          "operation_type": "http_delete",
          "conditions": ["Always"],
          "operations": [
            {
              "operation": "Delete TiDB pod",
              "trigger": "Clean up TiDB pod",
              "conditions": ["Always"],
              "implementation": "mgr.GetClient().Delete"
            }
          ]
        }
      ]
    },
    "ZoneRedundantEvicterController.Reconcile": {
      "infrastructure": {
        "dynamodb": {
          "conditions": ["CloudProviderType == AWS"],
          "operations": [
            {
              "operation": "GET",
              "trigger": "Get cluster zone redundant status",
              "conditions": ["Always"],
              "implementation": "infraClusterCli.Get"
            }
          ]
        },
        "tablestore": {
          "conditions": ["CloudProviderType == AliCloud"],
          "operations": [
            {
              "operation": "GET",
              "trigger": "Get cluster zone redundant status",
              "conditions": ["Always"],
              "implementation": "infraClusterCli.Get"
            }
          ]
        }
      },
      "services": [
        {
          "name": "kubernetes-api",
          "target_interface": "DELETE /api/v1/namespaces/{ns}/pods/{name}",
          "operation_type": "http_delete",
          "conditions": ["Always"],
          "operations": [
            {
              "operation": "Evict zone redundant pod",
              "trigger": "Evict pod from zone redundant node",
              "conditions": ["Always"],
              "implementation": "mgr.GetClient().Delete"
            }
          ]
        }
      ]
    },
    "TidbNodeScalerController.Reconcile": {
      "infrastructure": {},
      "services": [
        {
          "name": "kubernetes-api",
          "target_interface": "PATCH /apis/serverless.tidbcloud.com/v1alpha1/namespaces/{ns}/tidbnodescalers/{name}",
          "operation_type": "http_patch",
          "conditions": ["Always"],
          "operations": [
            {
              "operation": "Update TiDB node scaler",
              "trigger": "Scale TiDB nodes",
              "conditions": ["Always"],
              "implementation": "mgr.GetClient().Patch"
            }
          ]
        }
      ]
    },
    "TidbPodEvicterController.Reconcile": {
      "infrastructure": {},
      "services": [
        {
          "name": "kubernetes-api",
          "target_interface": "DELETE /api/v1/namespaces/{ns}/pods/{name}",
          "operation_type": "http_delete",
          "conditions": ["Always"],
          "operations": [
            {
              "operation": "Evict TiDB pod",
              "trigger": "Evict TiDB pod for rebalancing",
              "conditions": ["Always"],
              "implementation": "mgr.GetClient().Delete"
            }
          ]
        }
      ]
    },
    "TidbPodReschedulerController.Reconcile": {
      "infrastructure": {},
      "services": [
        {
          "name": "kubernetes-api",
          "target_interface": "DELETE /api/v1/namespaces/{ns}/pods/{name}",
          "operation_type": "http_delete",
          "conditions": ["Always"],
          "operations": [
            {
              "operation": "Reschedule TiDB pod",
              "trigger": "Reschedule TiDB pod",
              "conditions": ["Always"],
              "implementation": "mgr.GetClient().Delete"
            }
          ]
        }
      ]
    },
    "NodeRebalanceController.Reconcile": {
      "infrastructure": {},
      "services": [
        {
          "name": "kubernetes-api",
          "target_interface": "GET /api/v1/nodes",
          "operation_type": "http_get",
          "conditions": ["Always"],
          "operations": [
            {
              "operation": "List nodes for rebalancing",
              "trigger": "Check node balance",
              "conditions": ["Always"],
              "implementation": "mgr.GetClient().List"
            }
          ]
        }
      ]
    },
    "NodeRecoverController.Reconcile": {
      "infrastructure": {},
      "services": [
        {
          "name": "kubernetes-api",
          "target_interface": "GET /api/v1/nodes/{name}",
          "operation_type": "http_get",
          "conditions": ["Always"],
          "operations": [
            {
              "operation": "Get node status",
              "trigger": "Check node recovery",
              "conditions": ["Always"],
              "implementation": "mgr.GetClient().Get"
            }
          ]
        }
      ]
    },
    "SecretSyncerController.Reconcile": {
      "infrastructure": {},
      "services": [
        {
          "name": "kubernetes-api",
          "target_interface": "GET /api/v1/namespaces/{ns}/secrets/{name}",
          "operation_type": "http_get",
          "conditions": ["Always"],
          "operations": [
            {
              "operation": "Get TiDB session certificate",
              "trigger": "Retrieve session cert",
              "conditions": ["Always"],
              "implementation": "mgr.GetClient().Get"
            }
          ]
        },
        {
          "name": "kubernetes-api",
          "target_interface": "PUT /api/v1/namespaces/{ns}/secrets/{name}",
          "operation_type": "http_put",
          "conditions": ["Always"],
          "operations": [
            {
              "operation": "Update TiDB session certificate",
              "trigger": "Sync session cert to namespaces",
              "conditions": ["Always"],
              "implementation": "mgr.GetClient().Update"
            }
          ]
        }
      ]
    },
    "VersionUpdater.Run": {
      "infrastructure": {
        "dynamodb": {
          "conditions": ["CloudProviderType == AWS"],
          "operations": [
            {
              "operation": "PUT",
              "trigger": "Update TiDB version info",
              "conditions": ["Always"],
              "implementation": "infraClusterCli.Update"
            }
          ]
        },
        "tablestore": {
          "conditions": ["CloudProviderType == AliCloud"],
          "operations": [
            {
              "operation": "PUT",
              "trigger": "Update TiDB version info",
              "conditions": ["Always"],
              "implementation": "infraClusterCli.Update"
            }
          ]
        }
      },
      "services": []
    },
    "RedisConsumer.Run": {
      "infrastructure": {
        "redis": {
          "conditions": ["Always"],
          "operations": [
            {
              "operation": "SUBSCRIBE",
              "trigger": "Consume cluster updates",
              "conditions": ["Always"],
              "implementation": "consumerredis.Consumer"
            }
          ]
        },
        "dynamodb": {
          "conditions": ["CloudProviderType == AWS"],
          "operations": [
            {
              "operation": "PUT",
              "trigger": "Update cache from stream",
              "conditions": ["Always"],
              "implementation": "infradynamo.NewDynamoClient.Put"
            }
          ]
        },
        "tablestore": {
          "conditions": ["CloudProviderType == AliCloud"],
          "operations": [
            {
              "operation": "PUT",
              "trigger": "Update cache from stream",
              "conditions": ["Always"],
              "implementation": "infraots.NewTableStoreClient.Put"
            }
          ]
        }
      },
      "services": []
    },
    "TidbScaler.Scale": {
      "infrastructure": {
        "etcd": {
          "conditions": ["Always"],
          "operations": [
            {
              "operation": "PUT/GET",
              "trigger": "Store scaling metadata",
              "conditions": ["Always"],
              "implementation": "etcdClient.KV"
            }
          ]
        }
      },
      "services": [
        {
          "name": "kubernetes-api",
          "target_interface": "PATCH /apis/apps/v1/namespaces/{ns}/statefulsets/{name}",
          "operation_type": "http_patch",
          "conditions": ["Always"],
          "operations": [
            {
              "operation": "Scale StatefulSet",
              "trigger": "Scale TiDB components",
              "conditions": ["Always"],
              "implementation": "mgr.GetClient().Patch"
            }
          ]
        }
      ]
    },
    "TidbUpgrader.Run": {
      "infrastructure": {
        "etcd": {
          "conditions": ["Always"],
          "operations": [
            {
              "operation": "GET",
              "trigger": "Get cluster token",
              "conditions": ["Always"],
              "implementation": "etcdClient.KV.Get"
            }
          ]
        }
      },
      "services": [
        {
          "name": "kubernetes-api",
          "target_interface": "PATCH /apis/apps/v1/namespaces/{ns}/statefulsets/{name}",
          "operation_type": "http_patch",
          "conditions": ["Always"],
          "operations": [
            {
              "operation": "Upgrade TiDB version",
              "trigger": "Update TiDB image version",
              "conditions": ["Always"],
              "implementation": "mgr.GetClient().Patch"
            }
          ]
        }
      ]
    },
    "TidbAutoscaling.Run": {
      "infrastructure": {
        "dynamodb": {
          "conditions": ["CloudProviderType == AWS"],
          "operations": [
            {
              "operation": "GET",
              "trigger": "Get cluster RCU config",
              "conditions": ["Always"],
              "implementation": "infraClusterCli.Get"
            }
          ]
        },
        "tablestore": {
          "conditions": ["CloudProviderType == AliCloud"],
          "operations": [
            {
              "operation": "GET",
              "trigger": "Get cluster RCU config",
              "conditions": ["Always"],
              "implementation": "infraClusterCli.Get"
            }
          ]
        }
      },
      "services": [
        {
          "name": "kubernetes-api",
          "target_interface": "PATCH /apis/apps/v1/namespaces/{ns}/statefulsets/{name}",
          "operation_type": "http_patch",
          "conditions": ["Always"],
          "operations": [
            {
              "operation": "Autoscale TiDB",
              "trigger": "Adjust TiDB replicas based on load",
              "conditions": ["Always"],
              "implementation": "mgr.GetClient().Patch"
            }
          ]
        }
      ]
    },
    "TidbPDB.Run": {
      "infrastructure": {},
      "services": [
        {
          "name": "kubernetes-api",
          "target_interface": "GET /apis/policy/v1/namespaces/{ns}/poddisruptionbudgets/{name}",
          "operation_type": "http_get",
          "conditions": ["Always"],
          "operations": [
            {
              "operation": "Get PodDisruptionBudget",
              "trigger": "Retrieve PDB",
              "conditions": ["Always"],
              "implementation": "mgr.GetClient().Get"
            }
          ]
        },
        {
          "name": "kubernetes-api",
          "target_interface": "POST /apis/policy/v1/namespaces/{ns}/poddisruptionbudgets/{name}",
          "operation_type": "http_post",
          "conditions": ["Always"],
          "operations": [
            {
              "operation": "Create PodDisruptionBudget",
              "trigger": "Create PDB",
              "conditions": ["Always"],
              "implementation": "mgr.GetClient().Create"
            }
          ]
        },
        {
          "name": "kubernetes-api",
          "target_interface": "PUT /apis/policy/v1/namespaces/{ns}/poddisruptionbudgets/{name}",
          "operation_type": "http_put",
          "conditions": ["Always"],
          "operations": [
            {
              "operation": "Update PodDisruptionBudget",
              "trigger": "Update PDB",
              "conditions": ["Always"],
              "implementation": "mgr.GetClient().Update"
            }
          ]
        }
      ]
    },
    "TidbReclaimer.Run": {
      "infrastructure": {
        "etcd": {
          "conditions": ["Always"],
          "operations": [
            {
              "operation": "DELETE",
              "trigger": "Clean up cluster data",
              "conditions": ["GC interval reached"],
              "implementation": "etcdClient.KV.Delete"
            }
          ]
        }
      },
      "services": [
        {
          "name": "kubernetes-api",
          "target_interface": "DELETE /apis/serverless.tidbcloud.com/v1alpha1/namespaces/{ns}/keyspaces/{name}",
          "operation_type": "http_delete",
          "conditions": ["Always"],
          "operations": [
            {
              "operation": "Reclaim keyspace",
              "trigger": "Delete unused keyspaces",
              "conditions": ["Always"],
              "implementation": "mgr.GetClient().Delete"
            }
          ]
        }
      ]
    },
    "DmScaler.Run": {
      "infrastructure": {},
      "services": [
        {
          "name": "kubernetes-api",
          "target_interface": "PATCH /apis/apps/v1/namespaces/{ns}/statefulsets/{name}",
          "operation_type": "http_patch",
          "conditions": ["Always"],
          "operations": [
            {
              "operation": "Scale DM components",
              "trigger": "Adjust DM replicas",
              "conditions": ["Always"],
              "implementation": "mgr.GetClient().Patch"
            }
          ]
        }
      ]
    },
    "NodeScorer.Run": {
      "infrastructure": {},
      "services": [
        {
          "name": "kubernetes-api",
          "target_interface": "GET /api/v1/nodes",
          "operation_type": "http_get",
          "conditions": ["Always"],
          "operations": [
            {
              "operation": "Score nodes",
              "trigger": "Calculate node scores",
              "conditions": ["Always"],
              "implementation": "mgr.GetClient().List"
            }
          ]
        }
      ]
    },
    "NodeDrainer.Run": {
      "infrastructure": {},
      "services": [
        {
          "name": "kubernetes-api",
          "target_interface": "GET /api/v1/nodes/{name}",
          "operation_type": "http_get",
          "conditions": ["Always"],
          "operations": [
            {
              "operation": "Check node status",
              "trigger": "Check if node needs draining",
              "conditions": ["Always"],
              "implementation": "mgr.GetClient().Get"
            }
          ]
        },
        {
          "name": "kubernetes-api",
          "target_interface": "DELETE /api/v1/namespaces/{ns}/pods/{name}",
          "operation_type": "http_delete",
          "conditions": ["Node needs draining"],
          "operations": [
            {
              "operation": "Evict pods from node",
              "trigger": "Drain node",
              "conditions": ["Node needs draining"],
              "implementation": "mgr.GetClient().Delete"
            }
          ]
        }
      ]
    }
  }
}
