The agent that grows with you
Python aiai-agentai-agentsanthropicchatgptclaudeclaude-codecodexhermeshermes-agentllmnous-researchopenai
test: tighten the audit's new assertions after review
kshitijk4poora0425672960e
diff --git a/apps/desktop/src/plugins/hermes-bots/relay-deliver-budget.test.ts b/apps/desktop/src/plugins/hermes-bots/relay-deliver-budget.test.tsindex 48ce87e00d4..cf57c0ec264 100644--- a/apps/desktop/src/plugins/hermes-bots/relay-deliver-budget.test.ts+++ b/apps/desktop/src/plugins/hermes-bots/relay-deliver-budget.test.ts@@ -54,12 +54,12 @@ describe('bot_relay.deliver budget mirrors', () => {// Strictly greater, not equal: a backend that answers at its own limit// still has to serialize and transport that answer.expect(RELAY_DELIVER_SETTLEMENT_MARGIN_MS, 'settlement margin must be positive').toBeGreaterThan(0)- expect(RELAY_DELIVER_TIMEOUT_MS).toBeGreaterThan(RELAY_DELIVER_BACKEND_CEILING_MS)- // The ceiling is the backend's own worst case: lock wait + every attempt.- const lockWaitMs = Number(configDefaults.match(/"turn_wait_seconds":\s*(\d+)/)![1]) * 1000- const attemptsMs = pyConstant('TURN_ATTEMPT_TIMEOUT_SECONDS') * 1000 * pyConstant('TURN_MAX_ATTEMPTS')-- expect(RELAY_DELIVER_BACKEND_CEILING_MS).toBe(lockWaitMs + attemptsMs)+ // The ceiling is the backend's own worst case: lock wait + every attempt;+ // the mirror tests above tie each term to its Python default.+ expect(RELAY_DELIVER_BACKEND_CEILING_MS).toBe(+ RELAY_TURN_LOCK_WAIT_MS + RELAY_TURN_ATTEMPT_MS * RELAY_TURN_MAX_ATTEMPTS+ )+ expect(RELAY_DELIVER_TIMEOUT_MS).toBe(RELAY_DELIVER_BACKEND_CEILING_MS + RELAY_DELIVER_SETTLEMENT_MARGIN_MS)})})diff --git a/tests/plugins/test_retaindb_plugin.py b/tests/plugins/test_retaindb_plugin.pyindex b066c507993..a85605d1f27 100644--- a/tests/plugins/test_retaindb_plugin.py+++ b/tests/plugins/test_retaindb_plugin.py@@ -266,10 +266,15 @@ class TestPrefetch:p.initialize("test-session", hermes_home=str(hermes_home))return p- def test_queue_prefetch_skips_without_client(self):+ def test_queue_prefetch_skips_without_client(self, monkeypatch):+ spawned = []+ monkeypatch.setattr(+ "plugins.memory.retaindb.spawn_context_thread",+ lambda *a, **k: spawned.append(k.get("name")),+ )p = RetainDBMemoryProvider()p.queue_prefetch("test")- assert p._prefetch_threads == []+ assert spawned == []def test_prefetch_returns_empty_when_nothing_cached(self, tmp_path, monkeypatch):p = self._make_initialized_provider(tmp_path, monkeypatch)diff --git a/tests/test_live_system_guard_self_test.py b/tests/test_live_system_guard_self_test.pyindex 3ba780323d8..aeb5860cfc0 100644--- a/tests/test_live_system_guard_self_test.py+++ b/tests/test_live_system_guard_self_test.py@@ -337,4 +337,4 @@ def test_bypass_marker_disables_guard():# checks that the PID exists — harmless.os.kill(os.getpid(), 0) # No exception — guard is OFF.# Signal 0 passes the guard too, so prove the patch itself is absent.- assert isinstance(os.kill, types.BuiltinFunctionType)+ assert not _live_system_guard_is_active()diff --git a/tests/tools/test_terminal_config_env_sync.py b/tests/tools/test_terminal_config_env_sync.pyindex 7840a74c410..eec78ae0035 100644--- a/tests/tools/test_terminal_config_env_sync.py+++ b/tests/tools/test_terminal_config_env_sync.py@@ -16,40 +16,51 @@ silently does nothing for that entry-point. This bug already shipped oncefor ``docker_run_as_host_user`` (gateway and CLI maps) and once for``docker_mount_cwd_to_workspace`` (gateway map).-This test guards against future drift by driving each bridge with every-known ``terminal.*`` key and asserting they all write the same env var.+This test guards against future drift by driving the gateway bridge with+every known ``terminal.*`` key and comparing the env var it writes against+cli.py's map; the config-set path is checked for key coverage only."""import osfrom unittest.mock import patch-def _cli_env_map_keys() -> set[str]:- """terminal config keys bridged by cli.load_cli_config() (via _mirror_config_to_env)."""+def _cli_env_map() -> dict[str, str]:+ """terminal config key -> env var bridged by cli.load_cli_config() (via _mirror_config_to_env)."""import cli- return set(cli._TERMINAL_ENV_MAPPINGS.keys())+ return dict(cli._TERMINAL_ENV_MAPPINGS)def _gateway_env_map() -> dict[str, str]:"""terminal config key -> env var actually written by the gateway bridge."""- import clifrom gateway.run import _bridge_terminal_config_to_envfrom hermes_cli import config as hc_configclass _KeyRecorder(dict):- """Empty config that records every key the bridge asks about."""+ """Empty config that records every key the bridge looks up."""- seen: set[str] = set()+ def __init__(self):+ super().__init__()+ self.seen: set[str] = set()def __contains__(self, key):self.seen.add(key)return super().__contains__(key)- _bridge_terminal_config_to_env(_KeyRecorder()) # empty: writes nothing+ def get(self, key, default=None):+ self.seen.add(key)+ return super().get(key, default)++ def __getitem__(self, key):+ self.seen.add(key)+ return super().__getitem__(key)++ recorder = _KeyRecorder()+ _bridge_terminal_config_to_env(recorder) # empty: writes nothing+ # A bridge that stopped consulting its config would make the probe below vacuous.+ assert len(recorder.seen) > 1, "gateway bridge looked up no terminal keys"probe = "/hermes-bridge-probe" # absolute, so the cwd placeholder skip never fires- candidates = (- set(cli._TERMINAL_ENV_MAPPINGS) | set(hc_config.TERMINAL_CONFIG_ENV_MAP) | _KeyRecorder.seen- )+ candidates = set(_cli_env_map()) | set(hc_config.TERMINAL_CONFIG_ENV_MAP) | recorder.seenbridged: dict[str, str] = {}with patch.dict(os.environ): # restores the process env on exitfor key in sorted(candidates):@@ -101,9 +112,7 @@ def test_cli_and_gateway_env_maps_agree():them means a config.yaml setting that "works in CLI mode but not gatewaymode" (or vice-versa) — the bug class that shipped twice already."""- import cli-- cli_map = {k: v for k, v in cli._TERMINAL_ENV_MAPPINGS.items() if k not in _CLI_ONLY_OK}+ cli_map = {k: v for k, v in _cli_env_map().items() if k not in _CLI_ONLY_OK}gw_map = _gateway_env_map()# cli.py copies the canonical `backend` key onto the legacy `env_type`# alias before bridging, so the gateway's `backend` is cli's `env_type`.@@ -132,7 +141,7 @@ def test_save_config_set_bridges_every_cli_terminal_key():save_keys = _save_config_env_sync_keys()# cwd is bridged separately by set_config_value; home_mode is CLI-only.exempt = _CLI_ONLY_OK | {"cwd", "home_mode"}- missing = (_cli_env_map_keys() - exempt) - save_keys+ missing = (set(_cli_env_map()) - exempt) - save_keysassert not missing, (f"`hermes config set terminal.X` doesn't sync these keys to .env: "f"{sorted(missing)}. Add them to TERMINAL_CONFIG_ENV_MAP in "