{
  "repo": "tidbcloud/dataservices",
  "binary": "tools",
  "binary_path": "cmd/tools/main.go",
  "dependencies": {
    "ToolsLifecycle.LoadConfigAndDatabase": {
      "infrastructure": {
        "filesystem": {
          "conditions": [
            "Always at startup"
          ],
          "operations": [
            {
              "operation": "READ FILE",
              "trigger": "Load config before tracing, metrics, and ETL execution",
              "conditions": [
                "Always"
              ],
              "implementation": "config.InitConfig(configPath)"
            }
          ]
        },
        "mysql": {
          "conditions": [
            "Always after config initialization succeeds"
          ],
          "operations": [
            {
              "operation": "CONNECT",
              "trigger": "Create the SQL connection used by ETL statistics queries and rollup writes",
              "conditions": [
                "config.InitConfig(configPath) succeeded"
              ],
              "implementation": "database.Connect(ctx, ...)"
            }
          ]
        }
      },
      "services": []
    },
    "ToolsLifecycle.StartTracing": {
      "infrastructure": {},
      "services": []
    },
    "ToolsLifecycle.RunEtlHourJob": {
      "infrastructure": {
        "mysql": {
          "conditions": [
            "Only when --job_type=etl_hour"
          ],
          "operations": [
            {
              "operation": "SELECT / UPSERT / DELETE",
              "trigger": "Run hourly ETL statistics for each hour in the requested range with refresh=true",
              "conditions": [
                "job_type == etl_hour"
              ],
              "implementation": "etlWorker.RunEtlJobHourly(ctx, tempTimestamp, true)"
            }
          ]
        }
      },
      "services": [
        {
          "name": "core-svc",
          "target_repo": "tidbcloud/core-svc",
          "target_interface": "ListClusterByIdsWPC",
          "operation_type": "grpc_unary",
          "conditions": [
            "Only when hourly ETL needs org -> region mapping for endpoint traffic logs"
          ],
          "operations": [
            {
              "operation": "LOOK UP CLUSTER REGIONS",
              "trigger": "Resolve cluster ids to region names before iterating regional execution logs",
              "conditions": [
                "hourly ETL discovered draft or deployed endpoint clusters"
              ],
              "implementation": "worker.EndpointAllLogIterator.initRegions -> grpc.ListClusterByIdsWPC(it.ctx, clusterIDs)"
            }
          ]
        },
        {
          "name": "regional-dataapp-control",
          "target_repo": "tidbcloud/dataservices",
          "target_interface": "POST /inner/dataservice/apps/:app_id/dataapp-log/query",
          "operation_type": "http_post",
          "conditions": [
            "Only when hourly ETL iterates a concrete org-region pair"
          ],
          "operations": [
            {
              "operation": "QUERY REGIONAL EXECUTION LOGS",
              "trigger": "Fetch endpoint execution logs used to compute per-hour traffic and latency aggregates",
              "conditions": [
                "job_type == etl_hour",
                "Region iterator produced a region for the current org"
              ],
              "implementation": "http.QueryDataAppLog(it.ctx, region, 0, req)"
            }
          ]
        }
      ]
    },
    "ToolsLifecycle.RunEtlDayJob": {
      "infrastructure": {
        "mysql": {
          "conditions": [
            "Only when --job_type=etl_day"
          ],
          "operations": [
            {
              "operation": "SELECT / UPSERT",
              "trigger": "Compute daily feature usage and active-user rollups for each day in the requested range",
              "conditions": [
                "job_type == etl_day"
              ],
              "implementation": "etlWorker.RunEtlJobDaily(ctx, tempTimestamp)"
            }
          ]
        }
      },
      "services": []
    }
  }
}
