Skip to content

The agent that grows with you

fix(migration): the config.yaml an env-only left-core conversion creates carries the current stamp and the rows in use

Teknium9dd0545f739b
diff --git a/hermes_cli/left_core_migration.py b/hermes_cli/left_core_migration.py
index 13e1a7b3984..cc5101b9feb 100644
--- a/hermes_cli/left_core_migration.py
+++ b/hermes_cli/left_core_migration.py
@@ -515,6 +515,7 @@ def _record_migration(home: Path, feature: LeftCoreFeature) -> None:
from hermes_cli.config import atomic_config_write, read_user_config_raw
from hermes_cli.toolset_validation import parse_platform_toolsets_value
path = home / "config.yaml"
+ created = not path.exists()
config = read_user_config_raw(path)
installed = plugin_present(feature.plugin, home) and not _marked(config, _INSTALLED_KEY, feature)
if _scope_kept(config, feature) and not installed:
@@ -542,9 +543,21 @@ def _record_migration(home: Path, feature: LeftCoreFeature) -> None:
if feature.replaces_toolsets:
_turn_off_replaced(config, feature)
_mark(config, _SCOPED_KEY, feature)
+ if created:
+ _stamp_created(home, config)
atomic_config_write(path, config)
+def _stamp_created(home: Path, config: dict) -> None:
+ """A missing config.yaml reads as the current schema, so no config step ever ran on this home: the file
+ the conversion creates carries that stamp (unstamped, every boot warns it predates the support floor)
+ and, as a plain save's first stamp does, the rows in use, or the stamp makes the home look post-split."""
+ from hermes_cli.config_defaults import DEFAULT_CONFIG
+ from hermes_cli.config_version_stamp import note_first_stamp
+ config["_config_version"] = DEFAULT_CONFIG["_config_version"]
+ note_first_stamp(home, {}, config)
+
+
def _pending(home: Path, *, say: Callable[[str], None], process_env: bool = False,
backoff: bool = False) -> list[LeftCoreFeature]:
"""Rows *home* uses whose plugin it never had and that the catalog ships (a catalog miss is
diff --git a/tests/hermes_cli/test_left_core_camofox.py b/tests/hermes_cli/test_left_core_camofox.py
index 91334e0e352..2737417896e 100644
--- a/tests/hermes_cli/test_left_core_camofox.py
+++ b/tests/hermes_cli/test_left_core_camofox.py
@@ -283,6 +283,30 @@ def test_an_unversioned_camofox_home_is_converted(tmp_path, monkeypatch, config)
assert _config(home)["agent"]["disabled_toolsets"] == ["browser"]
+def test_the_config_yaml_an_env_only_conversion_creates_is_stamped(tmp_path, monkeypatch, caplog):
+ """An env-only Camofox home has no config.yaml; the conversion creates one. It carries the current
+ stamp (a missing file read as current) and the row in use, so the next boot's config step neither
+ warns that the file predates the support floor nor makes the home look newer than the split."""
+ import logging
+
+ from hermes_cli import post_update
+ from hermes_cli.config_defaults import DEFAULT_CONFIG
+
+ home = _home(tmp_path, env=_SPLIT_ENV)
+ assert _boot(home, monkeypatch) == ["camofox"]
+ with caplog.at_level(logging.WARNING):
+ assert post_update.step_migrate_config() == {"ok": True, "skipped": "up-to-date"}
+ assert "predates version" not in caplog.text
+ config = _config(home)
+ assert config["_config_version"] == DEFAULT_CONFIG["_config_version"]
+ assert config["_left_core_used"] == ["camofox"]
+
+ monkeypatch.setattr(lcm, "_attempted", set()) # the next process
+ said = []
+ assert _boot(home, monkeypatch, said) == []
+ assert said == []
+
+
def test_a_plain_save_stamping_an_unversioned_camofox_home_keeps_its_conversion(tmp_path, monkeypatch):
"""Any config write before the first left-core pass (`hermes config set`, a model switch) stamps an
unstamped config.yaml at the current version without running the v52 step; the home still converts."""