The agent that grows with you
Python aiai-agentai-agentsanthropicchatgptclaudeclaude-codecodexhermeshermes-agentllmnous-researchopenai
fix(gateway): don't start sibling deferred loads from a nested registry walk
kshitijk4poor0e77d0597416
diff --git a/gateway/platform_registry.py b/gateway/platform_registry.pyindex 63fcb2bba3e..167cbe202bd 100644--- a/gateway/platform_registry.py+++ b/gateway/platform_registry.py@@ -218,6 +218,8 @@ class PlatformRegistry:global_key = (None, name)event = self._inflight.get(scoped_key)load_key = scoped_key+ if event is None and name not in entries and self._loading.get():+ return # nested walk inside a loader: the outer walk resolves siblingsif event is None and name not in entries:loader = deferred.pop(name, None)if event is None and loader is None and name not in entries:diff --git a/tests/gateway/test_platform_registry.py b/tests/gateway/test_platform_registry.pyindex e1ef7f6792b..b7825e4558e 100644--- a/tests/gateway/test_platform_registry.py+++ b/tests/gateway/test_platform_registry.py@@ -680,7 +680,9 @@ class TestMigratedPlatformWiring:def test_registry_walk_from_plugin_load_worker_does_not_wait_on_parent(monkeypatch):- """register() re-walking the registry on its deadline worker must not block on its own load."""+ """register() re-walking the registry on its deadline worker must not block on its own or a sibling load."""+ import threading+from hermes_cli import plugins_loadermonkeypatch.setattr(plugins_loader, "_resolve_plugin_load_timeout", lambda: 0.5)@@ -691,12 +693,21 @@ def test_registry_walk_from_plugin_load_worker_does_not_wait_on_parent(monkeypatdef _abandon_load(self):abandoned.append(True)- def register():- reg.plugin_entries()- reg.register(PlatformEntry(name="reentrant", label="Re-entrant", adapter_factory=lambda cfg: None,- check_fn=lambda: True, source="plugin"))+ discovery_lock = threading.RLock() # like PluginManager._discovery_lock, held while joining the worker++ def make_loader(name):+ def register():+ reg.plugin_entries()+ reg.register(PlatformEntry(name=name, label=name, adapter_factory=lambda cfg: None,+ check_fn=lambda: True, source="plugin"))++ def loader():+ with discovery_lock:+ plugins_loader.run_with_load_deadline(name, Ctx(), register)+ return loader- reg.register_deferred("reentrant", lambda: plugins_loader.run_with_load_deadline("reentrant", Ctx(), register))+ for name in ("reentrant", "sibling"):+ reg.register_deferred(name, make_loader(name))- assert [e.name for e in reg.plugin_entries()] == ["reentrant"]+ assert sorted(e.name for e in reg.plugin_entries()) == ["reentrant", "sibling"]assert abandoned == []