The agent that grows with you
Python aiai-agentai-agentsanthropicchatgptclaudeclaude-codecodexhermeshermes-agentllmnous-researchopenai
test(dashboard): trim the -p default salvage to two invariant tests (#120688, salvage #120689)
teknium1a335431b5d86
diff --git a/tests/hermes_cli/test_gateway_unnamed_default_home_verbs.py b/tests/hermes_cli/test_gateway_unnamed_default_home_verbs.pyindex c637f5cf0dd..ed210b0d6e3 100644--- a/tests/hermes_cli/test_gateway_unnamed_default_home_verbs.py+++ b/tests/hermes_cli/test_gateway_unnamed_default_home_verbs.py@@ -2,17 +2,10 @@``-p default`` explicitly (``_own_profile_selector``), so the spawned child can neverre-read the sticky ``active_profile`` and restart another profile's gateway, and so theaction environment takes the named-target scrub branch like every other named profile.--Regression for the Enough1122 automated-review blocker on the ``-p default`` hub-action-argv PR: ``_gateway_subcommand(None, "restart")`` used to emit a bare-``["gateway", "restart"]``; with ``active_profile=worker_gamma`` the child then resolved-``HERMES_HOME`` to ``<root>/profiles/worker_gamma`` while the dashboard served the-default root, and the default profile's ``MY_PLATFORM_TOKEN`` survived into the child."""from __future__ import annotations-import osfrom pathlib import Pathimport pytest@@ -27,10 +20,8 @@ def default_home_process(tmp_path, monkeypatch):(root / "profiles" / "coder" / "config.yaml").write_text("{}\n") # identity marker(root / "config.yaml").write_text("model: {default: x}\n")(root / "active_profile").write_text("coder") # sticky: points at a named profile- (root / ".env").write_text("MY_PLATFORM_TOKEN=dashboard-secret\n")monkeypatch.setattr(Path, "home", lambda: tmp_path)monkeypatch.setenv("HERMES_HOME", str(root))- monkeypatch.setenv("MY_PLATFORM_TOKEN", "dashboard-secret")for var in ("HERMES_SUPERVISED_CHILD", "HERMES_S6_SUPERVISED_CHILD", "INVOCATION_ID","HERMES_GATEWAY_EXTERNAL_SUPERVISOR", "HERMES_UPDATE_POST_SWAP"):monkeypatch.delenv(var, raising=False)@@ -40,8 +31,8 @@ def default_home_process(tmp_path, monkeypatch):def test_unnamed_lifecycle_verbs_from_default_home_always_name_default(default_home_process):- """Every unnamed verb pins ``-p default``: the child argv names a profile, the env- scrub branch treats it as a named target, and the dashboard token does not survive."""+ """Every unnamed verb pins ``-p default``: the child argv names a profile and the env+ pins the default home even though the sticky ``active_profile`` names ``coder``."""from hermes_cli.web_server_gateway import (_gateway_subcommand,_named_profile_from_action,@@ -54,19 +45,3 @@ def test_unnamed_lifecycle_verbs_from_default_home_always_name_default(default_hassert _named_profile_from_action(argv) == "default"env = _profile_action_environment(_gateway_subcommand(None, "restart"))assert env["HERMES_HOME"] == str(default_home_process)- assert "MY_PLATFORM_TOKEN" not in env---def test_unnamed_restart_child_ignores_sticky_active_profile(default_home_process, monkeypatch):- """End to end: the spawned child's first act (``_apply_profile_override``) must land- on the default root even though the sticky ``active_profile`` names ``coder``."""- from hermes_cli.main import _apply_profile_override- from hermes_cli.web_server_gateway import _gateway_subcommand, _profile_action_environment-- restart = _gateway_subcommand(None, "restart")- for var, value in _profile_action_environment(restart).items():- if var == "HERMES_HOME":- monkeypatch.setenv(var, value)- monkeypatch.setattr("sys.argv", ["hermes", *restart])- _apply_profile_override() # what the spawned child does first- assert os.environ["HERMES_HOME"] == str(default_home_process)diff --git a/tests/hermes_cli/test_web_routers_destructive_profile_scope.py b/tests/hermes_cli/test_web_routers_destructive_profile_scope.pyindex 0397a655d92..2220456ab17 100644--- a/tests/hermes_cli/test_web_routers_destructive_profile_scope.py+++ b/tests/hermes_cli/test_web_routers_destructive_profile_scope.py@@ -271,19 +271,6 @@ def test_spawned_action_carries_the_named_profile(client, homes, seams, tmp_pathassert [argv[:2] for _name, argv in seams["spawn"]] == [["-p", "worker_beta"]][email protected]("route", sorted(SPAWNING))-def test_spawned_action_scoped_to_default_still_carries_the_selector(- client, homes, seams, tmp_path, route-):- """``default`` is a real named target, not "no override": a pooled ``-p X serve``- backend must still put ``-p default`` in the child's argv or the subprocess resolves- the ambient home and the action lands on X."""- resp = SPAWNING[route](client, "default", tmp_path)-- assert resp.status_code == 200, resp.text- assert [argv[:2] for _name, argv in seams["spawn"]] == [["-p", "default"]]--@pytest.mark.parametrize("route", ["sessions-prune", "sessions-empty", "sessions-bulk-delete"])def test_session_route_opens_the_named_profiles_store(client, homes, seams, tmp_path, route):resp = DESTRUCTIVE[route](client, "worker_beta", tmp_path)diff --git a/tests/hermes_cli/test_web_server_skills_profiles.py b/tests/hermes_cli/test_web_server_skills_profiles.pyindex 38b444aa49e..db394e84333 100644--- a/tests/hermes_cli/test_web_server_skills_profiles.py+++ b/tests/hermes_cli/test_web_server_skills_profiles.py@@ -132,7 +132,6 @@ class TestProfileScopedHubActions:)assert resp.status_code == 404-def test_hub_install_scoped_to_default_still_carries_the_selector(self, client, isolated_profiles, monkeypatch):@@ -164,51 +163,3 @@ class TestProfileScopedHubActions:# ambient one it would inherit from a selector-less argv.env = _web_server_gateway._profile_action_environment(calls[0])assert env["HERMES_HOME"] == str(isolated_profiles["default"])--- @pytest.mark.parametrize("profile", ["Default", "DEFAULT"])- def test_hub_install_mixed_case_default_is_rejected_not_ambient(- self, client, isolated_profiles, monkeypatch, profile- ):- """A non-canonical casing is not a valid profile id: the request 400s like any- mixed-case name instead of silently falling back to the ambient home."""- calls = []-- class _FakeProc:- pid = 4242-- def _fake_spawn(subcommand, name):- calls.append(list(subcommand))- return _FakeProc()-- monkeypatch.setattr(_web_server_gateway, "_spawn_hermes_action", _fake_spawn)- resp = client.post(- "/api/skills/hub/install",- json={"identifier": "official/demo", "profile": profile},- )- assert resp.status_code == 400- assert calls == []--- @pytest.mark.parametrize("profile", [None, "", " ", "current", "CURRENT"])- def test_hub_install_without_a_named_profile_keeps_ambient_argv(- self, client, isolated_profiles, monkeypatch, profile- ):- """Only a real profile name earns ``-p``: unnamed/``current`` requests keep- the selector-less argv so the child resolves the dashboard's own home."""- calls = []-- class _FakeProc:- pid = 4242-- def _fake_spawn(subcommand, name):- calls.append(list(subcommand))- return _FakeProc()-- monkeypatch.setattr(_web_server_gateway, "_spawn_hermes_action", _fake_spawn)- resp = client.post(- "/api/skills/hub/install",- json={"identifier": "official/demo", "profile": profile},- )- assert resp.status_code == 200- assert calls == [["skills", "install", "official/demo", "--yes"]]