Public ranked game hosting -- 2026-10-13
=======================================

MS-02 retains accounts, registration, friends/invites, matchmaking, server health,
ratings/placements, moderation, website/downloads and the encrypted voice relay.
Only dedicated games and their scoped presence/result bridges run on Psychz.
No central database, owner identity, central CA private key, staff credential or
Cloudflare tunnel credential is copied to a game host.

Inventory
---------
zeal-01: 108.181.132.237, UDP 28960/28961, instances zeal01-1/zeal01-2.
zeal-02: 108.181.132.159, UDP 28960/28961, instances zeal02-1 (Ranked) and zeal02-2 (Unranked: registry kind unranked, instance.cfg comp_ranked_rated 0).
Each instance starts in Killhouse FFA warmup and uses the existing ranked
map/mode/rule pool. All base and DLC assets are installed. Eight admitted
players are required to start; duo placement, Intervention restrictions,
ratings and resume behavior use the same code as installer 1.29.

The two-instance starting allocation is conservative. Do not add a third
instance solely because idle/warmup CPU usage looks low; qualify full concurrent
matches, frame time and network loss first. Each game has a 3 GiB cgroup limit.

Host layout and access
----------------------
/opt/zeal-ranked: root-owned code and the matching native DLL.
/srv/zeal/assets: root-owned, shared, verified game/map files.
/srv/zeal/instances/ID/game: isolated game tree; assets/code are read-only.
/var/lib/zeal-instances/ID/wine: private Wine prefix for user zg-ID.
/etc/zeal/instances/ID: game environment and private bridge credentials.
Game user zg-ID and bridge user zb-ID share only the instance spool group zi-ID.
Only writable game state and the spool belong to these service users. Each
virtual display also requires its own private Xauthority cookie. A game user
cannot read its bridge credentials or another instance's private state.
Remote RCON is disabled. SSH access is separate from in-game staff permissions.

The provider forced initial root password changes. Replacement credentials are
stored privately on the owner's workstation, outside this repository and all
installer/download assets. SSH management uses a dedicated key. Root password
access was retained for the owner's staff; no password appears in this document.

Operations
----------
For an instance ID, its supervised services are:
  zeal-ranked-display@ID
  zeal-ranked-game@ID
  zeal-ranked-lobby-bridge@ID
  zeal-ranked-rating-bridge@ID

They are enabled at boot. The central container also has boot.autostart=true;
MS-02 lobby/rating services are enabled independently of the retired LAN game.
Games restart after failure, and MS-02 removes stale
instances from new matchmaking after five seconds without valid game presence.
One game crashing does not restart another game or any central service.
Use journalctl -u zeal-ranked-game@ID for the dedicated stdout log.

Drain an instance centrally before maintenance; wait for its players/match to
finish, then restart/update it. The registry CLI is documented in
CENTRAL-OPERATIONS.txt. Resume restores a client's seat in a still-running match;
it does not reconstruct a crashed server's in-memory match state.

Adding another instance
-----------------------
Enroll a unique ID and public UDP port on MS-02 and immediately set it to drain.
Transfer ONLY that instance's private enrollment JSON pair to its game host.
After installing the shared assets/runtime and dependencies, run as root:

  python3 /opt/zeal-ranked/deploy/create-ranked-instance.py ID \
    --port PORT --display DISPLAY_NUMBER --label "Server label"

Use a free port and display (101/102 are already assigned on each current host).
The script refuses existing instance directories and duplicate configured ports
or displays. It provisions service users, permissions, prefix paths, game
settings and systemd templates, without starting or publishing the instance.
Allow the chosen game UDP port in that host's firewall, start all four services,
and validate asset hashes, public getinfo, central heartbeats, account admission
and a native client connection before making the entry active. No client pool
file or installer rebuild is needed. Adding hosts does not require a new central
database or a separate rating pool. Additional game hosts need HTTPS egress to
ranked.zeal.family and results.zeal.family, not a tunnel into MS-02.

Public voice forwarding
-----------------------
Zeal-01 UDP 29901 is DNAT/SNAT forwarded through wg-zeal to the MS-02 relay.
The WireGuard interface permits one /32 peer address on each end. MS-02 initiates
the connection to 108.181.132.237:51820 and keeps its NAT mapping alive; no home
router port forward is needed. Only UDP 29901 can cross the tunnel. Forwarding
to any other MS-02/home address or service is blocked. SRTP remains authenticated
and encrypted across the public path, with an additional WireGuard layer over
the central link. The relay, on MS-02, remains the trusted SRTP terminator.

Root-only WireGuard material is in /etc/wireguard on each endpoint. Central
zeal-voice-guard.service must succeed before wg-quick@wg-zeal can start. Public
host rules are /etc/nftables.conf; the central guard is /etc/zeal/voice-guard.nft.
Rule reloads replace only Zeal-owned tables. Voice gateway failure/reboot affects
public voice for both hosts; automatic gateway redundancy is not configured.

Recovery
--------
Central online SQLite/config snapshots made before migration are under
/root/qa-state/psychz-20261013/before on MS-02. They are private operational
backups, not distribution files. Do not overwrite active ratings/accounts with
an old snapshot just to change the game pool. Registry mode changes are enough
to drain a failed public instance; the former LAN instance is retained offline
for deliberate diagnostics only and must not become a public fallback.

Deployment validation and remaining test limits: docs/qa/psychz-20261013/REPORT.txt.
