Let commands be server-only and let host code reset departed players - #1854
Merged
Merged
Conversation
A command whose input carries host-decided facts could be sent by any client through the public runCommand, so a game had to remember to strip it from its exports. CommandDef.access "server" makes the public Convex mutation and WebSocket client messages refuse it while helpers.runCommand and trusted host calls still run it. resetPlayerProfile threw for a player who had left the server, which aborted whole scheduled batches; it now resets anyone with a profile. Closes #1853 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01GvRbbu8yG1WYz7wQnZUpC8
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This came out of an LLMville audit. There, a client could send
startTrainingwith forged unlock and multiplier inputs through the publicrunCommand, and an insolvency reset for a player who had left threw and rolled back a whole 25-game billing batch.CommandDef.access: "server"(core). The public ConvexrunCommandmutation and WebSocket client messages now refuse such commands withSERVER_ONLY_COMMAND_REASON.helpers.runCommandandhost.runCommand({ trusted: true })still run them. The default is"client", so existing games are unchanged.GameRuntime.commandAccess(name)reports a command's access.helpers.resetPlayerProfilenow resets a player who left but still has a profile. A user with no membership and no profile still throws.jgengine-multiplayerskill now says to treat command input as client-controlled and to usenowMs, not anowfield ininput.Closes #1853
Bugfix notes
access: "server"now covers it."client": flipping it would break existing probe games.Verification
bun test packages/convex packages/ws packages/core/src/runtime: pass. New tests cover refusal and trusted runs on both hosts, and resetting a player who left.check-typesfor core, convex and ws: pass.bun run gen: done;ship:preflight: ok.🤖 Generated with Claude Code
https://claude.ai/code/session_01GvRbbu8yG1WYz7wQnZUpC8
Generated by Claude Code