Refresh the payload hash on killphrase, insert, and HOTP mutations - #562
Merged
Merged
Conversation
triggerBackupIfNeeded compares currentPayloadHash against the last backup hash and skips when equal. Killphrase deletion, item insert, and HOTP counter increments all mutated the vault without refreshing the hash, so auto-backup silently skipped them — leaving killed items recoverable from the newest backup and new items unbacked-up until a later mutation. Match the update/delete/reorder ordering on all three. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
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.
Problem
AutoBackupServiceImpl.triggerBackupIfNeeded()comparesdataModel.currentPayloadHashagainstconfiguration.lastBackupHashand skips the backup when they match. Three mutation paths changed the vault without refreshing that hash, so auto-backup silently skipped them:reloadItems()): firedonDataChangedbut never refreshed the hash — so the killed items remained recoverable from the newest auto-backup, undermining the killphrase (MANIFESTO C6/C10 spirit).insert(item:): refreshed neither the hash nor firedonDataChanged— newly created items never triggered an auto-backup until some later update/delete.incrementCounter(id:)(HOTP): firedonDataChangedwithout the hash refresh.update/delete/reorder/tag mutations already did both; these three now match.Fix
Add
await updateCurrentPayloadHash()(andonDataChanged?()for insert) to the three paths, ordered the same as the existing siblings. Plain reloads (every search keystroke) still do not export/recompute — the refresh happens only when a killphrase actually deleted something, and a test pins that.C3 note:
notifyDataChangedremains cause-agnostic — nothing records that a change was killphrase-caused.Tests
reloadItems_refreshesPayloadHashWhenKillphraseDeletesItemsreloadItems_doesNotRefreshPayloadHashWhenNoKillphraseDeletionOccurs(no per-keystroke export regression)insert_refreshesPayloadHashAndNotifiesDataChangedincrementCounter_refreshesPayloadHashtriggerBackupIfNeeded_runsAfterKillphraseDeletionChangesHash— realVaultDataModelwired toAutoBackupServiceImpl; backup taken, killphrase fires, trigger must write a second backup.calledMethodssequence assertions for insert/incrementCounter.Local verification: VaultFeedTests scheme, all tests passed on iPhone 18 Pro Max / iOS 27.0.
🤖 Generated with Claude Code