The agent that grows with you
Python aiai-agentai-agentsanthropicchatgptclaudeclaude-codecodexhermeshermes-agentllmnous-researchopenai
test(cron): restore the routed-fire handoff test for _launch_external_cron_worker
kshitijk4poor3b3b61ff4c69
diff --git a/tests/cron/test_restart_safe_worker.py b/tests/cron/test_restart_safe_worker.pyindex 961453aacaa..879517c1e34 100644--- a/tests/cron/test_restart_safe_worker.py+++ b/tests/cron/test_restart_safe_worker.py@@ -319,6 +319,49 @@ def test_scoped_wrapper_exit_without_user_bus_names_the_cause_and_invalidates_prassert pr._SYSTEMD_SCOPE_AVAILABLE is False+def test_launch_external_worker_treats_a_routed_fire_as_multiplexed(tmp_path, monkeypatch):+ """A fire routed to another profile is multiplexed at the handoff boundary (#107695 review on+ f5f88d5058). ``run_one_job`` only enables the context in ``_install_fire_secret_scope``, which runs+ AFTER this handoff, so a routed desktop fire on the managed path serialized ``multiplex_active=False``+ and the worker inherited the launch profile's residue. The payload must carry ``True`` and the+ worker env must not carry a launch-only value — and the context must not outlive the handoff."""+ import cron.scheduler as scheduler+ import hermes_constants+ from agent import secret_scope+ from hermes_constants import reset_hermes_home_override, set_hermes_home_override+ from tools.process_registry import GatewayChildDispatch++ launch = tmp_path / "launch"+ routed = tmp_path / "routed"+ launch.mkdir()+ routed.mkdir()+ (launch / ".env").write_text("LAUNCH_ONLY_SECRET=launch-secret\n", encoding="utf-8")+ (routed / ".env").write_text("", encoding="utf-8")+ monkeypatch.setenv("LAUNCH_ONLY_SECRET", "launch-secret")+ monkeypatch.setattr(scheduler, "_get_hermes_home", lambda: routed)+ monkeypatch.setattr(hermes_constants, "get_process_hermes_home", lambda: launch)+ monkeypatch.setattr("cron.scheduler_provider.routed_profile_fire", lambda: True)+ monkeypatch.setattr(+ "tools.process_registry.restart_safe_gateway_child_argv",+ lambda command, *, unit_suffix, require_restart_safe_scope=False: GatewayChildDispatch(+ "scoped", ["scope", "--", *command]),+ )+ spawned, payloads, _handoff, _get = _stub_external_worker_launch(scheduler, monkeypatch)++ assert not secret_scope.is_multiplex_active() # the desktop tick itself is NOT a multiplexer+ home_token = set_hermes_home_override(str(routed))+ try:+ assert scheduler._launch_external_cron_worker(+ {"id": "job-r", "execution_id": "exec-1", "prompt": "work"}) is True+ finally:+ reset_hermes_home_override(home_token)++ assert payloads[0]["multiplex_active"] is True+ assert "LAUNCH_ONLY_SECRET" not in spawned[0][1]["env"]+ assert not secret_scope.is_multiplex_active() # enabled for the handoff span only+ assert os.environ["LAUNCH_ONLY_SECRET"] == "launch-secret" # parent untouched++def test_launch_external_worker_uses_restart_safe_scope_and_acknowledges(tmp_path, monkeypatch):