The agent that grows with you
Python aiai-agentai-agentsanthropicchatgptclaudeclaude-codecodexhermeshermes-agentllmnous-researchopenai
refactor(plugins): one per-home enable lock, not two
kshitijk4poor7abd2e5fec2b
diff --git a/hermes_cli/plugins_cmd_install.py b/hermes_cli/plugins_cmd_install.pyindex e6c58e6c8d6..c8492898178 100644--- a/hermes_cli/plugins_cmd_install.py+++ b/hermes_cli/plugins_cmd_install.py@@ -11,7 +11,6 @@ import loggingimport osimport sysimport tempfile-import threadingfrom contextlib import contextmanagerfrom contextvars import ContextVarfrom pathlib import Path@@ -19,7 +18,6 @@ from typing import Any, Callable, Optionalfrom hermes_cli.cli_output import line_inputfrom hermes_cli.plugin_install_phase import InstallPhase-from hermes_constants import hermes_home_keylogger = logging.getLogger(__name__)@@ -804,18 +802,6 @@ def _place_tree(entry, identifier: str, *, force: bool, ref: Optional[str], assureturn {"ok": False, "error": str(exc)}-# One lock per Hermes home. The Desktop install card enables several plugins at once, each on its own-# thread; without it every thread read the same config version and all but the first commit were-# refused as stale. The version check in PM stays: it still catches an edit from another process.-_ENABLE_LOCKS: dict[str, threading.Lock] = {}-_ENABLE_LOCKS_GUARD = threading.Lock()---def _enable_lock() -> threading.Lock:- with _ENABLE_LOCKS_GUARD:- return _ENABLE_LOCKS.setdefault(hermes_home_key(), threading.Lock())--def _enable_placed(installed_name: str, deps, step: Callable[[InstallPhase], None]) -> Optional[dict]:"""None once enabled, else the refusal result. Enabling admits the plugin, and admission resolvesits Python dependencies."""@@ -824,8 +810,8 @@ def _enable_placed(installed_name: str, deps, step: Callable[[InstallPhase], Nonif deps:step(InstallPhase.python_packages)try:- with _enable_lock():- _pc()._set_plugin_enabled(installed_name, enable=True)+ # _set_plugin_enabled serializes per home itself (parallel install-card rows).+ _pc()._set_plugin_enabled(installed_name, enable=True)except AdmissionRefused as exc:return {"ok": False, "error": f"enable refused: {exc}", "plugin_name": installed_name, "enabled": False}return None