# Game package — the contract Status: contract 1, text v1.1, 2026-10-05 (KazokuAI pass 26.1: the navigation limit stated, the Theme's shape ruled, the `mute` message added; still contract 1, as nothing had vendored v1.0). Text v1.0: pass 26. Written from Sumi's brief: §7 (the contract) and the rulings R2 (the package), R5 (where this lives, how it is versioned), R33 (audience), with R25 and R31 for what music and songs mean, and J's pass-26.1 rulings. Nothing here goes beyond them; where §7 left a shape open, this text picked the plainest one and the pass-26 report lists each pick. This directory is canonical: `docs/game-package/` in the KazokuAI repo — SPEC.md (this), manifest.schema.json (the manifest as JSON Schema, field for field with §2), harness.html (a page that hosts a package by this text, for checking one), VERSION (the contract number) and CHECKSUMS (sha256 of the three files). Sumi vendors a verbatim copy under `spec/`; a test in each repo checks the copy against the version it claims. kazokuai.dev/spec will publish it. A **package** is a game as a static bundle with a manifest. A **host** is anything that loads one over this contract: KazokuAI's Games tab, Sumi's Play room, or a third party's page. The contract is the whole interface between a game and a host: a game never imports host code, a host never imports game code, and a package can be written with neither tool. Words: MUST, MUST NOT and MAY are requirements; "never" is MUST NOT. ## 1. The zip - A package is one `.zip` file of at most **10 MB** (10,485,760 bytes, the file as stored). - `manifest.json` and `index.html` sit at the **root** of the zip, not inside a folder. - Every other file is reached from `index.html` by a relative path. Paths use `/`, never start with `/`, never contain a `..` segment, a scheme (`https:`), a backslash or a control character. - A package has **no audio files** (an MP3, M4A, AAC, OGG, Opus, WAV, FLAC or WebM audio file, or any other audio type). Sound effects are synthesised by the game (Web Audio); music is the host's to play, asked for by name (§6). - A package has **no network**, ever (§3). ## 2. The manifest `manifest.json` is one JSON object, UTF-8. Fields not listed here are refused (manifest.schema.json: `additionalProperties: false`). | field | type | required | meaning | |---|---|---|---| | `contract` | integer, `1` | yes | The contract this package speaks (§9). | | `id` | string, a slug: `^[a-z0-9]+(-[a-z0-9]+)*$`, 1–64 characters | yes | The package's identity and **the scores key**. It never changes: a new version keeps its id; a different id is a different game, with its own scores and saves. | | `name` | string, not empty | yes | The game's name, as the tile shows it. | | `version` | string, semver 2.0 (`1.4.0`, `2.0.0-beta.1`) | yes | This build's version. A host shows it and may keep several; scores and saves follow `id`, not `version`. | | `entry` | string, `"index.html"` | yes | The page the host loads. In contract 1 it is always `index.html` at the root. | | `icon` | string, a path inside the package ending `.png`, `.svg` or `.webp` | yes | The tile's image, as a host shows it with an ``. | | `aspect` | array of `"portrait"` · `"wide"`, at least one, no repeats | yes | The shapes the game can lay out to: portrait (taller than wide: a phone held upright) and wide (wider than tall: a desktop, a phone on its side). The host picks one and says which in `hello`; `aspect` tells the game when it changes. | | `inputs` | array of `"touch"` · `"keys"` · `"pad"`, at least one, no repeats | yes | What the game can be played with: a touchscreen; a keyboard (and the mouse beside it); a gamepad, through the Gamepad API (§3's `allow="gamepad"`). | | `save` | boolean | yes | The game keeps a save (§5). False: it never sends `save` and `hello.save` is always null. | | `score` | `"high"` · `"none"` | yes | high: the game sends `score` at the end of a run and higher is better; the host keeps a leaderboard by `id`. none: no scores. | | `music` | boolean | yes | The game asks the host for music by playlist name (§6). False: it never sends `music`. | | `audience` | `"all"` · `"adult"` | no; absent means `all` | Who the game is for (R33). A host's "minors can play" switch, set to everyone-rated, hides `adult` packages from minors (§7). | | `songs` | array of song objects (below) | no | The briefs the game's songs were made from (R31): never the audio. | | `story` | string, a path inside the package ending `.md` | no | The game's story as markdown (Sumi's `story.md`). | | `author` | string, not empty | yes | Who made it: a person's or a studio's name. | A song object (each field required, nothing else allowed): | field | type | meaning | |---|---|---| | `id` | string, a slug like the package's | The song's identity within the package: no two alike (a validator checks this; the schema can't). | | `playlist` | string, not empty | The playlist the song belongs to: the name the game asks for in `music {playlist}`. | | `brief` | string, not empty | The text the song was made from (a music model's prompt). | | `mood` | array of strings | Mood words for the music model ("driving", "dark"). The list may be empty. | | `lyrics` | boolean | The song has words (true) or is instrumental (false). | ## 3. The sandbox A host loads `index.html` in exactly this frame: ```html ``` - **Opaque origin.** The sandbox has no `allow-same-origin`: the game's origin is opaque (`"null"`). It reads no host cookie, storage or DOM, and nothing the host's origin can do. Nor has it storage of its own: `localStorage`, `sessionStorage`, IndexedDB and cookies throw or hold nothing; a game keeps its state through `save` (§5). - **The policy.** The package is served under the Content Security Policy ``` default-src 'self'; connect-src 'none' ``` A host sends it as the `Content-Security-Policy` header of `index.html`'s response. What follows from it, for a game's author: - no network: no `fetch`, XHR, WebSocket, EventSource or beacon, not even to the package's own files; - files load only from the package itself, by element: `