Skip to content

The agent that grows with you

fix(dashboard): keep -p default in hub-action argv so actions hit the default profile

beardthelion9bdecbbf57b9
diff --git a/hermes_cli/web_server_profiles.py b/hermes_cli/web_server_profiles.py
index 618f21d4779..1fbc7b54f04 100644
--- a/hermes_cli/web_server_profiles.py
+++ b/hermes_cli/web_server_profiles.py
@@ -436,11 +436,14 @@ def _aux_task_summary(aux_rows: List[Dict[str, Any]]) -> List[Dict[str, Any]]:
def _profile_cli_args(profile: Optional[str]) -> List[str]:
- """``["-p", <name>]`` for a validated non-default profile, else ``[]``. Hub actions run in
+ """``["-p", <name>]`` for a validated named profile, else ``[]``. Hub actions run in
a fresh ``hermes`` subprocess whose ``_apply_profile_override()`` reads ``-p`` from argv —
- the only mechanism that reaches import-time-bound globals like ``skills_hub.SKILLS_DIR``."""
+ the only mechanism that reaches import-time-bound globals like ``skills_hub.SKILLS_DIR``.
+ ``default`` is a real named target, not an alias for the dashboard's own profile:
+ selector-less argv would make the child resolve the ambient ``HERMES_HOME`` (the launch
+ profile under a pooled ``-p X serve``), not the default home."""
requested = (profile or "").strip()
- if not requested or requested.lower() in {"current", "default"}:
+ if not requested or requested.lower() == "current":
return []
from hermes_cli import profiles as profiles_mod
_resolve_profile_dir(requested)
diff --git a/tests/hermes_cli/test_web_routers_destructive_profile_scope.py b/tests/hermes_cli/test_web_routers_destructive_profile_scope.py
index 2220456ab17..0397a655d92 100644
--- a/tests/hermes_cli/test_web_routers_destructive_profile_scope.py
+++ b/tests/hermes_cli/test_web_routers_destructive_profile_scope.py
@@ -271,6 +271,19 @@ def test_spawned_action_carries_the_named_profile(client, homes, seams, tmp_path
assert [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.py
index 99b5d44f9aa..38b444aa49e 100644
--- a/tests/hermes_cli/test_web_server_skills_profiles.py
+++ b/tests/hermes_cli/test_web_server_skills_profiles.py
@@ -131,3 +131,84 @@ class TestProfileScopedHubActions:
json={"identifier": "official/demo", "profile": "ghost"},
)
assert resp.status_code == 404
+
+
+ def test_hub_install_scoped_to_default_still_carries_the_selector(
+ self, client, isolated_profiles, monkeypatch
+ ):
+ """``default`` is a real named profile, not an alias for "the dashboard's own".
+ A pooled ``hermes -p worker_alpha serve`` dashboard answering a hub action with
+ ``profile=default`` must still emit ``-p default``: without it the child's env
+ carries this process's home verbatim and the install lands on worker_alpha."""
+ calls = []
+
+ class _FakeProc:
+ pid = 4242
+
+ def _fake_spawn(subcommand, name):
+ calls.append(list(subcommand))
+ return _FakeProc()
+
+ # Ambient home of a dashboard serving under the named profile.
+ monkeypatch.setenv("HERMES_HOME", str(isolated_profiles["worker_alpha"]))
+ monkeypatch.setattr(_web_server_gateway, "_spawn_hermes_action", _fake_spawn)
+ resp = client.post(
+ "/api/skills/hub/install",
+ json={"identifier": "official/demo", "profile": "default"},
+ )
+ assert resp.status_code == 200
+ assert calls == [
+ ["-p", "default", "skills", "install", "official/demo", "--yes"]
+ ]
+ # The spawn-path env pin must land the child on the default home, not the
+ # 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"]]