# Controlled updates

> Planned: a game holds an update while a round runs, servers report what they run so routing can send new players elsewhere, and a rollout goes in waves that stop when a server cannot run the new revision.

> **Planned:**
> This page describes a design that is not built yet. Today you publish with `mk publish`, `mk revisions` and `mk unpublish`; see [Publish a revision](https://minekube.com/games/versions-and-deployments/publish).

Today the Minekube plugin swaps a game as soon as a new revision arrives, so a running round starts over in the middle. Three planned primitives make updates controlled. When to swap and where new players go stays the decision of the network's own code.

## A game holds the update

```ts
const round = Effect.gen(function* () {
  yield* Game.holdUpdates; // while this scope is open, an update waits
  // … the round …
}).pipe(Effect.scoped);
```

- The new revision is already loaded while it waits. When the last hold is released, the plugin swaps it in.
- `Game.updatePending` tells the game that an update waits, so it starts no new rounds or shows "update after this round".
- `mk deploy --deadline 30m` sets an upper limit. After it, the plugin swaps even if a game hangs.

## Servers report what they run

The connector tells the registry which revision runs and whether one waits. The registry turns that into a label, such as `minekube.com/update=pending`. A network's routing can then send new players to other servers while rounds end. `mk deployments list` shows how many servers run the new revision and how many wait.

## Rollouts in waves

`mk versions deploy <id> --batch 20%` assigns a revision to a part of the matching servers first. The next wave starts when those servers report that the new revision runs. If it fails to start on one, the rollout stops, and `mk rollback` goes back. Waves split by servers, not by requests: a server runs one revision.

A restart for a plugin update waits for the same holds.

## Related

- [Live swap](https://minekube.com/games/local-development/live-swap): what a swap does today.
- [Labels and selectors](https://minekube.com/guide/networks/labels): the labels routing reads, in Connect.
