Skip to content

Fix snapshot personaStats startup migration#1240

Merged
Xelvanis merged 1 commit into
refactorfrom
fix/persona-stats-startup-migration
May 26, 2026
Merged

Fix snapshot personaStats startup migration#1240
Xelvanis merged 1 commit into
refactorfrom
fix/persona-stats-startup-migration

Conversation

@Xelvanis
Copy link
Copy Markdown
Collaborator

@Xelvanis Xelvanis commented May 26, 2026

Linked issue

Closes #1239

Why this change

  • Existing refactor save data can contain game-state-snapshots.personaStats as an array, matching tracker snapshot readers/writers.
  • Startup storage migration was treating snapshot personaStats as object/null, so valid saves could fail app initialization with invalid_input.
  • A malformed old snapshot row should not brick startup when the frontend already treats non-array snapshot personaStats as null.

What changed

  • Normalize game-state-snapshots.personaStats as a nullable JSON array while keeping playerStats and metadata as nullable objects.
  • Add startup-only repair for malformed snapshot personaStats, coercing bad non-array values to null before strict storage normalization runs.
  • Add Rust coverage for valid array/null/empty snapshot values, strict API rejection of malformed snapshot values, and startup repair of malformed saved rows.

Refactor impact

Primary owner:

Rust storage startup migration and storage shape normalization.

Impact areas reviewed:

  • Tauri AppState startup storage migration
  • Shared Rust storage normalization contracts
  • Tracker snapshot storage writer/reader shape
  • Roleplay/Game world-state consumers that expect snapshot personaStats as array/null

Boundary notes:

  • Rust storage-only change; no React, Zustand, Tauri JS API, feature internals, or engine imports added.
  • Strict create/update validation stays in the shared storage normalizer; startup repair is limited to persisted old game-state-snapshots rows.

Pressure points touched:

  • src-tauri/src/state.rs startup migration
  • src-tauri/src/commands/storage/shared.rs typed JSON normalization

Validation

  • pnpm check passes locally
  • pnpm typecheck passes locally
  • pnpm build passes locally
  • pnpm check:architecture passes locally
  • pnpm check:docs passes locally
  • cargo check --manifest-path src-tauri/Cargo.toml --workspace passes locally
  • Rust clippy/tests were run for Rust behavior changes
  • Browser or Tauri app manual verification completed
  • Playwright, screenshot, or recording evidence added for UI changes
  • Remote runtime smoke checked when relevant

Manual verification notes

  • cargo test --manifest-path src-tauri\Cargo.toml persona_stats passed.
  • cargo check --manifest-path src-tauri\Cargo.toml passed.
  • git diff --check origin/refactor...HEAD passed.
  • rustfmt --edition 2021 --check src-tauri/src/state.rs passed.
  • Tauri desktop was launched with local test save data; the app opened and loaded existing roleplay/tracker data. QA process was closed afterward.
  • Known existing gap: cargo fmt --manifest-path src-tauri\Cargo.toml --check still fails repo-wide on unrelated pre-existing Rust formatting drift, so this PR avoids a broad formatting-only sweep.

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 changes needed: this is a storage migration compatibility fix with no user-facing settings or documented workflow changes.

UI evidence

No UI screenshots added. The relevant proof is startup/data migration behavior plus Rust storage tests.

Summary by CodeRabbit

  • Bug Fixes

    • Enhanced game state snapshot data handling with improved validation for player statistics and metadata. Malformed data values are now properly converted to null instead of potentially causing errors.
  • Tests

    • Added tests for game state snapshot data normalization and repair scenarios.

Review Change Stack

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented May 26, 2026

Important

Review skipped

Auto reviews are disabled on base/target branches other than the default branch.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 1d90f0d4-d75d-4a11-88b7-3bc8e8e6bbe4

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • ✅ Review completed - (🔄 Check again to review again)
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/persona-stats-startup-migration

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@github-actions github-actions Bot added the bugfix Bug fix label May 26, 2026
@Xelvanis Xelvanis merged commit a0cd7e9 into refactor May 26, 2026
22 of 26 checks passed
@Xelvanis Xelvanis deleted the fix/persona-stats-startup-migration branch May 26, 2026 04:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bugfix Bug fix

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant