# Session recordings

> Every revision of a Minekube bundle records its message log - each message, the Model after it and the Commands it issued - so a session can be read in the devtools and replayed by bun test through today's rules.

A recording is the message log of one revision of a bundle, written while it runs: every message, the Model after it, the Commands it issued, its Subscriptions and its failures. The runtime writes one recording per revision, on Paper, on Velocity and in the client, without any code in your game.

A replay sends a recording's messages through your current rules and compares what comes out. It turns a real session into a test.

## Why record the rules

A game's rules decide without touching the server: the same message gives the same Model and the same Commands. So the messages of a session are enough to reproduce every decision the game made in it. Packets, the world and the server are not needed.

- **A bug report becomes a test.** Copy the session where a player hit the bug into your project, and `bun test` replays it.
- **A change shows what it changes.** A replay names the first message whose result differs from the recording, so you see whether a change did what you meant and nothing else.
- **You and your coding agent read the same session.** The devtools show each recording as a timeline with cause chains and Model changes, and your agent reads the same data over MCP.

## What a recording holds

- **One file per revision,** in plain JSON, one entry per line. Messages and Models are encoded through the component's Schemas.
- **The game time of every entry.** Clients and the server count the same game time, so a client's recording lines up with the server's, tick for tick.
- **Every instance of the component,** with its path, such as the game's instance after a restart.

The server keeps the newest recordings per game and deletes older ones; [Limits](https://minekube.com/games/platform/limits#games) says how many.

A recording outlives a full disk or a file it cannot write. The server logs that the recording stopped, holds what happens meanwhile, and writes it to the same file once it can. A write that broke off is cut back, so the file has no broken or doubled lines. If too much piles up while it cannot write, it drops the oldest entries and logs how many each time. If the game stops before the recording can write again, the server logs how many entries the recording ends without.

## What a replay checks

A replay checks the rules, not the server. It replays messages through `update` and compares the Model and Commands. It does not run Paper, and it does not check what Commands did in the world.

- **A divergence on a changed rule** is expected: record a new session and replace the file.
- **A divergence on an unchanged rule** means that `update` read something outside its message and Model, such as the clock or a random number. Move that value into a message or a Command.

## What a recording is not

- **Not a video or a world replay.** It holds the rules' side of a session, not what players saw.
- **Not a packet capture.** Tools that record Minecraft packets replay what a client received; a Minekube recording replays the decisions.

## Built and planned

Recordings on all three platforms, replays in `bun test`, and the devtools are built. Planned, to grow a recording into a full match record: a world track from a camera next to the message log, replay in the browser with a timeline, checkpoints to jump to any tick, and clips of a match to share.

## Related

- [Recordings and replay](https://minekube.com/games/testing/recordings): where recordings are written, and how to turn one into a test.
- [Devtools and message logs](https://minekube.com/games/testing/devtools): read recordings as sessions.
- [Test rules with Stories](https://minekube.com/games/testing/rules): the Story API that replays use.
