The agent that grows with you
Python aiai-agentai-agentsanthropicchatgptclaudeclaude-codecodexhermeshermes-agentllmnous-researchopenai
test(kanban): pin the install root on the owner-submit worker for every resolved argv
Teknium54f60dfb4603
diff --git a/hermes_cli/kanban_db_dispatch.py b/hermes_cli/kanban_db_dispatch.pyindex 97727e07d72..8503309f9fa 100644--- a/hermes_cli/kanban_db_dispatch.py+++ b/hermes_cli/kanban_db_dispatch.py@@ -2527,26 +2527,6 @@ def _module_hermes_argv() -> list[str]:return [sys.executable, "-m", "hermes_cli.main"]-def _propagate_module_import_root(cmd: list[str], env: dict[str, str]) -> None:- """Put the running install's package root on a module-form worker's path.-- ``_resolve_hermes_argv`` proves ``hermes_cli`` importable in THIS process,- where a store-python shim has the repo root on ``sys.path`` in-process;- the spawned child runs the bare ``sys.executable`` from the task workspace- with a scrubbed ``PYTHONPATH`` and cannot import the package the parent- just proved importable — it dies before any work and the board- auto-blocks (#122299, #122487, #122500). Same-interpreter child, so the- root is version-safe to propagate; ``hermes_cli.main``'s own bootstrap- then owns dependency activation as usual. A resolved shim path owns its- imports and is left alone. Same pin cron's external worker uses (#112729).- """- if cmd[1:3] != ["-m", "hermes_cli.main"]:- return- from cron.scheduler_worker_env import pin_hermes_tree_on_pythonpath-- pin_hermes_tree_on_pythonpath(env, Path(__file__).resolve().parents[1])--def _absolute_hermes_path(path: str) -> str:"""Return an absolute filesystem path for a resolved Hermes shim."""expanded = os.path.expanduser(path)diff --git a/tests/hermes_cli/test_kanban_db.py b/tests/hermes_cli/test_kanban_db.pyindex 0734a74703b..a07e3fe1dd8 100644--- a/tests/hermes_cli/test_kanban_db.py+++ b/tests/hermes_cli/test_kanban_db.py@@ -1620,15 +1620,15 @@ def test_resolve_hermes_argv_module_actually_runs():def test_default_spawn_pins_repo_root_on_module_worker_pythonpath(tmp_path, monkeypatch):- """A module-form worker must carry the import context that selected it.-- ``_resolve_hermes_argv`` proves ``hermes_cli`` importable in the gateway,- where a store-python shim has the repo root on ``sys.path`` in-process;- the worker env scrub strips Hermes-owned PYTHONPATH entries, so the bare- ``sys.executable -m hermes_cli.main`` child died on import and the board- auto-blocked (#122299, #122487, #122500). The spawned env must put the- running install's root first on PYTHONPATH — and never for a resolved shim- path, which owns its own imports.+ """The dispatcher's worker must carry the import context of the install that spawned it.++ The worker is always ``sys.executable -m hermes_cli.kanban_worker_client`` (it only submits+ the claim to the profile owner), and the worker env scrub strips Hermes-owned PYTHONPATH+ entries, so a bare module child died on import and the board auto-blocked (#122299,+ #122487, #122500). The spawned env must put the running install's root first on+ PYTHONPATH. Main's carve-out for a resolved ``hermes`` shim path does not apply here: the+ worker never runs the resolved CLI argv, so a ``$HERMES_BIN``/PATH shim can neither replace+ the module child nor drop the pin."""import osimport sys@@ -1662,13 +1662,11 @@ def test_default_spawn_pins_repo_root_on_module_worker_pythonpath(tmp_path, monkclaim_expires=None, tenant=None, branch_name=None,)- monkeypatch.setattr(kbd, "_resolve_hermes_argv", lambda: [sys.executable, "-m", "hermes_cli.main"])- kbd._default_spawn(task, str(tmp_path / "ws"))- assert captured["env"]["PYTHONPATH"].split(os.pathsep)[0] == root-- monkeypatch.setattr(kbd, "_resolve_hermes_argv", lambda: ["/opt/hermes/bin/hermes"])- kbd._default_spawn(task, str(tmp_path / "ws"))- assert root not in captured["env"].get("PYTHONPATH", "").split(os.pathsep)+ for resolved in ([sys.executable, "-m", "hermes_cli.main"], ["/opt/hermes/bin/hermes"]):+ monkeypatch.setattr(kbd, "_resolve_hermes_argv", lambda resolved=resolved: resolved)+ kbd._default_spawn(task, str(tmp_path / "ws"))+ assert captured["cmd"][-3:] == [sys.executable, "-m", "hermes_cli.kanban_worker_client"]+ assert captured["env"]["PYTHONPATH"].split(os.pathsep)[0] == root# ---------------------------------------------------------------------------