The agent that grows with you
Python aiai-agentai-agentsanthropicchatgptclaudeclaude-codecodexhermeshermes-agentllmnous-researchopenai
test(config): trim the explicit-null salvage to one invariant test
teknium19c97fb6e34af
diff --git a/tests/hermes_cli/test_config.py b/tests/hermes_cli/test_config.pyindex bc67b22b16d..e29b63521e4 100644--- a/tests/hermes_cli/test_config.py+++ b/tests/hermes_cli/test_config.py@@ -1758,70 +1758,6 @@ class TestConfigNormalizationDoesNotOverwriteUserValues:-class TestExplicitNullConfigPreservation:- def test_first_save_keeps_null_instead_of_a_non_null_default(self, tmp_path, monkeypatch):- monkeypatch.setenv("HERMES_HOME", str(tmp_path))- monkeypatch.setitem(DEFAULT_CONFIG, "x_first_save", {"optional": "default"})- config_path = tmp_path / "config.yaml"- assert not config_path.exists()-- save_config({"x_first_save": {"optional": None}})-- raw = yaml.safe_load(config_path.read_text(encoding="utf-8"))- assert raw["x_first_save"] == {"optional": None}- assert load_config()["x_first_save"]["optional"] is None-- @pytest.mark.parametrize("operation", ["save", "partial_save", "migrate"])- def test_authored_nulls_survive_config_writes(self, tmp_path, monkeypatch, operation):- from hermes_cli.resource_limits import configured_nofile_soft_limit- from agent.agent_runtime_helpers import prompt_caching_disabled_from_config-- monkeypatch.setenv("HERMES_HOME", str(tmp_path))- config_path = tmp_path / "config.yaml"- seed = {- "_config_version": DEFAULT_CONFIG["_config_version"] - (operation == "migrate"),- "runtime": {"nofile_soft_limit": None},- "prompt_caching": {"cache_ttl": None},- "x_null_preservation": {"nested": {"optional": None}, "keep": "value"},- }- config_path.write_text(yaml.safe_dump(seed), encoding="utf-8")-- if operation == "migrate":- migrate_config(interactive=False, quiet=True)- elif operation == "partial_save":- save_config({"display": {"skin": "mono"}}, merge_existing=True)- else:- config = load_config()- config["display"]["skin"] = "mono"- save_config(config)-- raw = yaml.safe_load(config_path.read_text(encoding="utf-8"))- assert raw["runtime"]["nofile_soft_limit"] is None- assert raw["prompt_caching"]["cache_ttl"] is None- assert raw["x_null_preservation"] == seed["x_null_preservation"]- assert "terminal" not in raw- assert configured_nofile_soft_limit() is None- assert prompt_caching_disabled_from_config() is True- if operation == "migrate":- assert raw["_config_version"] == DEFAULT_CONFIG["_config_version"]- else:- assert raw["display"]["skin"] == "mono"-- @pytest.mark.parametrize("value", [None, False, 0, "", [], [None], {"optional": None}])- def test_authored_default_values_survive_stripping(self, value):- from hermes_cli.config import _strip_default_values-- config = {"authored": value, "default_only": {"optional": None, "enabled": True}}- result = _strip_default_values(config, defaults=config, preserve_keys={("authored",)})- assert result == {"authored": value}-- def test_only_default_nulls_produce_an_empty_mapping(self):- from hermes_cli.config import _strip_default_values-- defaults = {"optional": None, "nested": {"optional": None}}- assert _strip_default_values(defaults, defaults=defaults) == {}--class TestCodexAppServerAutoConfig:"""codex_app_server_auto ships a default and survives migration untouched."""diff --git a/tests/hermes_cli/test_config_save_integrity.py b/tests/hermes_cli/test_config_save_integrity.pynew file mode 100644index 00000000000..7c6e6397051--- /dev/null+++ b/tests/hermes_cli/test_config_save_integrity.py@@ -0,0 +1,43 @@+"""config.yaml write integrity: a save keeps what the user wrote."""++import pytest+import yaml++from hermes_cli.config import DEFAULT_CONFIG, load_config, migrate_config, save_config++[email protected]("operation", ["save", "partial_save", "migrate"])+def test_authored_nulls_survive_config_writes(tmp_path, monkeypatch, operation):+ from hermes_cli.resource_limits import configured_nofile_soft_limit+ from agent.agent_runtime_helpers import prompt_caching_disabled_from_config++ monkeypatch.setenv("HERMES_HOME", str(tmp_path))+ config_path = tmp_path / "config.yaml"+ seed = {+ "_config_version": DEFAULT_CONFIG["_config_version"] - (operation == "migrate"),+ "runtime": {"nofile_soft_limit": None},+ "prompt_caching": {"cache_ttl": None},+ "x_null_preservation": {"nested": {"optional": None}, "keep": "value"},+ }+ config_path.write_text(yaml.safe_dump(seed), encoding="utf-8")++ if operation == "migrate":+ migrate_config(interactive=False, quiet=True)+ elif operation == "partial_save":+ save_config({"display": {"skin": "mono"}}, merge_existing=True)+ else:+ config = load_config()+ config["display"]["skin"] = "mono"+ save_config(config)++ raw = yaml.safe_load(config_path.read_text(encoding="utf-8"))+ assert raw["runtime"]["nofile_soft_limit"] is None+ assert raw["prompt_caching"]["cache_ttl"] is None+ assert raw["x_null_preservation"] == seed["x_null_preservation"]+ assert "terminal" not in raw+ assert configured_nofile_soft_limit() is None+ assert prompt_caching_disabled_from_config() is True+ if operation == "migrate":+ assert raw["_config_version"] == DEFAULT_CONFIG["_config_version"]+ else:+ assert raw["display"]["skin"] == "mono"