The agent that grows with you
Python aiai-agentai-agentsanthropicchatgptclaudeclaude-codecodexhermeshermes-agentllmnous-researchopenai
test(kanban): assert worker toolsets through the owner policy, not the removed dispatcher helper
teknium16b47623aca66
diff --git a/tests/hermes_cli/test_kanban_worker_spawn_toolsets.py b/tests/hermes_cli/test_kanban_worker_spawn_toolsets.pyindex b1f221b3631..669f079a9ee 100644--- a/tests/hermes_cli/test_kanban_worker_spawn_toolsets.py+++ b/tests/hermes_cli/test_kanban_worker_spawn_toolsets.py@@ -1,5 +1,6 @@from __future__ import annotations+import pytestimport subprocess@@ -160,38 +161,46 @@ def test_default_spawn_resolves_env_passthrough_under_multiplex(monkeypatch, tmpassert captured["env"].get("MY_PASSTHROUGH_VAR") == "elias-value"-def test_resolve_worker_cli_toolsets_uses_profile_home_not_parent_config(monkeypatch, tmp_path):- root = tmp_path / ".hermes"- profile = root / "profiles" / "elias"- profile.mkdir(parents=True)- root.joinpath("config.yaml").write_text("platform_toolsets:\n cli:\n - kanban\n", encoding="utf-8")- profile.joinpath("config.yaml").write_text(- """-platform_toolsets:- cli:- - terminal- - web-toolsets:- - hermes-cli-""".lstrip(),- encoding="utf-8",- )- monkeypatch.setenv("HERMES_HOME", str(root))+def test_worker_toolsets_come_from_the_assignee_profile_not_the_parent_config(tmp_path, monkeypatch):+ """The worker's toolsets are frozen by the assignee profile's own gateway (its config), never+ by the dispatcher's root/active profile: a root config that only lists ``kanban`` must not+ reach a worker whose profile grants ``terminal`` and ``web``."""+ import json+ from contextlib import closing+ from types import SimpleNamespacefrom hermes_cli import kanban_db as kb- from hermes_cli import kanban_db_dispatch as kbd+ from hermes_cli.kanban_db_connect import connect+ from gateway.session_contract import Principal+ from gateway.session_kanban import build_kanban_policy- resolved = kbd._resolve_worker_cli_toolsets(str(profile))-- assert resolved is not None- assert "terminal" in resolved- assert "web" in resolved- # Opt-in is no longer inferred for ordinary chats. The dispatcher-owned- # worker gets lifecycle tools at schema assembly, independently of the- # assignee's saved chat selection.- monkeypatch.setenv("HERMES_KANBAN_TASK", "t_spawn_tools")- from model_tools import get_tool_definitions- names = {t["function"]["name"] for t in get_tool_definitions(resolved, quiet_mode=True, skip_tool_search_assembly=True)}- assert "kanban_complete" in names- assert "kanban_list" not in names- assert resolved != ["kanban"]+ profile = tmp_path / "profiles" / "elias"+ profile.mkdir(parents=True)+ monkeypatch.setenv("HERMES_KANBAN_HOME", str(tmp_path))+ monkeypatch.setenv("HERMES_HOME", str(profile))+ monkeypatch.setenv("HOME", str(tmp_path / "home"))+ monkeypatch.delenv("HERMES_KANBAN_DB", raising=False)+ monkeypatch.setattr("hermes_cli.profiles.resolve_profile_env", lambda name: str(profile))+ workspace = tmp_path / "workspace"+ workspace.mkdir()+ with closing(connect(board="owned")) as conn:+ task_id = kb.create_task(conn, title="t", body="b", assignee="elias",+ workspace_kind="dir", workspace_path=str(workspace))+ kb.recompute_ready(conn)+ task = kb.claim_task(conn, task_id)+ actor = Principal("owner", str(profile), frozenset({"session:create"}), "transport")+ connection = SimpleNamespace(authority=SimpleNamespace(profile_id=str(profile)), actor=actor, native_owner=True)+ params = dict(board="owned", task_id=task.id, run_id=task.current_run_id, claim_lock=task.claim_lock)++ assignee_config = {"model": {"default": "m", "provider": "custom"},+ "platform_toolsets": {"cli": ["terminal", "web"]}, "toolsets": ["hermes-cli"]}+ policy, _ = build_kanban_policy(connection, params, assignee_config)+ assert {"terminal", "web", "kanban"} <= set(policy.toolsets)++ root_only_kanban = {"model": {"default": "m", "provider": "custom"}, "platform_toolsets": {"cli": ["kanban"]}}+ other_profile = tmp_path+ with pytest.raises(Exception):+ # A dispatcher acting for another profile cannot mint this worker's policy at all.+ build_kanban_policy(SimpleNamespace(authority=SimpleNamespace(profile_id=str(other_profile)),+ actor=actor, native_owner=True), params, root_only_kanban)+ assert json.loads(policy.kanban_json)["profile"] == "elias"