docs/ARCHITECTURE_MODES.md

Architecture modes: CampaignCoop and planned PublicRealm

Reviewed 2026-10-20 against main 2ed98fa. The online co-op plan owns product decisions, route gates and qualification. CampaignCoop is implemented; PublicRealm and PvP are future work. A runtime enum or schema type does not establish a playable realm service.

Current CampaignCoop

Up to three session roles (player, friend1, friend2) share the host's world. Each human controls the native local player at engine slot 0 on their own PC. Remote humans appear as friend-slot puppets. Session ownership is paired with connection/generation provenance; it does not mean that friend1 controls native slot 1 on its own machine.

LayerImplementation and responsibility
Inject DLLNative hooks, local input/character, puppets, world application, damage policy, SaveGuard and rendering
RuntimeAvatar interpolation, shared-memory bridge pumping, transport and bounded recovery
SessionHostAuthenticated session slots, owner avatar relay, host-only world traffic/caches and client claim routing
TransportENet with reliable control/world, unreliable avatars and reliable diagnostics; or opt-in authenticated Steam relay-only broker
AvatarBridge / WorldBridgeVersioned DLL/runtime mappings with owner and native delivery provenance
Progress mirrorHost-owned allowlisted shared story data, preserving personal data in memory
SeatState / native HUDSelected profile/readiness and authenticated owner HP/MP for display-only native friend gauges

The host's game runs authoritative enemy decisions. Player-launch defaults mirror their motion on clients and enable population removal, remote targeting, co-op difficulty, event hold, friendly fire and downed/revive. General native factory spawning and the legacy target-forward path remain parked. Direct DLL/developer launches may have different defaults; consult the launch defaults. Enabled behavior is broader than its live qualification: denylisted families, record binding, bosses, projectiles and story programs retain specific limits.

A client's native player hit produces an authenticated claim to the host; the host attempts the supported native damage once and broadcasts absolute HP and deaths. Incoming enemy attacks on the local player remain native on that player's machine. Puppet HP and HUD display do not authorize remote damage. See enemy parity, targeting and damage/revive.

Session and transport shape

ENet uses a standalone kh2coop_server, which can run on a PC or Mac. Steam keeps SessionHost in the gameplay host's runtime and uses each game's broker and Valve relays, with explicit account admission and no direct-IP fallback. Neither path moves the host's enemy/story simulation into a dedicated server. See ENet joining and Steam transport.

Host loss ends the session. A verified roster or successful reconnect is not proof of native room/enemy recovery. Prologue profile/readiness agreement gates construction and input release at checked sites; broader opening-scene identity and the uninterrupted two-PC route remain open. See party setup and prologue encounters.

Configuration and persistence

runtime_mode = campaign_coop
# Session role, independent of local native slot zero:
client_role = 0

Protocol 34, AvatarBridge 4, WorldBridge 13, CaptureChannel 1 are the current source versions. Match all source products; old receipts remain historical. Package validation has its own version contract; see packaging before assembling a ZIP.

Shared story state is mirrored in memory; personal stats/inventory remain personal. Automation must never save in-game. SaveGuard redirects writes as a backstop and grants no permission to persist co-op progress to original saves.

Planned PublicRealm and PvP

The direction is playable three-player co-op first, then PvP, then a hosted server mode (plan D14). The older realm design proposes public hubs, parties, adventure instances, persistent characters and arenas. These are design ideas, not current commands or supported services.

AspectCurrent co-opProposed realm
IdentityThree session slots plus connection provenanceServer-assigned actor/instance identities
LifetimePrivate play session, host-owned worldPersistent realm with separate adventure instances
JoiningPrivate ENet address or allowlisted SteamID invitationPublic hubs and party formation
PersistenceAllowlisted in-memory shared progressSeparate character, realm and instance stores
AuthorityHost KH2 enemies/story, owner local avatarsStronger server validation for competitive instances

A future save-to-seed import would select accessible content, not replay a live save as a server simulation. No public login, database, matchmaking or reward writeback service is delivered here. RealmSeed and related retained types are schema background.

Historical design references: scope expansion and realm protocol sketch. Current contracts live in common/include/kh2coop/Protocol.hpp and the feature docs above.