The Sep 2026 decomposition (PR #102117) makes internal import paths a non-API: names now live in the focused modules that define them. This commit is the ONLY thing keeping the old paths alive, so external plugins have time to update. It is deliberately a single, unsquashed commit: git revert <this sha> removes every shim, stub and manifest at once on the announced date. Nothing in-tree may depend on these pointers: scripts/check_compat_pointers.py (wired into lint.yml) fails CI if it does. What it adds (see COMPAT_MANIFEST.md, compat_manifest.json): - 332 facade modules get one delimited `PLUGIN-COMPAT` block appended at the end of the file - 1,172 moved names resolved lazily via a module `__getattr__` (PEP 562) — never a top-level import, so no import cycles; facades that already had `__getattr__` get a chained one - 592 third-party/stdlib names the old modules used to expose, with their original import statements - 266 public definitions that had been deleted as unused, restored byte-for-byte from the pre-decomposition tree (+40 private helpers and 16 imports pulled in only because a restored definition needs them) - 3 deleted modules recreated as re-export stubs (gateway/startup_watchdog, hermes_cli/observability/ relay_runtime, tools/environments/modal_utils) - private names (`_x`) get no pointer: they were never API (3,792 skipped) Verified: all 335 touched modules import under a fresh HERMES_HOME and every manifest name resolves; the lint reports zero in-tree uses; ruff clean; targeted suites unchanged.
76 lines
2.8 KiB
Python
76 lines
2.8 KiB
Python
"""Local JSON registry of approved remote meet nodes.
|
|
|
|
``$HERMES_HOME/workspace/meetings/nodes.json``::
|
|
|
|
{"nodes": {"<name>": {"url": "ws://host:port", "token": "...", "added_at": <epoch>}}}
|
|
"""
|
|
|
|
from __future__ import annotations
|
|
|
|
import time
|
|
from pathlib import Path
|
|
from typing import Any, Dict, List, Optional
|
|
|
|
from hermes_constants import get_hermes_home
|
|
|
|
from plugins.google_meet._jsonfile import read_json, write_json_atomic
|
|
|
|
|
|
def _default_path() -> Path:
|
|
return Path(get_hermes_home()) / "workspace" / "meetings" / "nodes.json"
|
|
|
|
|
|
class NodeRegistry:
|
|
"""File-backed registry; single writer assumed (the gateway CLI)."""
|
|
|
|
def __init__(self, path: Optional[Path] = None) -> None:
|
|
self.path = Path(path) if path is not None else _default_path()
|
|
|
|
def _load(self) -> Dict[str, Dict[str, Any]]:
|
|
"""The ``nodes`` map (name → entry); empty when the file is missing or malformed."""
|
|
data = read_json(self.path)
|
|
nodes = data.get("nodes") if isinstance(data, dict) else None
|
|
return nodes if isinstance(nodes, dict) else {}
|
|
|
|
def _save(self, nodes: Dict[str, Dict[str, Any]]) -> None:
|
|
write_json_atomic(self.path, {"nodes": nodes})
|
|
|
|
def get(self, name: str) -> Optional[Dict[str, Any]]:
|
|
entry = self._load().get(name)
|
|
return None if entry is None else {"name": name, **entry}
|
|
|
|
def add(self, name: str, url: str, token: str) -> None:
|
|
for label, value in (("node name", name), ("url", url), ("token", token)):
|
|
if not isinstance(value, str) or not value:
|
|
raise ValueError(f"{label} must be a non-empty string")
|
|
nodes = self._load()
|
|
nodes[name] = {"url": url, "token": token, "added_at": time.time()}
|
|
self._save(nodes)
|
|
|
|
def remove(self, name: str) -> bool:
|
|
nodes = self._load()
|
|
if name not in nodes:
|
|
return False
|
|
del nodes[name]
|
|
self._save(nodes)
|
|
return True
|
|
|
|
def list_all(self) -> List[Dict[str, Any]]:
|
|
return [{"name": name, **entry} for name, entry in sorted(self._load().items())]
|
|
|
|
def resolve(self, chrome_node: Optional[str]) -> Optional[Dict[str, Any]]:
|
|
"""Named node's entry, or (``chrome_node`` falsy) the sole registered node; None if unknown
|
|
or when zero / several nodes are registered (ambiguous)."""
|
|
if chrome_node:
|
|
return self.get(chrome_node)
|
|
nodes = self.list_all()
|
|
return nodes[0] if len(nodes) == 1 else None
|
|
|
|
|
|
# ---- BEGIN PLUGIN-COMPAT (revert-scheduled; see COMPAT_MANIFEST.md) ----
|
|
# Names external plugins imported from this module before the Sep 2026 decomposition.
|
|
# Internal code MUST NOT use these (scripts/check_compat_pointers.py fails CI if it does).
|
|
# The whole block is removed by reverting the commit that added it.
|
|
import json # noqa: F401,E402
|
|
# ---- END PLUGIN-COMPAT ----
|