claude-of-tanks / server
Purpose
Provide the renderer-free match authority (server/match), the room service
the LAN helper and every headless proof run (server/rooms), and the small
HTTP services the site deploys. The signaling server, the Redis room store, the
dedicated match server and the ranked service of the first multiplayer left the
tree with the cutover of 2026-09-29 (docs/MULTIPLAYER-V2.md §13.10).
Mental model and invariants
match/is the Multiplayer v2 match service (docs/MULTIPLAYER-V2.md§11 and
§13): MatchActor (one room: roster, the authority, the loop, seat admission,
lag compensation, interest-tiered snapshots), the binary wire in src/mp/wire,
seat tokens (seatToken.ts) the room service signs, service.ts +
localRoomService.ts (the in-process match the LAN helper and the receipts
use), server/match/README.md. The same actor runs in the host commander's
browser (src/mp/host).
- Scaling with the player count (
docs/MULTIPLAYER-V2.md§13.30): a viewer
frame reads the authority's view (observeForViewer, snapshotMeta), never a
full viewer snapshot; the publisher encodes straight from the frames
(encodeSnapshotFrame) on each viewer's keyframe slot, every 6 s; the
snapshot budget (interestTiers.ts) shares the host's uplink target among the
viewers; events go as binary payloads encoded once (wire 8). Measure with
tools/mp-scale-bench.mjs before and after any change to that path.
rooms/is the LAN / offline helper (npm run server:mp, port 8792): the
shared room actor (src/mp/room/roomActor.ts) over real sockets, the match
in-process or in the admin's browser (COT_ROOMS_MATCH_TRANSPORT).
COT_ROOM_DEV_MAX_TEAM_SIZE (up to 32) lets a versus room seat a larger,
bot-filled test team; the rooms Worker never sets it.
dedicatedWorldCollision.tsinflates match-local state from generated
per-map collision shards (collisionManifestCodec.ts, collisionManifestLoader.ts,
mapResourceCache.ts); do not hand-edit their records or checksum index. Keep
idle map retention bounded and release active terrain leases on teardown.
dedicatedWorldCollisionBrowser.ts is the browser-side loader the manifest
receipt compares against.
pacingRoster.test-support.tsis the battle-pacing gate's roster fixture
(battlePacing.selftest.mjs, tools/pacing-trace.mjs): the seeded
era-matched bot fill the gate's bands were measured over.
- The core pacing run plays in eight one-thread receipts,
battlePacingShard1.selftest.mjs to battlePacingShard8.selftest.mjs
(2026-10-16, test-speed R9a). battlePacing.selftest.mjs merges their records
from the run's directory (COT_SELFTEST_RUN_DIR) and judges all 132. Each share
is claimed by one live process, and the judge plays any share nobody plays
(battlePacingRun.test-support.mjs; docs/DEVELOPMENT.md, "The pacing tail").
relayCredentials.tsmints a seated player's short-lived TURN credentials
inside the room (2026-10-02, docs/MULTIPLAYER-V2.md §13.14): the rooms Worker
and the LAN helper hand it to the room actor's relayCredentials port, one
grant per admitted room_relay, never cached or logged; STUN only when no
secret is set. Run node server/relayCredentials.selftest.mjs. Credentials are
never committed (the deprecated STUN-only api/ice.ts route is retired, 229).
telemetryRecord.tsis the shared entry-telemetry schema;jev/main.tsis the
local HTTP wrapper around api/jev.ts for the Vite dev server (npm run jev:dev,
port 8794; docs/JEV-COMMANDER.md).
- Never make a client authoritative for hits, damage, reloads or the match
result; a room migrates its host, it never hands a client the verdict.
- Keep payloads, queues, rooms, rates, and lifetimes bounded.
Verification
Run node server/match/matchActor.selftest.mjs, node server/match/service.selftest.mjs,
node server/dedicatedWorldCollision.selftest.mjs and node server/battlePacing.selftest.mjs.
Regenerate world manifests with tools/capture-world-collision-manifests.mjs after
authored map collision changes. Any gameplay authority added here must also run the
deterministic match tests, abuse cases, and the headless peer-to-peer proofs
(npm run test:net:v2:p2p:headless, npm run test:net:v2:p2p).