# `Milvex.Migration.Runner`

Applies a list of `%Milvex.Migration.Plan{}` against a live Milvus cluster.

The runner is the only module in the migration pipeline that issues mutating
RPCs. It walks the plans sequentially and applies each operation per the
rules in `apply/2`:

  * If any plan in the batch contains an `:impossible` operation, the runner
    returns immediately. No RPC is attempted; every non-impossible operation
    across all plans is reported as `:blocked_by_impossible` and every
    `:impossible` op as `:blocked_impossible`.
  * For each plan, when `manage_load: true` AND any operation in that plan
    requires release AND the live collection is loaded, the runner releases
    the collection before applying the operations and re-loads it after.
  * Operations are applied in plan order. `:additive` ops always run.
    `:destructive` ops run only when `allow_drop: true`; otherwise they are
    `:skipped_no_flag`. `:descriptive` ops always come back as
    `:skipped_idempotent` and never go through the dispatch path.
  * Per-operation RPC failures DO NOT abort the plan. The failure is recorded
    and the runner moves on to the next op. Release / reload failures DO
    abort the plan (no further ops attempted on release failure; ops up to
    the failure point are kept on reload failure).
  * Plans are isolated. A failure in one plan never leaks load state to the
    next plan.

The runner emits `:telemetry` spans:

  * Run-level: `[:milvex, :migrate, :run, :start | :stop | :exception]` with
    start metadata `%{mode, allow_drop, manage_load}` and stop metadata
    `%{summary: counts}`.
  * Op-level: `[:milvex, :migrate, :op, :start | :stop | :exception]` with
    start metadata
    `%{kind, category, collection_name, module, requires_release, milvus_version}`
    and stop metadata `%{result: status}`. Only operations that actually
    reach the dispatch path emit telemetry; skipped/blocked ops do not.

# `apply`

```elixir
@spec apply([Milvex.Migration.Plan.t()], Milvex.Migration.Runner.Context.t()) ::
  Milvex.Migration.Runner.ApplyReport.t()
```

Applies the given plans against the connection captured in `ctx`.

See the moduledoc for the full set of rules. Returns an `%ApplyReport{}`.

---

*Consult [api-reference.md](api-reference.md) for complete listing*
