The agent that grows with you
Python aiai-agentai-agentsanthropicchatgptclaudeclaude-codecodexhermeshermes-agentllmnous-researchopenai
fix(config): retired-key steps no longer depend on a stamp that does not prove they ran
Tekniumd1a08c92350e
diff --git a/hermes_cli/config_migrations.py b/hermes_cli/config_migrations.pyindex d7a223c870f..260d09a14dd 100644--- a/hermes_cli/config_migrations.py+++ b/hermes_cli/config_migrations.py@@ -858,19 +858,31 @@ MIGRATIONS: tuple[tuple[int, Callable[[dict[str, Any], bool], None]], ...] = (#: out: it clears OPENAI_MODEL from .env, a generic name Hermes never reads but the user's tools may.#: v41 is left out too: it rewrites profile SOUL.md on a heading match, an artifact whose#: provenance the config stamp says nothing about.-LEGACY_KEY_STEPS = frozenset({12, 14, 16, 17, 29, 33, 38, 39, 42, 43, 46, 50})+LEGACY_KEY_STEPS = frozenset({12, 14, 16, 17, 29, 33, 38, 39, 42, 43, 46, 50, 51})++#: Legacy-key steps that run on every migration pass whatever the stamp says, because a stamp at+#: or past their version does not prove they ran: unreleased builds of the gateway-runtime branch+#: put their retired-cron-key step at 44, 45, 46, 47 and 50 before it landed at 51, so a home one+#: of them stamped skipped main's step of that number. Only a step triggered by a key NO runtime+#: reads qualifies (re-running it is a no-op once the key is gone, and it never overrides a value+#: something consumes). The value-based steps such a home also skipped (44 curator defaults, 45+#: connections, 47 threshold_tokens) are NOT re-run: past the stamp, their trigger value may be+#: the user's own choice.+STAMP_INDEPENDENT_STEPS = frozenset({46, 50})def run_migrations(current_ver: int, results: dict[str, Any], quiet: bool, *, unversioned: bool = False) -> None:- """Apply every registered migration whose target version exceeds *current_ver*; a config- with no ``_config_version`` (*unversioned*) gets only :data:`LEGACY_KEY_STEPS`.+ """Apply every registered migration whose target version exceeds *current_ver* (plus+ :data:`STAMP_INDEPENDENT_STEPS`); a config with no ``_config_version`` (*unversioned*) gets+ only :data:`LEGACY_KEY_STEPS`.*current_ver* is the on-disk schema version captured ONCE before any step runs and does notadvance between steps — each step is gated on the same initial value."""for target_ver, migration_fn in MIGRATIONS:- if current_ver < target_ver and (target_ver in LEGACY_KEY_STEPS or not unversioned):+ due = current_ver < target_ver or target_ver in STAMP_INDEPENDENT_STEPS+ if due and (target_ver in LEGACY_KEY_STEPS or not unversioned):try:migration_fn(results, quiet)except Exception as exc:diff --git a/tests/hermes_cli/test_config_retired_key_migrations.py b/tests/hermes_cli/test_config_retired_key_migrations.pyindex 6b7f0cfc366..68226c5620b 100644--- a/tests/hermes_cli/test_config_retired_key_migrations.py+++ b/tests/hermes_cli/test_config_retired_key_migrations.py@@ -1,4 +1,4 @@-"""Config migrations that retire or rewrite obsolete keys (v43 / v44 / v51)."""+"""Config migrations that retire or rewrite obsolete keys (v43 / v44 / v51, stamp-independent steps)."""import hermes_yaml as yaml@@ -60,3 +60,43 @@ class TestRetiredBotChatDeliveryTimeout:assert raw["cron"]["max_parallel_jobs"] == 2assert any("bot_chat_delivery_timeout_seconds" in note for note in results["config_added"])assert "bot_chat_delivery_timeout_seconds" not in DEFAULT_CONFIG["cron"]+++class TestRetiredKeysWhateverTheStamp:+ """Retired-key steps must not depend on a stamp that does not prove they ran: an unversioned+ file (seeded from an older template) and a home an unreleased branch build stamped with its+ own step numbers both still carry keys nothing reads."""++ def test_unversioned_config_drops_the_retired_bot_chat_timeout(self, tmp_path, monkeypatch):+ from hermes_cli.config import migrate_config++ config_path = tmp_path / "config.yaml"+ config_path.write_text(yaml.safe_dump({+ "cron": {"bot_chat_delivery_timeout_seconds": 900, "max_parallel_jobs": 2},+ }), encoding="utf-8")+ monkeypatch.setenv("HERMES_HOME", str(tmp_path))+ migrate_config(interactive=False, quiet=True)+ raw = yaml.safe_load(config_path.read_text(encoding="utf-8"))+ assert raw["cron"] == {"max_parallel_jobs": 2}++ def test_branch_stamped_home_still_gets_main_retired_key_steps(self, tmp_path, monkeypatch):+ """A home stamped 50 by a build whose v50 was the cron-key step skipped main's v46 (MCP+ `disabled: true`) and v50 (tirith keys). Both apply, and a second pass writes nothing."""+ from hermes_cli.config import migrate_config++ config_path = tmp_path / "config.yaml"+ config_path.write_text(yaml.safe_dump({+ "_config_version": 50,+ "mcp_servers": {"old": {"command": "x", "enabled": True, "disabled": True}},+ "security": {"redact_secrets": True, "tirith_enabled": True},+ }), encoding="utf-8")+ monkeypatch.setenv("HERMES_HOME", str(tmp_path))+ migrate_config(interactive=False, quiet=True)+ raw = yaml.safe_load(config_path.read_text(encoding="utf-8"))+ assert raw["mcp_servers"]["old"] == {"command": "x", "enabled": False}+ assert raw["security"] == {"redact_secrets": True}+ settled = config_path.read_bytes()+ assert migrate_config(interactive=False, quiet=True)["config_added"] == []+ assert config_path.read_bytes() == settled+ from hermes_cli.config_migrations import LEGACY_KEY_STEPS, STAMP_INDEPENDENT_STEPS+ assert STAMP_INDEPENDENT_STEPS <= LEGACY_KEY_STEPS