Every retired shim called stop_for_relaunch() unconditionally, so a current-tree
caller (a plugin, a serve/dashboard/gateway, main.__getattr__'s lazy export)
reaching one ran the whole update-finish takeover: dependency sync, desktop
rebuild, gateway restart, backend kill -- and the restarted process could reach
the shim again (#122656). lazy_deps.install_specs and psutil_android's import
were already gated on in_historical_update(); the other 60 shims were not.
One shared gate, _old_updater.stop_historical_updater(hook, error): hands off
exactly as before when a historical updater entrypoint frame is on the stack
(or the process already handed off and is unwinding), otherwise raises a
catchable error (ImportError for installer-shaped shims, matching
install_specs; RetiredUpdaterHook otherwise). install_specs now uses it too.
main._write_update_incomplete_marker resolves to a gated old_updater_deps shim
instead of aliasing stop_for_relaunch. Every frozen-surface name is retained.
Fixes#124881Fixes#122656
hermes_cli/psutil_android.py called stop_for_relaunch() at module level,
so any importer (an import smoke, a doc tool) ran a full update takeover:
dependency sync, launcher publication, then finish_update's launchd
restart. Gate the import-time handoff on _old_updater.in_historical_update(),
the same frame-walk gate tools.lazy_deps.install_specs uses; every shipped
caller ran inside _cmd_update_impl.
_restart_launchd_gateway_after_update now applies the
launchd_label_foreign_home rule the sibling loop already applies, so an
invoking label whose plist pins another HERMES_HOME is left alone.
Tests: new tests/hermes_cli/test_import_side_effect_canary.py imports every
shipped module under a temp HOME/HERMES_HOME with an audit hook that refuses
service-manager execs, child interpreters and out-of-root writes. On
be5e9f72c6 it fails naming only hermes_cli.psutil_android; with this change
it passes. Also: test_invoking_label_of_another_home_is_left_alone,
test_psutil_android_import_outside_an_update_starts_nothing, the e2e
import-smoke exclusion of psutil_android dropped (AST check inverted).
An origin/main merge brought back main's live implementations where this
branch had retirement shims: psutil_android (download + extract), the
dashboard_procs concurrent-shim scan, and update_cmd_windows reaching the
holder scan through hermes_cli.main's retired alias. An already-running
pre-PM updater must hand off to the fresh child, never resume its ladder.
Post-update dashboard cleanup is isolated like its siblings (#112604), and
the holder-retirement probes assert the hand-off through the fresh-child
seam instead of a bare SystemExit(0).
hermes_cli/psutil_android carried its own tar path-traversal / link-member
guard (a 0.87 copy of archive_safe.safe_extract_targz). One guard for every
tar.gz we extract; the installer keeps raising PsutilAndroidInstallError so
its callers' except clauses are unchanged.
Behavior change: the psutil path now also rejects Windows-absolute and
backslash-smuggled member names (archive_safe.normalize_archive_parts), and
chmod failures on extracted files are suppressed identically.