# TiDB-Mgmt Migration Design

## Goal

This change isolates the control-plane dependency shift required by the TiDB-X refactor.

The main point is simple:

- old dependency: `core-svc`
- new dependency: `tidb-mgmt`

## Why It Exists

`core-svc` could no longer serve as a complete source of cluster metadata for the TiDB-X rollout.

The refactor needs cluster metadata that can correctly support:

- Dedicated
- Premium
- Essential
- Starter

and later drive:

- service-plan-aware datasource routing
- target-cluster rendering
- event handling
- label and query behavior selection

## Main Design

### Metadata Source of Truth

Global uses `tidb-mgmt` as the canonical cluster lookup service.

### Materialized Inputs

The migration must provide enough data downstream to:

- derive `ServicePlan`
- render pipeline config safely
- avoid assuming Dedicated-only component topology for non-Dedicated clusters

### Compatibility Posture

- Dedicated remains the safety baseline
- missing or partial non-Dedicated metadata must not crash shared paths
- event handling should tolerate richer or poorer payload shapes than before

## Functional Impact

- cluster lookup implementation changes
- event source / event model changes
- Helm target-cluster rendering changes
- old `core-svc`-oriented assumptions are reduced or removed

## What Reviewers Should Check

- `tidb-mgmt` is actually the active lookup path
- rendered pipeline config still works for Dedicated
- service plan is available to later routing logic
- non-Dedicated clusters do not rely on Dedicated-only fields
