Jump to content

Unity.Multiplayer/BIBLE

From MindAttic Docs

MindAttic.Unity.Multiplayer — Project Bible

Single source of truth for what MindAttic.Unity.Multiplayer IS, is NOT, and the rules that keep it coherent. README says how to use it; RFC 0001 holds the design and build order; this says how to think about the system.

Status legend: ✅ done (verified by a test/build) · 🟡 partial · ⬜ planned · living.

1. The one sentence

MindAttic.Unity.Multiplayer is a Unity 6 package that gives any MindAttic game server-authoritative multiplayer, written as attribute-decorated partial methods and fields, in either a listen-server or a dedicated-server topology, joined by IP:port or a join code.

2. The product promise

  • A game adds one local package and one NetBootstrap component, marks methods [ToServer] / [ToClients] / [ToOwner] / [ToClient] and fields [Synced], and is networked.
  • The same game code runs as host, dedicated server or client; the topology is configuration, not code.
  • A player who drops and reconnects gets the same seat back.
  • With MindAttic Components and Unity.Shared it is one kit, a one-stop shop: MindAttic ▸ Multiplayer ▸ New Game… turns an empty project into a working networked game with menus, votes, keyed objects, a bot, tests and a deploy config (kit).

3. What it is NOT

  • NOT a netcode engine. Netcode for GameObjects 2.x and Unity Transport 2.x do the transport and replication; this package is the API and policy on top.
  • NOT client-authoritative. There is no client-side prediction of shared state; see UM-LAW-1.
  • NOT reflection-based. RPC plumbing is generated at compile time by the package's source generator, never discovered at runtime.

4. Architecture canon

The full layout lives in RFC 0001 § Architecture and is not repeated here (UM-LAW-4). The assembly boundary that the laws below depend on:

MindAttic.Unity.Multiplayer.Core     Runtime/Core   noEngineReferences; no UnityEngine, no Unity.Netcode
        ▲
MindAttic.Unity.Multiplayer          Runtime        the NGO adapter: the only runtime assembly that imports Unity.Netcode
        ▲
MindAttic.Unity.Multiplayer.UI       Runtime/UI     optional drop-in front end (only with MindAttic Components); NetBootstrap/NetSession only, no Unity.Netcode
MindAttic.Unity.Multiplayer.Editor   Editor         editor tooling
MindAttic.Unity.Multiplayer.Testing  Testing        the test kit games reference from their PlayMode tests (Editor and test builds only)
MindAttic.Unity.Multiplayer.Tests    Tests/Runtime  PlayMode suites, on the test kit's NetSessionTest
MindAttic.Unity.Multiplayer.UI.Tests Tests/UI       PlayMode suites for the front end
MindAttic.Unity.Multiplayer.Editor.Tests  Tests/Editor  EditMode suites for the editor tooling
game code                            (consumer)     talks to NetSession / NetEntity / attributes only

5. The Laws

MindAttic.Unity.Multiplayer inherits the org-wide house rules in ../../MindAttic.HouseRules.md. Of note here: [HOUSE-LAW-1] (whole-number versioning: the package is 0.0.0 until the v1.0.0 tag in UM-T20), [HOUSE-LAW-8] (done is verified, not asserted), [HOUSE-LAW-13] (LF-only, enforced by the root .gitattributes).

Project-specific laws:

UM-LAW-1 — The server owns state

Every piece of shared game state is written only on the server. Clients send intent ([ToServer] calls); the server validates it, applies it and replicates the result ([Synced] fields, [ToClients] / [ToOwner] / [ToClient] calls). A client never asserts an authoritative value, and the generator and analyzers reject client writes to [Synced] state.

UM-LAW-2 — Nothing above the NGO adapter imports Unity.Netcode

Unity.Netcode (and Unity.Networking.Transport) are referenced only by the adapter assembly MindAttic.Unity.Multiplayer and its Editor, Tests and Testing (test kit) companions. MindAttic.Unity.Multiplayer.Core is engine-free (noEngineReferences), and game code sees only MindAttic types (NetSession, NetEntity, NetSender, the attributes). Generated code is the one sanctioned exception: it is emitted into the game's assembly by the generator and is not hand-written there. Swapping the backend means rewriting the adapter, nothing else.

UM-LAW-3 — Generator output is C# 9

The source generator emits only C# 9 constructs (extended partial methods, no file-scoped namespaces, no record structs, no required, no raw string literals), so its output compiles on every Unity 6 compiler. It targets netstandard2.0 against Microsoft.CodeAnalysis.CSharp 4.3.x.

UM-LAW-4 — One home per fact

Every fact lives in exactly one place and everything else links to it. Dependency versions live in package.json; the design and ticket order live in RFC 0001; laws live here; story status lives in USER_STORIES.md. A second copy is a bug.

6. Verified state

  • ✅ Package skeleton (UM-T3): package.json, the four asmdefs, LICENSE, .gitattributes.
  • ✅ Generator approach proven (UM-T4, RFC 0002): a netstandard2.0 / Roslyn 4.3.1 IIncrementalGenerator emits [Rpc(SendTo.Server)] stubs and NetworkVariables from C# 9 partial methods and fields; NGO ILPP processes them; host+client and an IL2CPP Linux Dedicated Server run them. Decision: GO, no fallback.
  • ✅ Core session contracts (UM-T5): NetConfig (topology, address, port, transport, tick rate 30, max players, game version, Validate), SessionStateMachine (Host/Server Idle → Starting → Running → Stopping → Idle; Client Idle → Connecting → Connected → Disconnected with a DisconnectReason), and the ITickClock contract with ManualTickClock. Verified by dotnet test tests/Core.Tests (NetConfigTests, SessionStateMachineTests, ManualTickClockTests); tests/Core.Build compiles the same sources as netstandard2.1 / C# 9.
  • ✅ Join codes (UM-T6): JoinCode / JoinCodeFormat (9 characters shown as ABC-EFG-HJK: 8 data characters = 40 bits from a 32-symbol alphabet without 0, O, 1 or I, plus a Damm check character over GF(32) that catches every single substitution and every neighbour swap; parse ignores case and separators and corrects one look-alike the check confirms), JoinTarget (endpoint or relay allocation) and the IJoinCodeService contract (PublishAsync → code, ResolveAsync → target or null, idempotent RevokeAsync) with InMemoryJoinCodeService. Verified by dotnet test tests/Core.Tests (JoinCodeTests, JoinTargetTests, InMemoryJoinCodeServiceTests). Default length and 3-3-3 grouping set by UM-T32.
  • ✅ Connection approval payload (UM-T7): ConnectionPayload {game version, protocol hash, player token, display name, PlayerColor} with ConnectionPayloadCodec (versioned binary format 1: magic MA, version byte, game version first in every format so an unreadable newer payload still reports a version mismatch; strict, never-throwing decode), ConnectionApprovalValidator producing an ApprovalDecision with a typed ApprovalRejection (BadPayload → VersionMismatch → ProtocolMismatch → Banned → Full) and a wire reason string the client parses back, IBanList / InMemoryBanList, and the protocol-hash contract the generator fills: ProtocolHash.Compute (64-bit FNV-1a over the domain line plus sorted, de-duplicated signatures) emitted as [assembly: NetProtocol(hash, count)] and read by ProtocolHash.FromAssemblies. Verified by dotnet test tests/Core.Tests (ProtocolHashTests, ConnectionPayloadCodecTests, ConnectionPayloadTests, ConnectionApprovalValidatorTests).
  • ✅ NGO adapter (UM-T8): NetSession (StartHost / StartServer / JoinByAddress(ip, port) / Start(NetConfig) / Leave, events StateChanged / Started / Ended(Disconnection) / ClientConnected / ClientDisconnected) drives a NetworkManager and its Unity Transport (UDP or WebSocket from NetConfig.Transport) and keeps SessionStateMachine in step with NGO's callbacks, mapping client disconnects to a DisconnectReason (server shutdown, kicked/rejected with the server's text, connect failed, timed out, transport failure); NetworkTickClock implements ITickClock off NGO's NetworkTickSystem (one clock per live session, stopped when it ends); the headless bootstrap (HeadlessBootstrap: batch mode / -nographics / Dedicated Server build detection, vsync off and targetFrameRate = tick rate) with the engine-free NetCommandLine (-mode -address/-ip -port -transport -tickrate -maxplayers) and NetLaunch (an explicit -mode wins, else headless serves as a dedicated server, else autoStart); and the NetBootstrap component that owns the session. Verified by tests/run-playmode.ps1 (PlayMode, NetcodeIntegrationTest over real Unity Transport on loopback, UDP and WebSocket: HostAndClientTests, ServerAndClientsTests with 2 clients, NetworkTickClockTests, NetBootstrapTests) and dotnet test tests/Core.Tests (NetCommandLineTests, NetLaunchTests).
  • ✅ Connection approval and seats (UM-T9): Core PlayerIdentity (stable player token, name, colour → ConnectionPayload), SeatRegistry (token → seat; a dropped player's seat is held for NetConfig.ReconnectGraceSeconds, default 60 s, and held seats count as taken; the same token reconnecting reclaims it, or takes it over from a stale connection the server has not seen die; expiry, kick-free, lowest-free-index seating) and ConnectionAdmission (the validator counting seats, a returning player's own seat excluded, then seating in the same step); Disconnection.Rejection carries the typed approval reason and DisconnectReason.ClientLeft names a server-side clean leave. The adapter turns approval on at both ends: clients and a host's own player send Identity + game version + ProtocolHash; NetSession's NGO approval callback admits or refuses with the wire reason, and the client's LastDisconnect shows the sentence with its Rejection. Each seat keeps its player object (DontDestroyWithOwner); a reclaimed seat hands the same instance back (respawned as the new connection's player object) instead of spawning another, and an expired or kicked seat despawns it. Events: SeatTaken / SeatReclaimed / SeatHeld / SeatReleased, PlayerDisconnected (ClientLeft, TimedOut or Kicked, with the seat's fate), ConnectionRejected; Kick(clientId, reason). NetBootstrap remembers the token in PlayerPrefs per install folder (-playertoken overrides). Verified by tests/run-playmode.ps1 (ApprovalAndSeatTests: version, protocol and full rejections with reasons; drop and reconnect → same seat and player object; a killed client's restarted game taking its seat over; grace expiry; kick) and dotnet test tests/Core.Tests (SeatRegistryTests, ConnectionAdmissionTests, PlayerIdentityTests).
  • ✅ Entities, RPCs, scene flow and prefabs (UM-T10): Core gets the attributes ([ToServer] with Delivery, RateLimit, Burst, RequireOwnership = true; [ToClients], [ToOwner], [ToClient] whose first parameter is the target client id; [Synced] with OnChanged), NetSender (client id, seat index, display name; converts to its client id so a handler can answer its caller), TokenBucket / RpcRateLimiter (one bucket per sender and RPC, burst defaults to one second's worth, forgotten when the sender leaves) and RpcGate (ToServer: server only, then owner unless RequireOwnership = false, the server itself always passing, then rate; server-to-client calls must come from the server). The adapter adds NetEntity (non-generic NetworkBehaviour base: OnSpawned/OnDespawned, Owner, Session, and the Net* surface generated code calls; a client writing synced state throws), NetSession.RpcRejected / GetSender / Scenes / Prefabs, NetSceneFlow (server-only Load(scene, Single|Additive) / Unload, one change at a time, SceneRequestResult instead of NGO statuses, events LoadStarted, ClientLoaded, Loaded, Unloaded, ClientSynchronized for late joiners) and NetPrefabRegistry / NetPrefabList (checked registration before start; NetBootstrap registers its lists). The RPC and synced-field plumbing is hand-written in the generator's exact shape in Tests/Runtime/Entities/TestAvatar.g.cs (its header documents the shape: Move → MoveServerRpc → OnMove, …ClientsRpc, …OwnerRpc, …ClientRpc), which UM-T11 replaces. Verified by tests/run-playmode.ps1 (EntityRpcTests: every direction, ownership refusal, per-sender rate limit, server-to-client calls refused from a client, answering the caller, synced replication, OnChanged on every peer, client writes refused, late joiner, prefab registry; SceneFlowTests: additive load and unload followed by every client, late-joiner sync, client and unknown-scene refusals, scene management off, using tests/PlayModeHost's NetFlowArena scene) and dotnet test tests/Core.Tests (TokenBucketTests, RpcRateLimiterTests, RpcGateTests, NetSenderTests, RpcAttributeTests).
  • ✅ Source generator and analyzers (UM-T11): src/Generators (netstandard2.0, Microsoft.CodeAnalysis.CSharp 4.3.1, deterministic Release build copied to Runtime/Generators/MindAttic.Unity.Multiplayer.Generators.dll, labelled RoslynAnalyzer with every platform unticked, so Unity applies it to the adapter assembly and every assembly that references it, verified for the PlayMode test assembly). NetEntityGenerator writes, for each NetEntity subclass, the body of every [ToServer] / [ToClients] / [ToOwner] / [ToClient] C# 9 extended partial method and its NGO stub (MoveServerRpc, …ClientsRpc, …OwnerRpc, …ClientRpc with Delivery, server-only invoke for server-to-client calls, and the RequireOwnership / RateLimit / Burst passed to the gate), then calls On<Name>(args) or On<Name>(args, NetSender); each [Synced] field becomes a server-write NetworkVariable (a constant initializer becomes its first value) plus a property, with OnChanged wired through NetBindSynced / NetUnbindSynced; and one [assembly: NetProtocol(hash, count)] per assembly over every RPC signature (direction, type, name, wire parameter types, delivery) and synced signature (type, declaration index, name, type), listed in the generated file. Diagnostics MAMP001–MAMP013 (catalogued in src/Generators/Diagnostics.cs): not partial, missing handler, unsendable parameter, unreplicable synced type, generic NetEntity, direct write (error) or read (warning) of a [Synced] field, attribute outside a NetEntity, bad RPC shape, [ToClient] without a ulong target, bad OnChanged, bad synced field, non-constant initializer; a suppressor hides CS0169/CS0414/CS0649 on [Synced] fields. UM-T10's hand-written TestAvatar.g.cs is deleted and the generator writes it. Verified by dotnet test tests/Generators.Tests (snapshots of the package's own TestAvatar and of every member shape, each compiled clean as C# 9; one test per diagnostic; the hash checked against Core's ProtocolHash.Compute) and tests/run-playmode.ps1 (the whole PlayMode suite, EntityRpcTests unchanged, green against the generated code).
  • ✅ Rendezvous service (UM-T12): server/Rendezvous (ASP.NET Core .NET 10 minimal API, MindAttic.Unity.Multiplayer.Rendezvous) maps a join code to a dedicated server's IP:port. Routes, header and JSON field names live in Core's RendezvousProtocol so UM-T13's client shares them: POST /v1/register {secret, address?, port, transport?} → 201 {code, token, ttlSeconds, expiresAt} (an omitted address means the caller's own; JoinTarget.ForEndpoint rejects wildcards, whitespace and port 0), POST /v1/heartbeat {code, token} renews for another TTL, GET /v1/resolve/{code} → {code, address, port, transport} (player-typed forms accepted through JoinCode.TryParse; 400 with the parse reason, 404 for unknown or expired), DELETE /v1/register/{code} with X-Rendezvous-Token, and GET /healthz (Degraded when full, never rate limited). Codes are Core JoinCode.Generate from a cryptographic RNG (CodeDataLength, default 8 = 40 bits); each registration gets a private 256-bit token compared in fixed time, and a wrong token looks exactly like an unknown code. The store is in memory with a TTL (default 60 s): an expired code is gone on read and swept by ExpirySweeper; MaxRegistrations caps it (503). The registration secret is required at startup unless AllowOpenRegistration (Development only); per-IP fixed-window limits per route group (register, heartbeat/delete, resolve), IPv6 limited per /64, 429 with Retry-After. TLS-ready: Kestrel certificate configuration, RequireHttps (HSTS + redirect) or UseForwardedHeaders with KnownProxies behind a TLS proxy. The Dockerfile (built from the repo root, non-root $APP_UID, port 8080) has a HEALTHCHECK that runs the service's own --healthcheck probe, since the aspnet image has no curl. Verified by dotnet test tests/Rendezvous.Tests (WebApplicationFactory with a hand-driven clock and fake caller IPs: round trips, TTL expiry and heartbeat renewal, tokens, secret and startup refusal, bad endpoints, full store, rate limits per IP and per /64, health) and dotnet test tests/Core.Tests (RendezvousProtocolTests).
  • ✅ Join codes at runtime (UM-T13): Core gets the rendezvous client and service, engine-free so dotnet test covers them: RendezvousClient (register / heartbeat / resolve / unregister over IRendezvousHttp, default HttpClientRendezvousHttp; RendezvousJson reads and writes the flat bodies, since Unity has no System.Text.Json; refusals and unreachable services become RendezvousException with the service's own message and IsTransient for 0/429/5xx), RendezvousJoinCodeService (IJoinCodeService: RegisterAsync(ServerAdvertisement) keeps each registration alive with heartbeats every third of its TTL on the thread pool, retries transient failures, raises RegistrationLost when the service forgets it, and deletes what is left on Dispose), ServerAdvertisement (what a server registers: PublicAddress/PublicPort when set, else on RunPod with WebSocket the RUNPOD_TCP_PORT_{port} mapping at RUNPOD_PUBLIC_IP, else the listen port at the address the service sees; warns for UDP on RunPod), RelayCodes (Unity Relay's 6-12 character codes are written in 6789BCDFGHJKLMNPQRTW, all inside the join-code alphabet, so a Relay code plus the check character is the join code), JoinCodeProvider / JoinCodeDefaults (Auto = Relay for a listen server, rendezvous for a dedicated server), NetConfig.JoinCodes / RendezvousUrl / RendezvousSecret / PublicAddress / PublicPort with -joincodes -rendezvous -rendezvoussecret -publicaddress -publicport and NetEnvironment (MINDATTIC_RENDEZVOUS_URL, MINDATTIC_RENDEZVOUS_SECRET, MINDATTIC_PUBLIC_ADDRESS, applied before the command line). The adapter adds RelayJoinCodeService (Unity Relay through com.unity.services.multiplayer behind MINDATTIC_UGS: initializes Unity Services and signs in anonymously, allocates for the host, joins the allocation for a client, DTLS or wss; without the package it reports what to install) and on NetSession: HostWithCode (Relay by default; Rendezvous publishes a reachable host's address), PublishCode for a running Host or Server, a dedicated server with a rendezvous URL registering itself once Running (and again, with a new code, if the service loses it), JoinByCode(typed code) (rendezvous first when a URL is set, then Relay when installed and the code is Relay-shaped; the transport comes from the registration), PublishedCode / PublishedCodeText, JoinCodePublished, JoinCodeFailed (a message to show), a JoinCodes override, and the code withdrawn when the session ends; NetBootstrap gets the Inspector fields plus HostWithCode / JoinByCode. Verified by tests/run-playmode.ps1 (JoinByCodeTests, UDP and WebSocket, against InProcessRendezvousServer, a loopback HTTP implementation of the protocol: self-registration and heartbeats past a 1 s TTL, joining with the code typed lower case with spaces, withdrawal on leave, re-registration after the service forgets it, the RunPod mapped port and IP, a wrong secret, a listen server by rendezvous, the Relay default, bad, unknown and unresolvable codes), dotnet test tests/Core.Tests (RendezvousClientTests, RendezvousJoinCodeServiceTests, RendezvousJsonTests, RelayCodesTests, JoinCodeDefaultsTests, ServerAdvertisementTests, JoinCodeConfigTests) and dotnet test tests/Rendezvous.Tests (CoreClientInteropTests: the Core client against the real service). The MINDATTIC_UGS path compiles and the PlayMode suite passes with com.unity.services.multiplayer 2.4.1 installed; a live Relay allocation needs a linked Cloud project and is not exercised by the suite.
  • ✅ Network conditions (UM-T14): Core NetConditions (latency, jitter, packet loss for this peer's link; For(profile), Validate, TryParseProfile) and NetConditionsProfile (None default, Broadband 20 ms ±5, Mobile4G 60 ms ±15 / 1%, Mobile3G 200 ms ±50 / 3%, Lossy 150 ms ±10 / 5%, Custom), selected by NetConfig.Conditions with SimulatedLatencyMs / SimulatedJitterMs / SimulatedPacketLossPercent for Custom (EffectiveConditions, UseCustomConditions), -netsim and -latency -jitter -loss on the command line (a number after a profile keeps the profile's other numbers), and the NetBootstrap Inspector. The adapter's TransportConditions retunes the simulator pipeline stage NGO's UnityTransport puts under every pipeline (ModifySimulatorStageParameters, ApplyMode.AllPackets: each packet sent and received is delayed and may be dropped, below the reliable stage so reliable traffic is resent) right after NGO starts, before any pipelined packet; NetSession.Conditions reports what applies and SetConditions changes a live session. The stage exists only where NGO builds it (editor, development builds, UNITY_MP_TOOLS_NETSIM_* overrides); elsewhere conditions are ignored with a warning, and no simulation leaves the stage alone so Multiplayer Tools' Network Simulator can drive it instead. Verified by tests/run-playmode.ps1 (LossyNetworkTests: a Host and two clients on Lossy; connect with the simulator parameters read back from the driver and the measured round trip over 250 ms, 40 reliable [ToServer] calls per client and 30 each of [ToClients] / [ToOwner] / [ToClient] arriving once and in order, a round trip, [Synced] settling on the last of 30 writes with OnChanged, a late joiner, reconnecting to a held seat and taking over a stale connection's seat, and SetConditions slowing and restoring a live connection) and dotnet test tests/Core.Tests (NetConditionsTests). Removal reasons arrive first (UM-T34): Kick and the stale-connection takeover send the reason as their own reliable named message (MindAttic.Multiplayer.DisconnectNotice) instead of NGO's DisconnectClient(reason), which closes the connection at once and could lose the reason on a lossy link; the client ends Kicked with that reason and closes its own connection, and the server closes it after a 5 s grace if it has not (LossyNetworkTests asserts the reason for a takeover and a kick over the Lossy link). A shutdown is announced the same way (UM-T65): a stopping Host or Server sends every remote client MindAttic.Multiplayer.ShutdownNotice, the client ends ServerShutdown and closes its own connection, and NGO shuts down once they have gone (2 s grace), because closing a WebSocket connection with the client's sends still unread resets it and lost NGO's own shutdown reason (the client saw TransportFailure); ShutdownUnderLoadTests streams client messages through a Server's and a Host's shutdown over WebSocket and UDP.
  • ✅ Editor tooling (UM-T15): MindAttic ▸ Multiplayer ▸ Set Up Scene (NetSceneSetup.Run(scene, options)) networks the open scene in one click and one undo step. It finds the scene's NetworkManager or creates a NetworkManager GameObject, adds Unity Transport wired as NetworkConfig.NetworkTransport and a NetBootstrap, and assigns a NetPrefabList: the one already assigned, else the project's first, else a new Assets/NetPrefabs.asset holding the project's NetworkObject prefabs that no list registers yet. A second run changes nothing. Validate Prefabs (NetPrefabValidator) checks every network prefab under Assets, meaning any prefab with a NetworkObject or NetworkBehaviour or named by a list. Errors: MissingNetworkObject (none on the root, naming the child that has one), NotRegistered (no NetPrefabList or NGO NetworkPrefabsList asset holds it), GenericNetEntity (a NetEntity that is generic or derives from a generic class; the runtime check could never see this, since an attached component is never an open generic). Warning: EmptyListEntry. Build Dedicated Server (Linux) (DedicatedServerBuild.Build) validates first and refuses on errors. It then builds the enabled scenes as a Linux x86_64 Dedicated Server (StandaloneBuildSubtarget.Server; an optional Mono/IL2CPP override is restored afterwards) into Builds/LinuxServer/, and writes ServerDockerfile's Dockerfile (ubuntu:24.04, non-root server user, EXPOSE port/udp or /tcp for WebSocket, exec-form ENTRYPOINT ["./Game.x86_64", "-batchmode", "-nographics", "-logFile", "-", "-mode", "server", "-port", …, "-transport", …] so docker run arguments are appended) and a .dockerignore for Unity's DoNotShip folders. The port and transport come from the open scene's NetBootstrap. BuildFromCommandLine is the CI entry point (-serverOutput -port -transport -serverBackend -serverDevelopment). Verified by tests/run-editmode.ps1 (EditMode MindAttic.Unity.Multiplayer.Editor.Tests: NetSceneSetupTests, NetPrefabValidatorTests, DedicatedServerBuildTests, including a real Mono Linux server build of a wizard-networked scene with its Dockerfile).
  • ✅ Minimal sample (UM-T16): Samples~/Minimal, listed under samples in package.json so Package Manager's Samples tab imports it into Assets/Samples/MindAttic Multiplayer/<version>/Minimal. MinimalPlayer (the NetworkManager's player prefab) is the whole networked surface: one [ToServer(RateLimit = 20)] SetDirection sent by the owner when its keys change (the server clamps it to length 1), one [Synced] Vector2 _position the server moves inside an 8×8 arena, and one [ToClients] Bumped the server sends when a square first hits a wall; drawn with IMGUI so it needs no render pipeline, sprites or UI package. MinimalMenu drives NetBootstrap: Host, Join by IP, Host with code, Join by code, Leave, with Ended / JoinCodeFailed shown; MinimalInput reads the Input System or the Input Manager. The scene's NetworkManager was made by the Set Up Scene wizard (scene management off: one scene). The sample's README.md is the 10-minute getting-started walkthrough of every line, which UM-T19's guide builds on. tests/run-sample.ps1 builds a throwaway host project (tests/SampleHost, git-ignored), imports the sample through UnityEditor.PackageManager.UI.Sample, and runs tests/MinimalSample/Tests against the imported copy; -Author regenerates the scene, prefab and prefab list (MinimalSampleHost.Author, prefab validator clean). Verified by tests/run-sample.ps1 (MinimalSceneTests: the imported scene is wired as documented, hosts from its NetBootstrap, the host's player spawns at its seat's spot, moves to the wall and bumps; MinimalPlayerNetworkTests: host and client over loopback, the owner's SetDirection clamped on the server, the synced position on both peers, Bumped on both, a non-owner refused).
  • ✅ CI (UM-T17): .github/workflows/ci.yml runs dotnet test on Core.Tests, Generators.Tests and Rendezvous.Tests, and the PlayMode/EditMode suites through GameCI's unity-test-runner against tests/PlayModeHost (-runTests -batchmode, filtered per mode to Unity.Multiplayer.Tests / .Editor.Tests; EditMode's [Category("Build")] Linux server build is skipped in CI, since GameCI's editor image has no Linux Dedicated Server build-support module, and stays covered by run-editmode.ps1 locally). Both need a UNITY_LICENSE repository secret. .github/workflows/nightly-smoke.yml builds a StandaloneLinux64 Player of the Minimal sample (tests/MinimalSample/Editor/SmokeHostBuild.cs, run locally by tests/run-smoke.ps1) and runs it under Docker Compose (smoke/docker-compose.yml) as the rendezvous service, a dedicated server and two headless bot clients: one build plays every role, picked at run time by MINDATTIC_ROLE (tests/MinimalSample/Runtime/SmokeDriver.cs). The server self-registers and publishes a join code to a shared volume; each bot reads it, joins through the rendezvous service and drives its square into the arena wall, proving the join-code flow and the [ToServer]/[Synced] round trip end to end (smoke/wait-for-smoke.sh watches for both bots' OK: log lines).
  • ✅ Drop-in front end (UM-T48): the optional Unity.Multiplayer.UI assembly (Runtime/UI), compiled only when com.mindattic.components.unity is installed (versionDefines → MINDATTIC_COMPONENTS, required by its define constraint) and using com.mindattic.unity.shared profiles when present (MINDATTIC_SHARED); package.json cannot list file: packages, so a game adds both manifest lines itself. NetFrontEnd (one component beside the NetBootstrap; MindAttic ▸ Multiplayer ▸ Add Front End, NetFrontEndSetup.Run, networks the scene first and adds it, or changes nothing and names the exact manifest lines missing) builds, entirely from MindAttic Components: a main menu (Host, Join by IP, Join by code, Settings with name and colour, the game's items, Quit), a host lobby (the grouped join code in a MaCodeDisplay with Copy, or the LAN address when no code could be published; a live roster from the seats with colour swatches, a Host tag, held seats as "reconnecting...", remove with confirm; Leave/Start), a cancellable busy dialog while hosting or joining, a dialog per disconnect reason, an automatic reconnect for a lost connection (same address or code again, same player token, so the same seat; progress and Cancel; refusals and kicks are final) and an in-game Esc menu (Resume, Invite players, Settings, the game's items, Leave/End game). The name and colour come from IPlayerIdentitySource (ProfileIdentitySource over Profiles.Current.Settings.Common, else PlayerPrefsIdentitySource), cleaned to what the server accepts, and go in the approval payload through NetSession.Identity. Hooks: SessionStarted, GameStarted, Left(Disconnection), Reconnected, StateChanged, AddScreen, AddMainMenuItems, AddPauseMenuItems, AddSettingsItems, MenusVisible, and a method per button (HostAsync, JoinByAddressAsync, JoinByCodeAsync, StartGame, Leave); optional NetFrontEndSettings asset (title, buttons, lobby, a game scene the server loads on Start, kick message, pause menu, reconnect timing, theme). Core gains the engine-free rules it follows: DisconnectText (title, sentence and server detail for every DisconnectReason and ApprovalRejection, the one home of that wording), ReconnectPolicy (only TimedOut/TransportFailure after being connected; doubling capped delays), HostAddress (host, host:port, [v6]:port as typed) and NetLaunch.ShowsMenus (never headless, never on a -mode launch: servers and bots create no UI). Samples~/FrontEnd: the Minimal arena with the front end, each square in its player's name and colour ([Synced] from the seat), the hooks in FrontEndGame.cs, authored by run-sample.ps1 -Sample FrontEnd -Author through the Add Front End step. Verified by dotnet test tests/Core.Tests (FrontEndRulesTests), tests/run-playmode.ps1 (Unity.Multiplayer.UI.Tests, two front ends over real Unity Transport on loopback, free ports: host from the menu → lobby, Join by IP from the menu, roster name and colour from the payload, Start, Leave from the Esc menu; Join by code from the lobby's code through InProcessRendezvousServer; the version-mismatch and kicked dialogs; a lost link cut by UdpLinkProxy reconnecting to the same seat, and one that never comes back giving up; Settings saving and the new name reaching the server; a headless scene with a real NetBootstrap building no UI; the profile identity), tests/run-editmode.ps1 (NetFrontEndSetupTests) and tests/run-sample.ps1 -Sample FrontEnd. Found and fixed on the way in MindAttic.Components: M.COMP-T44 (Motion clashed with UnityEngine.Motion in any game with the animation module) and M.COMP-T45 (MenuScreen.Clear left dead items in navigation for a frame).
  • ✅ Votes kit (UM-T54, promoted from Unity.Cursory's UC-T10): Core VoteBox (engine-free; one vote at a time over a roster of client ids; the starter's Yes; passes when Yes reaches the quorum and runs the kind's server-side effect first; rejected as soon as the quorum is unreachable; lapses on the ITickClock with a per-second countdown; a leaver dropped and the quorum recomputed, the last one abandoning it; Cancel), VoteRules (quorum fraction, default 2/3 rounded up; timeout, default 15 s; optional per-starter cooldown after a failed vote; MayStart; StarterVotesYes), VoteKind (id, Title/Description worded from the request, Check with the starter's reason, MayVote, Passed, per-kind quorum and time), VoteRequest (a long and string payload), VoteStatus, VoteResult, VoteStartResult/VoteRefusal and VoteText (the overlay's words, their one home). The adapter's VoteBoard (a NetEntity from the package's own Resources/MindAttic.Multiplayer/VoteBoard prefab: RegisterPrefab, Spawn, Serve, AddKind, AddKickKind through NetSession.Kick with the target left out of the voters, StartVote, StartKickVote, CastVote; status in [Synced] fields, ballots, results and refusals as RPCs; Status, LocalChoice, ChoiceOf, VoteChanged, VoteEnded, VoteRefused), the NGO-free IVoteBoard/VoteBoards the UI binds to, and NetVotes (one component beside the NetBootstrap: registers the prefab on every peer, spawns and serves the board on the server with the Inspector's rules, the kick vote and the game's kinds). Unity.Multiplayer.UI gets VoteOverlay (question, description, tally, quorum bar, standing, Yes/No, result and refusal toasts), wired by itself for a NetFrontEnd with menus and shown only in game. Verified by dotnet test tests/Core.Tests (VoteBoxTests) and tests/run-playmode.ps1 (VoteBoardTests: host and two clients over loopback, number and text payloads, early rejection, a stepped-clock timeout, a leaver, refusals to the starter only, a kick, host-only starts; NetVotesTests; VoteOverlayTests); Unity.Cursory deletes its own VoteBox/VoteBoard/overlay and registers its reset and level kinds.
  • ✅ Player roster and identity (UM-T55): NetSession.Roster (NetRoster) gives every peer one Core NetPlayer per seat (seat, client id, name, colour, host, connected, ping, local), built by the server from its seats (NetPlayer.FromSeat: PlayerNames.Cleaned name, PlayerColors.Resolved colour with the seat's palette colour for an unpicked white) and kept in step over named messages (MindAttic.Multiplayer.Roster*): a client says hello once connected and gets a full RosterUpdate, then incremental ones from PlayerRoster.Replace's differences; a held seat stays as not connected and a reconnect keeps seat and record; the server probes each client's round trip once a second (first one interval after it joined). RequestChange is checked by the server (PlayerChangeRequest.Validate: PlayerNames.Validate, opaque PlayerColors.Validate, a rate limit) and an accepted change is stored with SeatRegistry.Rename and in NetSession.Identity. NetFrontEnd's lobby reads the roster, its Settings renames mid-game through the server, and an accepted local change is saved to the IPlayerIdentitySource. Wire format: RosterWire (versioned, strict, never throwing). Verified by dotnet test tests/Core.Tests (PlayerNamesTests, PlayerColorsTests, PlayerRosterTests, RosterWireTests) and tests/run-playmode.ps1 (RosterTests: host and two clients, late join, round trips, rename everywhere, bad names refused by the server, reconnect keeps identity, kick; NetFrontEndTests: the lobby follows a mid-game rename and the profile is saved). See Players.
  • ✅ Networked objects by key (UM-T60): a NetKey on a network prefab's root carries a game-given key (NetKeys: non-empty, at most 128 characters, no control characters or edge whitespace, ordinal) inside the object's spawn (NGO OnSynchronize), so every peer, late joiners included, knows it before any OnSpawned; it cannot change while spawned. NetSession.Objects (NetRegistry, also NetRegistry.Current) indexes spawned keyed objects on every peer over Core's NetKeyTable<T> (one holder per key, removal only by the holder): TryGet<T>/TryGet(GameObject)/Get<T>/Contains/Keys/All, Spawned/Despawned after every component's OnSpawned and before any OnDespawned, and server-side Spawn(prefab, key, ...) (refuses a bad or held key before anything spawns) and Despawn(key) (frees the key at once). An object spawned another way with a missing or duplicate key is logged on every peer and left out. Verified by dotnet test tests/Core.Tests (NetKeysTests, NetKeyTableTests) and tests/run-playmode.ps1 (NetRegistryTests, Host and dedicated Server with two clients: lookup on every client, late join, out-of-order spawn and replacement, despawn and same-frame respawn, duplicate keys). Unity.Cursory maps its level bodies by block/shape id with it. See Networked objects by key.
  • ✅ Bots and end-to-end smoke (UM-T57, promoted from Unity.Cursory's UC-T14): -bot <role> makes any game a headless bot client. Core NetLaunch never starts it by itself or shows it menus; NetBots joins by -joincode, -joincodefile or -address and hands the session to the game's IBotDriver ([NetBotDriver] class or scene component) through NetBot (role, scenario, Pass/Fail, frame-based waits). The verdict is a [NetBot:<role>] OK:/FAIL: line (Core BotLog). A server launched with -joincodefile writes its codes there (Core JoinCodeFile, atomic). -scenario is passed through (Core BotCommandLine). The test kit has NetBotTest (a server + N bots in process). BotPlayerBuild builds one Linux player for every role. mp-host game smoke writes and runs the compose stack (rendezvous + server + N bots, SDL_VIDEODRIVER=dummy) and judges the bots' log lines, and .github/workflows/game-smoke.yml is the reusable nightly a game adopts with one job. See Bots.
  • ✅ New Game wizard and game template (UM-T59, v2.0.0, the one-stop shop): MindAttic ▸ Multiplayer ▸ New Game… (NewGame, NewGameWindow; batch: NewGame.CreateFromCommandLine -checkOnly | -addPackages | -gameName <Name>, exit 2 when packages are missing) checks Packages/manifest.json with NewGameManifest (plain text: MindAttic Components required, Unity.Shared optional, com.unity.test-framework 1.6.0, NGO under testables; file: paths to the repos beside Unity.Multiplayer, relative on one drive, else absolute, else the documented sibling path flagged as not found and never written), adds the found lines, then copies Samples~/GameTemplate into Assets/<Name> (token MyGame → the name in every text file; every asset a fresh GUID with all references remapped), puts its scene first in Build Settings, turns on Run In Background, and writes mp-host.json (scene, bots A,B, scenario) and .github/workflows/nightly.yml (one uses: of game-smoke.yml). The template: Game.unity (NetworkManager + Unity Transport + NetBootstrap + NetFrontEnd + NetVotes, a Game object), Player (NetEntity, [ToServer(RateLimit = 20)] Move, [Synced] position, name and colour from NetRoster), Crate (NetKey prefab, keyed crate:0..2 through NetSession.Objects), Arena (plain server rules, push, the restart VoteKind that despawns and respawns by key), Game (serves the arena, registers the vote, front-end items), GameBot ([NetBotDriver]), PlayMode GameTests (NetSessionTest, NetBotTest) and EditMode GameSetupTests. Verified by EditMode NewGameTests (8: missing lines, adding them as valid JSON, empty blocks, a repo not on disk, renaming, fresh GUIDs that still resolve, mp-host.json) and tests/run-new-game.ps1 (a fresh -createProject 6000.4.3f1 project in %TEMP%: the check names the missing lines and exits 2, -addPackages adds them, -gameName SpaceCrates creates the game; its SpaceCrates.EditorTests 2/2 and SpaceCrates.Tests 5/5 pass, and -Smoke runs mp-host game smoke: the server and bots A and B under Docker Compose, both OK: pushed crate:N; -Author rebuilds the template's scene and prefabs). A project must list NGO under testables before batch mode will run anything: Unity.Multiplayer.Testing does not compile without it (UM-T67). Docs: getting-started (rewritten for a new game), kit, case-study-cursory.
  • ✅ Unity Relay for a home host (UM-T71): Core RelaySetup / RelayReadiness (engine-free: Check(installed, cloudProjectId) → NotInstalled / NotLinked / Ready, the not-installed, not-linked, Relay-off and offline sentences, ExplainFailure mapping a Unity Services failure to what to fix, EnvironmentOrDefault, IsProjectId); RelayJoinCodeService gains Readiness / IsInstalled (the join-code defaults now use it), Environment (Unity Services environment, production by default), a process-wide anonymous SignInAsync(), and fails before touching Unity Services when the project is not linked; other UGS failures become RelaySetupException with the explained message, which HostWithCode / JoinByCode raise as JoinCodeFailed and the front end shows (Host's "No join code: ..." toast, Join by code's "Couldn't join" dialog). NetBootstrap's Unity Relay section: Relay Environment, Relay Region, Sign In At Startup (signs in as the scene starts, not for a headless server or Join Codes None/Rendezvous). Setup: New Game wizard step 3 (RelaySetupCheck: add the package line at RelaySetup.PackageVersion, open Services settings or the dashboard, show the link), MindAttic ▸ Multiplayer ▸ Check Unity Relay Setup, RelaySetupCheck.CheckBatch (exit 0 when ready; -addRelayPackage), and tools/link-unity-cloud.ps1 (writes cloudProjectId / organizationId / projectName into ProjectSettings.asset and adds the package, refusing while the editor has the project open; -Check). Verified by dotnet test tests/Core.Tests (RelaySetupTests), tests/run-editmode.ps1 (RelaySetupCheckTests) and tests/run-playmode.ps1 (JoinByCodeTests and NetFrontEndTests: the not-linked path for HostWithCode / JoinByCode and for the menus). A live Relay game needs a Cloud project with Relay on; see Join codes.

7. Active frontier

The ticket chain in RFC 0001 § Ticket chain. The UM-T4 gate is passed (GO) and UM-T5 to UM-T17 are done; next is UM-T18 (hosting guide).

8. Glossary

  • NGO — Netcode for GameObjects, Unity's GameObject netcode package.
  • Adapter — the MindAttic.Unity.Multiplayer assembly; the only runtime code that touches NGO.
  • Listen server / host — one player's game is also the server.
  • Dedicated server — a headless server build everyone joins.
  • Join code — a short, checksummed code resolved to a relay allocation or an IP:port.
  • Seat — a player's slot on the server, kept across reconnects.
From Unity.Multiplayer/docs/BIBLE.md via MindAttic.Docs; synced automatically, so edit the repo, not this page.