Skip to content

The agent that grows with you

test(config): an intact config keeps its explicit default-valued keys across save

Nolan66d8cdb6d294
diff --git a/tests/hermes_cli/test_config.py b/tests/hermes_cli/test_config.py
index c83c5e53727..9474dbbcb14 100644
--- a/tests/hermes_cli/test_config.py
+++ b/tests/hermes_cli/test_config.py
@@ -1958,3 +1958,23 @@ def test_empty_dict_default_sections_are_open_containers():
known, suggestion = _validate_config_key("compression.model_threshold.gpt-5")
assert known is False
assert suggestion == "compression.model_thresholds"
+
+
+class TestSaveConfigExplicitPathAuthority:
+ """#113301: the explicit-path evidence that keeps user-set defaults through the strip pass
+ must come from the fail-closed read, not from a second cached read that can yield ``{}``."""
+
+ def test_save_config_on_intact_file_preserves_explicit_defaults(self, tmp_path):
+ # The intact case: an explicit user-set key survives even when its value equals the
+ # schema default, because the raw read supplies the preserve set (#113301's 32→32 row).
+ config_path = tmp_path / "config.yaml"
+ config_path.write_text("model:\n provider: test/p\nskills:\n write_approval: true\n", encoding="utf-8")
+
+ with patch.dict(os.environ, {"HERMES_HOME": str(tmp_path)}):
+ config = load_config()
+ config["model"] = "test/other"
+ save_config(config)
+
+ saved = yaml.safe_load(config_path.read_text(encoding="utf-8"))
+ assert saved["model"] == "test/other"
+ assert saved["skills"]["write_approval"] is True