Skip to content

The agent that grows with you

test(compat): the old-updater surface resolves through the pm facade

ethernetec1267da26fc
diff --git a/scripts/audit-old-updater-imports.py b/scripts/audit-old-updater-imports.py
index 4e3e5b312d1..9344a47080c 100644
--- a/scripts/audit-old-updater-imports.py
+++ b/scripts/audit-old-updater-imports.py
@@ -1097,6 +1097,19 @@ def resolve_in_tree(module: str, symbol: str | None, root: Path) -> tuple[bool,
if (alias.asname or alias.name.split(".")[0]) == symbol:
return True, ""
+ # A PEP 562 facade (``pm/__init__.py``) publishes names from a module-scope
+ # ``_EXPORTS = {"pm.install": ("ensure", ...)}`` table; resolve through it.
+ for node in tree.body:
+ if isinstance(node, ast.Assign) and any(
+ isinstance(t, ast.Name) and t.id == "_EXPORTS" for t in node.targets):
+ try:
+ exports = ast.literal_eval(node.value)
+ except ValueError:
+ break
+ for target_module, names in exports.items():
+ if symbol in names:
+ return resolve_in_tree(target_module, symbol, root)
+
return False, f"{module}.{symbol} not found"
diff --git a/tests/compat/old_updater_surface.json b/tests/compat/old_updater_surface.json
index 74977a94b05..0984de439ab 100644
--- a/tests/compat/old_updater_surface.json
+++ b/tests/compat/old_updater_surface.json
@@ -1457,19 +1457,19 @@
"pm.downloader::Download",
"pm.downloader::DownloadPaused",
"pm.downloader::_OPENER",
- "pm.ensure::_identity",
- "pm.ensure::_install",
- "pm.ensure::_installed_location",
- "pm.ensure::_lockfile",
- "pm.ensure::_refuse_lazy",
- "pm.ensure::ensure",
- "pm.ensure::env_for",
- "pm.ensure::installed_package",
- "pm.ensure::is_installed",
- "pm.ensure::lazy_installs_allowed",
- "pm.ensure::sealed",
- "pm.ensure::sync_venv",
- "pm.ensure::venv_is_current",
+ "pm.install::_identity",
+ "pm.install::_install",
+ "pm.install::_installed_location",
+ "pm.install::_lockfile",
+ "pm.install::_refuse_lazy",
+ "pm.install::ensure",
+ "pm.install::env_for",
+ "pm.install::installed_package",
+ "pm.install::is_installed",
+ "pm.install::lazy_installs_allowed",
+ "pm.install::sealed",
+ "pm.install::sync_venv",
+ "pm.install::venv_is_current",
"pm.environment::PythonEnvironment",
"pm.environment::_base_environment",
"pm.environment::managed_environment",
@@ -1662,7 +1662,7 @@
"plugins.memory.honcho::oauth",
"plugins.memory::_get_active_memory_provider",
"plugins.memory::load_memory_provider",
- "pm.ensure::enabled_extras",
+ "pm.install::enabled_extras",
"pm.recovery::repair_dependencies",
"tools.computer_use.cua_backend::cua_driver_child_env",
"tools.computer_use.cua_backend::cua_driver_update_check",
diff --git a/tests/hermes_cli/test_update_receipt_truthfulness.py b/tests/hermes_cli/test_update_receipt_truthfulness.py
index 129cb12a1c4..f91268a655c 100644
--- a/tests/hermes_cli/test_update_receipt_truthfulness.py
+++ b/tests/hermes_cli/test_update_receipt_truthfulness.py
@@ -60,9 +60,9 @@ def receipt_home(tmp_path, monkeypatch):
monkeypatch.setattr(
"hermes_cli.config.get_hermes_home", lambda: home, raising=False
)
- ur._current = None
+ ur._current.set(None)
yield home
- ur._current = None
+ ur._current.set(None)
def _receipt_files(home):
@@ -126,7 +126,7 @@ class TestReceiptAlwaysFinalized:
ur.record_step("git_pull", True)
ur.record_step("pip_install", True)
# Crash: module singleton is gone, finalize never ran.
- ur._current = None
+ ur._current.set(None)
assert _receipt_files(receipt_home) == []
latest = ur.read_latest_receipt()
@@ -157,8 +157,8 @@ class TestSuccessImpliesAccounting:
outcomes = match_runtime_outcomes(plan, **bookkeeping)
incomplete = report_unaccounted_runtimes(outcomes)
record_plan_in_receipt(plan)
- if ur._current is not None:
- ur._current.data["runtime_outcomes"] = outcomes
+ if ur._current.get() is not None:
+ ur._current.get().data["runtime_outcomes"] = outcomes
# Exact outcome-selection expression from update_cmd.py ~8360.
path = ur.finalize_update_receipt(
"partial" if incomplete else "success"
diff --git a/tests/hermes_cli/test_update_stale_dashboard.py b/tests/hermes_cli/test_update_stale_dashboard.py
index fc788f3fa52..2e11d53f47e 100644
--- a/tests/hermes_cli/test_update_stale_dashboard.py
+++ b/tests/hermes_cli/test_update_stale_dashboard.py
@@ -869,7 +869,7 @@ class TestPostUpdateDashboardCleanupIsolation:
import hermes_cli.update_receipt as ur
from hermes_cli import update_cmd
- ur._current = None
+ ur._current.set(None)
try:
ur.begin_update_receipt()
with patch(
@@ -880,9 +880,9 @@ class TestPostUpdateDashboardCleanupIsolation:
):
update_cmd._finish_dashboard_update_cleanup([]) # must not raise
- steps = {s["name"]: s for s in ur._current.data["steps"]}
+ steps = {s["name"]: s for s in ur._current.get().data["steps"]}
finally:
- ur._current = None
+ ur._current.set(None)
assert steps["dashboard_cleanup"]["ok"] is False
assert "_loaded_launchd_backend_jobs" in steps["dashboard_cleanup"]["detail"]