Skip to content

The agent that grows with you

test: restore five contracts the preservation review found uncovered

kshitijk4poor34a5f95a305f
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.ts
index 4f577e98a22..48ce87e00d4 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
@@ -55,5 +55,11 @@ describe('bot_relay.deliver budget mirrors', () => {
// 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)
})
})
diff --git a/tests/gateway/test_model_command_context_offload.py b/tests/gateway/test_model_command_context_offload.py
index 333d317097f..be1ab68e958 100644
--- a/tests/gateway/test_model_command_context_offload.py
+++ b/tests/gateway/test_model_command_context_offload.py
@@ -97,7 +97,7 @@ async def test_context_resolution_runs_off_the_loop_thread(tmp_path, monkeypatch
def _recording_resolver(model, provider, **kwargs):
seen.setdefault("threads", []).append(threading.current_thread())
- return 128000
+ return 123457
monkeypatch.setattr(
model_switch, "resolve_display_context_length", _recording_resolver
@@ -107,6 +107,7 @@ async def test_context_resolution_runs_off_the_loop_thread(tmp_path, monkeypatch
result = await runner._handle_model_command(_event("/model gpt-5.5"))
assert result is not None and "gpt-5.5" in result
+ assert "123,457" in result, "the async resolver must hand back the sync resolver's value"
assert seen.get("threads"), "handler never resolved the context length"
assert all(th is not loop_thread for th in seen["threads"]), (
"resolve_display_context_length ran on the event loop thread — "
diff --git a/tests/hermes_cli/test_model_switch_parsing.py b/tests/hermes_cli/test_model_switch_parsing.py
index 2b398ef6513..45f2e50bd76 100644
--- a/tests/hermes_cli/test_model_switch_parsing.py
+++ b/tests/hermes_cli/test_model_switch_parsing.py
@@ -21,6 +21,7 @@ def test_provider_flag_and_scopes():
assert req.scope == "global"
assert req.errors == ()
+ assert parse_model_switch_args("sonnet").scope == "default"
assert parse_model_switch_args("sonnet --session").scope == "session"
assert parse_model_switch_args("sonnet \u2013session").scope == "session" # iOS/Telegram en-dash
assert parse_model_switch_args("sonnet --once").scope == "once"
diff --git a/tests/hermes_cli/test_shared_metrics_send_wiring.py b/tests/hermes_cli/test_shared_metrics_send_wiring.py
index 293da0da71d..101a86a7a64 100644
--- a/tests/hermes_cli/test_shared_metrics_send_wiring.py
+++ b/tests/hermes_cli/test_shared_metrics_send_wiring.py
@@ -127,7 +127,9 @@ class TestOptIn:
def test_export_still_runs_when_sending_is_off(self, runtime, monkeypatch, capture_sender):
_set_config(monkeypatch, _config(enabled=True))
runtime._export()
+ runtime._join_send_thread(timeout=1)
assert runtime.subscriber.store.exported == 1
+ assert capture_sender["passes"] == [] # the gate reads resolved.send, not enabled
class TestInteractivePathIsNotBlocked:
diff --git a/tests/tools/test_code_execution_windows_env.py b/tests/tools/test_code_execution_windows_env.py
index ef6924b936d..c6ed6b6b8de 100644
--- a/tests/tools/test_code_execution_windows_env.py
+++ b/tests/tools/test_code_execution_windows_env.py
@@ -1,4 +1,4 @@
-"""Windows essentials and native Winsock/legacy-encoding controls.
+"""Windows essentials and the native Winsock control.
Actual production UTF-8 env and Unicode RPC are exercised in
`test_code_execution_modes.py`; never reproduce the production scrubber here.
@@ -84,8 +84,6 @@ class TestWindowsSocketSmokeTest:
f" scrubbed keys={sorted(scrubbed.keys())}"
)
assert "OK" in result.stdout
- # Otherwise: crash OR garbled output — both count as proving the
- # bug is real on this system.
def _configured_timezone_child_env():
diff --git a/tests/tools/test_terminal_config_env_sync.py b/tests/tools/test_terminal_config_env_sync.py
index 50d0c02c020..7840a74c410 100644
--- a/tests/tools/test_terminal_config_env_sync.py
+++ b/tests/tools/test_terminal_config_env_sync.py
@@ -36,8 +36,20 @@ def _gateway_env_map() -> dict[str, str]:
from gateway.run import _bridge_terminal_config_to_env
from hermes_cli import config as hc_config
+ class _KeyRecorder(dict):
+ """Empty config that records every key the bridge asks about."""
+
+ 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
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) | {"backend"}
+ candidates = (
+ set(cli._TERMINAL_ENV_MAPPINGS) | set(hc_config.TERMINAL_CONFIG_ENV_MAP) | _KeyRecorder.seen
+ )
bridged: dict[str, str] = {}
with patch.dict(os.environ): # restores the process env on exit
for key in sorted(candidates):
diff --git a/tools/bot_relay.py b/tools/bot_relay.py
index 6a761f3a2b0..a9992ea8fce 100644
--- a/tools/bot_relay.py
+++ b/tools/bot_relay.py
@@ -44,7 +44,7 @@ DEFAULT_ENVELOPE_TTL_SECONDS = 900 # older envelopes are refused at drain with
# Per-attempt turn timeout and attempt ceiling for bot_relay.deliver (tui_gateway/methods_bot_relay.py).
TURN_ATTEMPT_TIMEOUT_SECONDS = 600
TURN_MAX_ATTEMPTS = 2 # first attempt + the policy-gated re-run
-# Mirrors RELAY_DELIVER_TIMEOUT_MS in apps/desktop/src/plugins/hermes-bots/relay.ts; both test suites pin it.
+# Mirrors RELAY_DELIVER_TIMEOUT_MS in apps/desktop/src/plugins/hermes-bots/relay-budget.ts; both test suites pin it.
DESKTOP_DELIVER_SETTLEMENT_MARGIN_SECONDS = 180
DESKTOP_DELIVER_TIMEOUT_SECONDS = (
TURN_WAIT_SECONDS_FALLBACK + TURN_ATTEMPT_TIMEOUT_SECONDS * TURN_MAX_ATTEMPTS + DESKTOP_DELIVER_SETTLEMENT_MARGIN_SECONDS