Skip to content

The agent that grows with you

fix(pm): retries never displace an enabled plugin and cost nothing while unchanged

Tekniumd17855024716
diff --git a/agent/agent_init_memory_provider.py b/agent/agent_init_memory_provider.py
index bbcbabb6aec..1b970886f11 100644
--- a/agent/agent_init_memory_provider.py
+++ b/agent/agent_init_memory_provider.py
@@ -8,19 +8,20 @@ logger = logging.getLogger("run_agent")
# Deduped: the gateway builds a fresh AIAgent per message, so it would warn every turn.
-_warned_unavailable_providers: set[tuple[str, str]] = set()
+_warned_unavailable_providers: set[tuple[str, str, str]] = set()
-def _unavailable_warning_key(name: str) -> tuple[str, str]:
- """Once per profile home and provider: one multiplexed gateway/Desktop backend serves several
- profiles, and each one running without its memory must be told."""
+def _unavailable_warning_key(name: str, kind: str = "unavailable") -> tuple[str, str, str]:
+ """Once per profile home, provider and kind of trouble: one multiplexed gateway/Desktop backend
+ serves several profiles, each one running without its memory must be told, and a provider the
+ user turns back on that is then unavailable is news even after the "turned off" notice."""
from hermes_constants import get_hermes_home, hermes_home_key
- return hermes_home_key(get_hermes_home()), name
+ return hermes_home_key(get_hermes_home()), name, kind
-def _warn_once(name: str, message: str, say=None) -> None:
- """Log *message* and hand it to the user's sink once per home and provider."""
- key = _unavailable_warning_key(name)
+def _warn_once(name: str, message: str, say=None, kind: str = "unavailable") -> None:
+ """Log *message* and hand it to the user's sink once per home, provider and kind."""
+ key = _unavailable_warning_key(name, kind)
if key in _warned_unavailable_providers:
return
_warned_unavailable_providers.add(key)
@@ -55,18 +56,19 @@ def resolve_memory_provider(name: str, say=None):
parked = parked_provider_notice(name)
if parked:
# Installed but turned off (by the user or by an update): say so, never re-install it.
- _warn_once(name, parked, say=say)
+ _warn_once(name, parked, say=say, kind="parked")
return None
- # The provider left core for the catalog (or was never installed): fetch it once.
- from hermes_cli.memory_provider_migration import recover_at_startup
+ if find_provider_dir(name) is None:
+ # The provider left core for the catalog (or was never installed): fetch it once.
+ from hermes_cli.memory_provider_migration import recover_at_startup
- if recover_at_startup(name, say=say):
- provider = load_memory_provider(name)
- # Installed (now or before) yet still not loading: an install notice does not explain that.
+ if recover_at_startup(name, say=say):
+ provider = load_memory_provider(name)
+ # Installed (now or before) yet not loading: neither "not installed" nor an install notice explains that.
if provider is None and find_provider_dir(name) is not None:
_warn_once(name, f"⚠ Memory provider '{name}' is installed but failed to load, so external memory is off "
"for this session (built-in memory still works). The log names the error; "
- "`hermes memory status` shows the plugin's state.", say=say)
+ "`hermes memory status` shows the plugin's state.", say=say, kind="load")
if provider is None or provider.is_available():
return provider
if _unavailable_warning_key(name) not in _warned_unavailable_providers:
diff --git a/hermes_cli/config_defaults.py b/hermes_cli/config_defaults.py
index 04773029122..0a881fae506 100644
--- a/hermes_cli/config_defaults.py
+++ b/hermes_cli/config_defaults.py
@@ -1708,7 +1708,7 @@ DEFAULT_CONFIG = {
# are given.
"platform_hints": {},
# Plugin system. `enabled`/`disabled` (`hermes plugins enable|disable`) and `disabled_by_update` (pm.plugin_eviction:
- # plugins an update turned off, retried each update) are omitted so an empty default never clobbers a user's lists.
+ # plugins an update turned off, retried by later updates) are omitted so an empty default never clobbers a user's lists.
"plugins": {
# Deadline (seconds) for one plugin Git clone, fetch or checkout. Slow repositories may
# need more time; each network operation is capped at one hour.
diff --git a/hermes_cli/doctor_state.py b/hermes_cli/doctor_state.py
index 003bda333d2..b144c6c7e8c 100644
--- a/hermes_cli/doctor_state.py
+++ b/hermes_cli/doctor_state.py
@@ -657,7 +657,7 @@ def _check_plugins_disabled_by_update(should_fix: bool, f: Finding) -> None:
for name, entry in entries.items():
reason = entry.get("reason", "") if isinstance(entry, dict) else ""
check_warn(f"{name} is off", f"({reason})" if reason else "")
- f.manual_issues.append(f"Plugin '{name}' was turned off by an update; the next update retries it, "
+ f.manual_issues.append(f"Plugin '{name}' was turned off by an update; a later update retries it, "
f"or run: hermes plugins enable {name}")
diff --git a/hermes_cli/plugins_cmd.py b/hermes_cli/plugins_cmd.py
index f70b3ee230f..a57c74acb86 100644
--- a/hermes_cli/plugins_cmd.py
+++ b/hermes_cli/plugins_cmd.py
@@ -570,7 +570,7 @@ def _activate_key(key: str, *, enable: bool, console=None) -> bool:
enabled, disabled = _get_enabled_set(), _get_disabled_set()
aliases = _plugin_aliases(key)
target, other = (enabled, disabled) if enable else (disabled, enabled)
- # A plugin an update disabled is retried by the next update; disabling it yourself stops that.
+ # A plugin an update disabled is retried by later updates; disabling it yourself stops that.
if key in target and not (aliases & other) and not (not enable and _disabled_by_update(key, aliases)):
return False
_set_plugin_enabled(key, enable=enable, aliases=aliases, console=console)
diff --git a/plugins/memory/__init__.py b/plugins/memory/__init__.py
index e36df7bfb24..5df42ac9c93 100644
--- a/plugins/memory/__init__.py
+++ b/plugins/memory/__init__.py
@@ -513,7 +513,7 @@ def parked_provider_notice(name: str) -> Optional[str]:
from pm.plugins_state import RECORD
record = cfg_get(load_config(), "plugins", RECORD)
recorded = record.get(name) if isinstance(record, dict) else None
- why = (f" An update turned it off ({recorded.get('reason')}) and the next update retries it."
+ why = (f" An update turned it off ({recorded.get('reason')}) and a later update retries it."
if isinstance(recorded, dict) and recorded.get("reason") else "")
return (f"⚠ Memory provider '{name}' is turned off: plugins.disabled lists it, so external memory is off "
f"(built-in memory still works).{why} Turn it back on with `hermes plugins enable {name}`.")
diff --git a/pm/plugin_eviction.py b/pm/plugin_eviction.py
index f90229e239d..29ba4c1f02b 100644
--- a/pm/plugin_eviction.py
+++ b/pm/plugin_eviction.py
@@ -6,8 +6,11 @@ core moved (a newer Python, a bumped pin, a newer manifest contract) under a plu
that was admitted against the old core. Such a plugin is disabled in every home that
enables it, the reason reaches the operator and the receipt, and the update continues
with the rest. Only a core that cannot build on its own still fails. The edit is recorded
-in the home's config, so every later update retries the plugin and undoes the edit once it
-fits again; a user who re-enables, disables or removes it takes the decision back.
+in the home's config. A resolver or build verdict carries a fingerprint of what was tried
+(core's dependency inputs plus the plugin's) and is retried once either side changed; a fetch
+failure is retried by the next update. A plugin that fits again gets the edit undone; a user who re-enables, disables or removes it takes the decision back.
+Retries are tried only on top of the enabled plugins that build, so a recorded plugin can never
+cost an enabled one its place.
Disabling needs evidence about the plugin itself: its requires-python against the pinned
interpreter, its manifest contract, a resolver proof, or its build failing. A fetch or
@@ -90,7 +93,7 @@ def _list(plugins, key: str) -> list:
return plugins[key]
-def _disable(plugins, name: str, plugin_dir: Path, reason: str) -> None:
+def _disable(plugins, name: str, plugin_dir: Path, reason: str, tried: str | None = None) -> None:
"""Park *name* in plugins.disabled, drop it from plugins.enabled and record what to undo."""
from pm.plugins_state import plugin_spellings
@@ -107,7 +110,9 @@ def _disable(plugins, name: str, plugin_dir: Path, reason: str) -> None:
disabled.append(name)
if isinstance(enabled, list):
_discard(enabled, spellings)
- plugins[RECORD][name] = {"enabled": was_enabled, "reason": " ".join(reason.split())[-300:]}
+ plugins[RECORD][name] = {"enabled": was_enabled, "reason": " ".join(reason.split())[:300]}
+ if tried:
+ plugins[RECORD][name]["tried"] = tried
def _rejoin(plugins, name: str, plugin_dir: Path) -> None:
@@ -116,8 +121,10 @@ def _rejoin(plugins, name: str, plugin_dir: Path) -> None:
record = plugins.get(RECORD) if isinstance(plugins.get(RECORD), dict) else {}
earlier = record.get(name)
+ if not isinstance(earlier, dict):
+ return # the user settled it since this update read the config: their choice stands
_discard(_list(plugins, "disabled"), plugin_spellings(plugin_dir, name))
- if isinstance(earlier, dict) and earlier.get("enabled") and name not in _list(plugins, "enabled"):
+ if earlier.get("enabled") and name not in _list(plugins, "enabled"):
plugins["enabled"].append(name)
@@ -143,14 +150,14 @@ def _prune_record(plugins) -> None:
del plugins[RECORD]
-def recorded_evictions() -> list[Entry]:
- """Plugins an earlier update disabled that their home still has disabled: retried each update.
+def recorded_evictions() -> dict[Entry, dict]:
+ """Plugins an earlier update disabled that their home still has disabled, with their record.
A provider-only record (never in plugins.enabled) is retried only while memory.provider still
names it, so a rejoin never installs a provider the user has since switched away from."""
from pm.plugins_state import dependency_homes, plugin_spellings, read_home_selection
from pm.workspace import selected_plugin_dir
- entries: list[Entry] = []
+ entries: dict[Entry, dict] = {}
for home in dependency_homes():
try:
selection = read_home_selection(home) or {}
@@ -166,10 +173,9 @@ def recorded_evictions() -> list[Entry]:
plugin_dir = selected_plugin_dir(home / "plugins", name)
except InstallError:
continue # a hand-edited key that names no plugin tree
- earlier = record.get(name)
- was_enabled = isinstance(earlier, dict) and bool(earlier.get("enabled"))
- if plugin_dir is not None and (was_enabled or provider in plugin_spellings(plugin_dir, name)):
- entries.append((home / "plugins", name, plugin_dir))
+ earlier = record[name] if isinstance(record[name], dict) else {}
+ if plugin_dir is not None and (earlier.get("enabled") or provider in plugin_spellings(plugin_dir, name)):
+ entries[(home / "plugins", name, plugin_dir)] = earlier
return entries
@@ -183,11 +189,14 @@ class PluginEviction:
Published like a plugin selection.
"""
- def __init__(self, entries: list[Entry], reasons: dict[Path, str], rejoined: list[Entry] = ()):
+ def __init__(self, entries: list[Entry], reasons: dict[Path, str], rejoined: list[Entry] = (), *,
+ tried: dict[Path, str] | None = None, configs=None):
from hermes_yaml import roundtrip_yaml
from pm.publication import selection_snapshot
- self.configs = selection_snapshot()
+ # The snapshot the update decided from: a user edit since then refuses publication.
+ self.configs = selection_snapshot() if configs is None else configs
+ tried = tried or {}
by_home: dict[Path, list[tuple[str, Path, str | None]]] = {}
for plugins_dir, name, plugin_dir in entries:
if plugin_dir.resolve() in reasons:
@@ -208,7 +217,7 @@ class PluginEviction:
if reason is None:
_rejoin(plugins, name, plugin_dir)
else:
- _disable(plugins, name, plugin_dir, reason)
+ _disable(plugins, name, plugin_dir, reason, tried.get(plugin_dir.resolve()))
_prune_record(plugins)
output = io.StringIO()
yaml.dump(config, output)
@@ -229,8 +238,9 @@ class PluginEviction:
durable_write_bytes(path, proposed)
-def _trial(package, enabled, explicit: bool, plugin_dirs: list[Path]) -> str | None:
- """Why the last of *plugin_dirs* cannot join the build, or None when it builds."""
+def _trial(package, enabled, explicit: bool, plugin_dirs: list[Path]) -> tuple[str, bool] | None:
+ """Why the last of *plugin_dirs* cannot join the build, and whether that is a verdict on the
+ plugin (a resolver proof or its build failing) rather than the moment; None when it builds."""
cause = ""
# A fetch or tooling failure can be the moment rather than the plugin: one more try.
for _attempt in range(2):
@@ -238,10 +248,10 @@ def _trial(package, enabled, explicit: bool, plugin_dirs: list[Path]) -> str | N
package.apply(enabled, explicit=explicit, plugin_dirs=plugin_dirs, skip_invalid_secondary=True)
return None
except (ResolutionConflict, BuildFailure) as exc:
- return f"the dependency environment no longer builds with it: {exc.cause[-400:]}"
+ return f"the dependency environment no longer builds with it: {exc.cause[-400:]}", True
except InstallError as exc:
cause = exc.cause
- return f"its dependencies could not be prepared, twice: {cause[-400:]}"
+ return f"its dependencies could not be prepared, twice: {cause[-400:]}", False
def sync_evicting(package, facts, fact: dict, *, extras, shipped, frozen, explicit: bool) -> None:
@@ -250,13 +260,15 @@ def sync_evicting(package, facts, fact: dict, *, extras, shipped, frozen, explic
Static misfits go first (no resolver needed). If the rest still fails, core alone is
built to prove the plugins are the cause, then members are re-added in config order
and each one that breaks the build is disabled too. Plugins an earlier update disabled
- are retried after the enabled ones and re-enabled when they fit.
+ are retried once their fingerprint changed, on top of the enabled plugins that build,
+ and re-enabled when they fit.
"""
from pm import receipt
- from pm.install import _commit_selection, _runtime_state_matches, _target_selection
from pm.plugins_state import dependency_homes, read_home_selection
- from pm.workspace import _is_member_candidate, enabled_plugin_entries
+ from pm.publication import selection_snapshot
+ from pm.workspace import enabled_plugin_entries
+ configs = selection_snapshot()
notices: list[str] = []
for home in dependency_homes()[1:]:
try:
@@ -264,65 +276,136 @@ def sync_evicting(package, facts, fact: dict, *, extras, shipped, frozen, explic
except ValueError as exc:
notices.append(f"Skipped the plugins of profile {home}: {exc}; they rejoin once its config.yaml is fixed")
entries = enabled_plugin_entries(skip_invalid_secondary=True)
- retrying = recorded_evictions()
- reasons, waiting = static_verdicts([*entries, *retrying], _interpreter_version())
-
- def fits(plugin_dir: Path) -> bool:
- return plugin_dir.resolve() not in reasons and plugin_dir.resolve() not in waiting
+ recorded = recorded_evictions()
+ reasons, waiting = static_verdicts([*entries, *recorded], _interpreter_version())
+ update = _EvictingUpdate(package, facts, fact, dict(extras=extras, shipped=shipped, frozen=frozen),
+ explicit=explicit, configs=configs, entries=entries, recorded=recorded,
+ reasons=reasons, waiting=waiting)
+ update.run()
+ notices += _outcome_notices(entries, recorded, reasons, waiting, update.joined)
+ for message in notices:
+ print(f"⚠ {message}", file=sys.stderr, flush=True)
+ receipt.record_warning(message)
- def members() -> list[Path]:
- return list(dict.fromkeys(plugin_dir for _plugins_dir, _name, plugin_dir in [*entries, *retrying]
- if fits(plugin_dir) and _is_member_candidate(plugin_dir)))
- def commit() -> None:
- enabled, stamp, inputs = _target_selection(package, fact, extras=extras, inputs={"plugin_dirs": members()},
- repair=False, shipped=shipped, frozen=frozen)
+class _EvictingUpdate:
+ """One update's build: the enabled plugins first, then the recorded ones that are due."""
+
+ def __init__(self, package, facts, fact: dict, selection: dict, *, explicit: bool, configs,
+ entries: list[Entry], recorded: dict[Entry, dict], reasons: dict[Path, str],
+ waiting: dict[Path, str]):
+ from pm.install import _target_selection
+ from pm.workspace import _is_member_candidate
+
+ self.package, self.facts, self.fact, self.selection = package, facts, fact, selection
+ self.explicit, self.configs, self.entries, self.reasons = explicit, configs, entries, reasons
+ self.retrying = list(recorded)
+ self.tried: dict[Path, str] = {}
+ self.base = _target_selection(package, fact, inputs={"plugin_dirs": []}, repair=False, **selection)[0]
+
+ def fits(plugin_dir: Path) -> bool:
+ return plugin_dir.resolve() not in reasons and plugin_dir.resolve() not in waiting
+
+ self.kept = list(dict.fromkeys(plugin_dir for _plugins_dir, _name, plugin_dir in entries
+ if fits(plugin_dir) and _is_member_candidate(plugin_dir)))
+ # A plugin with nothing to build rejoins on its static verdict; one with dependencies is
+ # due only when core's inputs or its own changed since the attempt that failed.
+ self.joined = [entry for entry in recorded if fits(entry[2]) and not _is_member_candidate(entry[2])]
+ # Those whose last failure was no verdict on the plugin (a download failure, a static
+ # misfit since fixed) go first: they fitted beside the rest before.
+ self.due = sorted((entry for entry, record in recorded.items()
+ if fits(entry[2]) and _is_member_candidate(entry[2])
+ and record.get("tried") != self.fingerprint(entry[2])),
+ key=lambda entry: "tried" in recorded[entry])
+
+ def fingerprint(self, plugin_dir: Path) -> str:
+ return self.package.expected_stamp(self.base, plugin_dirs=[plugin_dir])
+
+ def commit(self, members: list[Path]) -> None:
+ from pm import receipt
+ from pm.install import _commit_selection, _runtime_state_matches, _target_selection
+
+ enabled, stamp, inputs = _target_selection(self.package, self.fact, inputs={"plugin_dirs": list(dict.fromkeys(members))},
+ repair=False, **self.selection)
receipt.record_feature_list(enabled)
- rejoined = [entry for entry in retrying if fits(entry[2])]
- edit = PluginEviction([*entries, *retrying], reasons, rejoined) if reasons or rejoined else None
- _commit_selection(package, facts, edit, enabled=enabled, stamp=stamp, inputs=inputs,
- current=_runtime_state_matches(fact, stamp), repair=False, explicit=explicit,
+ edit = None
+ if self.reasons or self.joined:
+ edit = PluginEviction([*self.entries, *self.retrying], self.reasons, self.joined,
+ tried=self.tried, configs=self.configs)
+ _commit_selection(self.package, self.facts, edit, enabled=enabled, stamp=stamp, inputs=inputs,
+ current=_runtime_state_matches(self.fact, stamp), repair=False, explicit=self.explicit,
skip_invalid_secondary=True)
- kept = members()
- try:
- commit()
- except InstallError as failure:
- if not kept:
- raise
- enabled = _target_selection(package, fact, extras=extras, inputs={"plugin_dirs": []},
- repair=False, shipped=shipped, frozen=frozen)[0]
+ def run(self) -> None:
+ due = [entry[2] for entry in self.due]
+ if due:
+ try:
+ self.joined += self.due
+ self.commit([*self.kept, *due])
+ return
+ except InstallError:
+ self.joined = self.joined[:-len(self.due)]
+ try:
+ if not due:
+ self.commit(self.kept)
+ return
+ self.package.apply(self.base, explicit=self.explicit, plugin_dirs=self.kept, skip_invalid_secondary=True)
+ except InstallError as failure:
+ self.evict_enabled(failure)
+ return
+ fitting = list(self.kept)
+ for entry in self.due:
+ if self.try_member(fitting, entry[2]):
+ self.joined.append(entry)
+ self.commit(fitting)
+
+ def try_member(self, fitting: list[Path], member: Path) -> bool:
+ """Add *member* to *fitting* when it builds on top; else record why. Only a verdict on the
+ plugin is fingerprinted: a fetch failure is the moment, so the next update retries it."""
+ verdict = _trial(self.package, self.base, self.explicit, [*fitting, member])
+ if verdict is None:
+ fitting.append(member)
+ return True
+ self.reasons[member.resolve()] = verdict[0]
+ if verdict[1]:
+ self.tried[member.resolve()] = self.fingerprint(member)
+ return False
+
+ def evict_enabled(self, failure: InstallError) -> None:
+ """Core alone must build; then each enabled member that breaks the build is disabled.
+ Nothing rejoins in such an update: a retried plugin must never take an enabled one's place."""
+ if not self.kept:
+ raise failure
try:
- package.apply(enabled, explicit=explicit, plugin_dirs=[], skip_invalid_secondary=True)
+ self.package.apply(self.base, explicit=self.explicit, plugin_dirs=[], skip_invalid_secondary=True)
except InstallError:
raise failure from None
+ self.joined = [entry for entry in self.joined if entry not in self.due]
fitting: list[Path] = []
- for member in kept:
- reason = _trial(package, enabled, explicit, [*fitting, member])
- if reason:
- reasons[member.resolve()] = reason
- else:
- fitting.append(member)
- commit()
- notices += _outcome_notices(entries, retrying, reasons, waiting)
- for message in notices:
- print(f"⚠ {message}", file=sys.stderr, flush=True)
- receipt.record_warning(message)
+ for member in self.kept:
+ self.try_member(fitting, member)
+ self.commit(fitting)
-def _outcome_notices(entries: list[Entry], retrying: list[Entry], reasons: dict[Path, str],
- waiting: dict[Path, str]) -> list[str]:
+_RETRY = "a later update retries it"
+
+
+def _outcome_notices(entries: list[Entry], recorded: dict[Entry, dict], reasons: dict[Path, str],
+ waiting: dict[Path, str], joined: list[Entry]) -> list[str]:
notices = []
for plugins_dir, name, plugin_dir in entries:
key = plugin_dir.resolve()
if key in reasons:
- notices.append(f"Disabled plugin '{name}' in {plugins_dir.parent}: {reasons[key]}; every update retries "
- f"it and turns it back on once it fits, or run `hermes plugins enable {name}` sooner")
+ notices.append(f"Disabled plugin '{name}' in {plugins_dir.parent}: {reasons[key]}; {_RETRY} and turns it "
+ f"back on once it fits, or run `hermes plugins enable {name}` sooner")
elif key in waiting:
notices.append(f"Left plugin '{name}' in {plugins_dir.parent} out of this update: {waiting[key]}; "
"it stays enabled and rejoins once Hermes reports a version it accepts")
- for plugins_dir, name, plugin_dir in retrying:
- why = reasons.get(plugin_dir.resolve()) or waiting.get(plugin_dir.resolve())
- notices.append(f"Plugin '{name}' in {plugins_dir.parent} is still disabled: {why}; the next update retries it"
- if why else f"Turned plugin '{name}' in {plugins_dir.parent} back on: it fits this Hermes again")
+ for entry, record in recorded.items():
+ plugins_dir, name, plugin_dir = entry
+ if entry in joined:
+ notices.append(f"Turned plugin '{name}' in {plugins_dir.parent} back on: it fits this Hermes again")
+ continue
+ why = reasons.get(plugin_dir.resolve()) or waiting.get(plugin_dir.resolve()) or record.get("reason") or "unknown"
+ notices.append(f"Plugin '{name}' in {plugins_dir.parent} is still disabled: {why}; {_RETRY}")
return notices
diff --git a/tests/pm/test_plugin_survival_contract.py b/tests/pm/test_plugin_survival_contract.py
index 115acf36a7c..6eadd70e552 100644
--- a/tests/pm/test_plugin_survival_contract.py
+++ b/tests/pm/test_plugin_survival_contract.py
@@ -460,7 +460,50 @@ def test_provider_only_record_is_retried_only_while_it_is_still_the_provider(adm
assert [name for _, name, _ in recorded_evictions()] == ["parked"]
(home / "config.yaml").write_text(record + "memory:\n provider: other\n", encoding="utf-8")
- assert recorded_evictions() == []
+ assert not recorded_evictions()
+
+
[email protected](not _uv_available(), reason="uv not on PATH")
+def test_recorded_plugin_is_retried_only_when_changed_and_never_displaces_an_enabled_one(admission_env, monkeypatch):
+ """A plugin an update disabled on a resolver verdict is not built again while neither it nor
+ core changed. Once it changed, it is tried only on top of the enabled plugins, so even a
+ download failure hitting an enabled plugin in that update can never swap the two."""
+ from pm.install import sync_venv, venv_is_current
+ from pm.package import InstallError
+ from pm.packages import Venv
+
+ tmp_path, home = admission_env
+ _plug_a, plug_b, _, _ = _local_conflict_members(home)
+ _write_enabled(home, ["plug-a", "plug-b"])
+ sync_venv(explicit=True, evict_incompatible_plugins=True)
+
+ builds: list[list[str]] = []
+ offline = {"plug-a": False}
+ real_apply = Venv.apply
+
+ def watched_apply(self, extras, *, plugin_dirs=None, **kwargs):
+ names = [Path(plugin_dir).name for plugin_dir in plugin_dirs or ()]
+ builds.append(names)
+ if offline["plug-a"] and names == ["plug-a"]:
+ raise InstallError("plug-a", "network unreachable")
+ return real_apply(self, extras, plugin_dirs=plugin_dirs, **kwargs)
+
+ monkeypatch.setattr(Venv, "apply", watched_apply)
+ sync_venv(explicit=True, evict_incompatible_plugins=True)
+ assert not any("plug-b" in names for names in builds)
+
+ manifest = plug_b / "pyproject.toml"
+ manifest.write_text(manifest.read_text(encoding="utf-8") + "# 0.1.1, still sharedlib 2\n", encoding="utf-8")
+ offline["plug-a"] = True
+ sync_venv(explicit=True, evict_incompatible_plugins=True)
+ plugins = yaml.safe_load((home / "config.yaml").read_text(encoding="utf-8"))["plugins"]
+ assert "plug-b" not in (plugins.get("enabled") or []) and "plug-b" in plugins["disabled"]
+
+ offline["plug-a"] = False
+ sync_venv(explicit=True, evict_incompatible_plugins=True)
+ plugins = yaml.safe_load((home / "config.yaml").read_text(encoding="utf-8"))["plugins"]
+ assert plugins["enabled"] == ["plug-a"] and plugins["disabled"] == ["plug-b"]
+ assert venv_is_current(project_root=tmp_path / "core") is True
@pytest.mark.skipif(not _uv_available(), reason="uv not on PATH")
diff --git a/website/docs/getting-started/updating.md b/website/docs/getting-started/updating.md
index 035dc115f04..81ef71a147a 100644
--- a/website/docs/getting-started/updating.md
+++ b/website/docs/getting-started/updating.md
@@ -128,7 +128,7 @@ For an admitted source checkout, `hermes update` runs these phases:
1. **Pre-update snapshot** — Hermes saves selected state files for every profile in that profile's `state-snapshots/` directory. These include pairing data, cron jobs, `config.yaml`, `.env`, and `auth.json`. Automatic quick snapshots skip individual files larger than 1 GiB. `updates.pre_update_backup` selects `quick`, `full`, or `off`. Full archives use the [backup exclusions](../reference/faq.md#hermes-backup-vs-hermes-profile-export). Recovery uses [Snapshots and rollback](../user-guide/checkpoints-and-rollback.md). Quick snapshots recover state files, not application code. The snapshot is best-effort: if it fails, the update prints a `⚠ Pre-update snapshot FAILED` warning and continues, and the receipt records `pre_update_backup` as a failed step (a deliberate `off`/`--no-backup` lands in the receipt's skips with its reason instead).
2. **Code update** — applies the configured source branch or stable release tag and updates submodules. On Linux and macOS every gateway running from this install is paused immediately before the first change to the checkout (see [Gateway downtime during an update](#gateway-downtime-during-an-update)); an update that has nothing to apply, or that fails before it changes the checkout, stops nothing.
3. **Post-pull syntax validation + auto-rollback** — after the pull, Hermes compiles the nine critical files every `hermes` invocation imports at startup. If any fails to parse (e.g. an orphan merge-conflict marker, an accidentally truncated file), Hermes rolls the install back so your shell stays bootable: it resets the checkout to the commit it ran before the pull (`git reset --hard <pre-pull-sha>`), or, when the update switched away from a detached checkout or a parked feature branch, returns there with `git checkout --detach <sha>` / `git checkout <branch>` (a branch it cannot check out again is restored detached at the same commit). Re-run `hermes update` once the upstream fix lands.
-4. **Dependency preparation** — PM provisions required tools and prepares a complete Python environment from the new lock, existing extras, and enabled plugin requirements. It validates that environment before publishing its selection. A plugin never fails the update. A plugin that no longer fits the new core is moved from `plugins.enabled` to `plugins.disabled` in every profile that enables it. A memory provider keeps its `memory.provider` selection; while the plugin is disabled, Hermes uses built-in memory and says so at startup, in `hermes memory status` and in `hermes doctor`. That covers a `requires-python` that excludes Hermes's Python, a `manifest_version` newer than this Hermes supports, and dependencies that the resolver proves can't resolve alongside core and earlier plugins in config order, or that fail their own build. A download or network failure gets one retry and is disabled if it fails again. The update prints `⚠ Disabled plugin '<name>' in <home>: <reason>`, records it in the receipt's warnings and under `plugins.disabled_by_update` in that profile's config, and continues. Every later update retries a recorded plugin and turns it back on (memory provider included) once it fits, for example after the plugin ships a compatible release or the network is back. To turn it back on sooner, run `hermes plugins enable <name>`. To keep it off, run `hermes plugins disable <name>`, which stops the retries. A `requires_hermes` range the running version misses never disables a plugin, because a source checkout without release tags can read as an older release. That plugin sits out instead (`⚠ Left plugin '<name>' … out of this update`), stays enabled, and rejoins once Hermes reports a version it accepts. A secondary profile whose config cannot be read sits out the same way until the config is fixed. Only a core that cannot build on its own fails this step.
+4. **Dependency preparation** — PM provisions required tools and prepares a complete Python environment from the new lock, existing extras, and enabled plugin requirements. It validates that environment before publishing its selection. A plugin never fails the update. A plugin that no longer fits the new core is moved from `plugins.enabled` to `plugins.disabled` in every profile that enables it. A memory provider keeps its `memory.provider` selection; while the plugin is disabled, Hermes uses built-in memory and says so at startup, in `hermes memory status` and in `hermes doctor`. That covers a `requires-python` that excludes Hermes's Python, a `manifest_version` newer than this Hermes supports, and dependencies that the resolver proves can't resolve alongside core and earlier plugins in config order, or that fail their own build. A download or network failure gets one retry and is disabled if it fails again. The update prints `⚠ Disabled plugin '<name>' in <home>: <reason>`, records it in the receipt's warnings and under `plugins.disabled_by_update` in that profile's config, and continues. The next update retries a plugin disabled by a download failure; one the resolver or its own build rejected is retried by the first update where the plugin or Hermes's dependencies have changed. Retries run after the enabled plugins have built, and turns it back on (memory provider included) once it fits, for example after the plugin ships a compatible release or Hermes fixes what broke it. A retried plugin never displaces an enabled one. A provider-only record is retried only while `memory.provider` still names it. To turn it back on sooner, run `hermes plugins enable <name>`. To keep it off, run `hermes plugins disable <name>`, which stops the retries. A `requires_hermes` range the running version misses never disables a plugin, because a source checkout without release tags can read as an older release. That plugin sits out instead (`⚠ Left plugin '<name>' … out of this update`), stays enabled, and rejoins once Hermes reports a version it accepts. A secondary profile whose config cannot be read sits out the same way until the config is fixed. Only a core that cannot build on its own fails this step.
5. **Config migration** — detects new config options added since your version and prompts you to set them
6. **Desktop rebuild (stage-and-swap)** — if the Hermes Desktop app was built from this checkout, it is rebuilt so the GUI matches the new code. The rebuild packs into a temporary staging directory next to `apps/desktop/release/`, verifies the staged app, and only then renames it over the previous build (on Windows a real-time scanner briefly holding `release/win-unpacked` is ridden out with a few short retries). A rebuild that fails at any point — corrupt Electron download, missing dependency, disk full — leaves the previous app untouched and launchable; the update prints a `⚠` line, still finishes the remaining steps (config migration, gateway restart) and exits 0 with a `build` follow-up in its receipt, and the next launch, `hermes update` or `hermes desktop --build-only --force-build` retries the rebuild. On macOS the rebuilt bundle is then copied (with `ditto`, signature intact) over a stale `/Applications/Hermes.app` or `~/Applications/Hermes.app`, so the copy Finder and the Dock launch matches the backend; an installed copy that is currently running is left alone and the update tells you to quit it and run `hermes update` again. If a copy an earlier update installed has since been removed (including dragged to the Trash), the update rebuilds it if needed, puts it back and says so, so Finder, the Dock and Spotlight find Hermes again; `hermes uninstall` removes the app for good. On Windows, when the update finishes from inside the Desktop app it would rebuild (the app completing an interrupted update at launch), the rebuild is skipped with a notice instead: Windows locks a running app's files, and stopping the app would end the update with it. The rest of the update completes; quit Hermes Desktop and run `hermes desktop` from a terminal, or use **Update now** in **Settings → About**, to rebuild and reopen it.
7. **Gateway auto-restart**: on Linux and macOS, gateways paused for the update are started again as soon as the dependencies are prepared and the launchers refreshed, before the product builds; on Windows they restart after the builds. Any other running gateway is refreshed after the update completes. Service-managed gateways (systemd on Linux, launchd on macOS) restart through the service manager. Manual gateways are relaunched when Hermes can map their PID to a profile. Manually launched `hermes serve` / `hermes dashboard` backends are different: the updater leaves them running and asks their owner to restart them. See [Manual backend restart reminders](#manual-backend-restart-reminders). Backends owned by a running Desktop app remain the app's responsibility.