[PR #1838] [MERGED] Fix tracker world-state snapshot parity #5308

Closed
opened 2026-10-22 04:15:07 +07:00 by bsakaguchi · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/Pasta-Devs/Marinara-Engine/pull/1838
Author: @cha1latte
Created: 6/1/2026
Status: ✅ Merged
Merged: 6/1/2026
Merged by: @cha1latte

Base: refactor ← Head: fix/issue-1804-tracker-world-state-parity


📝 Commits (2)

  • 4ae517a Fix tracker world-state snapshot parity
  • 93b88a1 Refresh PR metadata checks

📊 Changes

4 files changed (+462 additions, -7 deletions)

View changed files

📝 src-tauri/src/commands/storage/game_state_snapshots.rs (+152 -0)
➕ src/features/runtime/world-state/api/world-state-api.test.tsx (+120 -0)
📝 src/features/runtime/world-state/api/world-state-api.ts (+17 -7)
➕ src/features/runtime/world-state/hooks/use-tracker-character-avatar-actions.test.tsx (+173 -0)

📄 Description

Linked issue

Closes #1804

Why this change

Runtime tracker/world-state parity had three regressions from the legacy path:

  • opening the tracker on a visible assistant turn with no exact snapshot could show no tracker data even when older tracker state existed;
  • stale tracker avatar upload completions needed regression coverage so older responses cannot overwrite newer selections;
  • targeted tracker snapshot saves accepted a non-bootstrap messageId without proving it belongs to the target chat.

What changed

  • worldStateApi.get now falls back from a missing exact visible snapshot to synced chat tracker state from another visible assistant target, then to the latest tracker snapshot, stamping the fallback to the currently visible target.
  • Added focused Vitest coverage for visible fallback, latest snapshot fallback, explicit-target negative control, and outside-history negative control.
  • Added focused Vitest coverage proving the current per-character tracker avatar upload token keeps an older completion from overwriting a newer avatar.
  • save_tracker_snapshot now validates non-bootstrap target messages before save, rejecting missing or cross-chat targets while preserving bootstrap saves.
  • Added Rust unit coverage for same-chat target saves, bootstrap saves, missing target rejection, and cross-chat target rejection.

Refactor impact

Primary owner:

Runtime world-state and Rust storage.

Impact areas reviewed:

  • Tracker sidebar/world-state read path.
  • Tracker avatar upload async ordering.
  • Tauri and HTTP runtime tracker snapshot save path via shared Rust storage function.

Boundary notes:

  • Feature runtime code still calls shared API wrappers; no raw Tauri imports were added.
  • Rust storage owns the privileged message-ownership enforcement.
  • Engine contracts are consumed only as types; no React imports were added to engine code.
  • No dependency, schema, auth, prompt-pipeline, import/export, migration, release, or version files changed.

Pressure points touched:

  • TrackerDataSidebar data source through worldStateApi.get.
  • tracker_snapshot_save command implementation through game_state_snapshots::save_tracker_snapshot.

Validation

  • Matching validation command passes locally (for example pnpm typecheck, pnpm build, pnpm check:architecture, pnpm check:docs, or full pnpm check when warranted)
  • Full pnpm check passes before PR push/handoff
  • Human/manual validation completed by contributor or reviewer

Manual verification notes

Codex-run proof:

  • pnpm test src/features/runtime/world-state/api/world-state-api.test.tsx src/features/runtime/world-state/hooks/use-tracker-character-avatar-actions.test.tsx passed.
  • cargo test --manifest-path src-tauri/Cargo.toml game_state_snapshots::tests::save_tracker_snapshot -- --nocapture passed.
  • cargo check --manifest-path src-tauri/Cargo.toml passed.
  • pnpm typecheck passed.
  • pnpm check passed.
  • Marinara proof gate passed locally on the structured verification artifact.
  • Bunny review pass found no blocking issues before PR open.

Manual limitation:

  • I did not capture a reviewer-visible before/after app screenshot for the tracker sidebar. The core fallback and save paths are covered by targeted harness tests and full repo validation, but the PR is intentionally left draft for any desired visual confirmation.

Feature Discoverability

Check exactly one:

  • Updated src/features/shell/discovery/ because this PR adds or materially changes a user-discoverable feature, workflow, setting, mode, panel, import path, agent, media capability, or advanced tool.
  • N/A because this PR is only a bugfix, refactor, test, docs, internal wiring, visual polish, copy edit, or compatibility fix and does not add a new thing users need to find.

Reason:

  • This is a parity bugfix for existing tracker/world-state behavior and does not add a new discoverable feature.

Docs and release impact

  • No docs changes needed
  • Updated README.md
  • Updated CONTRIBUTING.md
  • Updated docs/developer/
  • Updated repo skills or AGENTS.md
  • Confirmed this PR does not restore old staging/package-workspace/release claims

No docs or release metadata changes were needed for this runtime/storage bugfix.

UI evidence (if applicable)

No screenshot captured. This PR is kept draft; the changed behavior is covered by focused runtime/storage tests and full pnpm check.


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/Pasta-Devs/Marinara-Engine/pull/1838 **Author:** [@cha1latte](https://github.com/cha1latte) **Created:** 6/1/2026 **Status:** ✅ Merged **Merged:** 6/1/2026 **Merged by:** [@cha1latte](https://github.com/cha1latte) **Base:** `refactor` ← **Head:** `fix/issue-1804-tracker-world-state-parity` --- ### 📝 Commits (2) - [`4ae517a`](https://github.com/Pasta-Devs/Marinara-Engine/commit/4ae517a8bc472eb2e24add4aca0edd11dc5617bd) Fix tracker world-state snapshot parity - [`93b88a1`](https://github.com/Pasta-Devs/Marinara-Engine/commit/93b88a1531fce101eb7d4f41d1730b600f059858) Refresh PR metadata checks ### 📊 Changes **4 files changed** (+462 additions, -7 deletions) <details> <summary>View changed files</summary> 📝 `src-tauri/src/commands/storage/game_state_snapshots.rs` (+152 -0) ➕ `src/features/runtime/world-state/api/world-state-api.test.tsx` (+120 -0) 📝 `src/features/runtime/world-state/api/world-state-api.ts` (+17 -7) ➕ `src/features/runtime/world-state/hooks/use-tracker-character-avatar-actions.test.tsx` (+173 -0) </details> ### 📄 Description <!-- Target branch: `refactor`. Change the base to `refactor` before submitting unless a maintainer explicitly asked for another base. --> <!-- Keep all checkboxes unchecked until a human has actually verified them. --> ## Linked issue Closes #1804 ## Why this change Runtime tracker/world-state parity had three regressions from the legacy path: - opening the tracker on a visible assistant turn with no exact snapshot could show no tracker data even when older tracker state existed; - stale tracker avatar upload completions needed regression coverage so older responses cannot overwrite newer selections; - targeted tracker snapshot saves accepted a non-bootstrap `messageId` without proving it belongs to the target chat. ## What changed - `worldStateApi.get` now falls back from a missing exact visible snapshot to synced chat tracker state from another visible assistant target, then to the latest tracker snapshot, stamping the fallback to the currently visible target. - Added focused Vitest coverage for visible fallback, latest snapshot fallback, explicit-target negative control, and outside-history negative control. - Added focused Vitest coverage proving the current per-character tracker avatar upload token keeps an older completion from overwriting a newer avatar. - `save_tracker_snapshot` now validates non-bootstrap target messages before save, rejecting missing or cross-chat targets while preserving bootstrap saves. - Added Rust unit coverage for same-chat target saves, bootstrap saves, missing target rejection, and cross-chat target rejection. ## Refactor impact Primary owner: Runtime world-state and Rust storage. Impact areas reviewed: - Tracker sidebar/world-state read path. - Tracker avatar upload async ordering. - Tauri and HTTP runtime tracker snapshot save path via shared Rust storage function. Boundary notes: - Feature runtime code still calls shared API wrappers; no raw Tauri imports were added. - Rust storage owns the privileged message-ownership enforcement. - Engine contracts are consumed only as types; no React imports were added to engine code. - No dependency, schema, auth, prompt-pipeline, import/export, migration, release, or version files changed. Pressure points touched: - TrackerDataSidebar data source through `worldStateApi.get`. - `tracker_snapshot_save` command implementation through `game_state_snapshots::save_tracker_snapshot`. ## Validation - [ ] Matching validation command passes locally (for example `pnpm typecheck`, `pnpm build`, `pnpm check:architecture`, `pnpm check:docs`, or full `pnpm check` when warranted) - [ ] Full `pnpm check` passes before PR push/handoff - [ ] Human/manual validation completed by contributor or reviewer ### Manual verification notes Codex-run proof: - `pnpm test src/features/runtime/world-state/api/world-state-api.test.tsx src/features/runtime/world-state/hooks/use-tracker-character-avatar-actions.test.tsx` passed. - `cargo test --manifest-path src-tauri/Cargo.toml game_state_snapshots::tests::save_tracker_snapshot -- --nocapture` passed. - `cargo check --manifest-path src-tauri/Cargo.toml` passed. - `pnpm typecheck` passed. - `pnpm check` passed. - Marinara proof gate passed locally on the structured verification artifact. - Bunny review pass found no blocking issues before PR open. Manual limitation: - I did not capture a reviewer-visible before/after app screenshot for the tracker sidebar. The core fallback and save paths are covered by targeted harness tests and full repo validation, but the PR is intentionally left draft for any desired visual confirmation. ## Feature Discoverability Check exactly one: - [ ] Updated `src/features/shell/discovery/` because this PR adds or materially changes a user-discoverable feature, workflow, setting, mode, panel, import path, agent, media capability, or advanced tool. - [x] N/A because this PR is only a bugfix, refactor, test, docs, internal wiring, visual polish, copy edit, or compatibility fix and does not add a new thing users need to find. Reason: - This is a parity bugfix for existing tracker/world-state behavior and does not add a new discoverable feature. ## Docs and release impact - [ ] No docs changes needed - [ ] Updated `README.md` - [ ] Updated `CONTRIBUTING.md` - [ ] Updated `docs/developer/` - [ ] Updated repo skills or `AGENTS.md` - [ ] Confirmed this PR does not restore old staging/package-workspace/release claims No docs or release metadata changes were needed for this runtime/storage bugfix. ## UI evidence (if applicable) No screenshot captured. This PR is kept draft; the changed behavior is covered by focused runtime/storage tests and full `pnpm check`. --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
bsakaguchi 2026-10-22 04:15:07 +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#5308
No description provided.