# Checking a video

The tool `check` runs a video's timeline and answers with what it found: what is wrong, with the line each finding comes from, and how long the video is. An agent calls it after every change, before it looks at a frame. Check draws nothing: the video's source is read and linted, and its timeline is run on the app's own server, its files read but never decoded, so it answers in moments, and a check of a video nothing it loads changed in answers from what the last one found. Framescript also runs the same check on every change an agent writes through `bash`, on the videos that change reaches, and writes nothing that fails it. Every export runs it before anything is drawn and refuses on an error with the findings, whoever starts it: the studio's **Export**, the tool `exports` or `render`.

The samples here read basics/tweens. A call names its video with `video`, as bash shows it, or works on the video of the window you used last ([Which video](/docs/framework/agents/tools.md#which-video)):

```json
{ "video": "/videos/basics/tweens" }
```

## What it answers

```json
{
  "ok": true,
  "video": "tweens",
  "status": "ready",
  "duration": 2.7,
  "frames": 162,
  "diagnostics": [],
  "files": []
}
```

- `status` is `ready` when the timeline ran to its end, `failed` when it threw, and `skipped` when it was not run, with why in `skipped` ([What check does not judge yet](#what-check-does-not-judge-yet)).
- `diagnostics` lists what is wrong. Each has the `rule` it breaks, one of [the rules of the check](/docs/framework/agents/rules.md), a `severity` (`error` or `warning`), a `message` that says what to do, the `site` of the call as `file:line:column` (or `null`), and the `time` and `frame` it belongs to.
- `ok` is `true` when no diagnostic is an error and the timeline did not fail. Warnings alone leave `ok` true. When `ok` is false, the tool's answer is marked as an error and still holds the diagnostics.
- `diagnostics` also holds what the video shows that is not seen as meant: an object added to be drawn that no moment shows, a material that takes light with none, a camera, viewport or image out of its picture's proportions. These are judged on the running video at taste's moments, at the start, middle and end of each object's animations and at least every quarter second, so an object that only crosses the frame quickly, or shows for a moment within a long animation, is seen; each finding names its object by name and line ([the objects' rules](/docs/framework/agents/rules.md#objects)).
- `diagnostics` also holds what [taste](/docs/framework/taste.md) finds: texts that overlap, leave the frame or are too small to read, titles that only fade, moves that stop at speed. Such a finding names what is on screen: its `rule`, the `objects` it is about by name with their lines and where they lie, the `clip` it happens in and the `crop` that shows them ([what a finding carries](/docs/framework/taste.md#what-a-finding-carries)). `tasteExceptions`, there when a text is let off a rule with `allow`, lists each exception with its rule and reason; an exception never fails the check.
- `diagnostics` also holds what the lint of the video's source finds, each at its `file:line:column`: a step never run for want of `yield*`, `Math.random` and the other calls that differ on every run, an async function, a request outside `load`, a `custom` that assigns what lies outside it, a `let` at the top of a module ([the rules of the video's source](/docs/framework/agents/rules.md#the-videos-source)). A line breaks one of them on purpose with a comment above it, `// framescript-allow module-state: <reason>`; a comment without a reason is an error of its own.
- Check runs the timeline a second time and plays sample frames forwards and then backwards. When the second run records anything else, or a moment comes out otherwise in the other order, `diagnostics` holds an error of `nondeterminism` at the first thing that differs. The run reaches only the video's own files: a `fetch` of the web fails there, and in an export.
- Check also runs the video at its controls' limits, one control at a time over the others' values: a slider or a number at its least and its most, a toggle the other way and a choice at each other option. An error such a run finds where the video's own run finds none is in `diagnostics` with the `inputs` it happens with, such as `{ "count": 10 }`. Those runs are judged by their timeline and by taste, and say only errors: a warning that a value brings, such as a length past what a video plays without scenes, is judgement, not a broken video. At most 12 are made.
- `files` lists the files the run read through `load.*`, each by the address the video names it, a sequence's pictures each apart, and the fonts its texts are laid out in.

## A video with an error

```json
{
  "ok": false,
  "video": "broken",
  "status": "ready",
  "duration": 1.6,
  "frames": 48,
  "diagnostics": [
    {
      "severity": "error",
      "rule": "unknown-label",
      "message": "There is no label \"beat\" in this clip or the clips around it. A label is made with label(\"beat\", time) before it is used.",
      "site": "broken/index.ts:22:12",
      "span": "s6",
      "time": 1.1,
      "frame": 33
    }
  ],
  "files": []
}
```

A diagnostic's `message` says what is wrong and what to do, and its `site` is the place to do it at. Treat warnings as work as well: [The loop an agent works in](/docs/framework/agents/loop.md) shows them and how to act on them.

A video whose file cannot be built, or throws before it exports its video, fails the same way, with one error that names the file and no `site`: `broken/index.ts could not be loaded: missing is not defined`. Only that video fails; the other videos answer as before.

A timeline that does not end within a minute is ended and fails with an error of `runaway`: a wait or a tween given a time that never comes is the usual cause.

## What check does not judge yet

Check judges what a video's run records, without drawing a frame or decoding a file, so these are not part of it yet:

- What a video costs to draw: its draw calls, its passes and what a frame holds. The studio's inspector shows them.
- How loud the mix is and how its sounds are mixed. See [Loudness and the master](/docs/framework/sound/loudness.md) for how to hear it.
- Whatever reads a frame's pixels, such as a picture whose transparent pixels are drawn solid.
- Whether the browser has a decoder for a media file's codec: check reads a media file's length, picture size and frame times from its container.

A video that loads a glTF model, an SVG drawing or what a media file sounds like (`listening`), a picture whose header does not say its size, starts a worker of its own or reads a file from the network is not run: its `status` is `skipped` and `skipped` says why. That is neither a pass nor an error; what the lint and the video's layout find is still said.

## Pictures of what taste finds

With `shots` set to `true`, `check` also draws a picture of each taste finding's moment, cut to its `crop` with each of its objects outlined, and names it in the finding as `shot`. The first eight come back as pictures beside the answer, also when the check fails, so an agent that can see looks at what a finding points at at once. At most 24 are drawn; `shots` in the answer says how many were drawn and how many findings were `left` without one.

```json
{ "video": "/videos/launch", "shots": true }
```

## Values to try

`inputs` runs the check with other values for the video's [controls](/docs/framework/media/inputs.md), the object itself or a JSON file of it in the video, and writes nothing; the runs at the controls' limits start from them:

```json
{ "video": "/videos/hello", "inputs": { "rise": 0.9 } }
```

## See also

- [Taste](/docs/framework/taste.md): the rules the check holds a video to
- [The loop an agent works in](/docs/framework/agents/loop.md)
- [Reading a video](/docs/framework/agents/reading.md) and [Looking at a frame](/docs/framework/agents/frames.md)
- [The tools an agent has](/docs/framework/agents/tools.md#check)
