houserules/packages/server/src
Joey Yakimowich-Payne 0bd65e0a73
feat(server): turn-boundary queue for modifier profile updates
Replace T1 immediate-apply semantics with a single-slot pending
queue (T2-ADR-1). On `modifier-profile.update` receipt the server
validates shape + layout legality, stashes the profile on
`Room.pendingProfile` with the proposer's token, and acks the
sender with a new `modifier-profile.queued` message. The actual
`reconcileProfileSwap` + version bump + `modifier-profile.updated`
broadcast now runs in `applyPendingProfileIfAny` after the next
successful `applyMove` — either player's move triggers it.

- `Room` gains `pendingProfile` and `pendingProposerToken`
  (token-keyed for reconnect-safe NACK routing).
- `game-session.ts` exposes `setPendingProfile`,
  `applyPendingProfile`, `clearPendingProfile`. Apply re-runs
  `validateProfile` as defence in depth; rejections clear the
  slot and surface the validator error code.
- New `modifier-profile.queued` wire schema (server\u2192client ack
  carrying the expected post-apply version).
- Last-write-wins: a second update overwrites the pending slot
  because the server's `profileVersion` only bumps on apply, so
  the second request legitimately carries the same version.
- Existing early-rejection paths (non-host, stale version,
  invalid profile) remain unchanged.

Tests updated: 7 scenarios covering queued ACK, deferred apply,
last-write-wins, opponent-move-drains-queue, and all original
rejection paths. 1220 unit tests + 18 modifier Playwright tests
green (e2e specs never used `modifier-profile.update` at
runtime so were unaffected).
2026-04-19 09:06:15 -06:00
..
broadcast.test.ts feat(server): add reconnection with 60s grace + snapshot resume (P4.7) 2026-04-16 17:38:26 -06:00
broadcast.ts feat(server): turn-boundary queue for modifier profile updates 2026-04-19 09:06:15 -06:00
game-session.test.ts feat(server): add authoritative game session per room (P4.5) 2026-04-16 17:17:42 -06:00
game-session.ts feat(server): turn-boundary queue for modifier profile updates 2026-04-19 09:06:15 -06:00
index.ts feat(server): add reconnection with 60s grace + snapshot resume (P4.7) 2026-04-16 17:38:26 -06:00
layouts.test.ts feat(server): layout-aware room.create + resolved layout echoes (Phase C) 2026-04-18 20:01:01 -06:00
layouts.ts feat(server): layout-aware room.create + resolved layout echoes (Phase C) 2026-04-18 20:01:01 -06:00
logger.ts feat(server): scaffold Bun HTTP+WS server with health + logging (P4.1) 2026-04-16 17:03:42 -06:00
logging.test.ts feat(server): add reconnection with 60s grace + snapshot resume (P4.7) 2026-04-16 17:38:26 -06:00
logging.ts feat(server): add reconnection with 60s grace + snapshot resume (P4.7) 2026-04-16 17:38:26 -06:00
middleware.test.ts feat(server): add rate-limit, origin allow-list, message-size cap (P4.4) 2026-04-16 17:11:40 -06:00
middleware.ts feat(server): add rate-limit, origin allow-list, message-size cap (P4.4) 2026-04-16 17:11:40 -06:00
protocol.test.ts feat(server): modifier profile protocol schemas + error codes 2026-04-18 22:43:58 -06:00
protocol.ts feat(server): turn-boundary queue for modifier profile updates 2026-04-19 09:06:15 -06:00
reconnect.test.ts feat(server): add reconnection with 60s grace + snapshot resume (P4.7) 2026-04-16 17:38:26 -06:00
reconnect.ts feat(server): add reconnection with 60s grace + snapshot resume (P4.7) 2026-04-16 17:38:26 -06:00
room.create-profile.test.ts feat(server): room-create accepts profile 2026-04-18 22:55:24 -06:00
rooms.test.ts feat(server): add room registry with codes + tokens (P4.3) 2026-04-16 17:09:43 -06:00
rooms.ts feat(server): turn-boundary queue for modifier profile updates 2026-04-19 09:06:15 -06:00
ws.modifier-profile-update.test.ts feat(server): turn-boundary queue for modifier profile updates 2026-04-19 09:06:15 -06:00