Parse command input once before scope, validate and apply - #1855
Merged
Merged
Conversation
Every game hand-rolled its own input readers and had to call them in each command stage, so a stage that skipped one accepted Infinity coordinates, fractional indices or NaN. CommandDef.parse (with defineCommand for typed input) runs first and refuses malformed input, and commandInput gains bounded readers for numbers, strings, enums, points and arrays. 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.
LLMville's audit turned up an
Infinityplacement coordinate that made a loop run forever, fractional rack slot indexes, and a NaN revenue share. Each happened because the game hand-rolls input readers and has to call them in every command stage.CommandDef.parseplusdefineCommand<TInput>()(core). The runner refuses anullparse result withMALFORMED_COMMAND_INPUT_REASONbeforescope,validateorapplyrun, and those stages receive the parsed, typed input.runtime/commandInput.readInputNumberis always finite and takes an optional range and integer flag. The others arereadInputString(length cap),readInputOneOf,readInputPoint2/readInputPoint3(maxAbs),readInputArray(maxItems) andisInputRecord.jgengine-multiplayerskill now points commands atdefineCommandand these readers.Commands without
parsebehave as before.Verification
bun test packages/core/src/runtime: pass. New tests cover the readers, parse running before validate, and scope using parsed input.check-types(core): pass.bun run gen: done;ship:preflight: ok.🤖 Generated with Claude Code
https://claude.ai/code/session_01GvRbbu8yG1WYz7wQnZUpC8
Generated by Claude Code