# alta.game/0.3: steps that act, ask and say why

<p class="generated-note">Generated from <a href="https://github.com/altasystem-ai/alta/blob/main/docs/standards/alta-game-0.3.md"><code>docs/standards/alta-game-0.3.md</code></a> · <code>npm run docs:gen</code></p>

Code: [`core/quests/standard.ts`](https://docs.altasystem.ai/reference/advanced/core-api/quests-standard) (fields, `checkGame`, `evaluate`), [`core/runs/inputs.ts`](https://docs.altasystem.ai/reference/advanced/core-api/runs-inputs) (inputs and arguments),
[`core/runs/executors.ts`](https://docs.altasystem.ai/reference/advanced/core-api/runs-executors) (what each executor takes). Tests: [`tests/inputs.test.ts`](https://github.com/altasystem-ai/alta/blob/main/tests/inputs.test.ts), [`tests/standard.test.ts`](https://github.com/altasystem-ai/alta/blob/main/tests/standard.test.ts),
[`tests/sdk.test.ts`](https://github.com/altasystem-ai/alta/blob/main/tests/sdk.test.ts). Everything of [alta.game/0.2](alta-game-0.2) still holds; this page says what 0.3 adds.

Status: **alpha**. This format can still change before its 1.0; a change follows the versioning rules of the project and is announced in the changelog.

Schemas: `alta.game/0.3` (a whole game) and `alta.quests/0.3` (a fragment). A 0.1 or 0.2 file is read as is
(`upgradeGame` keeps its version, 0.1 becomes 0.2) and evaluates the same as the same file declared 0.3: every 0.3
field is optional (tested on [`content/branches.json`](https://github.com/altasystem-ai/alta/blob/main/content/branches.json)). A fragment is checked by its own version, whatever the version
of the game it joins (`checkFragment`).

## What a step can say

| Field | Type | Meaning |
|---|---|---|
| `inputs` | `Input[]` | what the step asks before its `run`: a form in the plan card |
| `run.args` | `Record<string, ArgValue>` | literals, or `{ "input": "<id>" }` (a value of the form), or `{ "answer": "answers.<key>" }` (an answer already given, `Save.answers`). When the player changes that answer later ("Change" on the choice, also on a quest already done), a step whose `run` reads it and that has a check is played again: its earlier proof is set aside until its run succeeds with the new value (`Save.redo`); the same answer picked again changes nothing |
| `human` | `speak \| approve \| device \| external \| judge \| before` | why only the player can do this step |
| `provenBy` | step id | the step has no proof of its own: it is done as soon as that step of the same quest is proven |

```json
{ "id": "connect-your-google", "kind": "action",
  "title": { "en": "Connect your Google account", "fr": "Branche ton compte Google" },
  "inputs": [ { "id": "email", "kind": "email", "label": { "en": "Your Google address", "fr": "Ton adresse Google" } } ],
  "run": { "do": "connector.connect", "args": { "id": "google", "email": { "input": "email" } } },
  "check": { "type": "account", "service": "google" } }
```

### Inputs

`Input { id, kind, label, hint?, required? (default true), default?, from?, saves?, choices?, max?, min?, pattern?, not?, must? }`

| Kind | Field | Accepted value (core first, then the server again) |
|---|---|---|
| `text` | text field | 1 to `max` characters (default 200, at most 2000), no control character, `pattern` (anchored `^…$`, 200 characters at most), none of `not.values` (compared without case) |
| `choice` | buttons or list | one of `choices` (same shape as `Step.choices`) |
| `email` | e-mail field | a plain address (`x@y.z`, 254 characters at most) |
| `path` | text field | starts with `~/` or `/Volumes/`, no `..`; the server resolves it, refuses it outside those roots and checks `must` (`exist`, `dir`, `file`) |
| `number` | number field | a finite number between `min` and `max` |
| `boolean` | box | true or false |
| `secret` | password field | not empty, 4096 characters at most; nothing else is read |

- `from: "answers.<key>"` prefills from an answer; `saves: "answers.<key>"` keeps the value in `Save.answers`.
- `not: { values, why }` (text only): values the field refuses although they fit, such as names kept for something
  else (1 to 64 texts, compared without case), and the sentence the field says then (`why`, a `Text`: why, and what to
  type instead). The page, the server and `alta check` refuse them alike, before anything runs (rule `step.input-not`).
  The owner's short name of the Alta install refuses the engine's reserved names
  (`engine/scripts/install/alta-bootstrap` `RESERVED_SLUGS`; a test keeps the content and the examples equal to it).
- `inputProblems(input, value)`, `resolveArgs(step, os, values, answers)` → `{ args, secretIds, secretParams, saves,
  problems }` and `paramProblems(executor, args)` (0.2's `runArgsProblems` is its alias) are the same pure functions
  in the page, the server and `alta lint`. No problem message repeats a value.

### Inputs and executor arguments

An executor declares what a step may give it (`ExecutorInfo.args`, see [runs, routes, checks](runs-routes-checks)):
a closed list of values, or the kind of a value (`{ kind, values?, max?, min?, pattern?, required? }`). `checkGame`
checks every reference: the input exists, its kind fits the argument (the same kind; a `choice`, `email` or `path`
into a `text`; a `choice` whose choices are all in a closed list), and every input feeds an argument or is saved.

### Secrets

A `secret` input is a password, a token, a key or a one-time code (AGENTS.md §2). The standard makes it impossible to
keep one by mistake:

- it has no `default`, `from`, `saves` or `pattern`, and is never prefilled (types: `SecretInput`; rule `step.input-secret`);
- it only feeds an argument the executor declares `kind: "secret"`, and such an argument only takes a secret input
  (never a literal, never an answer); such an executor offers the way `page` (`ExecutorInfo.secret.via`);
- `resolveArgs` never puts it in `args`: it says which argument it feeds (`secretParams`), and the page sends the value
  once, in the body of the agreement (`POST /api/runs/run`, `secrets`), never in the plan, a URL or the save;
- a literal of `run.args`, or a value given to an argument, that looks like a credential is refused (`paramProblems`).

The value is typed in the game page in a local world and in a hosted world alike: the page is served by the player's
own server, and in a hosted world HTTPS ends on the player's own machine, so no service of Alta sees it in clear.

### Steps that stay with the player

- In 0.3 a `manual` step **must** say why (`human`, rule `step.manual-reason`): "I did it" never stays on a step the
  machine could do. `human` may sit on any kind of step (an `action` that needs the player to speak, for example).
- A manual step may carry a helper `run` only if it changes nothing (an executor with `card: "none"`, such as
  `mac.open-pane`; rule `step.run-card`). With a `check`, the proof decides.
- `provenBy` names a step of the same quest that has a `check` (or is a `mission`), directly or through other
  `provenBy`; never a loop, never a step without a proof, never on a step with its own `check` (rule `step.proven-by`).
  `evaluate` counts the step done when that proof passes (a ticked target proves nothing).

### A step proven by its own action

A `seen { key }` check whose key is not a scene (a scene is `trailer`, `trailer:<world>`, `intro:<uid>`,
`outro:<uid>`, `scene:<id>`; `isSceneKey` in [`core/quests/standard.ts`](https://docs.altasystem.ai/reference/advanced/core-api/quests-standard)) is marked by the game itself, never by a
"Watch" or "I did it" button:

- on a step with `run`: once the run succeeded, unless its result says `pass: false` (`voice.hear` heard nothing);
  for `voice.say`, once the page has played the line;
- on a step with `ask` (a message to its agent): once the agent answered;
- on a step a guide's tour stop ticks (`stops[].tick`): when the stop is visited.

Keys used by the built-in quests: `heard:<uid>.<step>`, `played:<uid>.<step>`, `read:<uid>.<step>`,
`ran:<uid>.<step>`, `asked:<uid>.<step>`, `tour:<agent>`. Use it only where no read-only check of the machine can see
the result (what the player heard, read or was told); a state of the machine has its own check.

```json
{ "id": "see-your-first", "kind": "action", "title": { "en": "See your first check", "fr": "Vois ta première vérification" },
  "run": { "do": "openclaw.read", "args": { "what": "update" } },
  "check": { "type": "seen", "key": "read:core.updates.see-your-first" } }
```

## Check types added

| Check | Passes when (read only) | Answered by |
|---|---|---|
| `bin { name }` | the program is found ([`server/lib/bins.mjs`](https://github.com/altasystem-ai/alta/blob/main/server/lib/bins.mjs)) | server |
| `permission { name }` | the OpenClaw app of this Mac has the permission: `microphone`, `speech`, `accessibility`, `screen`, `notifications`, `camera`, `location` | server |
| `channel { id, state? }` | the channel has an account (`configured`, the default), and no pairing request waits (`paired`) | server |
| `account { service, scope? }` | the account is connected (`google`, scope `gmail` or `calendar`) | server |
| `backup { maxAgeHours?, restoreTested? }` | a backup younger than that exists; its restore test passed | server |
| `host { mode }` | the world runs `local` or `hosted` | the core when it knows the host, else the server |
| `part { id }` | a part of the Alta install is applied: `machine`, `mind`, `memory`, `agents`, `map`, `modules` (the engine's own marker) | server |

Each is declared in [`server/checks/index.mjs`](https://github.com/altasystem-ai/alta/blob/main/server/checks/index.mjs); until its file exists the server answers it `unverifiable` ("not in
this version"). A result never carries an address, a token or an account name.

## Validator

`checkGame` adds, for a file that declares 0.3: `step.manual-reason`, `step.human`, `step.proven-by`,
`step.run-card`, `step.inputs`, `step.input-kind`, `step.input-ref`, `step.input-secret`. For a file that declares 0.1
or 0.2 it refuses `inputs`, `human`, `provenBy` and any reference in `run.args` (`game.v3-field`). In every version it
checks the fields of the check types above (`check.bin`, `check.permission`, `check.channel`, `check.account`,
`check.backup`, `check.host`, `check.part`), refuses a check whose `type` is not in `CHECK_TYPE_IDS` (`check.type`: such a step could never be proven), and refuses a literal of `run.args` that looks like a credential.
