Repository navigation
MnemoSync Phase 0: verified project backups and safe restore - #3
Merged
Merged
Conversation
This was referenced Nov 12, 2026
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>
Add the local sync core used by every transport: per-entity immutable revisions (project, folder, chapter metadata, chapter text, assets) with content-derived ids, SQLite WAL state outside project folders, disk scan change capture, causal fast-forward, deterministic field merges, preserved text conflicts, edit-beats-delete, staged updates for the open chapter, frozen batches for crash-safe publishing, and portable asset references. Fix backup restore leaving fantasy-map "My Imports" paths pointing at the original project (regression tests in backup/tests.rs). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Desktop sign-in uses the loopback redirect with PKCE (S256) in the writer's browser and only the drive.appdata scope; the refresh token lives in the OS secret store, access tokens in memory. The OAuth client comes from the environment or a git-ignored .env.local at build time. The Drive transport publishes gzip blobs before immutable batch files in appDataFolder, finds new batches through the changes feed with a listing fallback, ignores duplicate uploads and malformed files, and classifies 401/403/429/5xx/quota errors without discarding queued work. A background worker syncs enabled projects after saves (debounced) and on a poll with backoff, refuses silent Google account switches, and exposes status, download, conflict and staged-update commands. Also write imported images atomically so a crash or a sync scan never sees a half-written asset, and stop syncing a project that leaves the library. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…lict review Settings gains a Google Drive card (desktop and phone variants) with sign-in, per-project sync toggles, downloads from other devices and sync notes; a quiet status pill appears only for synced projects. The open chapter is reported to the backend so its text is never replaced under the editor: a banner offers to load the newer version (after saving), and parallel edits open a side-by-side review that keeps the other version as its own chapter by default. Remote renames and moves merge into the open chapter without dropping unsaved typing. Regression suites cover the settings flows, banner, review (inert previews) and the App save boundary. Widen the AI suite's streamed-response waits and cap Vitest at half the cores: App-mounting suites timed out on busy desktops. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Add the inline google-auth Android plugin (Google Play services AuthorizationClient for drive.appdata, no refresh token stored) with its ACL permission, and silent re-authorization when the short-lived token lapses. Fix two sync bugs found in review: turning a project's sync off and on reset its batch counter so new batches reused published numbers, and re-enabling under another Google account published nothing (both covered by engine regressions). Report needs-auth after signing out while projects stay bound to the account. Mark desktop-only pairing helpers so Android builds are warning-free. Document the design as built, Google Cloud setup and open items in MNEMOSYNC_DRIVE.md and update architecture, devlog, roadmap, testing, threat model, test matrix and the MnemoSync handoff. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…Drive test The first live setup showed a raw "403: accessNotConfigured" when the Cloud project lacked the Drive API; it now says what to enable. A retry after such a failure reuses the stored grant instead of repeating the browser consent. Add an ignored live test (cargo test live_drive -- --ignored) that runs two engines against the real appDataFolder under a throwaway project and cleans up. Passed against the writer's own Cloud project. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Data loss (each with an engine regression): - An unreadable chapter or a missing documents folder no longer becomes a delete on every device; the last good state is kept with one note. - Engine writes re-check the file under project::files_lock (shared with the save commands) and capture a newer save first, so it merges or conflicts. - Conflict review and resolve scan first, so the latest typing is a version. - Delete + two different edits keeps both edits as a conflict. - Remote deletes and replaced damaged copies go to <project>/sync-trash/. Sign-in and Drive client: - A stray loopback request no longer ends the sign-in. - Retrying Connect keeps a valid grant unless Google rejects it. - Drive sync is off on Linux (no keyring backend) and says why. - Read the newer error shape (SERVICE_DISABLED); shorter text in release. - Expired change cursor detected by status; catalogue date kept current. Smaller: id validation in sync commands, Android device model name, Drive space used in settings, "Back up, then sync", Beta label, stricter live-test cleanup. Docs and test matrix updated. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
ehitimum
force-pushed
the
codex/mnemosync-foundation
branch
from
November 15, 2026 10:48
8b4977b to
88a04de
Compare
ehitimum
force-pushed
the
codex/mnemosync-backup
branch
from
November 15, 2026 10:48
5096ebb to
3b0c25c
Compare
Owner
Author
Changes for the reviewThis 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 (
Small points:
ChecksOn the rebased stack top (this PR plus #4): Not verified: restore and "Save a copy" with Android's document picker on a real phone. 🤖 Generated with Claude Code |
MnemoSync: Google Drive sync on a shared sync engine
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.
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:
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.