mirror of
https://github.com/Pasta-Devs/Marinara-Engine.git
synced 2026-12-03 19:00:50 +07:00
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#6619
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?
📋 Pull Request Information
Original PR: https://github.com/Pasta-Devs/Marinara-Engine/pull/5084
Author: @kolacheee
Created: 8/15/2026
Status: ✅ Merged
Merged: 8/15/2026
Merged by: @kolacheee
Base:
staging← Head:fix/5077-checkpoint-game-engine-state📝 Commits (6)
2883badfix(game): restore turn-game engine state from checkpoints (#5077)3a05f5etest(game): clean up seeded chats in the checkpoint regression4958ddddocs(game): note the in-place-mutation limit of the checkpoint engine lookup01489beMerge branch 'staging' into fix/5077-checkpoint-game-engine-state855bbfcMerge branch 'staging' into fix/5077-checkpoint-game-engine-statef363d80Merge remote-tracking branch 'origin/staging' into fix/5077-checkpoint-game-engine-state📊 Changes
6 files changed (+269 additions, -4 deletions)
View changed files
📝
CHANGELOG.md(+1 -0)📝
package.json(+1 -1)📝
packages/server/src/routes/game.routes.ts(+23 -0)📝
packages/server/src/services/storage/game-engine-state.storage.ts(+26 -1)📝
packages/server/src/services/turn-games/turn-game-runner.service.ts(+24 -2)➕
scripts/regressions/game-checkpoint-engine-state.regression.ts(+194 -0)📄 Description
Linked issue
Closes #5077
Why this change
Game checkpoints captured the story and World Maps snapshots but never the turn-game engine state (
game_engine_state). Loading a checkpoint rewound the narration and the map while an active turn-game (UNO, Chess, Poker, Eight Ball) kept its post-checkpoint hand/board. This is also the missing hook for any capability package that stores per-message game state and wants to participate in checkpoints (the "why it matters beyond turn-games" from the issue).Reachability note (correcting the issue): the issue says the turn-game start route has "no mode gate, so the overlap is reachable via the API today." That is not accurate —
startTurnGamerefuses any non-conversation chat (this gate exists as far back as the issue's referenced068d01fad), and checkpoints require a game-mode world-state snapshot, so a turn-game and a checkpoint cannot coexist in one chat through normal play. The underlying gap is still real, but today it is only reachable by constructing the state directly; the value is future-proofing checkpoints (per the issue's own broader motivation) and closing the latent bug. Flagging so the scope is clear.What changed
The engine state's own
(message, swipe)anchor is independent of the game/spatial snapshot anchors a checkpoint captures, so re-looking it up by the captured anchor would miss it. Instead the fix recovers the engine state that was current at checkpoint time bycreatedAt(set once at create and never mutated) and clones it onto the restore anchor:game-engine-state.storage.ts: newgetLatestAtOrBefore(chatId, createdAtInclusive)— the latest snapshot for a chat created at or before a timestamp.POST /game/checkpoint/load: after cloning the game-state snapshot onto the restore message, clonegetLatestAtOrBefore(cp.createdAt)onto the restore anchor (committed: true). No-op when the chat has never had a turn-game (the lookup is chatId-scoped, so ownership needs no extra guard).resolveTurnGameAnchor: it previously matched onlyrole === "assistant"messages, so the restore'srole: "system"message (markedgameStateAnchor: "checkpoint_restore") was skipped and the cloned row stayed invisible behind the last real assistant message — the clone would have been inert. It now also accepts that marked system message, mirroringresolveVisibleGameStateAnchorused by the game-mode tracker.scripts/regressions/game-checkpoint-engine-state.regression.ts(wired intoregression:issues) + CHANGELOG entry.Validation
pnpm checkpasses locallyCONTRIBUTING.mdManual verification notes
Automated (done):
pnpm checkpasses, and the newgame-checkpoint-engine-stateregression passes. Because the overlap is not reachable through normal play, the regression constructs the state directly (registers a tiny echo engine and seeds the snapshots), then assertsgetTurnGameViewrewinds to the checkpoint-time state after a checkpoint load. It was confirmed to fail with each of the two behavioral changes reverted individually (revertresolveTurnGameAnchor→ the cloned state stays invisible; revert the clone → nothing lands at the restore anchor), so both changes are load-bearing and the test catches each.Still worth a manual pass if a reviewer wants to exercise it through the API (not reachable via the UI today): construct a game-mode chat with a turn-game engine row via the turn-games API in a conversation chat scenario, or use the regression as the reference. No normal-play repro exists because of the mode gate above.
Docs and release impact
docs-i18nbranch updated to match, or a[docs-i18n]follow-up issue opened (see CONTRIBUTING.md § Translated documentation)CHANGELOG updated under Fixed. No user-facing docs under
docs/changed, so nodocs-i18nfollow-up is needed. No version bump. No storage-format change (the fix re-looks up existing rows rather than adding columns, so nostorage-format.json/STORAGE_VERSIONbump).🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.