Docs / architecture

Kitty architecture

Source: docs/architecture.md

Install channels are in INSTALL.md.

Status: the CLI, manifest validator, and Kiri runtime adapter are implemented at commit 321e188. The TypeScript SDK, Electron desktop shell, and browser/web surfaces are scaffolds or proposed. Sections below label the implemented boundaries as Implemented and the rest as Proposed.

Product boundary

Game Composer should provide a versioned declarative manifest and a consistent lifecycle around a project of named services. Each service declares an emulated console, its OCI environment and emulator, game assets, controller mapping, resource limits, saves, network policy, and outputs. Dependencies govern startup and teardown within one host. The initial manifest contract is Game Compose v0.1.

The product has three different concerns that must remain separate:

  1. Library and project description: manifests and metadata say what a session needs; they do not provide games or firmware.
  2. Runtime and device access: a backend launches the emulator and connects permitted host resources.
  3. Streaming transport: a separate service encodes video/audio and carries controller input when the client is remote or browser-based.

OCI container support solves only part of item 2. It does not automatically solve graphics acceleration, audio routing, controller discovery, or interactive streaming.

Proposed components

Manifest and schema

The manifest is runtime-neutral. The CLI parses YAML or JSON, validates the declared API version, resolves project-relative paths, and negotiates requested features against a backend's advertised capabilities. Unknown fields fail closed in v0.1. The runtime must reject an unsupported request rather than silently dropping a device, network restriction, or output mode.

The JSON Schema is a structural check, not a security boundary. The implementation must also canonicalize paths and defend against traversal and symlink escapes; inspect resolved image references; validate arguments and resource bounds; and confirm backend support before launch.

CLI and local session service — Implemented CLI, proposed session service

The CLI in gamecomposer/cli.py owns the user-facing workflow: config, up, ps/status, logs, stop, and down, with --file/-f and --no-open flags. gamecomposer/api.py::execute is the shared entry point, and gamecomposer/core.py::load performs JSON-Schema validation, dependency ordering, and path normalization. The CLI is real and executable; this resolves review finding R5 (see REVIEW-NOTES.md). A separate local session service is proposed and not implemented: lifecycle state currently lives in Kiri container labels (gamecomposer.managed, .project, .service, .config), so simultaneous UI/CLI requests are not serialized by a host service.

Launching is an explicit operator action. Reading a manifest, opening a project, or loading the desktop/web UI must not pull an image, execute a command, or start a game implicitly. Every launch should show the image, resolved file mounts, network policy, device requests, resource limits, and output destinations before execution.

Runtime adapters

An adapter translates the Game Composer session model into a runtime-specific request and reports a capability set such as oci.run, resource.cpu, resource.memory, storage.project-relative, input.gamepad, output.video.local, output.audio.local, output.video.web-stream, and network.isolated.

Kiri is the implemented adapter (gamecomposer/runtime.py). It invokes the Kiri CLI through an argument vector and never invokes docker or manages a Docker daemon; Kiri-specific behavior is isolated in one module. Kiri is Docker-API-compatible and builds/runs container images through its own CLI, but that compatibility is not proof of gaming-device support. This shared wording resolves review finding R2 (see REVIEW-NOTES.md). The implemented capability check fails closed before launch for non-Linux guests, a missing image/build, browser outputs without bridge networking, and gamepads without a browser player.

Known Kiri evidence must be stated narrowly: Kiri documents beta USB passthrough, and its USB documentation says continuous isochronous streams used by audio/video devices do not currently pass through. This is a documented limitation of that USB passthrough path, not proof that all host audio output or every audio backend is impossible. The reviewed documentation does not establish accelerated GPU access, general gamepad support, or browser game-streaming support for this product. Those remain unverified capabilities, not claims that the hardware cannot do them. See the project landscape and Kiri USB documentation.

Emulator and game assets

The emulator image contains the emulator software and its dependencies. In the implemented v0.2 contract a source is either a project-relative ./path supplied by the operator or an HTTPS url with a required SHA-256; on explicit up the adapter downloads and verifies URL sources into .gamecomposer/cache/<sha256>/<filename> and mounts them read-only. config never downloads. All local paths are canonicalized and confined to the project root, and only the declared storage.saves / storage.writable directories are created and preserved on shutdown. This is stronger than the v0.1 "no URL fetch" rule while keeping asset fetch off the read/validation path.

Kitty does not bundle or link commercial ROMs, BIOS files or firmware; you can load any game file from your own computer, and the registry lists only games whose licence allows redistribution. Do not package, redistribute, or imply the right to distribute commercial ROMs, console keys, or proprietary firmware. The license field is descriptive provenance supplied by the operator, not a legal determination.

Controls and local outputs

controls.gamepads and controls.mapping express intent. A backend must map that intent to devices and input events only when it can actually access the requested device. It must not pretend that a manifest mapping has paired a Bluetooth controller or forwarded a USB controller. The first implementation should choose one supported host/controller path and document its measured behavior.

Local video and audio are separate output requirements. A manifest requesting web-stream requires an adapter and transport that explicitly support it. Lack of a capability should be reported before launch with the backend and missing capability named.

Desktop app — Proposed (scaffold at 321e188)

The Electron shell in desktop/ is a scaffold that shows an unverified contract and does not yet drive the Python runtime. It should become a user-facing shell over the same service and schema used by the CLI: create/open a project, edit or inspect its manifest, show validation and capability results, explicitly start/stop a session, view logs, and show detected controls. It must not implement a second independent lifecycle or schema.

Web app and streaming — Proposed

The web UI can manage projects and display session status, but a web page alone cannot execute a local emulator. A local agent/service must own host execution and expose a narrowly scoped, authenticated API to the browser UI. Do not expose the Docker/Kiri socket to the browser or public internet.

Interactive streaming is a distinct data plane from the management/control plane. The control plane can use ordinary authenticated HTTPS/WebSocket requests for configuration and status. A real game-stream data plane must be selected and tested for encoded video, audio, controller input, latency, reconnect behavior, and access control. Kiri Share is documented as a public HTTPS tunnel for a local port; its existence does not demonstrate low-latency game streaming, so it is not a substitute for this design. Kiri Share docs

Session lifecycle

The lifecycle as implemented (with proposed parts called out) is:

  1. Read — Implemented: load() resolves the manifest and identifies its root without executing it.
  2. Validate — Implemented: JSON-Schema validation, dependency/cycle checks, path canonicalization, and confinement to the project root happen before any runtime call.
  3. Negotiate — Implemented for Kiri: _capability_check compares the request against the adapter's fixed capabilities and fails closed. A general capability-query protocol is proposed.
  4. Preview — Partly implemented: config prints the normalized manifest as JSON. A separate human-readable plan with resolved mounts and devices is proposed.
  5. Start — Implemented: up launches in dependency order after an explicit command; each container carries labels and a config fingerprint as its session record.
  6. Observe — Implemented: ps/status and logs report observed state and output with actionable errors and no silent fallback.
  7. Stop — Implemented: stop refuses to strand active dependents and halts in reverse order; down removes managed containers and retains declared saves and user data.

Security and trust model

  • Treat manifests, game files, emulator images, and project paths as untrusted input.
  • Never construct a shell command by interpolating manifest values; pass an executable and argument vector.
  • Never mount the runtime socket, a home directory, secrets, or arbitrary host paths into an emulator by default.
  • Keep sessions unprivileged, isolated from the network by default, and bounded by CPU/memory/process limits.
  • Require explicit, adapter-enforced destination rules before enabling network access.
  • Do not offer public sharing without authentication, an explicit exposure step, and a clear view of who can connect.
  • Do not auto-download game assets or firmware on manifest read or config; URL assets are fetched only on an explicit up, over HTTPS, with digest and size checks.
  • Surface the effective runtime configuration so users can verify what was launched.

Compatibility and evidence

Compatibility should be recorded as a matrix by host OS/architecture, runtime and version, emulator image and digest, GPU path, audio path, controller model/transport, and output mode. Distinguish documentary support, unit-level adapter behavior, and a real end-to-end session on the target host. Only the last category proves the full path.

Real artifacts at 321e188 are the CLI (gamecomposer/cli.py), validator (gamecomposer/core.py), Kiri adapter (gamecomposer/runtime.py), the v0.2 schema, and the NES/SNES examples; config was executed against both examples. There is still no recorded E2E launch, so nothing here constitutes playability evidence. Review findings R2 and R5 are closed against these artifacts in REVIEW-NOTES.md.

The first architecture decision gate is a reproducible vertical slice on a declared host. If Kiri cannot provide a required capability, Game Composer should report that incompatibility and evaluate another adapter instead of weakening the manifest's promise.

For current host and guest support, see the platform matrix and PS3 guest adjudication. These documents replace the earlier platform and guest-OS swarm notes.

Back to all docs