Skip to content

The agent that grows with you

fix(plugins): never re-arm a disabled or gated platform plugin

kshitijk4poor9191be4486d4
diff --git a/hermes_cli/plugins_loader.py b/hermes_cli/plugins_loader.py
index e0b76d11312..ddd938a57da 100644
--- a/hermes_cli/plugins_loader.py
+++ b/hermes_cli/plugins_loader.py
@@ -270,11 +270,16 @@ class PluginLoaderMixin:
retries the import. A failed load disposes its lease (the registry forgets the platform), so without
this a load that raised or overran its deadline at startup stays down until a forced re-discovery
(#126356). True when a loader was re-armed."""
- with self._discovery_lock:
+ from hermes_cli.plugins_discovery import _get_disabled_plugins, _get_enabled_plugins, gate_manifest
+ from hermes_cli.plugins_manifest import requires_hermes_error
+ with self._discovery_lock, _plugin_home_scope(self.home_path):
failed = next((p.manifest for p in self._plugins.values()
if p.error and not p.enabled and p.manifest.kind == "platform"
and self._platform_name_from_manifest(p.manifest) == platform_name), None)
- if failed is None:
+ # Re-gate: a placeholder (disabled, not enabled, catalog-removed) or a requires_hermes mismatch
+ # carries the same error-set shape as a failed load but must never be imported.
+ if failed is None or requires_hermes_error(failed) or gate_manifest(
+ failed, _get_disabled_plugins(), _get_enabled_plugins()).action not in ("defer", "load"):
return False
logger.info("Re-arming failed platform plugin load: %s", platform_name)
self._register_deferred_platform(failed)
diff --git a/tests/hermes_cli/test_deferred_platform_client_tools.py b/tests/hermes_cli/test_deferred_platform_client_tools.py
index 0151c01c0e4..f9c625a8ab2 100644
--- a/tests/hermes_cli/test_deferred_platform_client_tools.py
+++ b/tests/hermes_cli/test_deferred_platform_client_tools.py
@@ -431,7 +431,7 @@ class TestDeferredPlatformToolPreregistration:
# The bookkeeping entry must not outlive the failed load attempt.
assert "probeplat-platform" not in mgr._predeclared_tools
- def test_failed_load_is_rearmed_and_heals_on_next_lookup(self, tmp_path, probe, clean_registry):
+ def test_failed_load_is_rearmed_and_heals_on_next_lookup(self, tmp_path, probe, clean_registry, monkeypatch):
"""A platform whose first deferred load raises (e.g. a load-deadline overrun under startup I/O) is
re-armed by the reconnect watcher's hook, so the next lookup imports it again and the platform
registers, without a forced re-discovery (#126356)."""
@@ -452,6 +452,10 @@ class TestDeferredPlatformToolPreregistration:
mgr._register_deferred_platform(manifest)
assert platform_registry.get("probeplat") is None
assert platform_registry.get("probeplat") is None # a failed load is never retried by a lookup
+ with monkeypatch.context() as m: # a placeholder the user disabled is never imported by a re-arm
+ m.setattr("hermes_cli.plugins_discovery._get_disabled_plugins", lambda: {"probeplat-platform"})
+ mgr._gate_manifest(manifest, {"probeplat-platform"}, None)
+ assert mgr.rearm_failed_platform("probeplat") is False
assert mgr.rearm_failed_platform("probeplat") is True
assert platform_registry.get("probeplat") is not None