[GH-ISSUE #2317] [Issue]: Manual world-state pins (location/date/weather/etc.) silently revert after one turn — manualOverrides nulled on every fresh-turn snapshot #1145

Closed
opened 2026-10-21 05:27:46 +07:00 by bsakaguchi · 0 comments
Owner

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

Originally assigned to: @Xelvanis on GitHub.

Summary

Severity: High — Data-loss / correctness. When a user manually pins a world-state field (Location, Date, Time, Weather, Temperature) in the tracker, the pin is silently reverted after the next assistant turn. persistTrackerSnapshotForTurn force-sets manualOverrides: null when seeding a fresh-turn snapshot, so the only mechanism that re-pins overrides (mergeWorldStatePatchWithManualOverrides) has nothing to re-apply and the world-state agent's freeform value overwrites the user's correction.

Expected behavior

A manually-pinned world-state field should carry forward across agent snapshots, per the documented contract in src/engine/contracts/types/game-state.ts:36-37 ("JSON object of manually-edited field names -> values. Carried forward across agent snapshots."). The pin should survive subsequent turns until the user clears it.

Actual behavior

In src/engine/generation/tracker-snapshots.ts:505-508:

let snapshot = normalizeGameState(existing ?? options.baseSnapshot ?? chat?.gameState, chatId, target, persona);
if (!existing) {
  snapshot = { ...snapshot, id: "", committed: false, manualOverrides: null, createdAt: nowIso() };
}

For a fresh message/swipe, existing (the snapshot keyed by the new messageId+swipeIndex) is null, so line 507 fires and nulls manualOverrides — even though options.baseSnapshot (the prior committed snapshot) still carried them. manualOverrides was wrongly bundled into the per-turn reset group alongside id: "" and committed: false; unlike those, it must persist.

Trace:

  1. Pin a field → worldStateApi.patch (world-state-api.ts:246-285) stores manualOverrides on the current snapshot and on chat.gameState.
  2. Next turn, selectTrackerSnapshotForGeneration returns the prior snapshot as baseSnapshot (overrides intact).
  3. persistTrackerSnapshotForTurn nulls manualOverrides (line 507).
  4. mergeWorldStatePatchWithManualOverrides (:434) reads snapshot.manualOverrides (now null) and returns the agent patch unmodified.
  5. The world-state agent's location (etc.) value (world-state-agent-result.ts:274-276) overwrites the pin; applyManualOverrides on the read path has nothing to re-apply.

Steps to reproduce

  1. Game/roleplay mode with the world-state tracker agent enabled.
  2. Open the tracker, manually edit (pin) Location (or Date/Time/Weather/Temperature).
  3. Send one more message.
  4. Next assistant turn's tracker shows the agent-generated value; the pin is gone.

Impact area

  • Game mode
  • Roleplay mode
  • Runtime systems: generation, world-state, visuals, tracker, or haptics
  • React-free engine behavior, contracts, agents, or capability ports

Environment

  • Branch or commit: refactor @ b0e5561d
  • Run mode: Tauri desktop (shared engine; also server mode)
  • OS + version: not relevant (static source audit)
  • Node + pnpm versions: not relevant
  • Rust version, if relevant: not relevant
  • Remote Runtime URL configured? not relevant (applies to both)
  • Provider, model, or integration, if relevant: world-state tracker agent

Logs, screenshots, or video

Static source audit; cited to file:line above.

Regression notes

Found via static audit of the refactor branch; not verified against main. Directly contradicts the documented carry-forward contract in game-state.ts:36-37.

Additional context

Suggested fix: drop the manualOverrides: null clause at line 507 — parseManualOverrides/normalizeGameState already normalize the carried value from baseSnapshot — so the prior snapshot's overrides survive for mergeWorldStatePatchWithManualOverrides to re-pin. Keep resetting only id/committed/createdAt for the new turn.

Template check

Please uncheck the box below before submitting so we know you read the template. It is intentionally pre-checked:

  • I DID NOT read this template and provide the requested details.
Originally created by @Romuromylus on GitHub (Jun 5, 2026). Original GitHub issue: https://github.com/Pasta-Devs/Marinara-Engine/issues/2317 Originally assigned to: @Xelvanis on GitHub. ## Summary **Severity: High — Data-loss / correctness.** When a user manually pins a world-state field (Location, Date, Time, Weather, Temperature) in the tracker, the pin is silently reverted after the next assistant turn. `persistTrackerSnapshotForTurn` force-sets `manualOverrides: null` when seeding a fresh-turn snapshot, so the only mechanism that re-pins overrides (`mergeWorldStatePatchWithManualOverrides`) has nothing to re-apply and the world-state agent's freeform value overwrites the user's correction. ## Expected behavior A manually-pinned world-state field should carry forward across agent snapshots, per the documented contract in `src/engine/contracts/types/game-state.ts:36-37` ("JSON object of manually-edited field names -> values. Carried forward across agent snapshots."). The pin should survive subsequent turns until the user clears it. ## Actual behavior In `src/engine/generation/tracker-snapshots.ts:505-508`: ```ts let snapshot = normalizeGameState(existing ?? options.baseSnapshot ?? chat?.gameState, chatId, target, persona); if (!existing) { snapshot = { ...snapshot, id: "", committed: false, manualOverrides: null, createdAt: nowIso() }; } ``` For a fresh message/swipe, `existing` (the snapshot keyed by the new messageId+swipeIndex) is null, so line 507 fires and nulls `manualOverrides` — even though `options.baseSnapshot` (the prior committed snapshot) still carried them. `manualOverrides` was wrongly bundled into the per-turn reset group alongside `id: ""` and `committed: false`; unlike those, it must persist. Trace: 1. Pin a field → `worldStateApi.patch` (`world-state-api.ts:246-285`) stores `manualOverrides` on the current snapshot and on `chat.gameState`. 2. Next turn, `selectTrackerSnapshotForGeneration` returns the prior snapshot as `baseSnapshot` (overrides intact). 3. `persistTrackerSnapshotForTurn` nulls `manualOverrides` (line 507). 4. `mergeWorldStatePatchWithManualOverrides` (`:434`) reads `snapshot.manualOverrides` (now null) and returns the agent patch unmodified. 5. The world-state agent's `location` (etc.) value (`world-state-agent-result.ts:274-276`) overwrites the pin; `applyManualOverrides` on the read path has nothing to re-apply. ## Steps to reproduce 1. Game/roleplay mode with the world-state tracker agent enabled. 2. Open the tracker, manually edit (pin) Location (or Date/Time/Weather/Temperature). 3. Send one more message. 4. Next assistant turn's tracker shows the agent-generated value; the pin is gone. ## Impact area - [x] Game mode - [x] Roleplay mode - [x] Runtime systems: generation, world-state, visuals, tracker, or haptics - [x] React-free engine behavior, contracts, agents, or capability ports ## Environment - Branch or commit: refactor @ b0e5561d - Run mode: Tauri desktop (shared engine; also server mode) - OS + version: not relevant (static source audit) - Node + pnpm versions: not relevant - Rust version, if relevant: not relevant - Remote Runtime URL configured? not relevant (applies to both) - Provider, model, or integration, if relevant: world-state tracker agent ## Logs, screenshots, or video Static source audit; cited to file:line above. ## Regression notes Found via static audit of the refactor branch; not verified against main. Directly contradicts the documented carry-forward contract in `game-state.ts:36-37`. ## Additional context Suggested fix: drop the `manualOverrides: null` clause at line 507 — `parseManualOverrides`/`normalizeGameState` already normalize the carried value from `baseSnapshot` — so the prior snapshot's overrides survive for `mergeWorldStatePatchWithManualOverrides` to re-pin. Keep resetting only `id`/`committed`/`createdAt` for the new turn. ## Template check Please uncheck the box below before submitting so we know you read the template. It is intentionally pre-checked: - [ ] I DID NOT read this template and provide the requested details.
bsakaguchi 2026-10-21 05:27:46 +07:00
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#1145
No description provided.