[GH-ISSUE #1804] [Issue]: Runtime world-state snapshot fallback and tracker upload regressions #883

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

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

Originally assigned to: @cha1latte on GitHub.

Summary

Runtime world-state/tracker has three parity regressions or gaps compared with the legacy implementation:

  • The tracker sidebar can show no tracker data when the latest visible assistant swipe has no tracker snapshot, even if an older committed or latest snapshot exists.
  • Tracker avatar uploads are no longer guarded against stale completions, so an older upload response can overwrite a newer avatar selection.
  • Explicit tracker snapshot patches are not validated against message ownership before save.

Expected behavior

  • Opening the tracker panel on a chat with prior tracker state should fall back to the latest committed or latest available snapshot when the visible swipe lacks its own target snapshot, or intentionally clone/bootstrap that state into the visible target.
  • If multiple avatar uploads are started for the same tracker character, only the newest upload should update the row.
  • A targeted tracker snapshot patch should save only when the target message is the bootstrap target or belongs to the same chat.

Actual behavior

  • src/features/runtime/world-state/api/world-state-api.ts resolves the visible target and returns only the exact snapshot or a matching chat.gameState fallback. If neither matches, src/features/runtime/tracker/components/TrackerDataSidebar.tsx shows No tracker data yet. Legacy GET /:id/game-state used getForGeneration(... preferLatestVisible), which fell back to latest committed or latest available state.
  • src/features/runtime/world-state/hooks/use-tracker-character-avatar-actions.ts uploads and applies the returned avatar path without a per-character stale-response token. Legacy packages/client/src/features/tracker-panel/hooks/use-tracker-mutations.ts used an upload serial and per-character token map.
  • src-tauri/src/commands/storage/game_state_snapshots.rs validates the snapshot chatId but does not verify that a supplied messageId belongs to that chat. Legacy packages/server/src/routes/chats.routes.ts checked the target message chat before updateByMessage.

Steps to reproduce

  1. Open a chat that has existing tracker/world-state data.
  2. Switch to or create a later visible assistant swipe/message that has no tracker snapshot yet.
  3. Open the tracker sidebar.
  4. Observe the panel can show No tracker data yet instead of falling back to prior tracker state.
  5. For avatar upload, start two avatar uploads for the same tracker character in quick succession and let the older request resolve last.
  6. Observe that the older response can still patch the character row.
  7. For target validation, save a tracker snapshot with one chat id and a non-bootstrap message id from another chat; the Rust save path does not reject that ownership mismatch.

Impact area

  • App shell, navigation, startup, or providers
  • Catalog resources
  • Chat mode
  • Roleplay mode
  • Game mode
  • Shared mode UI
  • Runtime systems: generation, world-state, visuals, tracker, or haptics
  • Professor Mari or shell tools
  • React-free engine behavior, contracts, agents, or capability ports
  • Shared API wrapper or remote runtime routing
  • Tauri/Rust storage, assets, LLM, integrations, security, imports, or HTTP runtime
  • Docs, contributor workflow, or templates

Environment

  • Branch or commit: refactor checkout at 6cc9d086
  • Run mode: static code audit; Tauri desktop path affected
  • OS + version: not relevant
  • Node + pnpm versions: not relevant
  • Rust version, if relevant: not checked
  • Remote Runtime URL configured? not relevant
  • Provider, model, or integration, if relevant: not relevant

Logs, screenshots, or video

No logs or screenshots. Evidence is from code-path comparison:

  • Refactor visible-state read: src/features/runtime/world-state/api/world-state-api.ts
  • Refactor empty tracker state: src/features/runtime/tracker/components/TrackerDataSidebar.tsx
  • Refactor avatar upload: src/features/runtime/world-state/hooks/use-tracker-character-avatar-actions.ts
  • Refactor snapshot save: src-tauri/src/commands/storage/game_state_snapshots.rs
  • Legacy snapshot fallback: packages/server/src/services/storage/game-state.storage.ts
  • Legacy chat route target validation: packages/server/src/routes/chats.routes.ts
  • Legacy avatar upload guard: packages/client/src/features/tracker-panel/hooks/use-tracker-mutations.ts

Regression notes

Legacy had fallback behavior for visible world-state reads, a stale-response guard for tracker avatar uploads, and message ownership validation before targeted snapshot updates. The refactor has stronger durable patch queuing and stable tracker row ids, so this issue is limited to the gaps above rather than a full rollback request.

Additional context

Recommended fix order:

  1. Add a visible-snapshot fallback or explicit clone/bootstrap path so existing tracker state does not disappear when the latest visible target lacks a snapshot.
  2. Restore a per-character avatar upload token or abort guard.
  3. Validate target message ownership before tracker_snapshot_save accepts non-bootstrap targets.

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 @Xelvanis on GitHub (Jun 1, 2026). Original GitHub issue: https://github.com/Pasta-Devs/Marinara-Engine/issues/1804 Originally assigned to: @cha1latte on GitHub. ## Summary Runtime world-state/tracker has three parity regressions or gaps compared with the legacy implementation: - The tracker sidebar can show no tracker data when the latest visible assistant swipe has no tracker snapshot, even if an older committed or latest snapshot exists. - Tracker avatar uploads are no longer guarded against stale completions, so an older upload response can overwrite a newer avatar selection. - Explicit tracker snapshot patches are not validated against message ownership before save. ## Expected behavior - Opening the tracker panel on a chat with prior tracker state should fall back to the latest committed or latest available snapshot when the visible swipe lacks its own target snapshot, or intentionally clone/bootstrap that state into the visible target. - If multiple avatar uploads are started for the same tracker character, only the newest upload should update the row. - A targeted tracker snapshot patch should save only when the target message is the bootstrap target or belongs to the same chat. ## Actual behavior - `src/features/runtime/world-state/api/world-state-api.ts` resolves the visible target and returns only the exact snapshot or a matching `chat.gameState` fallback. If neither matches, `src/features/runtime/tracker/components/TrackerDataSidebar.tsx` shows `No tracker data yet.` Legacy `GET /:id/game-state` used `getForGeneration(... preferLatestVisible)`, which fell back to latest committed or latest available state. - `src/features/runtime/world-state/hooks/use-tracker-character-avatar-actions.ts` uploads and applies the returned avatar path without a per-character stale-response token. Legacy `packages/client/src/features/tracker-panel/hooks/use-tracker-mutations.ts` used an upload serial and per-character token map. - `src-tauri/src/commands/storage/game_state_snapshots.rs` validates the snapshot `chatId` but does not verify that a supplied `messageId` belongs to that chat. Legacy `packages/server/src/routes/chats.routes.ts` checked the target message chat before `updateByMessage`. ## Steps to reproduce 1. Open a chat that has existing tracker/world-state data. 2. Switch to or create a later visible assistant swipe/message that has no tracker snapshot yet. 3. Open the tracker sidebar. 4. Observe the panel can show `No tracker data yet` instead of falling back to prior tracker state. 5. For avatar upload, start two avatar uploads for the same tracker character in quick succession and let the older request resolve last. 6. Observe that the older response can still patch the character row. 7. For target validation, save a tracker snapshot with one chat id and a non-bootstrap message id from another chat; the Rust save path does not reject that ownership mismatch. ## Impact area <!-- Check the areas you think are relevant. Leave uncertain items unchecked. --> - [ ] App shell, navigation, startup, or providers - [ ] Catalog resources - [ ] Chat mode - [x] Roleplay mode - [x] Game mode - [x] Shared mode UI - [x] Runtime systems: generation, world-state, visuals, tracker, or haptics - [ ] Professor Mari or shell tools - [x] React-free engine behavior, contracts, agents, or capability ports - [x] Shared API wrapper or remote runtime routing - [x] Tauri/Rust storage, assets, LLM, integrations, security, imports, or HTTP runtime - [ ] Docs, contributor workflow, or templates ## Environment - Branch or commit: refactor checkout at `6cc9d086` - Run mode: static code audit; Tauri desktop path affected - OS + version: not relevant - Node + pnpm versions: not relevant - Rust version, if relevant: not checked - Remote Runtime URL configured? not relevant - Provider, model, or integration, if relevant: not relevant ## Logs, screenshots, or video No logs or screenshots. Evidence is from code-path comparison: - Refactor visible-state read: `src/features/runtime/world-state/api/world-state-api.ts` - Refactor empty tracker state: `src/features/runtime/tracker/components/TrackerDataSidebar.tsx` - Refactor avatar upload: `src/features/runtime/world-state/hooks/use-tracker-character-avatar-actions.ts` - Refactor snapshot save: `src-tauri/src/commands/storage/game_state_snapshots.rs` - Legacy snapshot fallback: `packages/server/src/services/storage/game-state.storage.ts` - Legacy chat route target validation: `packages/server/src/routes/chats.routes.ts` - Legacy avatar upload guard: `packages/client/src/features/tracker-panel/hooks/use-tracker-mutations.ts` ## Regression notes Legacy had fallback behavior for visible world-state reads, a stale-response guard for tracker avatar uploads, and message ownership validation before targeted snapshot updates. The refactor has stronger durable patch queuing and stable tracker row ids, so this issue is limited to the gaps above rather than a full rollback request. ## Additional context Recommended fix order: 1. Add a visible-snapshot fallback or explicit clone/bootstrap path so existing tracker state does not disappear when the latest visible target lacks a snapshot. 2. Restore a per-character avatar upload token or abort guard. 3. Validate target message ownership before `tracker_snapshot_save` accepts non-bootstrap targets. ## 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:22:54 +07:00
Author
Owner

@cha1latte commented on GitHub (Jun 1, 2026):

Fixed in #1838

<!-- gh-comment-id:4595486134 --> @cha1latte commented on GitHub (Jun 1, 2026): Fixed in #1838
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#883
No description provided.