Skip to content

Refresh the payload hash on killphrase, insert, and HOTP mutations - #562

Merged
bradleymackey merged 1 commit into
mainfrom
fix/auto-backup-payload-hash
Sep 15, 2026
Merged

bradleymackey merged 1 commit into
mainfrom
fix/auto-backup-payload-hash

Conversation

@bradleymackey

Copy link
Copy Markdown
Member

Problem

AutoBackupServiceImpl.triggerBackupIfNeeded() compares dataModel.currentPayloadHash against configuration.lastBackupHash and skips the backup when they match. Three mutation paths changed the vault without refreshing that hash, so auto-backup silently skipped them:

  • Killphrase deletion (reloadItems()): fired onDataChanged but 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 fired onDataChanged — newly created items never triggered an auto-backup until some later update/delete.
  • incrementCounter(id:) (HOTP): fired onDataChanged without the hash refresh.

update/delete/reorder/tag mutations already did both; these three now match.

Fix

Add await updateCurrentPayloadHash() (and onDataChanged?() 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: notifyDataChanged remains cause-agnostic — nothing records that a change was killphrase-caused.

Tests

  • reloadItems_refreshesPayloadHashWhenKillphraseDeletesItems
  • reloadItems_doesNotRefreshPayloadHashWhenNoKillphraseDeletionOccurs (no per-keystroke export regression)
  • insert_refreshesPayloadHashAndNotifiesDataChanged
  • incrementCounter_refreshesPayloadHash
  • Integration guard: triggerBackupIfNeeded_runsAfterKillphraseDeletionChangesHash — real VaultDataModel wired to AutoBackupServiceImpl; backup taken, killphrase fires, trigger must write a second backup.
  • Updated the exact calledMethods sequence assertions for insert/incrementCounter.

Local verification: VaultFeedTests scheme, all tests passed on iPhone 18 Pro Max / iOS 27.0.

⚠️ Automatic CI is still disabled (#548), so this is local verification only.

🤖 Generated with Claude Code

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>
@bradleymackey
bradleymackey merged commit d36cf20 into main Sep 15, 2026
@bradleymackey
bradleymackey deleted the fix/auto-backup-payload-hash branch September 15, 2026 05:27
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.

1 participant