[GH-ISSUE #2619] [Issue]: /game/checkpoint/load drops fieldLocks and manualOverrides when cloning the restored snapshot #1291

Closed
opened 2026-10-21 05:30:47 +07:00 by bsakaguchi · 1 comment
Owner

Originally created by @Romuromylus on GitHub (Jun 18, 2026).
Original GitHub issue: https://github.com/Pasta-Devs/Marinara-Engine/issues/2619

Originally assigned to: @Romuromylus on GitHub.

Summary

Severity: Low — data-loss. POST /game/checkpoint/load clones the restored snapshot into a new committed game-state row but omits fieldLocks and manualOverrides from the clone. After a checkpoint restore the user's locked tracker fields are silently lost, and the next world-state/tracker agent run is free to overwrite fields the user had deliberately locked.

Expected behavior

Restoring a checkpoint should preserve the tracker field locks and manual overrides that were in effect in that snapshot, so the lock feature keeps protecting those fields after a restore.

Actual behavior

// packages/server/src/routes/game.routes.ts (~7705-7719)
await stateStore.create({
  chatId, messageId: restoreMsg.id, swipeIndex: 0,
  date: snapshot.date, /* time/location/weather/temperature/presentCharacters/recentEvents/playerStats/personaStats */
  committed: true,
}); // no fieldLocks in the state object, no manualOverrides second arg

game-state.storage.ts create() persists both state.fieldLocks (~256) and the second-arg manualOverrides (~255), and schema/game-state.ts:29-31 defines both columns. getByMessage returns the raw row, so snapshot.fieldLocks/snapshot.manualOverrides are available at the callsite but dropped. Downstream, generation reads the latest snapshot and runs applyTrackerFieldLocksToGameStatePatch(updates, parseGameStateRow(latest)) (generate.routes.ts:5432-5434,6014) to suppress tracker-agent writes to locked fields. After a restore the new latest row has fieldLocks=null, so the lock filter is a no-op and the next run overwrites the previously-locked fields. updateByMessage then re-propagates the empty locks.

Steps to reproduce

  1. Lock one or more tracker fields (or set a manual override).
  2. Create/auto-save a checkpoint, then load that checkpoint.
  3. Run a turn — observe the previously-locked fields get overwritten by the tracker agent.

Environment

  • Marinara Engine version: staging @ 56f700cd (v2.0.0)
  • Install type: source
  • OS + version: n/a — static source audit
  • Browser or app shell: n/a

Logs, screenshots, or video

Static source audit, cited to file:line above.

Additional context

Fix sketch. Include both when cloning the snapshot in checkpoint/load: parse snapshot.fieldLocks via parseTrackerFieldLocks and pass it on the create() state, and forward the parsed manualOverrides as the second create() argument, so locks/overrides survive a restore.

Regression notes. Not a regression — main's checkpoint/load body is byte-identical and also omits both. Note field_locks is a staging-only column (main's schema/game-state.ts has manual_overrides but no field_locks), so main never had field locks to drop; both branches drop manualOverrides identically.

Template check

  • I DID NOT read this template and provide the requested details.
Originally created by @Romuromylus on GitHub (Jun 18, 2026). Original GitHub issue: https://github.com/Pasta-Devs/Marinara-Engine/issues/2619 Originally assigned to: @Romuromylus on GitHub. ## Summary **Severity: Low — data-loss.** `POST /game/checkpoint/load` clones the restored snapshot into a new committed game-state row but omits `fieldLocks` and `manualOverrides` from the clone. After a checkpoint restore the user's locked tracker fields are silently lost, and the next world-state/tracker agent run is free to overwrite fields the user had deliberately locked. ## Expected behavior Restoring a checkpoint should preserve the tracker field locks and manual overrides that were in effect in that snapshot, so the lock feature keeps protecting those fields after a restore. ## Actual behavior ```ts // packages/server/src/routes/game.routes.ts (~7705-7719) await stateStore.create({ chatId, messageId: restoreMsg.id, swipeIndex: 0, date: snapshot.date, /* time/location/weather/temperature/presentCharacters/recentEvents/playerStats/personaStats */ committed: true, }); // no fieldLocks in the state object, no manualOverrides second arg ``` `game-state.storage.ts` `create()` persists both `state.fieldLocks` (~256) and the second-arg `manualOverrides` (~255), and `schema/game-state.ts:29-31` defines both columns. `getByMessage` returns the raw row, so `snapshot.fieldLocks`/`snapshot.manualOverrides` are available at the callsite but dropped. Downstream, generation reads the latest snapshot and runs `applyTrackerFieldLocksToGameStatePatch(updates, parseGameStateRow(latest))` (`generate.routes.ts:5432-5434,6014`) to suppress tracker-agent writes to locked fields. After a restore the new latest row has `fieldLocks=null`, so the lock filter is a no-op and the next run overwrites the previously-locked fields. `updateByMessage` then re-propagates the empty locks. ## Steps to reproduce 1. Lock one or more tracker fields (or set a manual override). 2. Create/auto-save a checkpoint, then load that checkpoint. 3. Run a turn — observe the previously-locked fields get overwritten by the tracker agent. ## Environment - Marinara Engine version: `staging @ 56f700cd` (v2.0.0) - Install type: source - OS + version: n/a — static source audit - Browser or app shell: n/a ## Logs, screenshots, or video Static source audit, cited to file:line above. ## Additional context **Fix sketch.** Include both when cloning the snapshot in checkpoint/load: parse `snapshot.fieldLocks` via `parseTrackerFieldLocks` and pass it on the `create()` state, and forward the parsed `manualOverrides` as the second `create()` argument, so locks/overrides survive a restore. **Regression notes.** Not a regression — `main`'s checkpoint/load body is byte-identical and also omits both. Note `field_locks` is a staging-only column (`main`'s `schema/game-state.ts` has `manual_overrides` but no `field_locks`), so `main` never had field locks to drop; both branches drop `manualOverrides` identically. ## Template check - [ ] I DID NOT read this template and provide the requested details.
bsakaguchi 2026-10-21 05:30:47 +07:00
  • closed this issue
  • added the
    server
    bug
    labels
Author
Owner

@Romuromylus commented on GitHub (Jun 18, 2026):

Fixed in #2623, merged to staging (e1132e5b). Closing manually since the PR targeted staging rather than the default branch.

<!-- gh-comment-id:4742296929 --> @Romuromylus commented on GitHub (Jun 18, 2026): Fixed in #2623, merged to `staging` (e1132e5b). Closing manually since the PR targeted `staging` rather than the default branch.
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#1291
No description provided.