{
  "repo": "tidbcloud/chaos-svc",
  "binary": "server",
  "binary_path": "cmd/server/main.go",
  "dependencies": {
    "ChaosService.EnableChaosBackend": {
      "infrastructure": {
        "mysql": {
          "conditions": ["Always"],
          "operations": [
            {"operation": "SELECT", "trigger": "Check if backend exists", "implementation": "repo.GetBackendByClusterID(ctx, clusterID)"},
            {"operation": "INSERT/UPDATE", "trigger": "Create or update chaos backend record", "implementation": "repo.UpsertBackend(ctx, backend)"}
          ]
        },
        "kubernetes": {
          "conditions": ["Always"],
          "operations": [
            {"operation": "GET", "trigger": "Get TiDB cluster from infra-api", "implementation": "infra.GetTiDBCluster(ctx, projectID, clusterID)"},
            {"operation": "CREATE", "trigger": "Create ChaosServer CRD", "implementation": "infra.CreateChaosServerIgnoreExist(ctx, cr)"}
          ]
        }
      },
      "services": [
        {
          "name": "core-svc",
          "target_repo": "tidbcloud/core-svc",
          "target_interface": "CoreService.ListClusters",
          "operation_type": "grpc_unary",
          "conditions": ["Always"],
          "operations": [
            {"operation": "gRPC ListClusters", "trigger": "Get cluster info for network name", "implementation": "coreSvc.GetCluster(ctx, clusterID)"}
          ]
        }
      ]
    },
    "ChaosService.DisableChaosBackend": {
      "infrastructure": {
        "mysql": {
          "conditions": ["Always"],
          "operations": [
            {"operation": "SELECT", "trigger": "Get backend by cluster ID", "implementation": "repo.GetBackendByClusterID(ctx, clusterID)"},
            {"operation": "SELECT", "trigger": "Count running/draft workflows", "implementation": "workflowRepo.Count(ctx, filter)"},
            {"operation": "UPDATE", "trigger": "Mark backend as disabled", "implementation": "repo.UpdateBackendStatus(ctx, backend)"}
          ]
        },
        "kubernetes": {
          "conditions": ["Always"],
          "operations": [
            {"operation": "GET", "trigger": "Get TiDB cluster for validation", "implementation": "infra.GetTiDBCluster(ctx, projectID, clusterID)"},
            {"operation": "LIST", "trigger": "List TiDB clusters in region for experiment check", "implementation": "infra.ListTiDBClusters(ctx, projectID, filter)"},
            {"operation": "DELETE", "trigger": "Delete ChaosServer CRD", "implementation": "infra.DeleteChaosServerIgnoreNotFound(ctx, projectID, networkName)"}
          ]
        }
      },
      "services": []
    },
    "ChaosService.GetChaosBackend": {
      "infrastructure": {
        "mysql": {
          "conditions": ["Always"],
          "operations": [
            {"operation": "SELECT", "trigger": "Get backend by project and network name", "implementation": "repo.Load(ctx, projectID, networkName)"}
          ]
        },
        "kubernetes": {
          "conditions": ["Always"],
          "operations": [
            {"operation": "GET", "trigger": "Get TiDB cluster for network name lookup", "implementation": "infra.GetTiDBCluster(ctx, projectID, clusterID)"}
          ]
        }
      },
      "services": []
    },
    "ChaosService.ListExperiments": {
      "infrastructure": {
        "mysql": {
          "conditions": ["Always"],
          "operations": [
            {"operation": "SELECT", "trigger": "List experiments by filter", "implementation": "repo.ListExperiments(ctx, filter)"}
          ]
        }
      },
      "services": []
    },
    "ChaosService.CreateExperiment": {
      "infrastructure": {
        "mysql": {
          "conditions": ["Always"],
          "operations": [
            {"operation": "SELECT", "trigger": "Load chaos backend", "implementation": "backendRepo.Load(ctx, projectID, networkName)"},
            {"operation": "SELECT", "trigger": "Count running/draft workflows", "implementation": "workflowRepo.Count(ctx, filter)"},
            {"operation": "SELECT", "trigger": "Lock workflow creation", "implementation": "workflowLockRepo.Lock(ctx, scene, identifier)"},
            {"operation": "INSERT", "trigger": "Create experiment record", "implementation": "repo.CreateExperiment(ctx, experiment)"}
          ]
        },
        "kubernetes": {
          "conditions": ["!req.Draft"],
          "operations": [
            {"operation": "GET", "trigger": "Get TiDB cluster for topology", "implementation": "infra.GetTiDBCluster(ctx, projectID, clusterID)"},
            {"operation": "CREATE", "trigger": "Create ChaosWorkflow CRD", "implementation": "infra.CreateWorkflowIgnoreExist(ctx, workflowEntity)"}
          ]
        }
      },
      "services": []
    },
    "ChaosService.UpdateExperiment": {
      "infrastructure": {
        "mysql": {
          "conditions": ["Always"],
          "operations": [
            {"operation": "SELECT", "trigger": "Load chaos backend", "implementation": "backendRepo.Load(ctx, projectID, networkName)"},
            {"operation": "SELECT", "trigger": "Get experiment by ID", "implementation": "repo.GetExperimentByID(ctx, experimentID)"},
            {"operation": "UPDATE", "trigger": "Update experiment record", "implementation": "repo.UpdateExperiment(ctx, experiment)"}
          ]
        },
        "kubernetes": {
          "conditions": ["Always"],
          "operations": [
            {"operation": "GET", "trigger": "Get TiDB cluster for validation", "implementation": "infra.GetTiDBCluster(ctx, projectID, clusterID)"}
          ]
        }
      },
      "services": []
    },
    "ChaosService.DeleteExperiment": {
      "infrastructure": {
        "mysql": {
          "conditions": ["Always"],
          "operations": [
            {"operation": "SELECT", "trigger": "Load chaos backend", "implementation": "backendRepo.Load(ctx, projectID, networkName)"},
            {"operation": "UPDATE", "trigger": "Soft delete experiment", "implementation": "repo.DeleteExperiment(ctx, experimentID)"}
          ]
        },
        "kubernetes": {
          "conditions": ["Always"],
          "operations": [
            {"operation": "GET", "trigger": "Get TiDB cluster for validation", "implementation": "infra.GetTiDBCluster(ctx, projectID, clusterID)"}
          ]
        }
      },
      "services": []
    },
    "ChaosService.GetExperiment": {
      "infrastructure": {
        "mysql": {
          "conditions": ["Always"],
          "operations": [
            {"operation": "SELECT", "trigger": "Get experiment by ID", "implementation": "repo.GetExperimentByID(ctx, experimentID)"}
          ]
        }
      },
      "services": []
    },
    "ChaosService.GetTiDBComponentTopology": {
      "infrastructure": {
        "kubernetes": {
          "conditions": ["Always"],
          "operations": [
            {"operation": "GET", "trigger": "Get TiDB cluster CRD for topology", "implementation": "infra.GetTiDBClusterCloudObj(ctx, projectID, clusterID)"}
          ]
        }
      },
      "services": []
    },
    "Runtime BackgroundWorker.SyncBackend": {
      "infrastructure": {
        "mysql": {
          "conditions": ["Always"],
          "operations": [
            {"operation": "SELECT", "trigger": "List all backends", "implementation": "repo.ListAllBackends(ctx)"},
            {"operation": "UPDATE", "trigger": "Update backend status", "implementation": "repo.UpdateBackendStatus(ctx, backend)"}
          ]
        },
        "kubernetes": {
          "conditions": ["Always"],
          "operations": [
            {"operation": "GET", "trigger": "Get ChaosServer CRD status", "implementation": "infra.GetChaosServer(ctx, projectID, networkName)"}
          ]
        }
      },
      "services": []
    },
    "Runtime BackgroundWorker.SyncWorkflow": {
      "infrastructure": {
        "mysql": {
          "conditions": ["Always"],
          "operations": [
            {"operation": "SELECT", "trigger": "Load workflow entity", "implementation": "repo.Load(ctx, workflowID)"},
            {"operation": "SELECT", "trigger": "List running experiments", "implementation": "repo.ListRunningExperiments(ctx)"},
            {"operation": "UPDATE", "trigger": "Update experiment status", "implementation": "repo.UpdateExperimentStatus(ctx, experiment)"}
          ]
        },
        "kubernetes": {
          "conditions": ["Always"],
          "operations": [
            {"operation": "GET", "trigger": "Check if TiDB cluster exists", "implementation": "infra.GetTiDBCluster(ctx, projectID, clusterID)"},
            {"operation": "GET", "trigger": "Get ChaosWorkflow CRD status", "implementation": "infra.GetWorkflow(ctx, projectID, workflowID)"},
            {"operation": "LIST", "trigger": "List ChaosWorkflowNode CRDs", "implementation": "infra.ListWorkflowNodes(ctx, projectID, workflowID)"}
          ]
        }
      },
      "services": []
    },
    "HTTP GET /metrics": {
      "infrastructure": {},
      "services": []
    },
    "HTTP GET /debug/pprof/": {
      "infrastructure": {},
      "services": []
    },
    "HTTP GET /debug/pprof/cmdline": {
      "infrastructure": {},
      "services": []
    },
    "HTTP GET /debug/pprof/profile": {
      "infrastructure": {},
      "services": []
    },
    "HTTP GET /debug/pprof/symbol": {
      "infrastructure": {},
      "services": []
    },
    "HTTP GET /debug/pprof/trace": {
      "infrastructure": {},
      "services": []
    }
  }
}
