refactor(update): inline the tests exclusion; fix comments the wider purge made stale
`_STALE_PURGE_EXCLUDED_TOP_LEVEL` had one reader and a re-export nothing patched; the config-check comment claimed root modules stay cached across the purge (no longer true); the purge test module docstring still described package prefixes.
This commit is contained in:
@@ -98,7 +98,7 @@ from hermes_cli.update_cmd_git import ( # noqa: F401
|
||||
_sync_with_upstream_if_needed)
|
||||
from hermes_cli.update_cmd_maint import ( # noqa: F401
|
||||
_PRE_UPDATE_SNAPSHOT_KEEP, _PRE_UPDATE_SNAPSHOT_MAX_FILE_SIZE,
|
||||
_STALE_PURGE_EXCLUDED_TOP_LEVEL, _STALE_PURGE_PROTECTED,
|
||||
_STALE_PURGE_PROTECTED,
|
||||
_UPDATE_RUNTIME_RELOAD_MODULES, _clear_stale_sqlite_sidecars,
|
||||
_ensure_acp_launcher, _ensure_fhs_path_guard, _finish_dashboard_update_cleanup,
|
||||
_format_time_ago, _post_update_sqlite_runtime_status, _print_bundled_skills_sync_report,
|
||||
|
||||
@@ -186,8 +186,8 @@ def _check_and_apply_config_migration(
|
||||
_m()._purge_stale_hermes_modules()
|
||||
# Reload BEFORE any config reads so all checks use the updated code.
|
||||
_reload_config_modules()
|
||||
# Post-purge this re-executes the NEW config.py against whatever root modules
|
||||
# (hermes_constants, utils, ...) are still cached, so it can fail too.
|
||||
# Post-purge this re-executes the NEW config.py; it still fails if the pulled tree
|
||||
# is internally inconsistent, hence the try.
|
||||
from hermes_cli.config import get_missing_env_vars, get_missing_config_fields
|
||||
# Log, point at the manual command, and return. See #91360.
|
||||
missing_env = get_missing_env_vars(required_only=True)
|
||||
|
||||
@@ -25,10 +25,6 @@ logger = logging.getLogger("hermes_cli.update_cmd")
|
||||
|
||||
_UPDATE_RUNTIME_RELOAD_MODULES = "hermes_constants", "tools.environments.local", "tools.lazy_deps"
|
||||
|
||||
#: Owned by the checkout but never purged: pytest resolves fixtures through the identity of
|
||||
#: its own already-imported test modules, and evicting them mid-session breaks that.
|
||||
_STALE_PURGE_EXCLUDED_TOP_LEVEL = frozenset({"tests"})
|
||||
|
||||
#: Modules EXECUTING the update survive the purge: evicting them buys nothing (running frames
|
||||
#: keep them alive) and reloading them mid-flight is the one genuinely unsafe move.
|
||||
#: ``hermes_logging`` is protected for a different reason: its queue listener, handler list and
|
||||
@@ -105,7 +101,9 @@ def _stale_purge_prefixes() -> frozenset:
|
||||
names.add(entry.stem)
|
||||
elif (entry / "__init__.py").is_file():
|
||||
names.add(entry.name)
|
||||
return frozenset(names) - _STALE_PURGE_EXCLUDED_TOP_LEVEL
|
||||
# ``tests`` is owned by the checkout but never purged: the in-process purge tests would
|
||||
# otherwise re-import a fresh copy of the very test module their monkeypatches point at.
|
||||
return frozenset(names) - {"tests"}
|
||||
|
||||
|
||||
def _purge_stale_hermes_modules() -> None:
|
||||
|
||||
@@ -9,9 +9,10 @@ import ...` in the restart phase raised ImportError, the whole phase
|
||||
aborted, and the running gateway kept serving pre-update code.
|
||||
|
||||
The old mitigation (_UPDATE_RUNTIME_RELOAD_MODULES) reloaded 3 hardcoded
|
||||
modules — re-fixed per symptom. The purge evicts EVERY cached module under
|
||||
the Hermes package prefixes so later imports rebuild a self-consistent
|
||||
module graph from the updated checkout.
|
||||
modules — re-fixed per symptom. The purge evicts EVERY cached module whose
|
||||
top-level name is a ``.py`` file or package in the checkout root (minus
|
||||
``tests``) so later imports rebuild a self-consistent module graph from the
|
||||
updated checkout.
|
||||
"""
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
Reference in New Issue
Block a user