Docs / GAMECOMPOSER-SPEC

Game Composer Manifest & Lifecycle Specification (gamecomposer.yml)

Source: docs/GAMECOMPOSER-SPEC.md

Status: Normative contract for the implemented manifest schema and the config / up / ps / status / logs / stop / down lifecycle. Aligned with reviewed code; not proven playable.

This document specifies a contract and records what the reviewed code does. It makes no playability claim: no launch → input → display E2E pass record exists for any emulator/game pair (tests/e2e-strategy/STRATEGY.md; docs/PLAYER-UX.md §10; review finding R1). Facts not established by a reviewed artifact are marked UNKNOWN. A successful Kiri start plus an HTTP 200 for a loopback page is delivery evidence only; it does not prove rendered frames, audio, controller response, or acceptable latency.

Authority. The authoritative structural schema is specs/game-compose.schema.json (JSON Schema draft 2020-12). The Python loader enforces it (gamecomposer/core.py; the package copy gamecomposer/game-compose.schema.json is a symlink to the same file). Only apiVersion: gamecomposer.dev/v0.2 is accepted. specs/game-compose-v0.1.md is superseded and must not be implemented. Earlier material in this repository describing version: 1 with top-level environment / emulator / game / config / resources / controls is superseded by this document and by the v0.2 schema.


1. Scope, authority, and non-goals

1.1 In scope

  • The file format and field schema of gamecomposer.yml (and .json).
  • Where the emulator and game come from (project-relative path or HTTPS URL + SHA-256) and how sources are validated.
  • The services model, dependency ordering, and per-service sections.
  • The config, up, ps / status, logs, stop, and down contract, including its CLI, Python SDK, and TypeScript SDK surfaces.
  • The runtime boundary: Kiri is the only runtime engine in v0.2; Docker CLI is not invoked.

1.2 Out of scope (owned elsewhere)

Area Owner / document
Per-OS Kiri compatibility and proof commands docs/PLATFORM-MATRIX.md
Browser/gamepad player states, input actions, status events, errors docs/PLAYER-UX.md
Manifest → launch descriptor transform and sessionId minting Unowned — see §6 / R3
Electron desktop shell and browser player implementation desktop/, player owner
E2E harness, fixtures, and pass/fail records tests/e2e-strategy/
User-facing quickstart and troubleshooting README.md, docs/user-guide.md

1.3 Conformance language

MUST, MUST NOT, SHOULD, SHOULD NOT, and MAY follow RFC 2119.

1.4 Status labels used in this document

Label Meaning
SPECIFIED Normative rule declared by this document / the authoritative schema. Implementation may be partial.
EVIDENCED Backed by a reviewed artifact (cited). Code-level review, not execution or playability.
ACCEPTANCE TARGET Named by item 159 acceptance and fixed in the authoritative schema.
ILLUSTRATIVE Example value only; not normative and not evidence of support.
UNKNOWN Not established by any reviewed artifact. Must not be assumed or advertised as fact.

A rule marked SPECIFIED is a decision of this contract, not a claim that code implements it. §8 records what is actually evidenced. Nothing in this document was executed in the authoring session (the jsonschema dependency was not installed here), so all runtime behavior is labelled at code-review level only.


2. Runtime boundary: Kiri, no Docker CLI

  1. In v0.2 runtime.engine is the single value kiri. SPECIFIED / ACCEPTANCE TARGET; EVIDENCED (specs/game-compose.schema.json const, gamecomposer.yml). The runtime-neutral auto / docker / podman choices in the superseded v0.1 draft are not accepted by the v0.2 schema.
  2. Game Composer MUST NOT require the user to install, configure, or run Docker CLI: no Docker daemon requirement, no Compose file, and no user-managed Docker images are part of this contract. SPECIFIED. EVIDENCED for the "no Docker CLI invocation" claim (gamecomposer/runtime.py calls the kiri binary only); whether Kiri's engine is Docker-API-compatible is a fact about Kiri, not a dependency of Game Composer (docs/PLATFORM-MATRIX.md).
  3. Kiri internals are out of scope. The adapter invokes Kiri's CLI (kiri build, run, start, inspect, logs, stop, rm, image inspect). EVIDENCED (gamecomposer/runtime.py). Whether the implementation builds images, pulls images, or supplies sources only via mounts is decision-dependent: the reviewed adapter builds a local image from environment.build and mounts sources; image-pull behavior is UNKNOWN.
  4. environment.os (§4.2) expresses declared intent. The current Kiri adapter fails preflight for any value other than linux. EVIDENCED (_capability_check in gamecomposer/runtime.py). The only supported guest OS is Linux. Linux-host compatibility is NOT_CHECKED; macOS evidence describes the development host, and Windows and SteamOS hosts are out of scope (docs/PLATFORM-MATRIX.md).
  5. Kiri install commands, minimum version, and per-OS support are in docs/PLATFORM-MATRIX.md and are not restated or guaranteed here. Linux is the target host; macOS is the development host. Windows and SteamOS hosts are out of scope for now.

3. The manifest file

Property Rule Status
Filename gamecomposer.yml is the default (--file / -f overrides it). SPECIFIED / EVIDENCED (gamecomposer/cli.py)
JSON form A .json file is parsed with json.loads; other suffixes use YAML. EVIDENCED (gamecomposer/core.py load)
Root structure A YAML/JSON mapping with required apiVersion, name, runtime, services. EVIDENCED (schema required; core root check)
API version apiVersion: gamecomposer.dev/v0.2 is a schema const; other values fail schema validation. SPECIFIED / EVIDENCED (schema)
Duplicate YAML keys Rejected by the loader. EVIDENCED (custom SafeLoader mapping constructor)
Unknown fields Rejected by the schema (additionalProperties: false at root and in every object). EVIDENCED (schema) / SPECIFIED
Name name is 1–80 chars matching ^[a-zA-Z0-9][a-zA-Z0-9._ -]*$. SPECIFIED / EVIDENCED (schema)
Paths path / build / saves / writable must start with ./, resolve inside the project after resolution, and (for inputs) exist. EVIDENCED (_resolve_project_path)
Discovery Exact ancestor search / alternate names beyond --file are UNKNOWN. UNKNOWN

The Python loader is schema-enforcing: load() parses, validates against the draft-2020-12 schema, verifies the dependency graph, normalizes paths, and returns a document. EVIDENCED (gamecomposer/core.py). The TypeScript SDK is deliberately schema-agnostic (parseConfig returns a frozen Record<string, unknown> and enforces only YAML-level rules). EVIDENCED (sdk/src/config.ts). Field-level validation therefore exists in Python but not in the TypeScript SDK — see R7 in §7.


4. Schema reference (v0.2)

4.1 Top-level fields

Field Type Required Status Meaning
apiVersion const yes SPECIFIED / EVIDENCED gamecomposer.dev/v0.2.
name string yes SPECIFIED / EVIDENCED Project label; see §3 for format.
runtime mapping yes SPECIFIED / EVIDENCED engine: kiri only; no extra keys.
services mapping yes SPECIFIED / EVIDENCED 1–64 entries; keys match ^[a-z][a-z0-9_-]{0,62}$.

All other root keys are invalid. EVIDENCED (schema additionalProperties: false).

4.2 services and depends_on

Each service is an independent session with required console, environment, emulator, game, controls, resources, storage, network, outputs, lifecycle; depends_on is optional. SPECIFIED / EVIDENCED (schema required).

  • depends_on: array of service names, max 64, unique. References must resolve; self-dependency and cycles are rejected; selection includes transitive dependencies; start order is topological and stop order is reverse. EVIDENCED (gamecomposer/core.py order, gamecomposer/runtime.py _names / stop loop).
  • A dependency being "running" is observed via Kiri state; it does not imply application health or ongoing supervision. UNKNOWN beyond that observation.
  • Stopping a selection that would strand an active dependent is refused. EVIDENCED (_dependents_outside).

4.3 console

Field Type Required Status Meaning
platform string yes SPECIFIED / EVIDENCED Emulated target id (e.g. nes, snes), ^[a-zA-Z0-9._+-]+$.
model string no SPECIFIED / EVIDENCED Operator label for the target.

generation and systemAssets from the superseded v0.1 draft are not in the v0.2 schema. EVIDENCED (schema additionalProperties: false).

4.4 environment

Field Type Required Status Meaning
os enum linux / windows / macos / steamos yes SPECIFIED / EVIDENCED Declared guest OS; only linux launches today.
distribution string no SPECIFIED / EVIDENCED Descriptive label (e.g. alpine).
image string exactly one of image / build SPECIFIED / EVIDENCED OCI image reference.
build project path exactly one of image / build SPECIFIED / EVIDENCED Directory containing a Dockerfile.
command argv, min 1 item yes SPECIFIED / EVIDENCED Entry-point vector.
args argv yes SPECIFIED / EVIDENCED Extra argv appended before the emulator.
workingDir absolute path yes SPECIFIED / EVIDENCED Container working directory.
env mapping yes SPECIFIED / EVIDENCED Non-secret env vars; keys ^[A-Z_][A-Z0-9_]{0,127}$.
  • The adapter rejects a service with neither image nor build, and rejects non-linux os before launch. EVIDENCED (_capability_check).
  • Whether os, distribution, restart and image selection map to anything beyond the reviewed behavior is UNKNOWN.

4.5 Source object (emulator.source, game.source)

Exactly one shape is valid: {path} or {url, sha256, maxBytes?}. SPECIFIED / EVIDENCED (schema oneOf; _normalize_source).

Field Type Required Status Meaning
path project path iff local SPECIFIED / EVIDENCED Must start ./, exist, and stay inside the project.
url HTTPS URI iff remote SPECIFIED / EVIDENCED No embedded credentials.
sha256 64 hex chars iff remote SPECIFIED / EVIDENCED Required for URL sources; verified after download.
maxBytes integer no SPECIFIED / EVIDENCED 1…8589934592, default 2147483648; capped at the adapter limit.
  • URL sources are downloaded to a content-addressed .gamecomposer/cache directory and mounted read-only; a digest mismatch or oversize aborts launch. EVIDENCED (_source_path in gamecomposer/runtime.py).
  • Redirect policy, archive extraction, artifact formats, and fetch timing beyond launch are UNKNOWN. Mixing local emulator + URL game (or reverse) is schema-valid; it has not been executed. UNKNOWN.

4.6 emulator, game, controls, resources, storage, network, outputs, lifecycle

Section Required members Status Meaning / evidence
emulator source, executable, args SPECIFIED / EVIDENCED Argument vector, never a shell string. Executable + {game} / {emulator} placeholders are substituted.
game title, source; optional platform SPECIFIED / EVIDENCED Title and asset source.
controls gamepads (0–8), mapping (open object) SPECIFIED / EVIDENCED Intent only. Gamepads > 0 without a browser player fail preflight. EVIDENCED (_capability_check).
resources cpus (>0, ≤256), memory (e.g. 256MiB) SPECIFIED / EVIDENCED Passed to Kiri as --cpus / --memory; enforcement is UNKNOWN.
storage saves, writable SPECIFIED / EVIDENCED Project-relative; overlap rejected; mounted at /gamecomposer/saves and /gamecomposer/user. EVIDENCED (_ensure_dirs).
network mode: none or bridge SPECIFIED / EVIDENCED bridge required for browser-local outputs. EVIDENCED (_capability_check).
outputs video, audio: browser-local or none; optional port 1–65535 SPECIFIED / EVIDENCED browser-local publishes a loopback page; it is browser-executed emulation, not relayed video. web-stream is not in v0.2.
lifecycle restart: never / on-failure; stopGraceSeconds 0–3600 SPECIFIED / EVIDENCED stopGraceSeconds → --stop-timeout. Whether restart is honoured is UNKNOWN.

4.7 Canonical example (structural only)

apiVersion: gamecomposer.dev/v0.2
name: color-arcade
runtime:
  engine: kiri
services:
  nes:
    console: { platform: nes, model: NES-compatible }
    environment:
      os: linux
      build: ./image
      command: ["/usr/bin/env"]
      args: []
      workingDir: /gamecomposer
      env: {}
    emulator:
      source:
        url: https://unpkg.com/jsnes@2.1.0/dist/jsnes.min.js
        sha256: 84946f0dae4bcf3b2dfebe84ad3bfeb1dbcb413bd9b1a69e1f45910a95fd7b41
      executable: /usr/local/bin/python
      args: ["/opt/player/serve.py", "{game}"]
    game:
      title: 8-Bit Table Tennis
      platform: nes
      source:
        url: https://example.invalid/game.nes
        sha256: 05122457672f95fcf2ee518c3f37e506617725c2d031100b1b1c8b7785068ea3
    controls: { gamepads: 1, mapping: { a: south, b: east } }
    resources: { cpus: 1, memory: 256MiB }
    storage: { saves: ./data/saves, writable: ./data/user }
    network: { mode: bridge }
    outputs: { video: browser-local, audio: browser-local, port: 8080 }
    lifecycle: { restart: never, stopGraceSeconds: 3 }

Field names and shapes are normative; values are ILLUSTRATIVE (the example.invalid URL is deliberately not a real asset). Structural validity does not prove the image, assets, licenses, or host device I/O.

4.8 Validation rules

# Rule Status
V1 Root is a mapping; duplicate YAML keys rejected. EVIDENCED (gamecomposer/core.py)
V2 Required root keys and apiVersion const hold. EVIDENCED (schema)
V3 Every service has the required sections with schema-typed members. EVIDENCED (schema + jsonschema in core.load)
V4 environment.os, network.mode, outputs.*, lifecycle.restart enums hold. EVIDENCED (schema)
V5 Each source is exactly one of path / url+sha256; paths stay in project; URLs are HTTPS. EVIDENCED (schema + _normalize_source)
V6 depends_on references resolve and the graph is acyclic. EVIDENCED (order)
V7 Unknown keys are rejected by the schema; the TS parser preserves them. EVIDENCED (schema; sdk/src/config.ts)

V3–V7 are enforced in Python by gamecomposer/core.py using this schema. The jsonschema dependency is declared in pyproject.toml; it was not installed in the authoring session, so no validation run is recorded here. See R7 in §7.


5. Lifecycle contract: config, up, ps / status, logs, stop, down

5.1 Surfaces

Surface Operation mapping Status
CLI kitty [--file PATH] [--no-open] <action> [SERVICE ...], actions config, up, ps, status, logs, stop, down. Install channels are in INSTALL.md. EVIDENCED (gamecomposer/cli.py, pyproject.toml scripts)
Python SDK gamecomposer.sdk.load_manifest(path), run_project(path, action, services), RuntimeAdapter protocol (name, capabilities(), invoke()). EVIDENCED (gamecomposer/sdk.py)
TypeScript SDK GameComposerClient.up/down/status() → LifecycleTransport.invoke({operation, projectDirectory?, configPath?, signal?}); parseConfig for YAML parsing. EVIDENCED (sdk/src/lifecycle.ts, sdk/src/config.ts)
  • config prints normalized configuration as JSON and starts no process. EVIDENCED (gamecomposer/api.py execute).
  • Exit codes: 0 success; 1 operation/runtime failure (RuntimeError / OSError); 2 invalid input or validation failure (ValueError, including ManifestError). EVIDENCED (gamecomposer/cli.py).
  • --json flag and machine-readable up / ps / logs output are not implemented; UNKNOWN. The superseded interfaces draft proposed them.
  • The TS SDK result shapes are generic (Result = unknown) and no concrete transport is bundled: exact status payloads, errors, and cancellation behavior are UNKNOWN. EVIDENCED (SDK boundary) / UNKNOWN (results).

5.2 Operations

Operation Target behavior Status
config Parse, schema-validate, resolve paths, order services, print normalized JSON; no process start. EVIDENCED (code); not executed here
up Build/select the Kiri image, provision mounts and env, start each selected service in dependency order, print a per-service line with a loopback URL when browser output is requested. EVIDENCED (code); UNKNOWN at runtime
ps / status Report each selected service's Kiri state (absent, running, other Kiri status strings) and URL if running. EVIDENCED (code); exact enum UNKNOWN
logs Retrieve Kiri logs for selected services; a failed read is an error, not empty success. EVIDENCED (code)
stop Stop selected services in reverse order; preserve declared saves/user data; refuse a selection that strands an active dependent. EVIDENCED (code)
down Stop and remove owned Kiri containers; preserve declared saves/user data. EVIDENCED (code)

Notes:

  1. ps / status MUST NOT be interpreted as proof that a game launched, accepted input, or displayed frames. SPECIFIED. That requires the E2E gate in §8; no pass record exists (R1).
  2. Runtime identity is a project ID derived from the manifest path plus service name (gc-<id>-<service>); configuration changes are detected by a fingerprint label and require down before up. EVIDENCED (gamecomposer/runtime.py).
  3. Capability negotiation: RuntimeAdapter.capabilities() is declared in the Python SDK protocol, but the reviewed Kiri adapter does not consult it. No capabilities CLI/API endpoint exists. Capability reporting and negotiation are UNKNOWN / target-only.
  4. Session correlation: no sessionId is minted by CLI/SDK/runtime; the TS SDK request carries no session identifier. Player descriptor correlation is UNKNOWN (R3).
  5. Cancellation: the TS SDK forwards an optional AbortSignal; whether an adapter honours it and what partial state remains are UNKNOWN.
  6. Serialization across concurrent callers is UNKNOWN (no lock found in reviewed code).

5.3 Failure behavior

  • Failed schema validation, unknown service, cycle, missing path, or unsafe path → validation error (CLI exit 2). EVIDENCED (core.py ManifestError).
  • Unsupported guest OS, missing image/build, browser output without bridge, or gamepads without a browser player → preflight runtime error (CLI exit 1). EVIDENCED (runtime.py _capability_check).
  • Idempotency of repeated up, down with no session, artifact deletion on down, timeouts/retries, and detach/foreground behavior beyond the reviewed argparse flow are UNKNOWN.

6. Relationship to the player launch descriptor (R3 — ownership)

docs/PLAYER-UX.md §5.1 defines a launch descriptor consumed by the browser player. It is a distinct artifact from gamecomposer.yml; this spec does not rename manifest fields to match it.

Descriptor concept Present in gamecomposer.yml (v0.2)? Status / notes
sessionId No Not minted by reviewed code; where/how is UNKNOWN.
game.title game.title Name matches; value mapping is UNKNOWN.
game.id, game.version No UNKNOWN.
emulator.coreId, coreVersion No No core identity in the manifest; UNKNOWN.
emulator.platform Approx. console.platform Mapping is UNKNOWN.
bundle.url game.source.url or resolved local path Descriptor needs a URL; local-path handling is UNKNOWN.
bundle.checksum game.source.sha256 (URL sources) Digest exists in v0.2; whether it satisfies the descriptor field is UNKNOWN.
bundle.sizeBytes game.source.maxBytes is a cap, not a measured size UNKNOWN.
inputProfile Approx. controls.mapping Mapping is UNKNOWN.

R3 ownership (unresolved). The transform from a validated manifest (+ generated artifacts/URLs) into a player descriptor, and the minting of sessionId, are unowned in the reviewed worktrees. This specification/schema is not the owner; the authoritative descriptor schema is owned by the schema/player-UX owners (docs/PLAYER-UX.md §5.1), and the producer was to be supplied by a host/runtime owner that has no implementation here. Until an owner is named, the transform and sessionId minting are UNKNOWN and the player cannot be launched from a manifest by a described code path.

Separately, two state vocabularies are unreconciled: this document's minimum distinctions (no session / in-progress / running / failure, surfaced as Kiri state strings) versus docs/PLAYER-UX.md §5.2's eight-state machine. Which document is authoritative for the state enum, and who owns the mapping, are UNKNOWN (R3). No mapping is invented here.


7. Review of parallel artifacts and open findings

This section records the reconciliation performed for item 159; no non-owned artifact was edited.

  • Implemented manifest + runtime (gamecomposer.yml, examples/*, gamecomposer/*.py): the shipped manifests use apiVersion: gamecomposer.dev/v0.2 with services, matching the authoritative schema. core.py performs schema validation, path normalization, and dependency ordering; runtime.py implements the Kiri lifecycle. No E2E pass record accompanies them. Aligned here; no change made.
  • CLI / SDK: kitty actions and exit codes are implemented in Python; the TypeScript SDK is a transport-agnostic scaffold. Install channels are in INSTALL.md. The superseded specs/interfaces-v0.1.md described --json, host HTTP APIs, and diagnostic codes that do not exist — reconciled in that file.
  • specs/game-compose-v0.1.md: superseded v0.1 draft (gamecompose.dev/v0.1, auto/docker/podman, web-stream, license, systemAssets). Marked superseded there; the v0.2 schema is authoritative.
  • README.md / docs/user-guide.md: now describe the v0.2 manifest and the implemented CLI; they defer schema authority here. No conflict found.
  • docs/PLATFORM-MATRIX.md: supplies Kiri/OS evidence and the no-playability boundary; its "Docker-API-compatible" wording is a fact about Kiri, not a user-facing Docker dependency. Consistent with §2.
  • docs/PLAYER-UX.md: descriptor field names differ from manifest names by design; §6 flags unmapped concepts rather than inventing a bridge (R3).
  • tests/e2e-strategy/STRATEGY.md: defines launch/input/display gates; no pass record found (R1).

R7 — validator ownership / gap

Review finding R7 ("field-level validation has no identified implementation or owner") is partially closed: gamecomposer/core.py now implements field-level validation by calling jsonschema.Draft202012Validator against specs/game-compose.schema.json (V1–V7 in §4.8), with jsonschema declared in pyproject.toml. The owner is the Python CLI/runtime (gamecomposer/core.py), and validation runs in load(), before any process starts. It was not executed in this session (dependency absent here), so runtime behavior is UNKNOWN at execution level. R7 remains open for the TypeScript SDK, whose parseConfig is schema-agnostic: no field-level validator, no shared schema import, and no owner identified there. UNKNOWN who will implement TS-side validation. This is recorded, not resolved, by this document.

R3 — manifest-to-descriptor ownership

See §6. The manifest→descriptor transform, sessionId minting, and the status-enum reconciliation remain unowned / UNKNOWN; this document records the gap and refuses to invent a mapping.


8. Verification status and proof obligations

Claim Evidence Status
v0.2 schema matches shipped manifests specs/game-compose.schema.json, gamecomposer.yml, examples/* EVIDENCED (structural review)
Field-level validation code present gamecomposer/core.py (jsonschema call), pyproject.toml EVIDENCED (code); execution UNKNOWN
CLI actions, flags, exit codes gamecomposer/cli.py EVIDENCED (code); not executed here
Python + TypeScript SDK surfaces gamecomposer/sdk.py, sdk/src/*.ts EVIDENCED (code)
TS field-level validation none found UNKNOWN (R7 open)
Kiri lifecycle calls gamecomposer/runtime.py EVIDENCED (code); not executed here
Kiri runs on macOS host docs/PLATFORM-MATRIX.md local evidence EVIDENCED for Kiri, not playability
Kiri on Linux host docs/PLATFORM-MATRIX.md NOT_CHECKED; Linux is the target host
Manifest → launch descriptor / sessionId no producer found UNKNOWN (R3)
Emulator/game launch, input, display for any manifest no E2E pass record UNKNOWN — playability not claimed (R1)

What would resolve the UNKNOWNs: execute config with jsonschema installed and record V3–V7 results; a TS-side validator or explicit decision to keep TS schema-agnostic; a named owner and code for the manifest→descriptor transform and sessionId (R3); a single authoritative status enum; a real Linux-host kiri version / kiri ps run; and the seven E2E scenarios in docs/PLAYER-UX.md §10.1 with artifacts per tests/e2e-strategy/REPORT_TEMPLATE.md.


9. Open questions / cross-owner dependencies

# Question Owner
Q1 Machine-readable (--json) output and exact status/log payloads for CLI and TS SDK. CLI / SDK owner
Q2 Where TS field-level validation runs, or a decision to remain schema-agnostic (R7). SDK owner
Q3 Runtime capability reporting/advertising adapter: wire RuntimeAdapter.capabilities() or drop it. Runtime owner
Q4 resources enforcement by Kiri and lifecycle.restart behavior. Runtime owner
Q5 Whether controls.mapping uses PLAYER-UX logical action names (R3). Schema + player UX owners
Q6 Manifest → launch descriptor transform and sessionId minting; authoritative state enum (R3). Unowned — must be assigned
Q7 URL schemes, maxBytes semantics, archive formats, and fetch timing. Runtime owner
Q8 Idempotency and failure semantics of repeated up / down. CLI / runtime owner
Q9 Manifest discovery rules beyond --file. CLI / SDK owner
Q10 Per-OS environment extensions and real-host proof commands. Platform owner

Until Q1–Q10 and R3/R7 are resolved, implementations and docs must keep describing this contract as aligned with code but unverified, and must not claim playability.

Back to all docs