Repository navigation
feat(mcp): add input recording and deterministic replay tools (#467) - #710
Merged
Merged
Conversation
…d seed Synchronous playback now advances the Bridge's loop (Config.Loop/LoopFunc) with Loop.StepNow instead of calling the raw Update callback, so game_loop_status counts the replayed steps and game time; ReplayConfig.Loop is gone and StepFunc stays as an explicit override. game_replay_play refuses a recording whose rate differs from the game's fixed rate (the loop's StepRate, else ReplayConfig.StepRate, else 60), and record_start no longer takes step_rate: recordings are always made at that rate. Record and play share one reset that defaults to true whenever there is something to reset: the Bridge's seed targets (Config.Random, RandomStreams, SetSeed, as game_loop_seed uses) are re-seeded and then ResetFunc runs. A recording started mid-game with default arguments now replays to the same state. steps is capped at MaxLoopSteps in schema and handler, and run_to_end is refused for recordings longer than MaxLoopSteps. ReplayConfig.Source is required (the Recorder fallback left live play without input), it keeps being stepped during playback, and a trailing playback step releases actions held at the end of the recording before live input resumes. save_path writes go through os.Root, so symlinks cannot leave SaveDir, and an existing file or stored name is refused unless overwrite: true. metadata is documented as in-memory only.
houko
force-pushed
the
feat/mcp-record-replay-467
branch
from
November 24, 2026 19:23
a54f86f to
253d854
Compare
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.
Summary
Implements MCP input recording and deterministic replay tools in
packages/game/mcpso coding agents can start and stop recordings and replay stored or inline YAML recordings back to the exact same game state.ReplayControllerandReplayConfig(packages/game/mcp/replay.go) implementingreplay.ActionSourceso games wire live play, recording (replay.Recorder), and deterministic playback (replay.Player) through one update loop.game_replay_*tools viaBridge.Tools():game_replay_statusgame_replay_record_startgame_replay_record_stopgame_replay_play(by storednameor inlineyaml, withResetFunc(seed)andrun_to_end,steps, or frame-by-frame playback)game_replay_stopgame_replay_listConfig.Random/RandomStreams/SetSeed, thenResetFunc(seed)), on by default for both whenever there is something to reset. Playback refuses a recording made at a rate other than the game's fixed rate, advances the Bridge's loop withLoop.StepNow(sogame_loop_statusstays in sync) unlessStepFuncis set, and is capped atMaxLoopStepsper call. A trailing playback step releases actions held at the end of the recording before live input resumes.save_pathwrites go throughos.Root(no symlink escapes), and an existing file or stored name is refused unlessoverwrite: true.packages/game/mcp/mcp.gochanges minimal (Config.Replayfield +b.replayTools()append) so parallel MCP PRs rebase cleanly.docs/en/mcp.mdanddocs/zh/mcp.md, adds changelog fragmentchangelog.d/mcp-record-replay.md, and records architectural decisions in.agents/notes/implemented/feature/2026-11-24-mcp-record-and-replay.md.Verification
After rebasing onto main and the review fixes:
gofmt -lempty,go tool nsgo test ./mcp(29 passed),go tool nsgo check -target linux,web ./mcp, fullgo tool nsgo test .inpackages/game(3426 passed),go run ./tools/changelog check.Before the rebase:
git ls-files -z -- '*.go' | xargs -0 -r gofmt -l(empty)(cd packages/game && env -u GOROOT go run ./cmd/gameschema -check)(cd packages/game && env -u GOROOT go tool nsgo check -target macos,windows,linux,android,web)(cd packages/game && env -u GOROOT go tool nsgo test ./mcp)(13 passed)(cd packages/game && env -u GOROOT go tool nsgo test ./replay)(17 passed)(cd packages/game && env -u GOROOT go tool nsgo test -run TestStabilityTable .)(1 passed)env -u GOROOT go run ./tools/changelog checkbun run verify-notesCloses #467