[GH-ISSUE #7783] Checkpoint loads don't restore the State Editor's World Edits #4293

Closed
opened 2026-10-21 06:14:22 +07:00 by bsakaguchi · 1 comment
Owner

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

Originally assigned to: @ylli-selmani on GitHub.

The Game data editor (#7743, #7773) takes a checkpoint before every save, so a bad edit can be undone with Game controls → Checkpoints → Load. Every section it can edit is restored by that load except one: World Edits, the hand-edits layer over a game's world (gameWorld.edits).

Why it isn't covered yet

Checkpoints capture and restore a list of top-level metadata keys (CHECKPOINT_GAME_METADATA_KEYS in packages/server/src/services/game/checkpoint.service.ts). The edits layer isn't a top-level key: it lives inside gameWorld, and #7743 rules that gameWorld itself is never written by hand. Restoring the layer also isn't just putting the value back. PUT /api/game/:chatId/world/edits checks a layer against the world, its towns and its story, and then re-saves the world snapshot (saveGameWorldSnapshot), rolling back if that fails. A load that sets the field directly would leave the snapshot describing the post-edit world.

So until this is done, the World Edits section's description and docs/game/sessions-and-saves.md say a checkpoint load doesn't undo World Edits.

What a fix needs

  • Capture gameWorld.edits with the checkpoint (null for a world without edits; nothing for a game without a world).
  • On load, restore it through the same path as PUT /world/edits: the world lock, the story check, and the snapshot re-save with its rollback. Not a direct metadata write.
  • Decide what a load does when the captured layer no longer fits the story as it stands now (the story is restored by the same load, from the same checkpoint, so restoring both together should fit; worth a regression either way).
  • Remove the "doesn't undo World Edits" notes from the section description and the doc, and update the [docs-i18n] follow-up for docs/game/sessions-and-saves.md (#7774).

Found by CodeRabbit's review of #7773.

Originally created by @ylli-selmani on GitHub (Oct 18, 2026). Original GitHub issue: https://github.com/Pasta-Devs/Marinara-Engine/issues/7783 Originally assigned to: @ylli-selmani on GitHub. The Game data editor (#7743, #7773) takes a checkpoint before every save, so a bad edit can be undone with **Game controls → Checkpoints → Load**. Every section it can edit is restored by that load except one: **World Edits**, the hand-edits layer over a game's world (`gameWorld.edits`). ## Why it isn't covered yet Checkpoints capture and restore a list of top-level metadata keys (`CHECKPOINT_GAME_METADATA_KEYS` in `packages/server/src/services/game/checkpoint.service.ts`). The edits layer isn't a top-level key: it lives inside `gameWorld`, and #7743 rules that `gameWorld` itself is never written by hand. Restoring the layer also isn't just putting the value back. `PUT /api/game/:chatId/world/edits` checks a layer against the world, its towns and its story, and then re-saves the world snapshot (`saveGameWorldSnapshot`), rolling back if that fails. A load that sets the field directly would leave the snapshot describing the post-edit world. So until this is done, the World Edits section's description and `docs/game/sessions-and-saves.md` say a checkpoint load doesn't undo World Edits. ## What a fix needs - Capture `gameWorld.edits` with the checkpoint (null for a world without edits; nothing for a game without a world). - On load, restore it through the same path as `PUT /world/edits`: the world lock, the story check, and the snapshot re-save with its rollback. Not a direct metadata write. - Decide what a load does when the captured layer no longer fits the story as it stands now (the story is restored by the same load, from the same checkpoint, so restoring both together should fit; worth a regression either way). - Remove the "doesn't undo World Edits" notes from the section description and the doc, and update the `[docs-i18n]` follow-up for `docs/game/sessions-and-saves.md` (#7774). Found by CodeRabbit's review of #7773.
bsakaguchi 2026-10-21 06:14:22 +07:00
Author
Owner

@ylli-selmani commented on GitHub (Oct 18, 2026):

One more consequence of this gap, from CodeRabbit's last review of #7773.

Since #7773, a checkpoint captures and restores the story script (gameStory), but still not World Edits. So a load can bring back an older story while keeping newer World Edits. If those edits removed or renamed something the older story names (a place, a person a later edit took away), the restored story no longer fits the world. gameStoryFromMetadata then reads it as null: the load reports success, but the story is silently inactive until someone fixes the script or the edits.

Restoring World Edits together with the story should fix this, since both come from the same checkpoint and so fit each other. When this issue is picked up, it's worth a regression that loads a checkpoint after a later edit took away something the story names, and checks the story is playable afterwards (gameStoryFromMetadata is not null).

<!-- gh-comment-id:6248154599 --> @ylli-selmani commented on GitHub (Oct 18, 2026): One more consequence of this gap, from CodeRabbit's last review of #7773. Since #7773, a checkpoint captures and restores the **story script** (`gameStory`), but still not World Edits. So a load can bring back an older story while keeping newer World Edits. If those edits removed or renamed something the older story names (a place, a person a later edit took away), the restored story no longer fits the world. `gameStoryFromMetadata` then reads it as null: the load reports success, but the story is silently inactive until someone fixes the script or the edits. Restoring World Edits together with the story should fix this, since both come from the same checkpoint and so fit each other. When this issue is picked up, it's worth a regression that loads a checkpoint after a later edit took away something the story names, and checks the story is playable afterwards (`gameStoryFromMetadata` is not null).
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#4293
No description provided.