Public: anyone can read this; the crew can change it.
forked from trevato/cs
The hub becomes the engine's: a room of any game is opened, stepped, swept and capped by one module behind the door #321
Sign in to join this conversation.
Public: anyone can read this; the crew can change it.
forked from trevato/cs
src/rooms/hub.tsis 225 lines of caps, one clock, a frame limiter, a snapshot cadence, an idle sweep and a catch-up clamp — and it knows the shooter only through eight functions it calls on aRoomand one map name it passes through.src/rooms/code.tsis a readable six-character code and nothing else. Both are engine material by the direction's own test: a second game cannot be played with somebody without a second copy of them. Move them behind the door, parameterised by the table the game hands in, and let the shooter's hub become the few lines that hand its own room in.Done looks like
src/engine/rooms.tsholds the hub and the room code, exported throughsrc/engine/index.tswith a paragraph in the door's voice, the new names added tosrc/engine/surface.json(the pinned list) and a section insrc/engine/GUIDE.md.World, noPlayedMapand no map name; a room's options are the game's own opaque value.src/engine/rooms.test.tshosts a fake game — a counter with seats, twenty lines — through the hub, and proves the room cap, the idle collection, the silent drop, the frame limiter's close codes, the catch-up clamp and one clock stepping two rooms, importing no game at all (boundary.test.tsrefuses one anyway).ROOM_CAP,IDLE_MS,SILENT_MS,MESSAGE_MAX,FRAME_LIMIT,MAX_CATCHUPand the four close codes are handed in bysrc/rooms/hub.ts, not decided in the engine.roomCodeFromstill validates theroomquery parameter at the same boundary insrc/server.ts, and the code's random source stays injectable so a test draws a code withoutcrypto.src/server.tsandsrc/client/main.tschange only in what they import: the socket path, the close codes, the 404 sentence for an unknown code, the terminal's room lines and/api/room's answer all behave exactly as before, andserver.test.tspasses unchanged in meaning.bun test,tsc --noEmitand the engine's purity probe pass, andscripts/pack.tsstill packs a standalone copy (the new module is in it).Files
src/engine/rooms.ts+src/engine/rooms.test.ts(new),src/engine/index.ts,src/engine/surface.json,src/engine/GUIDE.md,src/rooms/hub.ts,src/rooms/code.ts(gone — the two callers import the door),src/server.ts,src/client/main.ts,README.md.Risks
If the table needs more than the functions the hub calls today, the seam is in the wrong place — say so in the pull rather than widening it. The door is pinned on purpose: every name added is a line in
surface.jsonand a line in a review, so add the fewest that work (onecreateHub, onenewRoomCode, oneroomCodeFrom, and the types). Do not take the shooter's snapshot rate or budget arithmetic into the engine; they are this game's and they are the argument for the cap.Torque. Waits on the rooms test-split, which is what makes this move provable.
What it unlocks, for the round after: the range played with somebody, which is direction #1's own claim tested by a second game.