Skip to content

The agent that grows with you

test(pm): exercise active profile propagation through real subprocess env

ethernetabfefbf1fad1
diff --git a/pm/plugins_state.py b/pm/plugins_state.py
index 0039183b4d7..136867a8b8b 100644
--- a/pm/plugins_state.py
+++ b/pm/plugins_state.py
@@ -85,12 +85,8 @@ def enabled_plugins_ordered(*, proposed_home=None, enabled=None, disabled=None)
The ACTIVE MEMORY PROVIDER joins its home's list: providers install
via ``memory.provider`` (mnemosyne's documented path), not via
plugins.enabled — without this, a provider's dep plugin never joins
- the union. GAP, stated honestly: pm has NO automatic bisect or
- disable decision today — a resolver conflict fails loud and the
- admission authority refuses the candidate; nothing disables plugins
- on its own, so "prefer the memory provider" is not yet implemented
- by any code path. When such a decision exists it must keep the
- active memory provider over ordinary plugins."""
+ the union. Admission refuses a conflicting candidate without changing
+ the active environment or disabling an existing provider."""
out: dict[Path, list[str]] = {}
for home in _all_homes():
# ONE parse per home feeds both queries (enabled + provider).
diff --git a/tests/pm/test_plugin_survival_contract.py b/tests/pm/test_plugin_survival_contract.py
index 9db256c2181..77937d5327d 100644
--- a/tests/pm/test_plugin_survival_contract.py
+++ b/tests/pm/test_plugin_survival_contract.py
@@ -266,31 +266,20 @@ def test_retry_after_conflict_enables_resolvable_candidate(admission_env):
# 4. Active context home propagates to wrapper subprocess launches
# ---------------------------------------------------------------------------
[email protected](sys.platform != "win32", reason="detached respawn spec is Windows")
def test_active_context_home_exported_to_wrapper_subprocess(monkeypatch, tmp_path):
- """Hermes subprocess launchers must pass HERMES_HOME explicitly (the
- context-local override never crosses a process boundary on its own).
- The detached respawn spec exports the ACTIVE context home, and a
- child launched with that overlay observes it."""
from hermes_constants import reset_hermes_home_override, set_hermes_home_override
- from hermes_cli.gateway_windows import windowless_gateway_restart_spec
+ from tools.environments.local import build_subprocess_env
- active = tmp_path / "profiles" / "worker"
+ monkeypatch.setenv("HERMES_HOME", str(tmp_path / "ambient"))
+ active = tmp_path / "custom-root/profiles/worker"
active.mkdir(parents=True)
token = set_hermes_home_override(active)
try:
- argv, _cwd, overlay = windowless_gateway_restart_spec([sys.executable, "-c", "pass"])
- assert overlay.get("HERMES_HOME") == str(active), (
- "the respawn overlay must export the ACTIVE context home as HERMES_HOME"
+ child_env = build_subprocess_env()
+ child = subprocess.run(
+ [sys.executable, "-c", "import os; print(os.environ['HERMES_HOME'], end='')"],
+ env=child_env, capture_output=True, text=True, check=True, timeout=60,
)
+ assert child.stdout == str(active)
finally:
reset_hermes_home_override(token)
-
- # and a real subprocess launched with that overlay sees it
- child_env = {**os.environ, **overlay}
- out = subprocess.run(
- [sys.executable, "-c",
- "import os; print(os.environ['HERMES_HOME'], end='')"],
- env=child_env, capture_output=True, text=True, timeout=60,
- )
- assert out.returncode == 0 and out.stdout == str(active)