The agent that grows with you
Python aiai-agentai-agentsanthropicchatgptclaudeclaude-codecodexhermeshermes-agentllmnous-researchopenai
fix(plugins): the dependency probe reads the declaration PM installs from
Teknium73ce02847e68
diff --git a/hermes_cli/plugins_loader.py b/hermes_cli/plugins_loader.pyindex 65ba8ad9c93..8ad2ef2d0e9 100644--- a/hermes_cli/plugins_loader.py+++ b/hermes_cli/plugins_loader.py@@ -223,14 +223,31 @@ def _dist_installed(req: str, path: Optional[list[str]] = None) -> Optional[booldef missing_python_dependencies(manifest: Any) -> list[str]:- """The plugin's declared ``python_dependencies`` this process cannot import.+ """The plugin's effective Python requirements (:func:`_declared_requirements`) this process+ cannot import.A requirement whose environment marker excludes this interpreter is never missing: PM does notinstall it here, so reporting it would ask for a restart or repair that can never help."""- return [req for req in getattr(manifest, "python_dependencies", None) or ()+ return [req for req in _declared_requirements(manifest)if _applies_here(req) and _dist_installed(req) is False]+def _declared_requirements(manifest: Any) -> tuple[str, ...]:+ """What PM installs into Hermes's environment for this plugin: its declaration read the way+ admission reads it (``pm.plugin_declarations.read_python_declaration`` — an authored+ ``pyproject.toml`` first, then ``python_dependencies`` / ``pip_dependencies``; nothing for a+ ``python_runtime: external`` sidecar). A plugin with no directory (an entry point) has only its+ manifest list."""+ path = getattr(manifest, "path", None)+ if not path or not Path(path).is_dir():+ return tuple(getattr(manifest, "python_dependencies", None) or ())+ from pm.plugin_declarations import read_python_declaration+ try:+ return read_python_declaration(Path(path)).install_requirements+ except (OSError, ValueError): # a declaration PM cannot read is refused at admission, not ours to report+ return ()++def _applies_here(req: str) -> bool:if ";" not in req:return True@@ -481,27 +498,24 @@ class PluginLoaderMixin:Plugin admission and PM repair own dependency changes."""- deps = manifest.python_dependencies- if not deps:+ missing = missing_python_dependencies(manifest)+ if not missing:returnkey = manifest_key(manifest)- missing = missing_python_dependencies(manifest)- if missing and installed_in_selected_environment(missing):+ if installed_in_selected_environment(missing):logger.warning("Plugin %s's Python dependencies were installed after this process started: %s. ""A running process never switches dependency environments; restart Hermes ""(hermes gateway restart for the gateway) to load them.",key, ", ".join(missing),)- elif missing:+ else:logger.warning("Plugin %s declares Python dependencies that are not ""installed: %s. For an enabled plugin, run hermes pm repair, ""then restart Hermes. Discovery does not install dependencies.",key, ", ".join(missing),)- else:- logger.debug("Plugin %s python_dependencies satisfied: %s", key, ", ".join(deps))def _validate_plugin_config_schema(self, manifest: PluginManifest) -> None:"""Warn (never block) on plugins.entries.<id> settings that violate config_schema.diff --git a/tests/hermes_cli/test_plugin_dependency_restart.py b/tests/hermes_cli/test_plugin_dependency_restart.pyindex 7fe47592176..ce6834965e1 100644--- a/tests/hermes_cli/test_plugin_dependency_restart.py+++ b/tests/hermes_cli/test_plugin_dependency_restart.py@@ -211,6 +211,39 @@ def test_a_plugin_importing_its_new_dependency_at_load_still_asks_for_a_restart(PluginActivation.model_validate(result["activation"]) # the plugins.manage wire accepts it[email protected]("shape, restart", [+ ("pyproject", True), ("pip_dependencies", True), ("external", False)])+def test_restart_follows_what_pm_installs_for_the_plugin(home, shape, restart):+ """The probe reads the declaration the way PM admission does: an authored pyproject.toml, the+ legacy ``pip_dependencies`` alias, and nothing for a ``python_runtime: external`` sidecar (its+ dependencies never enter Hermes's environment, so no restart or repair can load them)."""+ from hermes_cli import plugins++ _select_generation(home, with_dist=True)+ plugin = home / "plugins" / "depprobe"+ manifest = {"pyproject": "name: depprobe\nversion: '1.0'\n",+ "pip_dependencies": f"name: depprobe\nversion: '1.0'\npip_dependencies:\n - '{REQ}'\n",+ "external": (f"name: depprobe\nversion: '1.0'\npython_runtime: external\n"+ f"python_dependencies:\n - '{REQ}'\n")}[shape]+ (plugin / "plugin.yaml").write_text(manifest, encoding="utf-8")+ if shape == "pyproject":+ (plugin / "pyproject.toml").write_text(+ f'[project]\nname = "depprobe"\nversion = "1.0"\ndependencies = ["{REQ}"]\n', encoding="utf-8")+ if shape != "external": # an external sidecar's dependency is never importable in-process+ (plugin / "__init__.py").write_text(+ "import hermes_depprobe_fixture\n\ndef register(ctx):\n pass\n", encoding="utf-8")+ try:+ plugins.discover_plugins(force=True)+ manager = plugins.get_plugin_manager()+ entry = plugins_activation.find_activation(+ plugins_activation.activation_summaries(manager)+ + plugins_activation.dependency_blocked_summaries(manager), "depprobe")+ finally:+ plugins._reset_plugin_managers_for_tests()++ assert bool((entry or {}).get("missing_dependencies")) is restart, entry++def test_an_installed_version_the_requirement_rejects_is_missing(home, monkeypatch, tmp_path):"""``plugins update`` raising a floor: the running process holds 1.0, the selected generation1.7. A name-only probe called that satisfied and asked for no restart."""