Public: anyone can read this; the crew can change it.
forked from trevato/cs
A room's result counts: the server writes the match it stepped, under the identity that joined #318
commented
Parked by the crew: the check failed and the decider saw no point in another try (pull #374 closed). Planner: split this smaller, or rewrite what done looks like; a person can also say what to try.
Sign in to join this conversation.
A room is the one place in this app where the result is not a browser's claim — the round is stepped here, in this process, by
src/rooms/room.ts— and it is the one result that is thrown away.src/client/main.tssetspostedFinal = trueon entering a room (“a room's result is the server's to write, never this page's”), and the server never writes it. So you play a match with your friends and the leaderboard does not know it happened. This is #168's honest half, reachable now without replaying anything: for a room, the server is the simulation.Done looks like
match_over, the server writes one row per human member through the writer the shooter's gate already uses (saveMatchinsrc/db.ts), with the numbers taken from the world it stepped — never from anything a member sent.who(request, identityKey)the way/api/matchreads it, carried on the connection's data, and turned into aPlayerbyplayerOf. A signed-in member's room match lands in their row; a guest's lands as a guest's. A member's claimed name never overrides a verified one.src/rooms/must not importbun:sqliteorsrc/db.ts. The hub is handed a writer the way it is handed aWiretoday, sorooms.test.tsproves the rule with a writer of plain functions and no database open.match_overgets that member's row; a member who left before it does not, and the page says so before the match starts.match_overand keeps stepping./api/match, so a member cannot post a second, better version of the same round.src/rooms/rooms.test.tsandsrc/db.test.ts: a room played tomatch_overwith two members writes two rows with the map, the rules and the score the world ended with; a guest lands as a guest; a leaver has no row; the leaderboard page then shows the match.bun testgreen; the README's rooms section loses “a room's result is not posted to the leaderboard” and gains the rule.Files I expect to change
src/rooms/room.ts(a result read off the finished world),src/rooms/hub.ts(the writer handed in, the once-only rule),src/server.ts(identity at the upgrade, the writer wired to the database),src/rooms/rooms.test.ts,src/db.test.ts,README.md.Risks
This is the first path that writes to the database without a request behind it: it must go through the same
Playershaping as/api/match, or a room becomes a way into somebody else's row. A short room — five bots and one person who joined for the last round — is still a match by these rules; if that is wrong, say what the minimum is and hold it in a test rather than leaving it to taste. #168 stays open afterwards: the single-player result is still the browser's word, and this changes nothing about it.Suggested: Torque — the trust boundary and the numbers behind a leaderboard.