Skip to content

The agent that grows with you

fix(left-core): refuse a moved provider's launch env on every home, not only without the plugin dir

Tekniumb3252c2ad54e
diff --git a/hermes_cli/auth_external_process.py b/hermes_cli/auth_external_process.py
index 396806cfe95..d136f800b58 100644
--- a/hermes_cli/auth_external_process.py
+++ b/hermes_cli/auth_external_process.py
@@ -43,9 +43,8 @@ def external_process_launch_env_names() -> frozenset[str]:
def env_writer_launch_denylist() -> frozenset[str]:
- """:func:`external_process_launch_env_names` plus the ``profile_env`` a left-core row keeps for a provider
- plugin the active home lacks: that plugin's profile, which would declare them, is not registered."""
- from hermes_cli.left_core_migration import absent_plugin_profile_env
- from hermes_constants import get_hermes_home
+ """:func:`external_process_launch_env_names` plus every left-core row's ``launch_env``: a plugin that is
+ not loaded (absent, disabled, failed, quarantined) registers no profile to declare them."""
+ from hermes_cli.left_core_migration import launch_env_names
- return external_process_launch_env_names() | absent_plugin_profile_env(get_hermes_home())
+ return external_process_launch_env_names() | launch_env_names()
diff --git a/hermes_cli/left_core_migration.py b/hermes_cli/left_core_migration.py
index 2fdd9352a08..2bb494e54cb 100644
--- a/hermes_cli/left_core_migration.py
+++ b/hermes_cli/left_core_migration.py
@@ -418,11 +418,14 @@ class LeftCoreFeature:
# never resolve through another rung (the models.dev catalog) while the plugin is not loaded.
providers: tuple[str, ...] = ()
# Env names the plugin's providers read that core kept profile-managed: scrubbed when inherited but
- # absent from the profile's .env (env_loader._PROFILE_MANAGED_ENV_KEYS), routed to .env by `hermes
- # config set` (config._EXTRA_ENV_KEYS), and refused by the generic env writers while the plugin is
- # absent (executable/argv authority its profile otherwise declares). Read statically: env_loader runs
- # before provider discovery.
+ # absent from the profile's .env (env_loader._PROFILE_MANAGED_ENV_KEYS) and routed to .env by `hermes
+ # config set` (config._EXTRA_ENV_KEYS). Read statically: env_loader runs before provider discovery.
profile_env: tuple[str, ...] = ()
+ # The subset of those names that choose an executable or its argv: the generic env writers refuse them
+ # on every home (:func:`launch_env_names`), as core did. A loaded plugin's profile declares them itself;
+ # a home whose plugin is absent, disabled, failed to load or quarantined would otherwise accept a value
+ # that runs as the provider's binary once the plugin loads.
+ launch_env: tuple[str, ...] = ()
# Hosts the plugin's providers serve (a host covers its subdomains). Core attached their wire quirks by
# host for any provider name, so a home with a route at one (a ``custom`` endpoint included) uses the
# feature (:func:`feature_in_use`), and a request rejected there names the install
@@ -494,6 +497,7 @@ LEFT_CORE: tuple[LeftCoreFeature, ...] = (
providers=_COPILOT_API + _COPILOT_ACP, hosts=("githubcopilot.com", "models.github.ai"),
profile_env=("HERMES_COPILOT_ACP_COMMAND", "HERMES_COPILOT_ACP_ARGS", "COPILOT_CLI_PATH",
"COPILOT_ACP_BASE_URL"),
+ launch_env=("HERMES_COPILOT_ACP_COMMAND", "HERMES_COPILOT_ACP_ARGS", "COPILOT_CLI_PATH"),
notice=copilot_relogin_notice,
),
)
@@ -591,10 +595,9 @@ def profile_env_names() -> frozenset[str]:
return frozenset(name for feature in LEFT_CORE for name in feature.profile_env)
-def absent_plugin_profile_env(home: Path) -> frozenset[str]:
- """``profile_env`` of the rows whose plugin *home* does not have: the generic env writers refuse them."""
- return frozenset(name for feature in LEFT_CORE if feature.profile_env and not plugin_present(feature.plugin, home)
- for name in feature.profile_env)
+def launch_env_names() -> frozenset[str]:
+ """Every row's :attr:`LeftCoreFeature.launch_env` (static): the generic env writers refuse them."""
+ return frozenset(name for feature in LEFT_CORE for name in feature.launch_env)
def legacy_plugin_alias(name: str) -> str:
diff --git a/tests/hermes_cli/test_left_core_provider_rows.py b/tests/hermes_cli/test_left_core_provider_rows.py
index 602b8198978..fd876b7916c 100644
--- a/tests/hermes_cli/test_left_core_provider_rows.py
+++ b/tests/hermes_cli/test_left_core_provider_rows.py
@@ -175,14 +175,33 @@ def test_runtime_resolution_installs_the_plugin_first_for_a_home_using_it(acme_r
assert len(calls) == 1
-def test_profile_env_is_refused_by_env_writers_only_while_the_plugin_is_absent(acme_row, monkeypatch):
[email protected]("plugin_dir", [False, True]) # absent, or installed but not loaded (disabled/failed)
+def test_launch_env_is_refused_by_env_writers_while_no_profile_declares_it(acme_row, monkeypatch, plugin_dir):
from hermes_cli.config import validate_env_var_name_for_write
import providers
+ monkeypatch.setattr(lcm, "LEFT_CORE", (replace(ACME, profile_env=("ACME_CLI_PATH", "ACME_BASE_URL"),
+ launch_env=("ACME_CLI_PATH",)),))
monkeypatch.setattr(providers, "list_providers", list)
+ if plugin_dir:
+ (acme_row / "plugins" / "acme-llm").mkdir(parents=True)
with pytest.raises(ValueError, match="denylist"):
validate_env_var_name_for_write("ACME_CLI_PATH")
- (acme_row / "plugins" / "acme-llm").mkdir(parents=True)
- validate_env_var_name_for_write("ACME_CLI_PATH")
+ validate_env_var_name_for_write("ACME_BASE_URL") # an address, not executable authority
+
+
[email protected]("plugin_dir", [False, True])
+def test_copilot_launch_names_stay_refused_and_its_base_url_writable(tmp_path, monkeypatch, plugin_dir):
+ from hermes_cli.config import validate_env_var_name_for_write
+ import providers
+ home = _home(tmp_path)
+ monkeypatch.setenv("HERMES_HOME", str(home))
+ monkeypatch.setattr(providers, "list_providers", list) # no profile registered: plugin not loaded
+ if plugin_dir:
+ (home / "plugins" / "github-copilot").mkdir(parents=True)
+ for name in ("HERMES_COPILOT_ACP_COMMAND", "HERMES_COPILOT_ACP_ARGS", "COPILOT_CLI_PATH"):
+ with pytest.raises(ValueError, match="denylist"):
+ validate_env_var_name_for_write(name)
+ validate_env_var_name_for_write("COPILOT_ACP_BASE_URL")
def test_models_dev_never_stands_in_for_a_provider_whose_plugin_left_core(acme_row, monkeypatch):