# Platform support (per OS, local or hosted)

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

Code: [`core/platform/platform.ts`](https://docs.altasystem.ai/reference/advanced/core-api/platform-platform). Tests: [`tests/platform.test.ts`](https://github.com/altasystem-ai/alta/blob/main/tests/platform.test.ts).

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.

```ts
type OS = "macos" | "linux" | "windows";   type Arch = "arm64" | "x64";
interface Platform { os: OS; arch?: Arch[]; min?: string }
type PerOS<T> = T | Partial<Record<OS, T>>;
type Need = "gui" | "audio" | "gpu" | "keychain" | "sudo" | "terminal" | "local-device";
interface Support { platforms: Platform[]; hosted?: "ok" | "limited" | "no"; needs?: Need[]; notes?: Partial<Record<OS, Text>> }
interface Host { os: OS; arch: Arch; version?: string; mode: "local" | "hosted"; has: Need[];
  tier?: "free" | "paid";   // hosted only: the trial or a kept world; absent = unknown
  axis?: string;             // the marketing axis the world was opened from
  machine?: Measured }       // what the server measured: cores, memory, free disk, GPU (resources.md)
type HostCond = "local" | "hosted" | "hosted-free" | "hosted-paid";
```

- `supports(s, host)` → `{ ok: true }` or `{ ok: false, reason: "os"|"arch"|"version"|"hosted"|"needs", detail }`.
  No `support` = supported everywhere.
- `hostedLevel(s)`: default `ok` when linux is listed and no need is declared, else `no`. In hosted mode the needs
  `keychain`, `gui`, `audio`, `local-device` are never present (`LOCAL_ONLY_NEEDS`).
- `pick(v, os)`: the value of a `PerOS` for this OS (a plain value is for every OS).
- `checkSupport(s, perOS)`: refuses an empty list, unknown OS/arch/need, a bad version, `hosted: "ok"` without
  linux, and a `PerOS` table that names an OS the support does not list.
- The server sends its `Host` in `/api/game` (`host`), computed by `describeHost()` in [`server/lib/mode.mjs`](https://github.com/altasystem-ai/alta/blob/main/server/lib/mode.mjs).

## Host conditions

`HostCond` says where a beat, a tour stop, a step or a choice applies (ONBOARDING-V2 §4.3); absent = everywhere.
`onHost(c, host)`: no host described = local. `hosted-free` holds only when `tier === "free"`, `hosted-paid` only
when `tier === "paid"`: an unknown tier shows neither. The reference hosts (`REF_HOSTS`, one table shared by the
client, the validators and the tests): `local` = macOS arm64 with its default needs; `hosted-free` and `hosted-paid`
= linux x64, `has: []`. `refHost(id)` reads a `?host=` value (`hosted` is the free tier).

## Machine resources

What a step, a choice or an executor needs of the machine (cores, memory, free disk, GPU, processor family) and what
the server measures of it (`Host.machine`): see [resources](resources).
