Skip to content

MnemoSync Phase 0: verified project backups and safe restore - #3

Draft
ehitimum wants to merge 4 commits into
codex/mnemosync-foundationfrom
codex/mnemosync-backup
Draft

ehitimum wants to merge 4 commits into
codex/mnemosync-foundationfrom
codex/mnemosync-backup

Conversation

@ehitimum

@ehitimum ehitimum commented Nov 12, 2026 •

Copy link
Copy Markdown
Owner

Add the first MnemoSync Phase 0 implementation: native local project recovery archives, before any transport or merge can mutate existing projects. Depends on #2 and targets its strategy branch; retarget after #2 merges.

Writers can create a backup in Settings, save a separate ZIP copy, and restore a selected backup. Desktop cards and phone rows use the existing visual conventions. The browser explains native-only availability. Progress, cancellation, errors, retry, duplicate requests and early file-size checks are covered by mounted tests. The App persists the latest dirty chapter first and aborts backup when that save fails.

Native ZIPs contain a versioned SHA-256/length manifest and allowlisted chapters, hierarchy, maps, assets, AI conversations and exports. Credentials, registry and pairing grants are excluded. Extraction rejects corruption, unsafe paths, case collisions, links, unsupported versions and oversized data. Restore verifies in private staging, activates a fresh UUID and visible (restored) name, disconnects the AI configuration, then registers the copy. Originals stay intact. Image attributes and known map asset fields relocate structurally, including Windows paths and HTML entities; prose and graph IDs remain unchanged.

Validation:

  • npm run check: lint, types, all 130 tests and production build pass.
  • npm run test:regression: 41 regressions pass (10 new backup UI/App tests, plus shared runtime and fixed-clock AI history regressions).
  • cargo check passes.
  • cargo test: 56 pass, including 11 new archive tests; 3 existing live-AI tests intentionally ignored. Loopback pairing passes with network permission.
  • cargo clippy -- -D warnings and git diff --check pass.

Draft acceptance gates: saved browser policy blocked visual preview, and installed Windows/real Android picker, off-device copy and rendering still need device verification. Large-project memory/crash testing remains pending. ZIPs are unencrypted, include private AI conversations, and checksums detect corruption rather than authenticate an author; settings explains this. Rust minimum rises to 1.88 for ZIP 9.5. Local E: build-cache hard-link warnings and existing Vite large-chunk warnings are environmental/pre-existing.

No LAN/Drive sync, Smart Merge, SQLite/IndexedDB migration or new device permissions are enabled. Updated architecture, DEVLOG, roadmap, test matrix and handoff memory with the implementation and remaining gates. Integrated #2's Node 24.15 runtime correction and explicit AI undo boundaries after CI exposed inherited startup/timing bugs; the full local frontend suite was rerun afterward.

ehitimum and others added 4 commits November 15, 2026 16:37
Each with a regression (cargo test backup::, backup*.regression.test.tsx):
1. A damaged chapter, a missing image or one outside the project no longer
   blocks the backup: damaged files are archived as-is (listed in the
   manifest) and reported as warnings. Restore stays strict about integrity
   and every chapter that was valid, and restores listed ones byte for byte.
2. Schema 2 archives store images as mnemo-asset:<file> and no sourceRoot
   (no source path or OS user name). Schema 1 archives still restore.
3. Backups are named <project>-<yyyy-mm-dd-hhmm>.zip, listed in the card
   with date, size, Save a copy and a confirmed delete; newest 5 kept.
4. Restore and Save a copy pass file locations; Rust opens the picked file
   (desktop path in the fs scope, Android content URI). No whole archive in
   the web view or memory, and it works with 2.1.1's narrowed fs scope.
5. The backup saves through flushIfDirty (the guarded persistCurrent).
Also: the card explains that restored copies keep AI chats but not the AI
connection. Docs updated.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@ehitimum
ehitimum force-pushed the codex/mnemosync-foundation branch from 8b4977b to 88a04de Compare November 15, 2026 10:48
@ehitimum
ehitimum force-pushed the codex/mnemosync-backup branch from 5096ebb to 3b0c25c Compare November 15, 2026 10:48
@ehitimum

Copy link
Copy Markdown
Owner Author

Changes for the review

This branch was rebased onto the updated PR #2 (which sits on 2.1.1), so the duplicate history and the merge commits are gone. The review fixes are in one commit on top. Each has a regression test (cargo test backup::, regression/backup*.regression.test.tsx).

# Finding Change
1 One bad reference or damaged chapter blocks every backup The export backs up everything valid and returns warnings. A damaged chapter file is archived as-is and listed under damaged in the manifest; images outside the project or missing are counted. Restore stays strict about integrity (sizes, checksums, paths, folder tree, every chapter that was valid) and restores the files the backup itself marked as damaged byte for byte, so the backup still restores. Folder cycles and a damaged project.json still refuse.
2 Absolute source path in the archive Schema 2 stores images as mnemo-asset:<file> (the same form as MnemoSync) and drops sourceRoot. A test asserts the archive contains no source folder. Schema 1 archives still restore (test).
3 Backups accumulate unseen Files are named <project>-<yyyy-mm-dd-hhmm>.zip. The card lists this project's backups (date, size) with "Save a copy…" and a confirmed delete, and says how many belong to other projects. The newest 5 per project are kept. New commands: list_backups, delete_backup. Both name only files directly in the backups folder.
4 Whole archive in memory restore_project_backup({path}) opens the dialog-picked file in Rust (desktop path checked against the fs scope, or an Android content URI) and reads it with bounded per-entry reads. save_backup_copy({source, destination}) copies file to file. This also keeps "Save a copy" working with 2.1.1's narrowed webview file access.
5 Duplicate save path onBackup now uses flushIfDirty (the 2.1.1 persistCurrent, with its guard and error result).

Small points:

  • The card says a restored copy brings AI conversations back but not the AI connection.
  • rust-version 1.88 (ZIP 9.5) is noted here, as asked, for contributors.

Checks

On the rebased stack top (this PR plus #4): npm run check (155 tests, lint, types, build) · cargo test 106 passed · clippy clean.

Not verified: restore and "Save a copy" with Android's document picker on a real phone.

🤖 Generated with Claude Code

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