Skip to content

The agent that grows with you

fix(plugins): removed_annotation takes the resolved kill list as a required argument

teknium1f971bbf51298
diff --git a/hermes_cli/plugins_cmd_catalog.py b/hermes_cli/plugins_cmd_catalog.py
index e99057d5596..44324150d25 100644
--- a/hermes_cli/plugins_cmd_catalog.py
+++ b/hermes_cli/plugins_cmd_catalog.py
@@ -94,15 +94,13 @@ def catalog_annotation(dir_path) -> Optional[str]:
return f"catalog:{sidecar.get('tier') or 'community'}@{str(sidecar.get('sha') or '')[:8]}"
-def removed_annotation(name: str, dir_path, removed_entries: Optional[List[RemovedEntry]] = None) -> Optional[str]:
+def removed_annotation(name: str, dir_path, removed_entries: List[RemovedEntry]) -> Optional[str]:
"""Kill-list reason when an INSTALLED plugin matches by name, catalog name or repo, else ``None``.
- Callers annotating many rows (``plugins list``, the dashboard hub) resolve the kill list once
- with :func:`plugin_catalog.resolved_removed_entries` and pass it as ``removed_entries``:
- resolving per row cost one live-catalog fetch — one network timeout, offline — per plugin.
+ ``removed_entries`` is required: callers annotating many rows (``plugins list``, the dashboard hub)
+ resolve the kill list once with :func:`plugin_catalog.resolved_removed_entries` and pass it in.
+ Resolving per row cost one live-catalog fetch — one network timeout, offline — per plugin.
"""
- if removed_entries is None:
- removed_entries = resolved_removed_entries()
sidecar = read_catalog_sidecar(dir_path) or {}
for candidate in (name, sidecar.get("catalog_name"), sidecar.get("repo")):
removed = match_removed(str(candidate), removed_entries) if candidate else None
diff --git a/tests/hermes_cli/test_plugins_cmd_catalog.py b/tests/hermes_cli/test_plugins_cmd_catalog.py
index c6261e517b2..c7c99c02363 100644
--- a/tests/hermes_cli/test_plugins_cmd_catalog.py
+++ b/tests/hermes_cli/test_plugins_cmd_catalog.py
@@ -96,7 +96,14 @@ def test_kill_list_blocks_cli_dashboard_and_tui_paths(world, monkeypatch):
pc.cmd_install("cat-plugin", enable=False)
pc.cmd_install("cat-plugin", enable=False, allow_removed=True)
assert (world["plugins_dir"] / "cat-plugin" / cat.CATALOG_SIDECAR).exists()
- assert cat.removed_annotation("cat-plugin", world["plugins_dir"] / "cat-plugin") == "malware"
+ assert cat.removed_annotation("cat-plugin", world["plugins_dir"] / "cat-plugin",
+ cat.resolved_removed_entries()) == "malware"
+
+
+def test_removed_annotation_requires_a_pre_resolved_kill_list(world):
+ """No on-demand fallback: callers must resolve the kill list once, never per row."""
+ with pytest.raises(TypeError):
+ cat.removed_annotation("cat-plugin", world["plugins_dir"] / "cat-plugin")
def test_owner_repo_hash_subdir_shorthand_resolves_like_the_catalog_spelling():
diff --git a/tests/hermes_cli/test_plugins_hub_perf_guard.py b/tests/hermes_cli/test_plugins_hub_perf_guard.py
index 6bfd8a2155d..c78616e123a 100644
--- a/tests/hermes_cli/test_plugins_hub_perf_guard.py
+++ b/tests/hermes_cli/test_plugins_hub_perf_guard.py
@@ -157,7 +157,7 @@ def test_plugins_hub_route_builds_catalog_annotations_off_event_loop(monkeypatch
_patch_minimal_hub_dependencies(monkeypatch, check_fn=lambda: True)
monkeypatch.setattr(web_server, "_require_token", lambda _request: None)
- def removed_annotation(name, _dir_path, _removed_entries=None):
+ def removed_annotation(name, _dir_path, _removed_entries):
annotation_threads.append(threading.current_thread())
return "withdrawn by catalog" if name == "demo" else None