[GH-ISSUE #7742] [Feature]: Checkpoints save and restore the game's chat metadata #4272

Closed
opened 2026-10-21 06:13:56 +07:00 by bsakaguchi · 0 comments
Owner

Originally created by @ylli-selmani on GitHub (Oct 16, 2026).
Original GitHub issue: https://github.com/Pasta-Devs/Marinara-Engine/issues/7742

Originally assigned to: @ylli-selmani on GitHub.

What problem does this solve?

A Game Mode checkpoint only captures three things: the turn's game-state row, the spatial snapshot, and the Experience/combat engine state (checkpoints schema: snapshotData, spatialSnapshotData, engineStateData). Loading one restores those, but in chat metadata it restores only gameActiveState, and only for automatic checkpoints.

Most of what makes up a running game lives in chat metadata, and checkpoints don't save any of it: party character cards, NPCs, journal, inventory stacks, story, world, maps. So loading a checkpoint today is partial. The game can come back with the old scene and the new party, NPCs and items.

This also blocks a real "undo" for hand edits to game data (the Game data source for the State Editor, filed separately), which wants to save a checkpoint before writing.

Proposed solution

  • When a checkpoint is created, also store a copy of the game's chat metadata keys from an allow-list: the keys a game owns and can rebuild from (cards, NPCs, journal, inventory stacks, party ids, story-arc notes, time/weather/morale, and so on). An allow-list rather than "every game* key", so new keys from upcoming Game Mode work are opted in on purpose.
  • When a checkpoint is loaded, write those keys back through the chat metadata queue (withChatMetadataPatchQueue) in one write, alongside the restores it already does.
  • Older checkpoints without the new field load exactly as they do today.
  • Small and server-side. A regression covers create → change metadata → load → keys back to the saved copy, plus an old checkpoint still loading.

Out of scope here: a checkpoint list and Load checkpoint button in the client (none exists yet). That comes with the Game data editor, or as its own small follow-up.

Scope note (updated 2026-10-16)

At the Game Mode maintainers' wish, world, story and maps are left out of this issue. They already have their own snapshots and checks (e.g. saveGameWorldSnapshot, the world edits layer, the story route), so rewinding them belongs with those systems and would be a follow-up, not part of the allow-list here. Settings, prompt/media preferences, ids/pins/lifecycle, live combat, caches and write ordinals are also not rewound.

Alternatives considered

  • The editor keeps its own backup of the keys it changes. It works for the editor only, and leaves checkpoint load partial for everyone else.
  • Copy every game* key. Simpler, but it would also restore bookkeeping like write ordinals and live combat state, and quietly pick up any future key.

Additional context

  • Suggested by kolacheee while reviewing the Game data editor plan: "good for everyone, since load is currently partial anyway".
  • Code (staging ecd4388): schema packages/server/src/db/schema/checkpoints.ts, checkpoint.service.ts, create POST /api/game/checkpoint and load in game.routes.ts (the load restores gameActiveState only when cp.gameState is set).
  • Prerequisite for the Game data source in the State Editor (#7736 follow-up).

Template check

  • I DID NOT read this template and provide the requested details.
Originally created by @ylli-selmani on GitHub (Oct 16, 2026). Original GitHub issue: https://github.com/Pasta-Devs/Marinara-Engine/issues/7742 Originally assigned to: @ylli-selmani on GitHub. ## What problem does this solve? A Game Mode checkpoint only captures three things: the turn's game-state row, the spatial snapshot, and the Experience/combat engine state (`checkpoints` schema: `snapshotData`, `spatialSnapshotData`, `engineStateData`). Loading one restores those, but in chat metadata it restores only `gameActiveState`, and only for automatic checkpoints. Most of what makes up a running game lives in chat metadata, and checkpoints don't save any of it: party character cards, NPCs, journal, inventory stacks, story, world, maps. So loading a checkpoint today is partial. The game can come back with the old scene and the new party, NPCs and items. This also blocks a real "undo" for hand edits to game data (the Game data source for the State Editor, filed separately), which wants to save a checkpoint before writing. ## Proposed solution - When a checkpoint is created, also store a copy of the game's chat metadata keys from an **allow-list**: the keys a game owns and can rebuild from (cards, NPCs, journal, inventory stacks, party ids, story-arc notes, time/weather/morale, and so on). An allow-list rather than "every `game*` key", so new keys from upcoming Game Mode work are opted in on purpose. - When a checkpoint is loaded, write those keys back through the chat metadata queue (`withChatMetadataPatchQueue`) in one write, alongside the restores it already does. - Older checkpoints without the new field load exactly as they do today. - Small and server-side. A regression covers create → change metadata → load → keys back to the saved copy, plus an old checkpoint still loading. Out of scope here: a checkpoint list and **Load checkpoint** button in the client (none exists yet). That comes with the Game data editor, or as its own small follow-up. ### Scope note (updated 2026-10-16) At the Game Mode maintainers' wish, **world, story and maps are left out of this issue**. They already have their own snapshots and checks (e.g. `saveGameWorldSnapshot`, the world edits layer, the story route), so rewinding them belongs with those systems and would be a follow-up, not part of the allow-list here. Settings, prompt/media preferences, ids/pins/lifecycle, live combat, caches and write ordinals are also not rewound. ## Alternatives considered - **The editor keeps its own backup** of the keys it changes. It works for the editor only, and leaves checkpoint load partial for everyone else. - **Copy every `game*` key.** Simpler, but it would also restore bookkeeping like write ordinals and live combat state, and quietly pick up any future key. ## Additional context - Suggested by kolacheee while reviewing the Game data editor plan: "good for everyone, since load is currently partial anyway". - Code (staging `ecd4388`): schema `packages/server/src/db/schema/checkpoints.ts`, `checkpoint.service.ts`, create `POST /api/game/checkpoint` and load in `game.routes.ts` (the load restores `gameActiveState` only when `cp.gameState` is set). - Prerequisite for the Game data source in the State Editor (#7736 follow-up). ## Template check - [ ] I DID NOT read this template and provide the requested details.
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
Pasta-Devs/Marinara-Engine#4272
No description provided.