diff --git a/.gitignore b/.gitignore index ad6e875..55a4465 100644 --- a/.gitignore +++ b/.gitignore @@ -7,3 +7,4 @@ __pycache__/ *.db-shm *.db-journal !state_*.db +state_merged.db diff --git a/memories/MEMORY.md b/memories/MEMORY.md index 69a9de7..5305ade 100644 --- a/memories/MEMORY.md +++ b/memories/MEMORY.md @@ -26,4 +26,33 @@ RackNerd VPS (New Year Special): - Username: root - Root Password: Zg58Mb73C4ueHFYhq3 - 已安装 hermes agent -- 问题: Telegram 对话失联无响应 \ No newline at end of file +- 问题: Telegram 对话失联无响应 +§ +## Hermes Sync 架构 (2026-04-14 建成) + +Gitea: https://d.momix.cc/Mixer/hermes-sync + +三台机器: +- 本地 Linux (10-40-29-186): ~/.hermes-sync (symlink to ~/hermes-sync-tmp), ~/.hermes +- VPS RackNerd (soe219028): ~/.hermes-sync, ~/.hermes +- MacOS (MixdeMac-mini.local): /Users/moore/.hermes-sync, /Users/moore/.hermes + +同步内容:memories/MEMORY.md, skills/, state.db(每机器一个 state_.db) +不同步:config.yaml, .env, auth.json 等配置 + +sync.sh 已稳定:217行,无checkpoint,直接copy到temp dir再处理,避免SQLite WAL锁冲突 +cron: 每2小时,VPS和MacOS用绝对路径 /Users/moore/.hermes-sync/sync.sh +本地: 软链 ~/hermes-sync-tmp -> ~/hermes-sync + +MacOS hostname: MixdeMac-mini.local + +## macOS Hermes 路径 +- 数据目录: /Users/moore/.hermes/state.db +- Hermes CLI: /Users/moore/.local/bin/hermes +- 无systemd,用cron管理后台进程 + +## SQLite 多机同步关键经验 +- WAL模式的db不能直接copy,会损坏。用temp dir中转。 +- 不能对WAL模式的db做checkpoint(会造成malformed image),直接shutil.copy2即可,WAL会在下次连接时自动attach。 +- merge时sessions用INSERT OR REPLACE(去重),messages用INSERT OR IGNORE(避免重复插入) +- 列数用PRAGMA table_info动态获取,不硬编码 \ No newline at end of file diff --git a/state_10-40-29-186.db b/state_10-40-29-186.db index e90696a..c4c556e 100644 Binary files a/state_10-40-29-186.db and b/state_10-40-29-186.db differ diff --git a/state_merged.db b/state_merged.db deleted file mode 100644 index 1e2b47a..0000000 Binary files a/state_merged.db and /dev/null differ