bug(achievements): XP granted before persistence confirmed — reward lost on crash #56

Closed
opened 2026-05-28 01:48:59 +00:00 by funman300 · 0 comments
Owner

Bug

In achievement_plugin.rs, the flow is:

  1. Add XP to the profile resource
  2. Set reward_granted = true
  3. Trigger save

If step 3 fails (disk full, permission error, etc.), the player loses the XP on the next launch because the profile on disk was never updated, but the in-memory flag was already set.

Affected file

solitaire_engine/src/achievement_plugin.rs

Fix

Invert the order: only set reward_granted = true and update the in-memory XP after the save operation returns Ok. Use the result of the save to decide whether to grant the reward, or implement a two-phase commit (write intent → apply → confirm).

## Bug In `achievement_plugin.rs`, the flow is: 1. Add XP to the profile resource 2. Set `reward_granted = true` 3. Trigger save If step 3 fails (disk full, permission error, etc.), the player loses the XP on the next launch because the profile on disk was never updated, but the in-memory flag was already set. ## Affected file `solitaire_engine/src/achievement_plugin.rs` ## Fix Invert the order: only set `reward_granted = true` and update the in-memory XP **after** the save operation returns `Ok`. Use the result of the save to decide whether to grant the reward, or implement a two-phase commit (write intent → apply → confirm).
funman300 added the bugcorrectness labels 2026-05-28 01:48:59 +00:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: funman300/Ferrous-Solitaire#56