Files
hermes-agent/plugins/config_backends/remote/__init__.py
Ben Barclay 3f903abeed refactor(config-remote): core resolves a backend kind generically and asks it through the protocol
HERMES_CONFIG_BACKEND=<kind> now resolves to plugins.config_backends.<kind>.get_backend() (a
direct import, never the general plugin loader, D11), with the kind checked against a package-name
pattern before any import. What core read from the remote plugin's internals is a protocol method
with a no-op FileBackend version: bootstrap_env_names() (env_loader's .env bootstrap),
preserve_read_base() (keeping_read_base) and doctor_warnings() (hermes doctor).

Addresses teknium1's P2-1 on #122509.
2026-10-27 17:33:48 -07:00

38 lines
1.0 KiB
Python

"""Remote config backend: ``HERMES_CONFIG_BACKEND=remote`` serves each profile's config from the
config plane (config-config) instead of ``config.yaml``. See ``backend.py``."""
from __future__ import annotations
import threading
from typing import Optional
from .backend import RemoteBackend
_BACKEND: Optional[RemoteBackend] = None
_LOCK = threading.Lock()
def get_remote_backend() -> RemoteBackend:
"""The process-wide instance (one poller and one in-memory layer per profile home)."""
global _BACKEND
if _BACKEND is None:
with _LOCK:
if _BACKEND is None:
_BACKEND = RemoteBackend()
return _BACKEND
def get_backend() -> RemoteBackend:
"""The entry point ``hermes_cli.config_backend`` resolves ``HERMES_CONFIG_BACKEND=remote`` to."""
return get_remote_backend()
def _reset_for_tests() -> None:
global _BACKEND
with _LOCK:
if _BACKEND is not None:
_BACKEND._stop.set()
_BACKEND = None
__all__ = ["RemoteBackend", "get_backend", "get_remote_backend"]