# The production handbook

From `create_game` to a signed release, and what to do after. It is for whoever is producing a MysteryForge game — one person wearing every hat, or a producer coordinating a team. Every command in it
is real: `make handbook-check` (part of `make check`) fails if this document names a command, a tool file or a release gate that does not exist, or leaves one out.

**Two ways to run everything.** Inside a game folder (a standalone Godot project) the tools are scripts in its `tools/` folder, written below as `bash tools/check.sh`, `python3 tools/package.py` and so on.
In the MysteryForge repository the same things run on the demo as `make` targets (`make check`, `make release-check`, `make release`…). An AI agent reaches them through the MCP tools named in `docs/MCP.md`.

## 1. Who does what

| role | owns | works in | hands off through |
|---|---|---|---|
| **Producer** | the schedule, the milestones, the gate | the Studio's Dashboard and Production tab, `bash tools/release.sh` | the release gate |
| **Writer** | story, dialogue, clues, endings, the script | Studio: Dialogue, Characters, Case board, Mystery, Endings | Review mode (the script export, pinned comments) |
| **Level designer** | rooms, hotspots, doors, puzzles, the map | Studio: Scenes, Places, Doors, Puzzles | the story check and the exact search |
| **Artist** | room pictures, items, portraits, overlays | the Art panel, or outside tools | the render hand-off pack (`make handoff`) |
| **Audio / voice** | music, ambience, recorded lines | Studio: Music, Assets; the voice scripts | `bash tools/check.sh` budgets, the loudness check |
| **Translator** | every other language | Studio: Languages | pseudo-localisation and the UI lint |
| **QA** | finding what breaks | the bots, playtest builds, the support bundle | `make playtest-report`, the soft-lock search |
| **Engineer** | game scripts, platform, CI, releases | `tools/`, the CI workflow, signing | the packager and patch builder |

## 2. Starting a game

1. **Create it.** The MCP tool `create_game` (or copy what it copies): a standalone Godot project with the engine, `tools/`, `tests/`, a CI workflow and a tiny playable starter. Open it in the Studio (`make studio`, then **Open…**).
2. **Put it in version control now.** A game is JSON and assets; every change is a readable diff. The Studio and the MCP write byte-identical files, so a human and an agent can edit the same game without noise.
3. **Run the check suite once, on the starter:** `bash tools/check.sh`. It passes. From here on, it stays passing.
4. **Set who you are:** title, author, credits and a `1.0.0`-style version in the Dashboard — the gate asks for them.

## 3. The daily loop

1. Edit in the Studio (or ask an agent). Nothing is saved until you press Save; undo works across everything.
2. **Validate** (`validate_project`, or the Validate button): every reference resolves, every file exists, no conversation dead-ends.
3. **Play it** — the Play button, or `bash tools/check.sh` to have a bot do it: `walkthrough` replays your recorded routes through the real UI, `autoplay` plays the game to its ending by itself, `fuzz` plays at random, `text` plays it as typed commands — the same front end an AI tester uses (`docs/LLM_PLAYTEST.md`).
4. **Commit** when `bash tools/check.sh` is green. CI runs the same script on every push.

## 4. Milestones

Each milestone has an **exit gate** — a command, not an opinion. Alpha, beta and gold are levels of `bash tools/release.sh <level>` (section 6).

| milestone | what it means | exit gate |
|---|---|---|
| **M0 Prototype** | one room, one puzzle, one ending, ugly | `bash tools/check.sh` is green |
| **M1 Vertical slice** | one chapter start to finish, in every system the game will use | `bash tools/release.sh alpha` passes; `autoplay` wins |
| **M2 Content complete** | every room, puzzle, conversation and ending exists (placeholder art and voice allowed) | the story check is clean, the exact soft-lock search is complete and reaches **every ending**, every puzzle is proved winnable; the hand-off pack is with the artists |
| **M3 Beta** | looks and sounds finished; being played by people | `bash tools/release.sh beta` passes; two rounds of playtests triaged |
| **M4 Release candidate** | nothing placeholder, nothing missing | `bash tools/release.sh gold` passes |
| **M5 Release** | built, signed, verified, archived | `python3 tools/package.py` succeeds; checksums and manifest archived |
| **M6 Live** | supported and patched | support bundles read, patches built, saves still load |

## 5. The work, by discipline

### Story and investigation
Characters, dialogue (branching, with topics and show-an-item), clues and deductions on the **case board**, the **mystery** (who did it, what proves it, the accusation finale) and **endings** (named, starred, best first). The tools tell you when the story is
unfair: the story check proves every clue can be found and every culprit candidate can be convicted; the **exact soft-lock search** (`bash tools/check.sh`, step `softlocks`) plays every order of play and names the move after which the game can no longer be won — and which ending nothing reaches.
Writers read the whole game as a script (`export_script`, the Review tab) and pin comments to the line they mean.

### Rooms, art and the hand-off
Flat rooms or 360° panoramas, hotspots, doors (`links.json`), views and close-ups, overlays and actors. Art comes from the Art panel (providers are paid and run only on your say-so and your own keys, never in CI) or from people:
**`make handoff`** writes a layout guide per room (every hotspot where it will be clicked, the parts of the screen the interface covers), a shot list and a contact sheet for an outside artist. **`make scene-diff BEFORE=<revision>`** draws what changed in the rooms between two versions (hotspots added, gone, moved or edited, pictures repainted) — the producer's way to review a week of edits and the artist's way to see what moved under their picture. The asset manifest tracks which pictures are placeholders; the
**budget** step keeps video memory per room inside what the machine allows.

### Puzzles
Forty built-in types, each with a solver: `puzzles` proves every instance — each difficulty level — can be won. Skip assists and difficulty are data. Write a game-local script only for a true one-off.

### Audio and voice
Adaptive score, positional ambience, ducking. Voice lines are recorded against the script; the producer's report counts recorded, synthesized, missing and *stale* (edited since recorded) lines per room. Loudness is checked across the whole game. Before actors, an AI read can stand in: cast each speaker in `game/vo/casting.json`, price the whole game for free with `make voices-estimate GAME=<folder>`, then record a sample and the rest under a dollar cap with `make voices-record GAME=<folder> MAX_USD=<dollars>` (resumable; the takes stay placeholders). Once a batch of lines is recorded (or re-recorded), `make lipsync GAME=<folder>` gives each one a mouth track (Rhubarb Lip Sync: which mouth shape shows when), so the living portraits shape their lips to the words; a line without one still moves its mouth by loudness.

### Languages
Every on-screen text goes through one function, so translation is a file per language (the Languages panel, CSV round-trip). **Pseudo-localisation** (accented, 40% longer text) and the **UI lint** (`lint` in `tools/check.sh`) catch layout that only works in English. Every locale file counts as a shipped language: the gate asks for it to be finished.

### Accessibility
Text size, high contrast, colour filters, reduced motion, remappable keys, keyboard and gamepad play, read-aloud. They are player settings and part of the engine, tested; do not build around them.

### Playtesting
Build with `--mf-telemetry` (or the `MF_TELEMETRY` variable, or an export carrying the `mfplaytest` feature). A playtest build writes what a tester does to a **local file** — rooms, puzzle tries and walk-aways, hints, endings, frame rates — and the title screen says so; nothing is sent. Put the testers' files in `game/playtests/`
(kept out of builds) and run **`make playtest-report`** (`playtest_report`): completion, the puzzles people gave up on, the rooms that ran badly, ranked "where to look first". **F3** shows live frame rate and memory.

## 6. The release gate

One command, one verdict: **`bash tools/release.sh <alpha|beta|gold>`** (`make release-check LEVEL=…` on the demo; `release_check` over MCP). It runs the **proof suite** (`bash tools/check.sh`) and the **data gates**. Nothing in it calls a paid provider or needs a key.

The proof suite, step by name: `validate` · `story` · `softlocks` · `puzzles` · `budget` · `walkthrough` · `autoplay` · `fuzz` · `a11y` · `text` · `lint`. Skip steps while developing with `SKIP="fuzz lint" bash tools/check.sh`; never to release.

The data gates, by name (the thresholds are the table in `docs/SPEC.md` "Release gate"):

| gate | alpha | beta | gold |
|---|---|---|---|
| `identity` | title, a `1.0.0`-like version | + author, credits | same |
| `validation` | no error | + no warning | same |
| `pictures` | none missing | at most 50% placeholder | none placeholder or missing |
| `voice` | — | at most 50% missing, none stale | none missing, stale or synthesized |
| `translations` | — | every locale ≥ 80% | every locale 100% |
| `review` | — | warns if comments are open | none open |
| `builds` | presets keep the Studio, `tools/` and `tests/` out | same | same |
| `bundle` | — | warns if the macOS bundle id is still the template's | the game's own |
| `legal` | — | warns if there is no licence file | a licence or EULA of substance |
| `playtests` | — | warns if no playtest notes | same |

A **fail** blocks; a **warn** is worth reading; a **skip** means the game has nothing of that kind. Every failure says what it found and how to fix it.

## 7. Releasing

1. **Gate:** `bash tools/release.sh gold` passes.
2. **Set the identity once:** your own macOS bundle identifier in the export preset, your licence as `LICENSE.txt`, your version in `game/project.json`.
3. **Dry run:** `python3 tools/package.py --dry-run` says, per platform, whether the template and preset are there and what signing would be used, and checks the identities you named exist.
4. **Package:** `python3 tools/package.py` (on the demo: `make release`). It runs the gate, exports every platform with a template, packs each with a README, `VERSION.txt`, a changelog, your licence and generated third-party notices, stamps the version into the macOS app, signs,
   verifies, and writes `SHA256SUMS` and `manifest.json`. Signing comes only from the environment — `MF_CODESIGN_IDENTITY`, `MF_NOTARY_PROFILE`, `MF_WINDOWS_SIGN_CMD`, `MF_GPG_KEY` — as CI secrets, never in the repository. Without an identity the macOS app is ad-hoc signed: it verifies, but it is not for distribution.
5. **On the web:** `python3 tools/deploy_cloudflare.py --project <name>` (on a sample: `make deploy-cloudflare GAME=… SITE=<name>`) exports the web build and puts it on Cloudflare — the page on Pages, the engine and the game data (each over Pages' 25 MiB limit) gzipped in R2 and served from the same site. Wrangler signs in from `CLOUDFLARE_API_TOKEN` in the environment; `--dry-run` prepares without uploading.
6. **On itch.io:** `python3 tools/itch.py --target <user>/<game>` (on a sample: `make itch-release GAME=… TARGET=<user>/<game>`) packages the game, builds the split web version (itch refuses a file over 200 MB, so the web build is the small main pack plus the late packs and their manifests, every file checked against the limit) and pushes the channels html5, windows, mac and linux with butler, `--userversion` = the game's version. butler must be on PATH (or `BUTLER=`) and logged in; `--dry-run` builds everything and prints the pushes; `--skip-package` / `--skip-web` reuse builds already made.
6. **Archive** the `manifest.json`, the checksums and the base packs of what you shipped: patches are built against them.
7. **Store submission** (Steam App ID and depots, age ratings, notarisation accounts) needs accounts only you hold; everything up to it is done.

## 8. After release

- **A player has a problem:** they use **Report a problem** (pause menu, or the link on the title). It writes one zip to their computer that they send you; they saw its contents first. It holds versions, system, display, the state of their saves (not what is in them), the log tail, their settings and a note. No names, no save contents.
- **A fix:** change the game, bump the version, then `python3 tools/patch.py --release-zip <the shipped build> --from <the release tag>` (on the demo: `make patch`). It builds a small zip of only what changed, refuses engine and script changes (a full release), and refuses removing a scene, item or variable that
  saves from the shipped version may use unless a **migration** covers it. Patches go in `patches/` beside the game (macOS: the player's `user://patches/`); the engine mounts them at start, refusing damaged or mismatched ones.
- **Saves:** they are written atomically and keep a backup; a damaged one is recovered or reported, never shown as empty; one from a newer version is refused with both versions named. Migrations (`project.json`) carry saves across versions.
- **Versions:** `MAJOR.MINOR.PATCH` in `game/project.json`. Patch releases are patches; content releases are new builds. `upgrade_engine` brings a game's engine copy up to date — deliberately, with a backup, then run `bash tools/check.sh`.

## 9. When something fails

| you see | it means | do |
|---|---|---|
| `validate` lists errors | a reference or file is broken | the message names the file and field; fix it, or `rename_id` if you renamed something |
| `softlocks` names a "point of no return" | a move after which the game cannot be won | the report gives the shortest way there; make the thing recoverable or unavailable |
| `softlocks` says an ending is reached by no play-through | its conditions can never hold when the game ends | check its `when`, or whether any `end_game` can reach it |
| `puzzles` says a puzzle is unsolvable | the settings cannot be won | the message says why (a Sokoban box in a corner, a circuit bulb that can never light) |
| `budget` is over | a room's pictures need too much video memory | `-s res://tools/budget.gd -- --text` lists the rooms, heaviest first; shrink pictures, split the room |
| `autoplay` stalls | the real UI cannot finish the game | it names the room, what it reached and what it held; usually a gate nothing opens |
| `lint` finds text off the screen | a layout that only works in English | wrap it (`autowrap_mode`), widen the container |
| the gate fails `builds` | a preset would ship the editor or dev tools | add the exclude patterns it names to the preset |
| the macOS export fails | the bundle id has characters Apple forbids, or ETC2/ASTC import is off | letters, digits, `-` and `.` only; the project setting is on in a current game (`upgrade_engine`) |
| a patch is refused at start | damaged, wrong game, or wrong version | the log line and the support bundle's manifest say which |

## 10. Checklists

Copy these into your tracker. Every item is a command or a gate.

**Alpha (vertical slice)**
- [ ] `bash tools/check.sh` is green
- [ ] `bash tools/release.sh alpha` passes
- [ ] `autoplay` wins and a walkthrough of the main route is recorded
- [ ] the starter game is gone; title, author, credits and a `1.0.0`-style version are set

**Content complete**
- [ ] the story check is clean and the exact soft-lock search is complete, with every ending reached
- [ ] every puzzle is proved winnable at every difficulty
- [ ] `make handoff` has gone to the artists; the shot list shows what is still placeholder
- [ ] every spoken line exists as text; the producer's report lists what is not yet recorded

**Beta**
- [ ] `bash tools/release.sh beta` passes
- [ ] gates `pictures`, `voice` and `translations` are within beta limits
- [ ] two playtest rounds in; `make playtest-report` triaged: no puzzle most testers gave up on, no room under 30 fps
- [ ] gate `bundle` and `legal` have no warning you do not understand

**Release candidate**
- [ ] `bash tools/release.sh gold` passes — every row above, by name: `identity`, `validation`, `pictures`, `voice`, `translations`, `review`, `builds`, `bundle`, `legal`, `playtests`
- [ ] your own bundle identifier and licence are in place; no review comment is open
- [ ] `python3 tools/package.py --dry-run` is clean for every platform you ship

**Release**
- [ ] `python3 tools/package.py` succeeded with real signing; the macOS app verifies and is notarised
- [ ] every artifact's SHA-256 matches `SHA256SUMS`; `manifest.json`, the checksums and the base packs are archived
- [ ] a fresh machine opens, plays and saves the build; "Report a problem" works there

**Live**
- [ ] support bundles are read, not guessed at
- [ ] every patch passes `python3 tools/patch.py` with `--from` the release tag, so saves are checked
- [ ] a save from the shipped version loads after each patch
