mirror of
https://github.com/Pasta-Devs/Marinara-Engine.git
synced 2026-12-03 19:00:50 +07:00
[GH-ISSUE #5077] Game checkpoints don't capture turn-game state (game_engine_state) — restore rewinds the story but not the game #2809
Labels
No labels
android
bug
bugfix
ci
client
code freeze pause
container
dependencies
docs
documentation
duplicate
enhancement
feature
feature
feature
feature-creep
fixed-in-refactor
fixed-in-staging
good first issue
help wanted
in-pr
in-pr
needs-codeowner-decision
normal-scope
old-codebase
old-codebase
pull-request
qol
question
refactor
regression
revisit later
roadmap
scope-risk
scope-risk
server
server
shared
soup
upstream
windows
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
Pasta-Devs/Marinara-Engine#2809
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @kolacheee on GitHub (Aug 15, 2026).
Original GitHub issue: https://github.com/Pasta-Devs/Marinara-Engine/issues/5077
Originally assigned to: @kolacheee on GitHub.
What happens
Game checkpoints capture the story state and the World Maps location, but not the turn-game engine state table. Loading a checkpoint rewinds the narration and the map — while an active turn-game (UNO, Chess, Poker, Eight Ball) keeps its newest state as if nothing happened.
Try it yourself
Turn-games are normally started from conversation chats (where checkpoints don't exist), but the start route has no mode gate, so the overlap is reachable via the API today:
POST /api/game/checkpoint), then make more moves.POST /api/game/checkpoint/load). The story gets its[Checkpoint restored]marker and the game-state + spatial snapshots are restored — butGET /api/turn-games/<chatId>/statestill shows the post-checkpoint hand/board.Why it happens
checkpoint.service.tsknows about exactly two snapshot stores:packages/server/src/services/game/checkpoint.service.ts:10imports onlygameCheckpoints, gameStateSnapshots, spatialContextSnapshots, andcreate()(:57-100) captures only those two rows. Thegame_engine_statetable (packages/server/src/db/schema/game-engine-state.ts) — which is per-(chatId, messageId, swipeIndex)and already correctly wired into swipe delete/re-index, message/chat/group delete prunes, and branch re-anchoring — is never captured or restored by checkpoints.Why it matters beyond turn-games
This is also the missing hook for any current or future capability package that stores per-message game state. A Game Mode "Experience" package (e.g. the pixel-RPG design being explored) has no way to participate in checkpoints at all: its world state survives a checkpoint load un-rewound, silently diverging from the restored story and map.
Suggested fix
Capture the
game_engine_stateanchor alongside the existing two snapshots and re-look-up on restore (keying bychatId/messageId/swipeIndex), rather than denormalizing new columns ontogame_checkpoints— the re-lookup variant changes no on-disk table shape, so nostorage-format.json/STORAGE_VERSIONbump is needed. The existing cross-chat ownership guards increate()(:63-66,:85-88) should be mirrored for the new capture.Verified against
staging@068d01fad.@kolacheee commented on GitHub (Aug 15, 2026):
Reachability correction while implementing this (PR #5084):
The repro as written does not run today.
startTurnGamerefuses any non-conversation chat ("Turn-games can only be started in conversation mode.") and this gate is present as far back as the referenced068d01fad, so step 2 (starting UNO in a Game Mode chat) fails. Checkpoints in turn need a game-mode world-state snapshot. So a turn-game and a checkpoint cannot coexist in one chat through normal play — the turn-game <-> checkpoint overlap is not reachable via the API today.The underlying gap is still real (checkpoint create/load completely ignore
game_engine_state), and the fix ships it as the future-proofing hook this issue's "why it matters beyond turn-games" section describes, plus closing the latent bug. Flagging so the scope is honest.Implementation note: the engine state's own (message, swipe) anchor is independent of the game/spatial snapshot anchors a checkpoint captures, so re-lookup by the captured anchor would miss it. The PR keys off
createdAt <= checkpoint.createdAtinstead, and also teachesresolveTurnGameAnchorto honour thecheckpoint_restoremarked system message (otherwise the cloned row stays invisible behind the last real assistant message).