fix(backup): include projects.db and kanban.db in pre-update snapshot - #52930
0xDevNinja wants to merge 1 commit into
Conversation
The pre-update quick snapshot (_QUICK_STATE_FILES) backs up state.db, config.yaml, auth.json and the pairing stores, but not projects.db or kanban.db. Both are per-profile, user-created SQLite stores that live outside the git checkout. When a desktop upgrade restarts the backend and projects_db.connect()/kanban runs CREATE TABLE IF NOT EXISTS against a missing or zeroed file, every project, folder mapping, active-project pointer and board row is silently destroyed with no recovery path. Add both to _QUICK_STATE_FILES so they are preserved alongside state.db. projects.db always resolves under $HERMES_HOME; kanban.db sits at the shared root for the default profile (snapshot is HERMES_HOME-relative, so non-root profiles skip it best-effort, same as the pairing entries). Fixes NousResearch#52889
|
Verified the premise against current |
…n pre-update snapshot (#52889) projects.db (per-profile project store) and kanban.db were missing from _QUICK_STATE_FILES, so the pre-update quick snapshot never backed them up. On a desktop upgrade, when the update flow removes/replaces the file and the post-update schema-init re-creates an empty one, all user-created projects, folder mappings, the active-project pointer, kanban board bindings, and tasks vanish silently — no error. Add the per-profile user-created stores to the snapshot set: - projects.db — project store - response_store.db — gateway conversation history / tool payloads (WAL) - memory_store.db — holographic memory facts/entities (WAL) - verification_evidence.db — agent verification audit trail - kanban.db — default board (back-compat <root>/kanban.db) - kanban/boards — non-default boards (<root>/kanban/boards/<slug>/kanban.db + metadata); workspaces/ and attachments/ subtrees are skipped as large + regenerable. Also: the directory-branch of create_quick_snapshot now routes *.db through the WAL-safe _safe_copy_db (SQLite backup() API), matching the top-level file path — previously a non-default board DB with an open WAL could be copied inconsistently. Salvaged from #52930 by @0xDevNinja (authorship preserved via cherry-pick). On top of the original (which covered only projects.db + the default kanban.db), this adds: non-default-board coverage, the three sibling per-profile DBs that meet the same upgrade-wipe criteria, WAL-safe directory copies, and a workspaces/attachments skip to avoid snapshot bloat (×20 retained). 8 tests, all mutation-verified; E2E verified snapshot→wipe→restore preserves all six store types on the real code path. Closes #52889. Supersedes #52930.
|
Closing in favor of #52990, which salvages this fix onto current |
…n pre-update snapshot (NousResearch#52889) projects.db (per-profile project store) and kanban.db were missing from _QUICK_STATE_FILES, so the pre-update quick snapshot never backed them up. On a desktop upgrade, when the update flow removes/replaces the file and the post-update schema-init re-creates an empty one, all user-created projects, folder mappings, the active-project pointer, kanban board bindings, and tasks vanish silently — no error. Add the per-profile user-created stores to the snapshot set: - projects.db — project store - response_store.db — gateway conversation history / tool payloads (WAL) - memory_store.db — holographic memory facts/entities (WAL) - verification_evidence.db — agent verification audit trail - kanban.db — default board (back-compat <root>/kanban.db) - kanban/boards — non-default boards (<root>/kanban/boards/<slug>/kanban.db + metadata); workspaces/ and attachments/ subtrees are skipped as large + regenerable. Also: the directory-branch of create_quick_snapshot now routes *.db through the WAL-safe _safe_copy_db (SQLite backup() API), matching the top-level file path — previously a non-default board DB with an open WAL could be copied inconsistently. Salvaged from NousResearch#52930 by @0xDevNinja (authorship preserved via cherry-pick). On top of the original (which covered only projects.db + the default kanban.db), this adds: non-default-board coverage, the three sibling per-profile DBs that meet the same upgrade-wipe criteria, WAL-safe directory copies, and a workspaces/attachments skip to avoid snapshot bloat (×20 retained). 8 tests, all mutation-verified; E2E verified snapshot→wipe→restore preserves all six store types on the real code path. Closes NousResearch#52889. Supersedes NousResearch#52930.
…n pre-update snapshot (NousResearch#52889) projects.db (per-profile project store) and kanban.db were missing from _QUICK_STATE_FILES, so the pre-update quick snapshot never backed them up. On a desktop upgrade, when the update flow removes/replaces the file and the post-update schema-init re-creates an empty one, all user-created projects, folder mappings, the active-project pointer, kanban board bindings, and tasks vanish silently — no error. Add the per-profile user-created stores to the snapshot set: - projects.db — project store - response_store.db — gateway conversation history / tool payloads (WAL) - memory_store.db — holographic memory facts/entities (WAL) - verification_evidence.db — agent verification audit trail - kanban.db — default board (back-compat <root>/kanban.db) - kanban/boards — non-default boards (<root>/kanban/boards/<slug>/kanban.db + metadata); workspaces/ and attachments/ subtrees are skipped as large + regenerable. Also: the directory-branch of create_quick_snapshot now routes *.db through the WAL-safe _safe_copy_db (SQLite backup() API), matching the top-level file path — previously a non-default board DB with an open WAL could be copied inconsistently. Salvaged from NousResearch#52930 by @0xDevNinja (authorship preserved via cherry-pick). On top of the original (which covered only projects.db + the default kanban.db), this adds: non-default-board coverage, the three sibling per-profile DBs that meet the same upgrade-wipe criteria, WAL-safe directory copies, and a workspaces/attachments skip to avoid snapshot bloat (×20 retained). 8 tests, all mutation-verified; E2E verified snapshot→wipe→restore preserves all six store types on the real code path. Closes NousResearch#52889. Supersedes NousResearch#52930.
…n pre-update snapshot (NousResearch#52889) projects.db (per-profile project store) and kanban.db were missing from _QUICK_STATE_FILES, so the pre-update quick snapshot never backed them up. On a desktop upgrade, when the update flow removes/replaces the file and the post-update schema-init re-creates an empty one, all user-created projects, folder mappings, the active-project pointer, kanban board bindings, and tasks vanish silently — no error. Add the per-profile user-created stores to the snapshot set: - projects.db — project store - response_store.db — gateway conversation history / tool payloads (WAL) - memory_store.db — holographic memory facts/entities (WAL) - verification_evidence.db — agent verification audit trail - kanban.db — default board (back-compat <root>/kanban.db) - kanban/boards — non-default boards (<root>/kanban/boards/<slug>/kanban.db + metadata); workspaces/ and attachments/ subtrees are skipped as large + regenerable. Also: the directory-branch of create_quick_snapshot now routes *.db through the WAL-safe _safe_copy_db (SQLite backup() API), matching the top-level file path — previously a non-default board DB with an open WAL could be copied inconsistently. Salvaged from NousResearch#52930 by @0xDevNinja (authorship preserved via cherry-pick). On top of the original (which covered only projects.db + the default kanban.db), this adds: non-default-board coverage, the three sibling per-profile DBs that meet the same upgrade-wipe criteria, WAL-safe directory copies, and a workspaces/attachments skip to avoid snapshot bloat (×20 retained). 8 tests, all mutation-verified; E2E verified snapshot→wipe→restore preserves all six store types on the real code path. Closes NousResearch#52889. Supersedes NousResearch#52930.
…n pre-update snapshot (NousResearch#52889) projects.db (per-profile project store) and kanban.db were missing from _QUICK_STATE_FILES, so the pre-update quick snapshot never backed them up. On a desktop upgrade, when the update flow removes/replaces the file and the post-update schema-init re-creates an empty one, all user-created projects, folder mappings, the active-project pointer, kanban board bindings, and tasks vanish silently — no error. Add the per-profile user-created stores to the snapshot set: - projects.db — project store - response_store.db — gateway conversation history / tool payloads (WAL) - memory_store.db — holographic memory facts/entities (WAL) - verification_evidence.db — agent verification audit trail - kanban.db — default board (back-compat <root>/kanban.db) - kanban/boards — non-default boards (<root>/kanban/boards/<slug>/kanban.db + metadata); workspaces/ and attachments/ subtrees are skipped as large + regenerable. Also: the directory-branch of create_quick_snapshot now routes *.db through the WAL-safe _safe_copy_db (SQLite backup() API), matching the top-level file path — previously a non-default board DB with an open WAL could be copied inconsistently. Salvaged from NousResearch#52930 by @0xDevNinja (authorship preserved via cherry-pick). On top of the original (which covered only projects.db + the default kanban.db), this adds: non-default-board coverage, the three sibling per-profile DBs that meet the same upgrade-wipe criteria, WAL-safe directory copies, and a workspaces/attachments skip to avoid snapshot bloat (×20 retained). 8 tests, all mutation-verified; E2E verified snapshot→wipe→restore preserves all six store types on the real code path. Closes NousResearch#52889. Supersedes NousResearch#52930.
…n pre-update snapshot (NousResearch#52889) projects.db (per-profile project store) and kanban.db were missing from _QUICK_STATE_FILES, so the pre-update quick snapshot never backed them up. On a desktop upgrade, when the update flow removes/replaces the file and the post-update schema-init re-creates an empty one, all user-created projects, folder mappings, the active-project pointer, kanban board bindings, and tasks vanish silently — no error. Add the per-profile user-created stores to the snapshot set: - projects.db — project store - response_store.db — gateway conversation history / tool payloads (WAL) - memory_store.db — holographic memory facts/entities (WAL) - verification_evidence.db — agent verification audit trail - kanban.db — default board (back-compat <root>/kanban.db) - kanban/boards — non-default boards (<root>/kanban/boards/<slug>/kanban.db + metadata); workspaces/ and attachments/ subtrees are skipped as large + regenerable. Also: the directory-branch of create_quick_snapshot now routes *.db through the WAL-safe _safe_copy_db (SQLite backup() API), matching the top-level file path — previously a non-default board DB with an open WAL could be copied inconsistently. Salvaged from NousResearch#52930 by @0xDevNinja (authorship preserved via cherry-pick). On top of the original (which covered only projects.db + the default kanban.db), this adds: non-default-board coverage, the three sibling per-profile DBs that meet the same upgrade-wipe criteria, WAL-safe directory copies, and a workspaces/attachments skip to avoid snapshot bloat (×20 retained). 8 tests, all mutation-verified; E2E verified snapshot→wipe→restore preserves all six store types on the real code path. Closes NousResearch#52889. Supersedes NousResearch#52930.
…n pre-update snapshot (NousResearch#52889) projects.db (per-profile project store) and kanban.db were missing from _QUICK_STATE_FILES, so the pre-update quick snapshot never backed them up. On a desktop upgrade, when the update flow removes/replaces the file and the post-update schema-init re-creates an empty one, all user-created projects, folder mappings, the active-project pointer, kanban board bindings, and tasks vanish silently — no error. Add the per-profile user-created stores to the snapshot set: - projects.db — project store - response_store.db — gateway conversation history / tool payloads (WAL) - memory_store.db — holographic memory facts/entities (WAL) - verification_evidence.db — agent verification audit trail - kanban.db — default board (back-compat <root>/kanban.db) - kanban/boards — non-default boards (<root>/kanban/boards/<slug>/kanban.db + metadata); workspaces/ and attachments/ subtrees are skipped as large + regenerable. Also: the directory-branch of create_quick_snapshot now routes *.db through the WAL-safe _safe_copy_db (SQLite backup() API), matching the top-level file path — previously a non-default board DB with an open WAL could be copied inconsistently. Salvaged from NousResearch#52930 by @0xDevNinja (authorship preserved via cherry-pick). On top of the original (which covered only projects.db + the default kanban.db), this adds: non-default-board coverage, the three sibling per-profile DBs that meet the same upgrade-wipe criteria, WAL-safe directory copies, and a workspaces/attachments skip to avoid snapshot bloat (×20 retained). 8 tests, all mutation-verified; E2E verified snapshot→wipe→restore preserves all six store types on the real code path. Closes NousResearch#52889. Supersedes NousResearch#52930.
…n pre-update snapshot (NousResearch#52889) projects.db (per-profile project store) and kanban.db were missing from _QUICK_STATE_FILES, so the pre-update quick snapshot never backed them up. On a desktop upgrade, when the update flow removes/replaces the file and the post-update schema-init re-creates an empty one, all user-created projects, folder mappings, the active-project pointer, kanban board bindings, and tasks vanish silently — no error. Add the per-profile user-created stores to the snapshot set: - projects.db — project store - response_store.db — gateway conversation history / tool payloads (WAL) - memory_store.db — holographic memory facts/entities (WAL) - verification_evidence.db — agent verification audit trail - kanban.db — default board (back-compat <root>/kanban.db) - kanban/boards — non-default boards (<root>/kanban/boards/<slug>/kanban.db + metadata); workspaces/ and attachments/ subtrees are skipped as large + regenerable. Also: the directory-branch of create_quick_snapshot now routes *.db through the WAL-safe _safe_copy_db (SQLite backup() API), matching the top-level file path — previously a non-default board DB with an open WAL could be copied inconsistently. Salvaged from NousResearch#52930 by @0xDevNinja (authorship preserved via cherry-pick). On top of the original (which covered only projects.db + the default kanban.db), this adds: non-default-board coverage, the three sibling per-profile DBs that meet the same upgrade-wipe criteria, WAL-safe directory copies, and a workspaces/attachments skip to avoid snapshot bloat (×20 retained). 8 tests, all mutation-verified; E2E verified snapshot→wipe→restore preserves all six store types on the real code path. Closes NousResearch#52889. Supersedes NousResearch#52930.
What does this PR do?
The pre-update quick snapshot (
_QUICK_STATE_FILESinhermes_cli/backup.py) preservesstate.db,config.yaml,auth.jsonand the pairing stores beforehermes updatepulls, but it never listedprojects.dborkanban.db. Both are per-profile, user-created SQLite stores that live outside the git checkout.When a desktop upgrade restarts the backend and
projects_db.connect()(or the kanban store) runsCREATE TABLE IF NOT EXISTSagainst a missing or zeroed file, every project, folder mapping, the active-project pointer and all board rows are silently re-created empty — with no backup and no recovery path. Every upgrade destroys all projects.This adds both files to
_QUICK_STATE_FILESso they are snapshotted alongsidestate.dband restored automatically if anything goes wrong, exactly as the issue suggests.Related Issue
Fixes #52889
Type of Change
Changes Made
hermes_cli/backup.py: add"projects.db"and"kanban.db"to_QUICK_STATE_FILES. The existing.dbbranch already routes them through_safe_copy_db(WAL-safe copy), so no other code path changes.tests/hermes_cli/test_backup.py: addTestQuickSnapshotProjectsKanban— asserts both files are in the manifest set, both get snapshotted (with row-level verification forprojects.db), and an emptiedprojects.dbis restored from the snapshot.Implementation note
The snapshot list is resolved relative to
HERMES_HOME(src = home / rel).projects.dbalways resolves to$HERMES_HOME/projects.db(perprojects_db.projects_db_path), so it is covered for every profile.kanban.dbsits at the shared root, which equalsHERMES_HOMEfor the default/root profile; on non-root profiles its real path is outsideHERMES_HOMEand the entry is silently skipped — the same best-effort behavior the pairing entries already rely on. A fully profile-aware kanban path (resolving viakanban_db.kanban_db_path) would need separate handling outside the relative-to-home model and is left as a follow-up; this PR fixes the reported data-loss for the default install where the bug bites.How to Test
uv run python -m pytest tests/hermes_cli/test_backup.py -q→ 141 passed.hermes project create), run a pre-update snapshot, emptyprojects.db, restore the snapshot — the project rows come back.Checklist
tests/hermes_cli/test_backup.py, 141 passed, ruff clean)HERMES_HOME-relative; behavior identical on Windows/macOS/Linux