Skip to content

Auto-update manager: update-available banner + pre-migration DB backup (closes #1321, #1887) - #1889

Merged
mstomar125 merged 1 commit into
mainfrom
issue-1321-auto-update-manager
Aug 1, 2026
Merged

mstomar125 merged 1 commit into
mainfrom
issue-1321-auto-update-manager

Conversation

@mstomar125

Copy link
Copy Markdown
Contributor

Summary

Completes the app-update manager on the merged detection backend (#1881): users get a non-blocking update-available banner, and — the piece a prospective client is blocking on — a pre-migration database backup so a new release can never lose their data.

Update prompt (closes #1321)

  • stores/update-status.svelte.ts: subscribes to the startup update://available event and runs one on-demand check_for_update_command (so a webview reload still learns of an update); showBanner is dismissible per version (localStorage) — dismissing 0.3.0 re-appears at 0.4.0.
  • components/update-banner.svelte (mounted in the app shell): "NodeSpace <latest> is available" with Download (opens the release page — the bundle is unsigned and ships no in-app installer) and Later.

Data safety — no data loss on update (closes #1887)

  • migrations::backup_before_pending_migrations: before any pending migration runs (user_version ∈ (0, LATEST)), WAL-checkpoint then copy the DB file to &lt;db_dir&gt;/backups/&lt;stem&gt;.v&lt;cur&gt;.&lt;ts&gt;.bak, pruned to the last 5. Wired into SqliteStore::new (best-effort — a backup failure is logged, never blocks startup).
  • Completes the three-layer guarantee: (1) the local store lives outside the app bundle → replacing the app never touches data; (2) migrations are transactional → crash-safe; (3) new — a committed bad/destructive migration is recoverable from the pre-release snapshot.

Tests

  • Rust: 3 backup unit tests + an end-to-end SqliteStore::new wiring test (an existing pre-migration db is snapshotted, then migrated to LATEST).
  • Frontend: 7 update-store tests (banner-on-event, per-version dismiss, re-show on newer version, on-demand check, download opens releases).
  • Full pre-push gate green.

Follow-ups

Interactive visual confirmation of the banner defers to a desktop session (requires a live update-available state).

Co-Authored-By: Claude Opus 4.8 [email protected]

closes #1321, #1887)

Completes the app-update manager on the merged detection backend (#1881): a
non-blocking update banner, plus a consistent pre-migration database backup so a
new release can never lose the user's data.

Update prompt (#1321): update-status store subscribes to the startup
update://available event + runs one on-demand check_for_update_command; a
per-version-dismissible UpdateBanner (mounted in the app shell) offers Download
(opens the release page — the bundle is unsigned, no in-app installer) and Later.

Data safety — no data loss on update (#1887): before any pending migration runs
AND when the db holds data, snapshot it with SQLite's consistent hot-backup
(VACUUM INTO) to a backups/ sibling dir, pruned to 5. Wired into SqliteStore::new
(best-effort — logged, never blocks startup). Completes the three-layer guarantee:
data lives outside the app bundle; migrations are transactional (crash-safe); and
now a committed bad/destructive migration is recoverable from the snapshot.

Hardened after adversarial review:
- VACUUM INTO (not checkpoint+file-copy): a transactionally-consistent snapshot
  even if another connection holds the db or has un-checkpointed WAL — the
  previous copy could silently omit WAL data under daemon+CLI concurrency.
- Gate on real data (a populated node table), not user_version==0, so a
  pre-versioning db at version 0 with data is still protected and empty dbs skip.
- Nanosecond + pid in the backup filename so two processes can't collide.
- app-shell cleanup now calls updateStatus.stop() (no leaked listener).

Tests: 6 migration-backup unit tests (data preserved in the snapshot, populated
version-0, empty-skip, current-skip, brand-new-skip) + an end-to-end
SqliteStore::new wiring test; 7 update-store tests. Live-validated against a real
185-node v2 profile: the daemon snapshots (v2/185) then migrates the live db to v3.

Co-Authored-By: Claude Opus 4.8 <[email protected]>
@mstomar125
mstomar125 force-pushed the issue-1321-auto-update-manager branch from 5c01c11 to 730beb2 Compare August 1, 2026 11:28
@mstomar125

Copy link
Copy Markdown
Contributor Author

APPROVE (self-review + adversarial review addressed; data-safety = full rigor).

Adversarial review found real gaps in the first cut — all fixed in 730beb2:

  • M1/m6 (silent partial backup under daemon+CLI concurrency / torn copy): replaced checkpoint+file-copy with VACUUM INTO — a transactionally-consistent hot-backup (verified it works with the sqlite-vec virtual tables).
  • m5 (populated user_version=0 pre-versioning db skipped): gate on real data (populated node table), not the version number; empty dbs still skip.
  • m4 (same-second filename collision): nanos + pid in the backup filename.
  • m7 (leaked listener): app-shell cleanup calls updateStatus.stop().
  • M2/M3 (best-effort-on-error / no restore tooling): conscious v1 decisions — proceed-with-warn (today's migrations are additive; the snapshot is defense-in-depth, and a future destructive migration should gate on backup success), and restore = copy the .bak back (a valid standalone SQLite db; restore tooling is a follow-up).

Live-validated on real data: built the daemon, booted against a sandbox copy of a real profile (v2, 185 nodes) → logged "Backed up database before applying pending migrations from_version=2 to_version=3"; live db migrated to v3, and the .bak snapshot preserved the exact pre-migration state (v2, 185 nodes).

Tests: 6 migration-backup unit + 1 end-to-end SqliteStore::new wiring + 7 update-store; full gate green; both audit checks SUCCESS.

@mstomar125
mstomar125 merged commit 27baef4 into main Aug 1, 2026
2 checks passed
@mstomar125
mstomar125 deleted the issue-1321-auto-update-manager branch August 1, 2026 11:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

1 participant