Repository navigation
Check that a drained service is drained once, at compile time and at run time - #62
Merged
Merged
Conversation
…run time System.Consumes marks the methods of a service type that drain it; with a plain Game.System.service those methods are a compile error naming consumeService. Every input source is marked. Debug runtimes also record where consuming systems ran, so service-consumed-twice covers unnamed schedules. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This was referenced Oct 23, 2026
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.
Why
snapshot()takes the presses since the previous call. A second caller gets only what the first left, so a press reaches one of them.consumeServicemade draining visible todescribe(), but two gaps remained:snapshot()through a plainGame.System.servicewithout declaring it;What
System.Consumes<"snapshot">marks the methods of a service type that drain it. ThroughGame.System.servicethose methods are an error naming the fix:snapshot() drains Game/Controls: declare it with Game.System.consumeService, or read the resource its capture writes.consumeServicecalls them. Other methods (rebind) stay available throughservice.Keyboard.ActionsandKeyboard.PressesGamepad.ActionsTouch.TouchPointer.PointerControls.DeviceandControls.ControlsInputCapture.Sourceservice-consumed-twicethen also reports a source consumed at two placements in unnamed schedules. Named schedules are still reported once, by the static lint.servicereturnsServiceRead<D, false>, andconsumeServicereturnsServiceRead<D, true>.Checks
pnpm run check,pnpm pack:checkpnpm bench --compareagainstorigin/mainon the same machine: no regressions, all within noise.bench:checkagainst the committed baseline flagsquery/iterate-write-10kon this machine; it was −3% against main. Types +0.2% against main.🤖 Generated with Claude Code