0027. Social features and multiplayer: profiles, leaderboards, achievements, input-relay netcode
- Status: Accepted 2026-11-29 (Phase 6; owner decisions 2026-11-30: split into 6a social and 6b multiplayer, a deterministic input relay, leaderboard limits plus replay checks, a 2–4 player top-down arena as the sample game)
- Date: 2026-11-30
- Phase: 6
Context
Section titled “Context”Phase 6 adds people to the platform: who made and played what, scores and achievements that span games, and playing together. Game code is untrusted (ADR 0012, 0020): it runs only on the play origin or in the sandbox, and anything it reports, such as a score, may be forged.
Decision
Section titled “Decision”6a — social
Section titled “6a — social”-
Profiles.
/u/<handle>shows:- the display name;
- a generated avatar (no uploads);
- the games and packs the player published;
- achievements and best leaderboard places.
There is no free-text bio, to keep moderation and minors’ safety simple. A player can make their profile private.
-
Leaderboards. Games declare boards in
game.json(leaderboards), each with:- a key, and the value it ranks (e.g.
session.score); higherorloweris better;minandmaxbounds.
A rule action
submitScoresends a score through the play bridge. The platform checks bounds and rate limits (per player, per board) and keeps each player’s best. - a key, and the value it ranks (e.g.
-
Replay checks. A score carries the run’s input recording: the seed, the game version, and the input actions per tick (recorded by the framework). The top entries of each board are verified by replaying the recording headless in the sandbox (the deterministic simulation must reach the same value). Entries that fail are hidden. Owners and moderators can also remove entries.
-
Achievements. Games declare them in
game.json(achievements: key, name, description, icon,hidden). AnunlockAchievementaction unlocks one through the bridge, once per player. Unlocks are rate-limited, and shown on the profile and the game page. -
Signed-out players can play but not submit scores or unlock achievements; the game page says so.
6b — multiplayer
Section titled “6b — multiplayer”- Deterministic input relay instead of server-authoritative rooms (this changes ADR 0014):
- The room server never runs game code. It collects each player’s inputs per tick, checks them (known actions, rate, size), orders them, and sends them to everyone.
- Each browser runs the same deterministic simulation in lockstep (rollback for responsive local input may come later; see the owner decisions below).
- Rooms, matchmaking by game, and invites by link.
- WebSocket first, behind the
NetTransportinterface (ADR 0014).
- Owner decisions for 6b (2026-11-30):
- Lockstep with input delay first; rollback can come later behind the same interface.
- The room server is its own service,
apps/rooms; it runs in the same process inpnpm platform:dev. - Only signed-in players can play online.
- How a match runs:
- The server paces the match. Each tick it sends a frame with every player’s latest inputs, so a slow player does not hold up the others.
- Each browser steps the game once per frame; the delay is the time a frame takes to arrive.
- Clients send a hash of the game state every second; a mismatch ends the match as “out of sync”.
- The platform page gets a short-lived signed ticket for the player from the API and passes it to the game over the play bridge. The game connects to the rooms service with it. The ticket carries the room, the player, the game’s input actions and the player limit, so the rooms service needs no database.
- Sample game: a 2–4 player top-down arena built on the top-down kit.
- Known limit: every client knows the whole game state, so games with hidden information need the authoritative model later.
Alternatives considered
Section titled “Alternatives considered”- An authoritative server simulation: the strongest anti-cheat and supports hidden information, but runs untrusted game code on our servers per room and costs far more.
- Leaderboard limits only: simpler, but scores would be easy to fake.
- Profiles with bios and uploaded avatars: more moderation work and more risk for minors.
Consequences
Section titled “Consequences”- The framework records inputs per tick, and replays must stay deterministic across framework versions. A score is replayed with the game version it was played on.
- The sandbox gains a replay job, with CPU limits per verification.
- Recordings count inputs by scene and fixed tick within the scene, so loading time between scenes cannot shift a replay; pointer positions are kept while an action is held, so taps on menus replay too.
- 6b as built:
@ludrel/netholds the protocol, tickets (HMAC),RoomServer(the logic, with no I/O) andNetClient.apps/roomswrapsRoomServerin a WebSocket server. The framework’sOnlinePlugin(framework/src/online.ts) drives the lobby and the lockstep match.- Players’ inputs are one
InputManagerper seat (thePlayerInputsresource); controllers read them throughinputFor. - The play CSP allows
connect-srcto the rooms service.
- Players’ inputs are one
- Lockstep needs the same floating-point results in every browser.
Math.sinand similar may differ across engines, so desyncs are detected and the match ends, rather than being prevented. - Names written as
@keysare shown in the game’s default language on boards, achievements and profiles.