houserules/packages/chess/src/net
Joey Yakimowich-Payne 4819676d84
fix(net): sync customModifiers to late-joiners + reconnects in game.state
T3 audit gap 2 (CRITICAL). The server's Room kept registered custom
modifier descriptors in a per-room Map but the game.state snapshot
carried no field for them. Impact:
  - Client A registers 'custom:shield' → server broadcasts
    custom-modifier.registered → A + any currently-connected B see it.
  - Client C joins AFTER the registration → receives game.state →
    has no knowledge of 'custom:shield'.
  - Client C's engine applies a profile with kind='custom:shield' →
    registry-dispatch fallback silently no-ops → apparent cosmetic
    modifier mismatch between A/B and C.

Symmetric fix across the wire:
  - GameStatePayloadSchema (server + client types) gains an optional
    customModifiers: CustomModifierDescriptorWire[] field.
  - Both emit sites in broadcast.ts (late-joiner path +
    reconnect-with-buffered-deltas path) include the room's registered
    descriptors.
  - PredictionManager.applyFullState mirrors received descriptors
    onto the fresh engine's customModifiers registry before handing
    control to the UI. Unknown descriptor shapes are accepted as-is
    (the wire-shape cast at the single boundary bridges the Zod v3/v4
    type split same as the custom-modifier.registered subscriber).

E2E regression guard (Oracle Q4.1 recommendation): new scenario
'late-joiner + reconnect receive registered custom modifiers in
game.state'. Host creates + registers, opponent joins AFTER
registration, asserts opponent's game.state carries the descriptor.
Would have caught the pre-fix behaviour as a test failure instead of
a manual audit find.

1393 unit + 19/19 custom-modifiers e2e green.
2026-04-20 16:58:48 -06:00
..
client.test.ts feat(chess): add WebSocket client library with reconnect (P4.9) 2026-04-16 17:44:13 -06:00
client.ts feat(net): client subscriber + send method for custom-modifier broadcast 2026-04-19 21:38:32 -06:00
lobby-request.ts feat(ui): lobby profile picker integration 2026-04-18 23:11:11 -06:00
prediction.test.ts feat(chess): add client prediction + server reconciliation (P4.10) 2026-04-16 17:48:33 -06:00
prediction.ts fix(net): sync customModifiers to late-joiners + reconnects in game.state 2026-04-20 16:58:48 -06:00
types.ts fix(net): sync customModifiers to late-joiners + reconnects in game.state 2026-04-20 16:58:48 -06:00