# alta.onboarding/0.2: the guide

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

Code: [`core/onboarding/onboarding.ts`](https://docs.altasystem.ai/reference/advanced/core-api/onboarding-onboarding). Tests: [`tests/contracts.test.ts`](https://github.com/altasystem-ai/alta/blob/main/tests/contracts.test.ts), [`tests/onboarding.test.ts`](https://github.com/altasystem-ai/alta/blob/main/tests/onboarding.test.ts).
Design: [`docs/ONBOARDING-V2.md`](https://github.com/altasystem-ai/alta/blob/main/docs/ONBOARDING-V2.md) (the guide on a Mac and in the cloud).

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.

The guide is a list of beats over the campaign quests; each world may ship `universes/<id>/onboarding.json`,
[`content/onboarding.json`](https://github.com/altasystem-ai/alta/blob/main/content/onboarding.json) is the neutral fallback. 0.1 files are still read.

0.2 adds:
- on a step: `setup` (the id of a setup plan the step shows; lot D1) and `cutscene` (a scene id of
  [alta-cinematics-0.1](alta-cinematics-0.1));
- on a beat: `auto: "app-open" | "hosted"` (the proof given by the app being open, or by running hosted:
  `AUTO_PROOFS`), and `wait` (the beat waits for its proof instead of offering "Next");
- on a beat and on a tour stop: `host: "local" | "hosted" | "hosted-free" | "hosted-paid"` (`HostCond`, see
  [platform](platform)): where it is played. Absent = everywhere.

## Host and axis: two questions, two mechanisms

| | Host: *where it runs* | Axis: *who arrives* |
|---|---|---|
| Changes | the facts: which quests and steps exist | the tone: lines, order, first tracked quest |
| Mechanism | the `host` condition inside the file | a file variant `onboarding.<axis>.json` |
| Comes from | `/api/game.host` (`mode`, `tier`) | `host.axis` |

- `beatsFor(o, host)`: the beats played on this host, in file order. An `auto` beat implies its host
  (`app-open` = local, `hosted` = hosted), so the two doors are two quests, hence two beats.
- `stopsFor(beat, host)`, `resumeAt(o, at, host)`: if the saved beat is not played on this host, the guide resumes at
  the first played beat after it in the file; if there is none, the guide ends.
- The counter "n / total" counts the played beats; `track` is read on the last played beat.
- `guideProofs(o, at, done, host?)` proves only the `auto` quests of played beats.
- `onboardingFor(files, universe, variant?)`: the first file that exists in
  `universes/<u>/onboarding.<v>.json` → `universes/<u>/onboarding.json` → `content/onboarding.<v>.json` →
  [`content/onboarding.json`](https://github.com/altasystem-ai/alta/blob/main/content/onboarding.json). A host mode is never a variant name (`HOST_VARIANT_NAMES`): such a variant is ignored.

## Validation

`checkOnboarding(o, questUids, sceneIds?, opts?: { game?, variant? })` refuses unknown quests, unknown scenes (when
`sceneIds` is given), an unknown `auto`, any 0.2 field in a file that declares 0.1, and:
1. a `host` outside `HOST_CONDS`;
2. a `host` that contradicts `auto` (`auto: "app-open"` with a hosted condition, `auto: "hosted"` with `local`);
3. a reference host (`local`, `hosted-free`, `hosted-paid`) on which no beat is played;
4. two beats of the same quest played on the same host (a variant that wants other lines per mode writes `wake` and
   `wake-hosted`, each with its host);
5. `opts.variant` equal to `local`, `hosted`, `free` or `paid`;
6. with `opts.game`: a played beat whose quest cannot be played on that host, a `track` to such a quest, a key of
   `steps` or a `tick` that is not a step of the beat's quest.
