The agent that grows with you
Python aiai-agentai-agentsanthropicchatgptclaudeclaude-codecodexhermeshermes-agentllmnous-researchopenai
fix(pm): active memory provider joins the union — the mnemosyne path
ethernet7a7abd3ebeea
diff --git a/pm/plugins_state.py b/pm/plugins_state.pyindex 38e130ce86e..b75e926241b 100644--- a/pm/plugins_state.py+++ b/pm/plugins_state.py@@ -11,6 +11,7 @@ second authority for enabled state.from __future__ import annotationsfrom pathlib import Path+from typing import Optionaldef _profiles_root() -> Path:@@ -74,15 +75,46 @@ def _all_homes() -> list[Path]:def enabled_plugins_ordered() -> dict[Path, list[str]]:"""plugins_dir → ordered enabled list, per home. Keyed by the- PLUGINS DIR (where the member dirs live), not the home itself."""+ PLUGINS DIR (where the member dirs live), not the home itself.++ 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. The provider rides LAST (newest — the bisect's+ incumbent-wins tiebreak disables it before older plugins)."""out: dict[Path, list[str]] = {}for home in _all_homes():enabled = _enabled_list_for_home(home)+ provider = _active_memory_provider(home)+ if provider and provider not in enabled:+ enabled = enabled + [provider]if enabled:out[home / "plugins"] = enabledreturn out+def _active_memory_provider(home: Path) -> Optional[str]:+ """The home's ``memory.provider`` config key, when set and its plugin+ dir exists (a provider name with no installed dir is not a member)."""+ try:+ import yaml++ config_path = home / "config.yaml"+ if not config_path.is_file():+ return None+ with config_path.open(encoding="utf-8-sig") as f:+ config = yaml.safe_load(f) or {}+ provider = (config.get("memory") or {}).get("provider")+ if not isinstance(provider, str) or not provider.strip():+ return None+ name = provider.strip()+ if (home / "plugins" / name).is_dir():+ return name+ return None+ except Exception:+ return None++def disable_plugins(names: list[str]) -> dict[str, list[str]]:"""Remove names from EVERY home's enabled list (a bisect decisionnames the plugin, not the profile — disable where it's enabled).diff --git a/tests/pm/test_plugins_state.py b/tests/pm/test_plugins_state.pyindex 57e38cc236e..28e1d26d5cd 100644--- a/tests/pm/test_plugins_state.py+++ b/tests/pm/test_plugins_state.py@@ -85,3 +85,48 @@ def test_enabled_read_survives_garbage_config(homes):default_home, _ = homes(default_home / "config.yaml").write_text("{ not yaml", encoding="utf-8")assert pstate.enabled_plugins_ordered() == {}+++def test_active_memory_provider_joins_union(homes, tmp_path):+ """The mnemosyne path: a provider installed via memory.provider (not+ plugins.enabled) must join the union — deps ride the lock either way."""+ default_home, _ = homes+ provider_dir = default_home / "plugins" / "mnemosyne-like"+ provider_dir.mkdir(parents=True)+ (provider_dir / "pyproject.toml").write_text("[project]\n", encoding="utf-8")+ import yaml++ with (default_home / "config.yaml").open("w", encoding="utf-8") as f:+ yaml.safe_dump(+ {"plugins": {"enabled": ["regular-plug"]},+ "memory": {"provider": "mnemosyne-like"}},+ f,+ )++ by_root = pstate.enabled_plugins_ordered()+ assert by_root[default_home / "plugins"] == ["regular-plug", "mnemosyne-like"]+++def test_memory_provider_without_dir_is_skipped(homes):+ """memory.provider set but no plugin dir on disk — not a member."""+ default_home, _ = homes+ import yaml++ with (default_home / "config.yaml").open("w", encoding="utf-8") as f:+ yaml.safe_dump({"memory": {"provider": "ghost-provider"}}, f)++ assert pstate.enabled_plugins_ordered() == {}+++def test_memory_provider_already_enabled_not_duplicated(homes):+ default_home, _ = homes+ (default_home / "plugins" / "dual").mkdir(parents=True)+ import yaml++ with (default_home / "config.yaml").open("w", encoding="utf-8") as f:+ yaml.safe_dump(+ {"plugins": {"enabled": ["dual"]}, "memory": {"provider": "dual"}}, f+ )++ by_root = pstate.enabled_plugins_ordered()+ assert by_root[default_home / "plugins"] == ["dual"] # once, not twice