Skip to content

fix: reject a stale snapshot after a profile name is reused - #55

Closed
Nardo021 wants to merge 2 commits into
EvanZhu0721:mainfrom
Nardo021:fix/profile-instance-identity
Closed

Nardo021 wants to merge 2 commits into
EvanZhu0721:mainfrom
Nardo021:fix/profile-instance-identity

Conversation

@Nardo021

@Nardo021 Nardo021 commented Nov 3, 2026

Copy link
Copy Markdown
Contributor

Summary

A save from an old snapshot can no longer overwrite a profile that was deleted and created again with the same name, or a collection rebuilt by sbms config reset --all --backup. The save matches the active profile's name, instance id, and revision, and asks the user to reload the configuration when they do not.

Identity

  • A new, copied, or recreated profile receives a new instance id. Rename, content replacement, and plain sbms config reset keep the id and increase the revision.
  • A conflict reports Reload the configuration before saving. The tray shows that error and does not retry the stale draft.
  • Import and export stay standalone AppConfig documents. An import file that contains instance_id is rejected. Replacing an existing profile keeps its id.

Migration

The store file remains config-profiles-v1.json. Valid version 1 collections are migrated once, inside the profile lock, to document version 2. The original file stays unchanged if that write fails, and no snapshot is returned until the new ids are read back. A numeric version greater than 2 is left unchanged. SBMS 2.0.2 cannot read version 2 and returns before writing.

Validation

cargo fmt --all -- --check and cargo clippy --all-targets --target x86_64-pc-windows-msvc --locked -- -D warnings passed. cargo test did not run: link.exe is not installed here.

Test plan

  • cargo test on windows-2022
  • Deleted gaming recreated at revision 1 rejects the old snapshot and keeps the new contents
  • The recreated profile's own snapshot saves
  • A stale revision is still rejected
  • Copy allocates a new instance id and rename keeps it
  • A version 1 collection migrates once and reloads the same ids
  • Recovery rejects snapshots taken before it
  • The damaged-collection recovery tests still pass

Related

Related: #54

This branch is based on #54. Until that PR is in main, this comparison also contains the damaged-collection recovery commit.

Nardo021 and others added 2 commits November 3, 2026 12:11
Plain reset could not load a corrupt config-profiles file, while the UI told users to reset or repair it.

Co-authored-by: Cursor <cursoragent@cursor.com>
A deleted profile rebuilt under the same name kept revision 1, so an old snapshot still passed the save check and overwrote the new profile.

Co-authored-by: Cursor <cursoragent@cursor.com>
@EvanZhu0721 EvanZhu0721 closed this Nov 5, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants