The agent that grows with you
Python aiai-agentai-agentsanthropicchatgptclaudeclaude-codecodexhermeshermes-agentllmnous-researchopenai
fix(cli): don't report a partially restored snapshot as missing
kshitijk4poore907a9a14bf6
diff --git a/hermes_cli/cli_commands_mixin.py b/hermes_cli/cli_commands_mixin.pyindex 655d94e0e07..51f2914dfa0 100644--- a/hermes_cli/cli_commands_mixin.py+++ b/hermes_cli/cli_commands_mixin.py@@ -856,6 +856,9 @@ class CLICommandsMixin:if restore_quick_snapshot(snap_id):_pr(f" {_t('snapshot.restored', snapshot_id=snap_id)}",f" {_t('snapshot.restart_recommended')}")+ elif snap_id in {s.get("id") for s in list_quick_snapshots(limit=10**6)}:+ # False also means the auth.json merge was refused; don't call an existing snapshot missing.+ print(f" {_t('snapshot.restore_incomplete', snapshot_id=snap_id)}")else:print(f" {_t('snapshot.not_found', snapshot_id=snap_id)}")diff --git a/locales/af.yaml b/locales/af.yamlindex e52447c9d50..abc0e2f975d 100644--- a/locales/af.yaml+++ b/locales/af.yaml@@ -2721,6 +2721,7 @@ cli:restored: "Toestand herstel vanaf: {snapshot_id}"restart_recommended: "Herbegin word aanbeveel sodat gateway-/kontroleskermprosesse die state.db-veranderinge oorneem."not_found: "Momentopname nie gevind nie: {snapshot_id}"+ restore_incomplete: "Momentopname {snapshot_id} gedeeltelik herstel: auth.json is geweier (sien logs)"usage_prune: "Gebruik: /snapshot prune [behou-aantal]"pruned: "{deleted} ou momentopname(s) gesnoei ({keep} word behou)."export:diff --git a/locales/ar.yaml b/locales/ar.yamlindex 505ae707c17..f371c9504eb 100644--- a/locales/ar.yaml+++ b/locales/ar.yaml@@ -2721,6 +2721,7 @@ cli:restored: "تمت استعادة الحالة من: {snapshot_id}"restart_recommended: "يُنصح بإعادة تشغيل عمليات البوّابة/لوحة التحكم لاعتماد تغييرات state.db."not_found: "اللقطة غير موجودة: {snapshot_id}"+ restore_incomplete: "تمت استعادة اللقطة {snapshot_id} جزئيًا: تم رفض auth.json (راجع السجلات)"usage_prune: "الاستخدام: /snapshot prune [keep-count]"pruned: "تم حذف {deleted} لقطة قديمة (مع الاحتفاظ بـ {keep})."export:diff --git a/locales/de.yaml b/locales/de.yamlindex 958d77ce307..94f2f76dce2 100644--- a/locales/de.yaml+++ b/locales/de.yaml@@ -2721,6 +2721,7 @@ cli:restored: "Zustand wiederhergestellt aus: {snapshot_id}"restart_recommended: "Neustart empfohlen, damit Gateway-/Dashboard-Prozesse die Änderungen an state.db übernehmen."not_found: "Schnappschuss nicht gefunden: {snapshot_id}"+ restore_incomplete: "Schnappschuss {snapshot_id} teilweise wiederhergestellt: auth.json wurde abgelehnt (siehe Logs)"usage_prune: "Verwendung: /snapshot prune [keep-count]"pruned: "{deleted} alte(r) Schnappschuss/Schnappschüsse entfernt ({keep} werden behalten)."export:diff --git a/locales/en.yaml b/locales/en.yamlindex ebd98cb8995..13f8bb8f4f7 100644--- a/locales/en.yaml+++ b/locales/en.yaml@@ -2821,6 +2821,7 @@ cli:restored: "Restored state from: {snapshot_id}"restart_recommended: "Restart recommended for gateway/dashboard processes to pick up state.db changes."not_found: "Snapshot not found: {snapshot_id}"+ restore_incomplete: "Snapshot {snapshot_id} restored partially: auth.json was refused (see logs)"usage_prune: "Usage: /snapshot prune [keep-count]"pruned: "Pruned {deleted} old snapshot(s) (keeping {keep})."export:diff --git a/locales/es.yaml b/locales/es.yamlindex 7e6af331028..a28156c8833 100644--- a/locales/es.yaml+++ b/locales/es.yaml@@ -2721,6 +2721,7 @@ cli:restored: "Estado restaurado desde: {snapshot_id}"restart_recommended: "Se recomienda reiniciar los procesos del gateway/dashboard para que apliquen los cambios de state.db."not_found: "Instantánea no encontrada: {snapshot_id}"+ restore_incomplete: "Instantánea {snapshot_id} restaurada parcialmente: auth.json fue rechazado (consulta los registros)"usage_prune: "Uso: /snapshot prune [keep-count]"pruned: "Se eliminaron {deleted} instantánea(s) antigua(s) (conservando {keep})."export:diff --git a/locales/fr.yaml b/locales/fr.yamlindex 5337c6afea7..9319592bd3b 100644--- a/locales/fr.yaml+++ b/locales/fr.yaml@@ -3006,6 +3006,7 @@ cli:restored: "État restauré depuis : {snapshot_id}"restart_recommended: "Redémarrage recommandé pour que les processus gateway/dashboard prennent en compte les changements de state.db."not_found: "Instantané introuvable : {snapshot_id}"+ restore_incomplete: "Instantané {snapshot_id} restauré partiellement : auth.json a été refusé (voir les journaux)"usage_prune: "Usage : /snapshot prune [nombre-à-conserver]"pruned: "{deleted} ancien(s) instantané(s) supprimé(s) ({keep} conservé(s))."export:diff --git a/locales/ga.yaml b/locales/ga.yamlindex baf6a08747c..7fcfc79e1c0 100644--- a/locales/ga.yaml+++ b/locales/ga.yaml@@ -2721,6 +2721,7 @@ cli:restored: "Staid aischurtha ó: {snapshot_id}"restart_recommended: "Moltar atosú do phróisis gateway/deais chun athruithe state.db a ghlacadh."not_found: "Níor aimsíodh an roghchóip: {snapshot_id}"+ restore_incomplete: "Athchóiríodh an roghchóip {snapshot_id} go páirteach: diúltaíodh auth.json (féach na logaí)"usage_prune: "Úsáid: /snapshot prune [keep-count]"pruned: "Baineadh {deleted} seanroghchóip(eanna) (ag coinneáil {keep})."export:diff --git a/locales/hu.yaml b/locales/hu.yamlindex a39bcfdd94e..df20fca8492 100644--- a/locales/hu.yaml+++ b/locales/hu.yaml@@ -2738,6 +2738,7 @@ cli:restored: "Állapot visszaállítva innen: {snapshot_id}"restart_recommended: "Az átjáró/dashboard folyamatok újraindítása ajánlott, hogy átvegyék a state.db változásait."not_found: "A pillanatkép nem található: {snapshot_id}"+ restore_incomplete: "A(z) {snapshot_id} pillanatkép részben visszaállítva: az auth.json elutasítva (lásd a naplókat)"usage_prune: "Használat: /snapshot prune [megtartandó-darabszám]"pruned: "{deleted} régi pillanatkép törölve ({keep} megtartva)."export:diff --git a/locales/it.yaml b/locales/it.yamlindex 386c280087c..187b79b75f5 100644--- a/locales/it.yaml+++ b/locales/it.yaml@@ -2721,6 +2721,7 @@ cli:restored: "Stato ripristinato da: {snapshot_id}"restart_recommended: "Riavvio consigliato per i processi gateway/dashboard affinché rilevino le modifiche a state.db."not_found: "Snapshot non trovato: {snapshot_id}"+ restore_incomplete: "Snapshot {snapshot_id} ripristinato parzialmente: auth.json è stato rifiutato (vedi i log)"usage_prune: "Uso: /snapshot prune [keep-count]"pruned: "Eliminati {deleted} snapshot vecchi (conservati: {keep})."export:diff --git a/locales/ja.yaml b/locales/ja.yamlindex 59a001f66ca..a9bcd75a161 100644--- a/locales/ja.yaml+++ b/locales/ja.yaml@@ -2721,6 +2721,7 @@ cli:restored: "状態を復元しました: {snapshot_id}"restart_recommended: "state.db の変更を反映するため、ゲートウェイ/ダッシュボードのプロセスを再起動することをおすすめします。"not_found: "スナップショットが見つかりません: {snapshot_id}"+ restore_incomplete: "スナップショット {snapshot_id} を部分的に復元しました: auth.json は拒否されました(ログを参照)"usage_prune: "使い方: /snapshot prune [keep-count]"pruned: "古いスナップショット {deleted} 件を削除しました({keep} 件を保持)。"export:diff --git a/locales/ko.yaml b/locales/ko.yamlindex 3f3c601feff..b2fe9f91f01 100644--- a/locales/ko.yaml+++ b/locales/ko.yaml@@ -2721,6 +2721,7 @@ cli:restored: "상태를 복원했어요: {snapshot_id}"restart_recommended: "게이트웨이/대시보드 프로세스가 state.db 변경을 반영하려면 재시작을 권장해요."not_found: "스냅샷을 찾을 수 없어요: {snapshot_id}"+ restore_incomplete: "스냅샷 {snapshot_id}을(를) 일부만 복원했어요: auth.json이 거부되었어요 (로그 확인)"usage_prune: "사용법: /snapshot prune [keep-count]"pruned: "오래된 스냅샷 {deleted}개를 정리했어요 ({keep}개 유지)."export:diff --git a/locales/pt.yaml b/locales/pt.yamlindex e3558d7232f..8e542331739 100644--- a/locales/pt.yaml+++ b/locales/pt.yaml@@ -2721,6 +2721,7 @@ cli:restored: "Estado restaurado de: {snapshot_id}"restart_recommended: "Recomenda-se reiniciar os processos do gateway/painel para que carreguem as alterações do state.db."not_found: "Instantâneo não encontrado: {snapshot_id}"+ restore_incomplete: "Instantâneo {snapshot_id} restaurado parcialmente: auth.json foi recusado (veja os logs)"usage_prune: "Uso: /snapshot prune [quantidade-a-manter]"pruned: "{deleted} instantâneo(s) antigo(s) removido(s) (mantendo {keep})."export:diff --git a/locales/ru.yaml b/locales/ru.yamlindex 60923900e63..cc508c14ef9 100644--- a/locales/ru.yaml+++ b/locales/ru.yaml@@ -2721,6 +2721,7 @@ cli:restored: "Состояние восстановлено из: {snapshot_id}"restart_recommended: "Рекомендуется перезапустить процессы шлюза/дашборда, чтобы они подхватили изменения state.db."not_found: "Снимок не найден: {snapshot_id}"+ restore_incomplete: "Снимок {snapshot_id} восстановлен частично: auth.json отклонён (см. логи)"usage_prune: "Использование: /snapshot prune [сколько-оставить]"pruned: "Удалено старых снимков: {deleted} (оставлено {keep})."export:diff --git a/locales/tr.yaml b/locales/tr.yamlindex 910ca95f6bb..f327d865f21 100644--- a/locales/tr.yaml+++ b/locales/tr.yaml@@ -2721,6 +2721,7 @@ cli:restored: "Durum şuradan geri yüklendi: {snapshot_id}"restart_recommended: "Gateway/panel süreçlerinin state.db değişikliklerini alması için yeniden başlatma önerilir."not_found: "Anlık görüntü bulunamadı: {snapshot_id}"+ restore_incomplete: "Anlık görüntü {snapshot_id} kısmen geri yüklendi: auth.json reddedildi (günlüklere bakın)"usage_prune: "Kullanım: /snapshot prune [tutulacak-sayı]"pruned: "{deleted} eski anlık görüntü silindi ({keep} tanesi tutuluyor)."export:diff --git a/locales/uk.yaml b/locales/uk.yamlindex 593b3300740..16df1dfe5cc 100644--- a/locales/uk.yaml+++ b/locales/uk.yaml@@ -2721,6 +2721,7 @@ cli:restored: "Стан відновлено з: {snapshot_id}"restart_recommended: "Рекомендовано перезапустити процеси шлюзу та панелі керування, щоб вони підхопили зміни state.db."not_found: "Знімок не знайдено: {snapshot_id}"+ restore_incomplete: "Знімок {snapshot_id} відновлено частково: auth.json відхилено (див. журнали)"usage_prune: "Використання: /snapshot prune [keep-count]"pruned: "Видалено старих знімків: {deleted} (залишено {keep})."export:diff --git a/locales/zh-hant.yaml b/locales/zh-hant.yamlindex 4383ca2edc8..75a141c5198 100644--- a/locales/zh-hant.yaml+++ b/locales/zh-hant.yaml@@ -2721,6 +2721,7 @@ cli:restored: "已從 {snapshot_id} 還原狀態"restart_recommended: "建議重新啟動閘道/儀表板程序,以套用 state.db 的變更。"not_found: "找不到快照:{snapshot_id}"+ restore_incomplete: "快照 {snapshot_id} 已部分還原:auth.json 被拒絕(請查看日誌)"usage_prune: "用法:/snapshot prune [keep-count]"pruned: "已清除 {deleted} 個舊快照(保留 {keep} 個)。"export:diff --git a/locales/zh.yaml b/locales/zh.yamlindex 92b79dc27b1..258027e95e3 100644--- a/locales/zh.yaml+++ b/locales/zh.yaml@@ -2721,6 +2721,7 @@ cli:restored: "已从 {snapshot_id} 恢复状态"restart_recommended: "建议重启网关/控制台进程,以加载 state.db 的更改。"not_found: "未找到快照:{snapshot_id}"+ restore_incomplete: "快照 {snapshot_id} 已部分恢复:auth.json 被拒绝(请查看日志)"usage_prune: "用法:/snapshot prune [保留数量]"pruned: "已清理 {deleted} 个旧快照(保留 {keep} 个)。"export:diff --git a/tests/hermes_cli/test_snapshot_restore_oauth.py b/tests/hermes_cli/test_snapshot_restore_oauth.pyindex 66f8e9395d7..8d74e30a511 100644--- a/tests/hermes_cli/test_snapshot_restore_oauth.py+++ b/tests/hermes_cli/test_snapshot_restore_oauth.py@@ -87,7 +87,7 @@ def test_quick_snapshot_restore_keeps_live_oauth_and_restores_static_auth(assert (home / "auth.json").stat().st_mode & 0o777 == 0o600-def test_auth_refusal_is_not_hidden_by_another_restored_file(tmp_path, monkeypatch):+def test_auth_refusal_is_not_hidden_by_another_restored_file(tmp_path, monkeypatch, capsys):"""A partial restore must not report success after refusing the auth store (#127010)."""from hermes_cli.backup import restore_quick_snapshot@@ -103,10 +103,22 @@ def test_auth_refusal_is_not_hidden_by_another_restored_file(tmp_path, monkeypat(snap_dir / "config.yaml").write_text("model: snapshot\n", encoding="utf-8")(snap_dir / "auth.json").write_text("{invalid-json", encoding="utf-8")files = {name: (snap_dir / name).stat().st_size for name in ("auth.json", "config.yaml")}- (snap_dir / "manifest.json").write_text(json.dumps({"files": files}), encoding="utf-8")+ (snap_dir / "manifest.json").write_text(json.dumps({"id": "partial", "files": files}), encoding="utf-8")result = restore_quick_snapshot("partial", hermes_home=home)assert live_path.read_bytes() == beforeassert (home / "config.yaml").read_text(encoding="utf-8") == "model: snapshot\n"assert result is False++ # The /snapshot restore caller must not report an existing snapshot as missing.+ from types import SimpleNamespace++ from hermes_cli.cli_commands_mixin import CLICommandsMixin++ capsys.readouterr()+ CLICommandsMixin._snapshot_restore(SimpleNamespace(), ["/snapshot", "restore", "partial"])+ out = capsys.readouterr().out+ assert "partial" in out and "auth.json" in out+ assert "not found" not in out.lower()+ assert live_path.read_bytes() == before