# Prove a step with a check

> Let the machine say a step is done: a file, a program, an answer, the map of the player's system.

You give a step a `check`: a question the game asks the machine, read only, that answers yes or no. When it says yes, the step turns green on its own; if it stops being true later, the quest reopens (the experience stays won). The player never has to say "I did it".

**Before you begin (10 minutes)**

- A quest pack that passes `alta lint`: the [quickstart](https://docs.altasystem.ai/quickstart) makes one, `my-pack`.

### Prove a file

A `check` step shows only its check. The `file` type passes when that path exists under the player's home folder (`~/`). Write a `hint` that says what to do: the step updates by itself when the file appears.

A check only reads, and never sends back what it read: here, only whether the folder exists.

```json [my-pack/checks.json]
{
  "id": "projects",
  "kind": "check",
  "title": {
    "en": "A Projects folder in your home",
    "fr": "Un dossier Projects chez toi"
  },
  "hint": {
    "en": "Create ~/Projects: the step turns green on its own.",
    "fr": "Crée ~/Projects : l'étape passe au vert toute seule."
  },
  "check": { "type": "file", "path": "~/Projects" }
}
```

### Prove a program

The `bin` type passes when a program is installed. For a program the game knows, it also asks the program its version, so a broken install does not pass.

```json [my-pack/checks.json]
{
  "id": "git",
  "kind": "check",
  "title": { "en": "Git is installed", "fr": "Git est installé" },
  "check": { "type": "bin", "name": "git" }
}
```

### Prove an answer

A `choice` step saves the player's answer under its `saves` key. An `answer` check passes once that key has an answer: use it to make a later step, or another quest, wait for the choice.

```json [my-pack/checks.json]
{
  "id": "editor",
  "kind": "choice",
  "title": {
    "en": "Which editor do you use?",
    "fr": "Quel éditeur utilises-tu ?"
  },
  "choices": [
    {
      "id": "vscode",
      "label": { "en": "VS Code", "fr": "VS Code" }
    },
    { "id": "zed", "label": { "en": "Zed", "fr": "Zed" } },
    {
      "id": "other",
      "label": { "en": "Another one", "fr": "Un autre" }
    }
  ],
  "saves": "answers.workbench.editor"
}
```

```json [my-pack/checks.json]
{
  "id": "editor-known",
  "kind": "check",
  "title": {
    "en": "Your agent knows your editor",
    "fr": "Ton agent connaît ton éditeur"
  },
  "check": { "type": "answer", "key": "answers.workbench.editor" }
}
```

### Prove from the map

The game keeps a map of the player's system: modules, automations, agents, devices. The `world` type counts entities of a kind (in some states) between `min` and `max`; `entity` asks about one entity; `automation`, `module` and `skill` ask about one thing by its name.

```json [my-pack/checks.json]
{
  "id": "one-automation",
  "kind": "check",
  "title": {
    "en": "At least one automation runs",
    "fr": "Au moins une automatisation tourne"
  },
  "check": {
    "type": "world",
    "kind": "automation",
    "state": ["running"],
    "min": 1
  }
}
```

### Check the pack

Save the complete example as `my-pack/checks.json` and check the folder. A check `type` the game does not know is refused: [`check.type`](https://docs.altasystem.ai/reference/errors#check-type). Each type has the fields it needs, listed with every other type on the [check types](https://docs.altasystem.ai/reference/standards/checks) page.

```json [my-pack/checks.json]
{
  "schema": "alta.quests/0.3",
  "branch": "core",
  "quests": [
    {
      "id": "workbench",
      "uid": "core.workbench",
      "act": 2,
      "giver": "architect",
      "title": {
        "en": "Set up your workbench",
        "fr": "Installe ton établi"
      },
      "summary": {
        "en": "A folder for your projects, the tools you code with, and one automation that runs.",
        "fr": "Un dossier pour tes projets, les outils avec lesquels tu codes, et une automatisation qui tourne."
      },
      "reward": { "xp": 50 },
      "steps": [
        {
          "id": "projects",
          "kind": "check",
          "title": {
            "en": "A Projects folder in your home",
            "fr": "Un dossier Projects chez toi"
          },
          "hint": {
            "en": "Create ~/Projects: the step turns green on its own.",
            "fr": "Crée ~/Projects : l'étape passe au vert toute seule."
          },
          "check": { "type": "file", "path": "~/Projects" }
        },
        {
          "id": "git",
          "kind": "check",
          "title": {
            "en": "Git is installed",
            "fr": "Git est installé"
          },
          "check": { "type": "bin", "name": "git" }
        },
        {
          "id": "editor",
          "kind": "choice",
          "title": {
            "en": "Which editor do you use?",
            "fr": "Quel éditeur utilises-tu ?"
          },
          "choices": [
            {
              "id": "vscode",
              "label": {
                "en": "VS Code",
                "fr": "VS Code"
              }
            },
            {
              "id": "zed",
              "label": {
                "en": "Zed",
                "fr": "Zed"
              }
            },
            {
              "id": "other",
              "label": {
                "en": "Another one",
                "fr": "Un autre"
              }
            }
          ],
          "saves": "answers.workbench.editor"
        },
        {
          "id": "editor-known",
          "kind": "check",
          "title": {
            "en": "Your agent knows your editor",
            "fr": "Ton agent connaît ton éditeur"
          },
          "check": {
            "type": "answer",
            "key": "answers.workbench.editor"
          }
        },
        {
          "id": "one-automation",
          "kind": "check",
          "title": {
            "en": "At least one automation runs",
            "fr": "Au moins une automatisation tourne"
          },
          "check": {
            "type": "world",
            "kind": "automation",
            "state": ["running"],
            "min": 1
          }
        }
      ]
    }
  ]
}
```

```sh [Terminal]
alta lint my-pack
```

```text [Output]
ok   my-pack/checks.json (quests)
ok   my-pack/quests.json (quests)
2 checked, 0 errors, 0 warnings
```

**Try it:**

```sh
alta dev my-pack
```

Open the address it prints, press <kbd>L</kbd> for the quests, then open **Set up your workbench**. In the demo the game reads a pretend machine: some checks pass, others wait. Nothing reads your own files.

## Pitfalls

| Do | Avoid |
|---|---|
| A check for what the step changes on the machine | A check that passes before the player did anything |
| A `hint` that says what makes the step pass | A check step with no clue for the player |
| Two steps with `os` when the path differs by system | One path that only exists on macOS |
| `answer` to wait for a choice | `answer` as the only proof of a daily quest |

A check never returns a value it read, never a secret, and never a file's content. A `service` check only asks addresses on the player's machine (`http://127.0.0.1:<port>`). A per-system `check` table is refused: write one step per system, see [One step per system](https://docs.altasystem.ai/guides/quests/per-os).

## Go further

- [Check types](https://docs.altasystem.ai/reference/standards/checks): every type, its fields, who answers it.
- [Quests and proof](https://docs.altasystem.ai/concepts/quests-and-proof): why a quest ends on a proof.
- [Make a step that does it](https://docs.altasystem.ai/guides/quests/do-it-step): a check after an action.

**Next:**

- [Make a step that does it](https://docs.altasystem.ai/guides/quests/do-it-step)
- [Check types](https://docs.altasystem.ai/reference/standards/checks)
- [One step per system](https://docs.altasystem.ai/guides/quests/per-os)
