Skip to content

The agent that grows with you

fix(config-remote): serve main's ConfigBackend.cache_version from the remote backend

Ben Barclayc0c74d20e485
diff --git a/plugins/config_backends/remote/backend.py b/plugins/config_backends/remote/backend.py
index 9f8afadd807..850b4708b98 100644
--- a/plugins/config_backends/remote/backend.py
+++ b/plugins/config_backends/remote/backend.py
@@ -476,6 +476,11 @@ class RemoteBackend:
_remember_read(st)
return self._version_of(st)
+ def cache_version(self, home: Path, version: tuple[Any, ...]) -> tuple[Any, ...]:
+ # The version is exact (etag + local generation): a remote write the cache cannot see
+ # always changes it, so nothing is added (the file backend adds a racy content digest).
+ return version
+
def exists(self, home: Path) -> bool:
return True # the plane always resolves a document (an absent level is empty, contract R4)
diff --git a/tests/plugins/config_backends/test_remote_backend.py b/tests/plugins/config_backends/test_remote_backend.py
index 9dcb0915fa4..addb6389037 100644
--- a/tests/plugins/config_backends/test_remote_backend.py
+++ b/tests/plugins/config_backends/test_remote_backend.py
@@ -307,6 +307,20 @@ def test_poll_picks_up_changes_and_invalidates_caches(plane):
assert load_config()["display"]["personality"] == "pirate"
+def test_config_cache_version_is_the_remote_version(plane):
+ # main's parse caches key on config_cache_version: the remote backend must serve it, and a
+ # poll that installs a new layer must change it exactly as it changes config_version.
+ from hermes_cli.config_backend import config_cache_version, config_cache_version_or_none
+ cfg = plane.home / "config.yaml"
+ backend = remote_pkg.get_remote_backend()
+ plane.upper = {"display": {"personality": "concise"}}
+ v1 = config_cache_version(cfg)
+ assert v1 == backend.version(plane.home) == config_cache_version_or_none(cfg)
+ plane.upper = {"display": {"personality": "pirate"}}
+ backend.poll_all()
+ assert config_cache_version(cfg) != v1
+
+
def test_outage_while_running_keeps_in_memory_doc(plane):
from hermes_cli.config import load_config
plane.upper = {"display": {"personality": "concise"}}