# Recipe: prove a behaviour change when the recording no longer holds

Goal: you meant to change how the game plays, so its recorded run fails. Prove that the
change does what you said and nothing else, record a run that still plays the game to
its end, look at it, and only then accept it.

## 1. Read what failed

```sh
frost test game.toml
```

A failure names the first step that differs, the value, what it was, and the script line
that last wrote it. If that first difference is not the thing you meant to change, stop:
the change does more than you think.

## 2. Say what the change changes, and hold it to that

With the game in git, name the parts your change may alter and the step each may start
to differ from (parts as `world.checksum` names them):

```sh
frost test --says Transform.x@140 game.toml
frost test --says state:main.luau game.toml
```

The game on disk is played beside the committed game on the same recorded input, and the
test fails at the first step where a part you did not name differs. Over the protocol,
`change.test` asks the same of a copy before it lands.

## 3. When the old input no longer plays the game

A recording is only input. After a real change to the rules (a gap is wider, an enemy is
faster) the same presses can fall into the gap or lose early, and the run proves nothing.
Record a new one by playing:

1. Play the game with the protocol beside it: `frost dev game.toml`, or `frost serve game.toml`
   and drive it with `input.set` and `game.step`.
2. When the run reaches the end you want to prove, ask for `input.history`. Its
   `recording` is the whole `[input] recording` key, ready to paste, or to save alone in a
   file named by `recording = "run.toml"`. `edits` must be empty: a write to the world
   during the session is not in the recording.
3. Set `replay = { steps = N, checksum = "0000000000000000" }` with `N` the step you
   reached.

## 4. Look before you accept

```sh
frost run --headless --steps 600 --state game.toml          # the values at the end
frost run --headless --steps 600 --shot 600=end.png game.toml   # and the picture
```

Open the picture. Check the values you care about (the score, the level, who is alive).
A checksum only says the run repeats; it does not say the run is right.

## 5. Accept, and keep the way back

```sh
frost test --write game.toml              # writes the new checksum and checkpoints
frost check --shots game.toml             # which kept pictures changed, the most first
frost check --shots --write-shots game.toml   # keep the new pictures, once you looked
frost test game.toml                      # passes on the accepted run
```

`frost test --write` keeps the game as accepted in `.frost/accepted/`, so a later failure is
compared with it. `frost test --unaccept game.toml` takes the last acceptance back. A kept
picture is never replaced by a test: only `--write-shots` replaces it, and only when
you ask.

## Checks that prove it worked

- `frost test --says ...` passed before you recorded again: the change touched only what you
  said.
- The new run reaches the end you meant, and you looked at its picture.
- `frost test` and `frost test --restore` pass on the accepted run.
