Skip to content

The agent that grows with you

test: no test reaches a live Nous service (Portal guest mints)

Teknium947e2c90caa1
diff --git a/tests/conftest.py b/tests/conftest.py
index 56422616f6a..2ad65e84413 100644
--- a/tests/conftest.py
+++ b/tests/conftest.py
@@ -1375,6 +1375,45 @@ def _audio_playback_guard(request, monkeypatch):
yield
+# ── Live Nous services fence ─────────────────────────────────────────────────
+# A test home starts with no Nous identity, so any path that ends in a hosted
+# connector action (connect, rename, status, the tool's first call) mints a REAL
+# guest on the production Portal: up to GUEST_MINT_TIMEOUT_SECONDS per test,
+# red whenever the Portal is slow, and a new guest identity on production on
+# every CI run. The same holds for billing, plan limits, the dashboard OAuth
+# provider and every other client built on a Nous URL. Refusing the name lookup
+# covers all of them at once (httpx, urllib, aiohttp and asyncio all resolve
+# through socket.getaddrinfo), and fails exactly like an offline host, which is
+# the path production already handles. Tests of these clients stub the
+# transport (tests/hermes_cli/anon_portal.py routes httpx at a fake Portal), so
+# they never reach the lookup. Live canaries opt in with ``@pytest.mark.live``.
+_NOUS_SERVICE_DOMAINS = ("nousresearch.com", "staging-nousresearch.com")
+
+
+def _is_nous_service_host(host) -> bool:
+ name = (host.decode() if isinstance(host, bytes) else str(host or "")).lower().rstrip(".")
+ return any(name == domain or name.endswith("." + domain) for domain in _NOUS_SERVICE_DOMAINS)
+
+
[email protected](autouse=True)
+def _no_live_nous_services(request, monkeypatch):
+ if request.node.get_closest_marker("live"):
+ return
+ import socket
+
+ real_getaddrinfo = socket.getaddrinfo
+
+ def fenced_getaddrinfo(host, *args, **kwargs):
+ if _is_nous_service_host(host):
+ raise socket.gaierror(
+ socket.EAI_NONAME,
+ f"test fence: {host!r} is a live Nous service; stub the HTTP layer "
+ "(tests/hermes_cli/anon_portal.py) or mark the test live")
+ return real_getaddrinfo(host, *args, **kwargs)
+
+ monkeypatch.setattr(socket, "getaddrinfo", fenced_getaddrinfo)
+
+
@pytest.fixture(autouse=True)
def _isolate_computer_use_approval_state():
"""Reset the computer-use explicit approval callback after every test.
diff --git a/tests/test_live_nous_services_fence.py b/tests/test_live_nous_services_fence.py
new file mode 100644
index 00000000000..1428ba1138f
--- /dev/null
+++ b/tests/test_live_nous_services_fence.py
@@ -0,0 +1,27 @@
+"""No test reaches a live Nous service unless it is a ``live`` canary (``tests/conftest.py``).
+
+A test home has no Nous identity, so a hosted connector action used to mint a real guest on
+the production Portal: seconds per test, red when the Portal was slow, and a new production
+guest on every CI run.
+"""
+
+import socket
+
+import pytest
+
+
+def test_first_connector_action_in_a_test_home_mints_no_portal_guest():
+ from hermes_cli import anon_auth
+ from tools.connectors.gateway.config import ensure_guest_identity
+
+ failure = ensure_guest_identity()
+
+ assert failure and failure.startswith("Hosted connectors could not be set up.")
+ assert not anon_auth.has_guest()
+
+
[email protected]("host", ["portal.nousresearch.com", "inference-api.nousresearch.com",
+ b"WELCOME-API.NOUSRESEARCH.COM.", "telemetry.staging-nousresearch.com"])
+def test_nous_hosts_are_refused_at_the_name_lookup(host):
+ with pytest.raises(socket.gaierror, match="test fence"):
+ socket.getaddrinfo(host, 443)