Files
buzz/desktop/src-tauri
npub1mn7jgtj4w2pd0g0zeuhxsa6jy6p0rewxz4kujt98my82ahfmp72sxjexk7 ba8ca96f3d fix(b1-store): round-7 — rebase, hash-verified recovery, tombstone propagation, tests
True git rebase onto bc9e6528a (current origin/main). Conflict resolution
preserves #3637 (spawn_snapshot, restart-diff) and #4522 (media_raw, deferred
uploads) alongside all B1 content.

Fix 3b (hash-verified file recovery):
- schema.rs: add agents_content_hash / teams_content_hash columns to
  file_commit_phases (schema v3 with ALTER TABLE migration for existing DBs).
- txn.rs: compute SHA-256 of staged payloads and record them in the intent row.
- Recovery now verifies canonical file hash against recorded hash before
  treating absent stage files as 'already completed'. All three missing-stage
  branches (intent/both-absent, intent/teams-absent, first_renamed/teams-absent)
  fail closed unless canonical matches. Only hash-verified canonicals advance
  to committed.

Fix 4 (tombstone/archive propagation):
- agents.rs: tombstone_managed_agent_pending and archive_managed_agent_pending
  use .map_err(|e| ...)?  — failures surface in the delete command's Result.
- personas/mod.rs: same pattern for cascaded agent tombstones and persona tombstone.
- teams.rs: tombstone_team_pending and cascaded persona tombstones propagate.
- agents_retain.rs: retain_managed_agent_pending keeps its outer log-and-swallow
  with an explicit comment documenting the boot-reconcile-recoverable contract
  (Thufir accepted this distinction for updates vs deletes).

Tests:
- store_journal_fix_tests.rs (5 new tests):
  - test_file_recovery_rename_done_phase_not_updated_succeeds: both stages absent,
    canonicals match hashes → advance to committed.
  - test_file_recovery_hash_mismatch_fails_closed: hash mismatch → uncommitted.
  - test_file_recovery_first_renamed_teams_done_hash_verified: teams hash verified.
  - test_file_recovery_first_renamed_teams_absent_no_hash_fails_closed: fail closed.
  - test_boot_recovery_inserts_into_supplied_retention_path_not_flat: scoped path.
- storage_tests.rs (2 new tests): keyring round-trip (Fix 2 coverage).

Co-authored-by: Will Pfleger <pfleger.will@gmail.com>
Signed-off-by: Will Pfleger <pfleger.will@gmail.com>
2026-08-04 18:24:37 -04:00
..