refactor: decouple legacy boolean privacy storage from PrivacyLevel (#317) - #323
Merged
MaryammAli merged 2 commits intoJul 21, 2026
Merged
Conversation
…lockDash-Studios#317) Separate legacy boolean privacy storage helpers from new PrivacyLevel storage paths for cleaner maintenance and independent evolution. - Create legacy_privacy.rs with backward-compatible boolean helpers (key construction, fallback reads, typed key cleanup) - Refactor privacy.rs to own PrivacyLevel (numeric) API, history, and a migrate_boolean_to_level() conversion function - Remove privacy-level functions from storage.rs (moved to privacy.rs) - Add migration tests for boolean-to-level conversion - Update storage.rs and UPGRADE_SAFETY_GATE_QUICK_REFERENCE.md docs
MaryammAli
approved these changes
Jul 21, 2026
MaryammAli
left a comment
Contributor
There was a problem hiding this comment.
LGTM
nice implementation of the issue
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Decouples legacy boolean
privacy_enabledstorage helpers from the new numericPrivacyLevelstorage paths so both APIs can evolve independently.Changes
legacy_privacy.rs(new) — backward-compatible boolean helpers: key construction, fallback reads from typed → legacy keys, cleanup of legacy keys on writeprivacy.rs— refactored to own thePrivacyLevel(numeric) API, per-account history, and a newmigrate_boolean_to_level()conversion function that mapsfalse → 0,true → 1and cleans up both boolean storage keysstorage.rs— privacy-level functions removed (now inprivacy.rs)lib.rs— updated imports to useprivacy::for level functionsstorage_test.rs— updated importsUPGRADE_SAFETY_GATE_QUICK_REFERENCE.mdandstorage.rsmodule docs updatedMigration
During a rolling upgrade, call
privacy::migrate_boolean_to_level(env, account)for each account with a legacy boolean flag. Both storage paths coexist until migration completes.Tests
All 330 existing tests pass. New tests added:
legacy_privacy::tests— 6 tests for boolean key fallback, precedence, cleanupprivacy::tests— 7 tests for level CRUD, history, and boolean→level migrationCloses #317