After a killed update, the first launch could refuse with "Gateway draining:
update_paused" although nothing was updating. A killed update always leaves a
dead .hermes-update-in-progress marker; while it is there, every ensure poll
probes the checkout kernel lock, and the gateway that ensure just started
probes the same lock while it boots (its launch reclaims that marker). The
probe took the lock exclusively, so two probes in the same instant read each
other as a holder, and the client's single sample fenced the launch.
checkout_lock_held now takes a SHARED lock (POSIX flock LOCK_SH; Windows
LockFileEx without LOCKFILE_EXCLUSIVE_LOCK over the owner byte and the 16
lease bytes). Holders still lock exclusively, so a real holder (or a leased
child of a dead one) still fences; probes never conflict with each other.
The macOS hand-off shell records creation times from ps lstart, so the
delegate line it writes for the update child reads ct:N.000. The Python
own-pid rule allowed 5 ms, so the child never recognised its own delegate
line. It saw a live foreign update and refused with exit 2, which failed
every macOS Desktop update leg since the strict own-pid rule landed.
Accept a whole-second claim when it falls in the second we started in.
A whole second from an earlier second is still a reused pid.
- A recovering launch killed mid-resume (taskkill, console close) left only its
.claim file, which nothing read: the paused gateways were never restarted.
Claims now carry the claimer's identity; a claim whose claimer is dead is
re-adopted like a dead owner's record. A launch that still owes part of the
set hands its claim back unowned so the next launch retries at once.
- Under a Desktop/Tauri-driven update the orchestrator holds the marker, so the
update saw its own partner as "another update", never adopted an orphaned
pause record and then overwrote it. The update tree holding the checkout lock
is no longer "elsewhere" (update_lock.update_in_progress for everyone else),
and write() merges another pause's orphaned set instead of overwriting it
(refuses when that pause's owner is live).
- Runtime-host detection (gateway run / serve / dashboard in the ancestry)
uses the canonical command-line matchers, so `--profile X gateway run` and
the hermes_cli/main.py path form are recognised; the rule sits in
_adopt_or_refuse's partner check.
- Whole-tree gate: at a moved HEAD only the interrupted-pull marker and current
dependencies count; a tracked file a build rewrote no longer keeps gateways
stopped forever. At the pre-update HEAD a new tracked change is still git's
torn checkout.
- _pause_windows_gateways_for_update split into record / cold-start / stop phases.
(cherry picked from commit a56eaa3a0f65c44f45600a9b2868859d98cc382e)
(cherry picked from commit a72664b05f5f789c0b238ee1fcd1e9e087851182)
The set of gateways/services `hermes update` stops on Windows lived only in the
updater's memory plus an atexit resume, so a killed updater (console closed,
taskkill, power loss) left them stopped with nothing on disk saying so, and the
atexit/foreground resume could restart them onto a half-written checkout or the
pre-sync dependencies.
- hermes_cli/update_pause_record.py: the paused set is written under the root
Hermes home BEFORE the first stop, owned by the updater (pid + creation time in
the update-marker ct format), mirrored after every resume attempt and removed
(compare-and-delete) only once the resume is done.
- Every in-process resume is gated on a whole tree: no interrupted-pull marker,
no tracked change beyond those present at pause time, and HEAD still at the
pre-update commit or dependencies current for the moved HEAD. Otherwise the
record stays for recovery.
- Start-of-run recovery (hermes_cli/main.py, beside the fleet-restart hint) claims
an orphaned record (dead owner, no live update) by rename and resumes it; a
later `hermes update` adopts an orphaned record into its own pause instead.
- update_lock: a claim is never adopted across a Hermes gateway/serve/dashboard
host in the process ancestry, so an update started from a gateway the first
update relaunched cannot run under that update's claim (cli §7 V9).
(cherry picked from commit fc0a9c3a53247a8779b5bd9f40b678a22a173521)
(cherry picked from commit 1c0292b5763ad82678309561da7a1eeec3fa0581)
checkout_lock_held answered "free" when the lock file existed but could not be
opened. The hand-off scripts (marker.sh / marker.ps1) and the Desktop probes
(checkout_held, WINDOWS_CHECKOUT_LOCK_PS) answer "held" for the same file, so a
Python reader could reclaim a marker or admit a launch the others would park.
Only a missing lock file is free now; an existing file that cannot be opened
answers held. A lock call that fails outright (ENOLCK on NFS without lockd,
EOPNOTSUPP on some SMB shares) still answers free: nothing can hold such a
lock, and the interrupted-pull repair relies on that to run unguarded there.
Both callers that act on "held" are bounded (_reclaim_dead keeps the dead
marker; the acquire path waits its contention budget).
`incarnation_live` (holder records, the pause record) and `_identity_live` (the marker
reader, matching marker.rs) restated the same (pid, creation time) rule and disagreed when our
own creation time is unreadable: the marker reader treated a no-ct claim naming our pid as ours
(a degraded updater writes no-ct claims) and a ct one as dead, while `incarnation_live`
answered "unprovable" for both, so `_lock_holder` named a previous incarnation as the holder.
Both now go through `_incarnation`; `_identity_live` only adds the v1 age ceiling for an
unprovable identity. `_compare_and_delete` had no callers and is removed.
Test: test_one_incarnation_rule_when_our_own_creation_time_is_unreadable fails on the previous
head and passes here; the shared marker corpus is unchanged and green. (kshitijk4poor review)
read_live_update() read a dead marker, then rechecked it under the marker
mutex in _reclaim_dead(). When a marker-only claimant (the launch hand-off,
no checkout lease) published in between, the recheck correctly kept the
replacement and returned "live" -- but the reader only handled "held" and
fell through to None. update_in_progress() then answered False for a live
update, and the skew watchdog counted that poll toward retirement; the
checkout-lock OR cannot correct it because a marker-only claim holds no
checkout lease.
A "live" recheck verdict now re-judges the marker once and returns its holder.
Review F2 (PR #132365 thread 2).
Review P2 (kshitijk4poor 5411135165): an unwritable marker directory/marker or checkout lock
now refuses the update where main ran it unlocked, and the refusal said only "not writable".
Decision: the refusal stays. Before the commit point it changes nothing (the update has not
started), and the marker is what the Desktop gate, the SSH remote probes, the Tauri updater and
the hand-off scripts read; running without it re-opens the race the lock exists to close.
nix/docker installs are stopped earlier by _update_preflight_handled. The checkout lock lives in
the git directory, which the update's own git commands must write anyway, so refusing there up
front only replaces a later git failure.
What changed is the message: each reason names what the path is for (the marker: the Desktop
app, gateways, installers and other updaters wait on it; the checkout lock: the git directory
git must write too), and describe_holder's remedy covers a read-only filesystem (remount
read-write, or fix owner/permissions) besides running as the owning user.
Test: an unwritable marker location's message names the path, its readers and the read-only
filesystem remedy; RED on the start sha.
What: the BLE001 waiver and docstring of read_live_update now say what makes the never-raises
probe safe: an unjudgeable marker fails open on the MARKER only; every caller that acts on None
still consults the checkout kernel lock (update_in_progress ORs checkout_lock_held,
UpdateLock.acquire/acquire_checkout take it). Behaviour unchanged.
Why: the old waiver ("unjudgeable = no live update") read as a fail-open where main caught only
OSError/ValueError (review L5). Narrowing the catch was rejected: the judge also runs the
incarnation probes (psutil/ctypes/proc readers), so a narrow catch would let an unexpected error
escape into update_in_progress and the launch path, which rely on never-raises; the guard that
actually prevents a race is the kernel lock, now named and pinned.
Test: an unjudgeable marker (the parse raising an unexpected exception) over a checkout lock held
by another process -> read_live_update None, update_in_progress True, a contender's acquire
refused. Comment-only fix, so this pins the guard (GREEN on bbfa23b137d too), it is not a RED test.
The six findings are deliberate boundaries, so each gets an explicit
`# health: allow` with its reason instead of a narrowed catch:
- _old_updater._run_in_custody / update_completion._prepare (HX006): the
waited child is the rest of the committed update (sync + build); it is
supervised and dies with the updater, a timeout would abandon it mid-write.
- _old_updater._checkout_custody (BLE001): calls whatever older release's
update_lock is loaded; no fds means the takeover takes the lock itself.
- update_custody._past_commit (BLE001): fail-closed, unknown = past commit.
- update_custody._held (BLE001): a torn tree's half-written module can raise
anything at import.
- update_lock.process_create_time (BLE001): liveness probe; any psutil failure
(including partial/stub modules) degrades to the stdlib probe instead of
escaping to read_live_update.
- update_lock.read_live_update (BLE001): documented never-raises probe.
Existing `# noqa: BLE001` comments become the health waiver (ruff does not
select BLE here). Comments only; behaviour is unchanged.
What: the Python and Rust tmp sweeps reclaim a tmp sibling named for our own pid once its mtime is older than 60 s (OWN_PID_TMP_STALE[_SECONDS]); other pids keep the liveness check, and an ASCII pid past u32 is dead in both (Python had kept it since N06; Rust always swept it).
Why: with deterministic container pids a previous holder of our pid number left a tmp that every later run skipped as 'our own in-flight write', so it was never cleaned. Every write of ours finishes far inside 60 s, so a fresh same-pid tmp is still kept.
Red: test_stale_tmp_under_our_own_pid_number_is_reclaimed FAILED and marker_tests::stale_tmp_under_our_own_pid_number_is_swept FAILED on 07c014355b5 (real marker.rs via a std-only harness; the Tauri crate cannot build here without webkit2gtk/dbus).
Green: both pass; test_update_lock.py 59 passed/1 skipped; marker tests 49 passed/2 ignored.
What: on win32, _acquire_checkout releases and refuses (reason: read-only; delete it or fix its permissions) when the lock file only opened read-only; the read-only fallback stays POSIX-only.
Why: Windows children find their owner via that record (_held_by_our_windows_ancestor); without it the parent admitted itself and its completion child was refused (RuntimeError mid-update).
Red: Linux stand-in probe (update_lock.sys.platform=win32, kernel-lock stubs) on 9afee3fc8a1: _acquire_checkout admitted=True with record b'0\\n0\\n'.
Green: same probe -> refused with the read-only reason; native test_read_only_lock_file_is_refused_on_windows (platforms windows) needs a Windows runner.
What: _open_lock_file opens with O_NOFOLLOW, and _acquire_checkout refuses (without unlinking) a lock file that is not a regular single-link file before locking or truncating it.
Why: the holder record is lseek/ftruncate/written into the lock file; a symlink or hard link at that name truncated a file outside the install.
Red: test_checkout_lock_never_writes_through_a_link_to_a_file_outside_the_install[symlink,link] both FAILED on d7dba9fb8d7 (sentinel overwritten).
Green: both pass; test_update_lock.py + _fd_provenance + _protocol 74/74 (incl. the read-only A5 lock-file test).
What: the no-hard-link fallback of _publish_exclusive treats a short write as ENOSPC and, on any write/fsync failure, closes the fd and unlinks the marker only if it is still the inode it created (compared under the marker mutex), then re-raises.
Why: the torn prefix named our live pid, so a process that never acquired blocked every updater for as long as it lived (disk full / EIO on FAT, exFAT, some network mounts).
Red: test_failed_exclusive_create_leaves_no_torn_claim FAILED on 1a545e69af9 (marker left behind).
Green: it passes; test_withdrawing_a_torn_claim_never_deletes_a_replacement (guard) passes before and after; test_update_lock.py 56/56.
What: _sweep_dead_tmp_siblings parses the pid field with _bounded_int (ASCII, u32, overflow-safe) and skips names it cannot attribute.
Why: str.isdigit() accepts Unicode digits like '²'/'①' that int() refuses, so one planted tmp name raised ValueError out of UpdateLock.acquire.
Red: test_tmp_litter_with_a_digit_lookalike_pid_never_breaks_admission[superscript-two,circled-one] both FAILED on 23b8a30cc4a.
Green: both pass; test_claim_publishes_whole_and_reclaims_dead_writers_tmp_files still passes.
What: _parse_marker binds the bounded delegate pid once and uses it, instead of re-parsing the raw token with int().
Why: a delegate line with >4300 leading zeros passed the _bounded_int filter but int() raised ValueError, hiding a live owner from read_live_update and crashing UpdateLock.acquire.
Red: corpus case delegate_pid_leading_zeros_past_int_limit -> ValueError at update_lock.py:594 on b0ced54db07.
Green: 62/62 test_update_marker_corpus.py; Rust corpus test runs the same case.
What: every Windows process that joins its ancestor's checkout lock also locks one of 16 lease bytes
past the owner's byte, taken while the owner is seen alive; _try_lock/checkout_lock_held and the Tauri
marker probe treat any held lease as a held lock. The refused completion child still runs (D2: a
committed update never fails) but is no longer unfenced.
Why: a child outside the kill-on-close job outlived a killed owner, whose msvcrt lock died with it,
so a contender acquired while the child still wrote.
Red/green: Windows-native cells (Python owner-killed/unbound child; Rust held lease) need a native run;
POSIX paths unchanged (update_lock suites pass, same failure set as base).
The Windows completion child (dependency sync, product builds) was started running and
bound afterwards, so a fast grandchild could escape the update's kill-on-close job, and
a refused bind was only a log line. It is now created suspended, bound, then resumed.
Post-commit a refused bind still runs it (ruling: refusing would fail a committed
update), but never silently: the refusal is printed and recorded as a failed
update_custody step in this run's receipt and in the receipt the child resumes (its
request is rewritten before it runs), so the terminal receipt carries it.
Windows live cell: the real AssignProcessToJobObject refuses an event handle; the
child must not have run at bind time and the step must reach the child's receipt.
venv_sync.prepare_launch and _prepare_borrowed_launch claimed the marker with
UpdateLock() (no install_root), and UpdateLock._claim_marker unlinked a dead
marker without asking whether the checkout lock was held. The claim then
failed acquire_checkout and released its own claim: the killed update's
marker was gone while its completion child still ran, and the Desktop gate
reopened over it.
- _claim_marker refuses as held (pid 0) and keeps the marker when the checkout
lock is held by another process tree (our own hold or an inherited lock fd
may still reclaim).
- UpdateLock(checkout_first=False): install_root names the guarding checkout
without taking its lock first; both venv_sync sites pass install_root=root.
- _lock_holder reports a dead recorded updater over a held lock as held, so
hermes update / launch repair / source completion refusals use the held
wording instead of naming the dead pid (m6).
R6: read_live_update/_reclaim_dead no longer delete a dead marker while the
checkout kernel lock is held (a killed updater's completion/build/git still
runs); the reader answers a 'held' UpdateHolder, matching marker.sh's held
verdict, and reclaims only once the tree is gone. update_in_progress and
read_live_update take install_root.
D17: the updater's checkout acquire waits up to 3 s on contention before
reporting busy: a marker.sh/marker.ps1/Python 'held?' probe holds the lock
for microseconds (reviewer: 257/3283 spurious hermes update failures).
D8: _parse_marker bounds pid (u32) / started_at (u64) / delegate pid by
significant digits before int(), so a 5000-digit field is malformed
(dead), never a ValueError out of read_live_update or acquire.
Windows: one kill-on-close job per lock owner (update_tree_job), shared by
every bound child, so a launcher can hand it to a child it cannot see.
Release now judges the marker by identity, and the identity check sent
os.kill(own_pid, 0) on every release. Our pid is alive by definition; only
the incarnation (5 ms ct) is in question. Same short-circuit in marker.rs.
R3 / A7 rule 1: every marker decision-and-mutation (reclaim of a dead claim,
adopt + delegate append, release, ownership hand-over) now runs while holding
the kernel lock on the never-deleted sidecar `<marker>.lock` (POSIX flock;
Windows: the file opened share-none, the same lock the PowerShell hand-off
takes), bounded to 10 s. Only the exclusive first publish stays lock-free
(rule 2). Python (update_lock.marker_mutex) and Rust (marker.rs lock_marker)
interoperate on the same lock. A stale reader paused before its unlink can no
longer delete a claim published after its read.
A7 rule 4 / R12: one incarnation rule. Our own pid is ours only within 5 ms of
our creation time; a no-ct claim naming our pid is a previous incarnation
(dead) — in Python (`update_lock.incarnation_live`, exported for the pause
record) and in marker.rs (no more 2 s self tolerance; Electron's v1 own-pid
pre-write is reclaimed and republished as v2; the exit-2 heal requires our
exact incarnation).
A7 rule 5: release is identity-based (`_release_decision` / `release_decision`).
The owner removes its claim regardless of delegate lines unless a LIVE
delegate other than itself exists, which then inherits the claim (rewritten
with the delegate as owner, started_at and run lines kept). A delegate drops
its line while the owner lives, else deletes. This is the native Windows
`orphaned_update` root cause: the hand-off script named `hermes update` as
delegate before it claimed, the child adopted without writing, and its exit
released nothing, leaving '<dead owner> ... delegate:<exited child>'.
Parser (A7 rule 7): lines 4+ are tagged — first well-formed delegate line,
every `run:<id>` line; pid must fit u32. Both consumers run
tests/fixtures/update_marker_corpus.json (judge + release cases).
R2: checkout mutators keep custody. `_git_run` passes the held checkout lock
fd to git (and its hooks); `run_source_script` passes it to the Node build;
`complete_source_checkout` ACQUIRES `UpdateLock(install_root=root)` instead of
claiming only its home's marker; venv_sync's interrupted-update finish acquires
the checkout lock before mutating instead of sampling it and hands the fd to
its completion child; the historical takeover chain passes it down. On Windows
a child of the update joins the lock when its holder record names a live
ancestor (it runs in that owner's kill-on-close job).
R11: a live pre-root-marker claim under <root>/profiles/*/ (the old per-profile
marker) is observed: a new update refuses while one is live and not a partner.
Real-process tests: tests/hermes_cli/test_update_lock_protocol.py (each fails on
6ff4055cd74), corpus consumers in Python and cargo.
A fresh pid namespace (bwrap, a container) hands a killed updater's pid to
the next launch about a second after the updater started: inside the 2 s
cross-writer create-time tolerance. The launch then read the dead claim as
its own live one, adopted it (acquired=False) and prepare_launch returned
early as "under the update's claim" -- silently skipping the source-update
tail the kill left owed (test_hostile_commit tail cells, red on the
composite CI only because their timing landed inside the window).
Compare our own pid against our own creation time exactly (3-decimal
marker rounding); other pids keep the 2 s skew window.
- A2: positional parse (BOM stripped, CRLF accepted, integer pid and
started_at or the marker is malformed = dead; a malformed ct line makes
it v1; only an exact line-4 `delegate:<pid> ct:<n>` counts).
- A1: a live pid whose creation time cannot be read is live only within
the v1 20-minute ceiling (it may be a reused pid).
- A3: claims are published whole (private tmp + exclusive hard link,
exclusive create where links are unsupported); a 0-byte marker younger
than 5 s is a claim in flight and is neither taken over nor deleted.
- A5: an existing lock file we cannot write (left root-owned by
`sudo hermes update`) is opened read-only for the kernel lock instead
of refusing every later update.
- m12: macOS `ps -o lstart` runs with TZ=UTC0 in a minimal env (no DST
skew, no raw environ copy) and is parsed as UTC.
- m10: tmp siblings left by a writer that died are reclaimed at claim.
- No delegate line is written when our own creation time is unknown.
The kill-on-close job that binds the completion child to `hermes update` allowed no breakaway,
so the gateways the completion restarts or resumes (gateway_windows._spawn_detached, which asks
for CREATE_BREAKAWAY_FROM_JOB) fell back into the job and were killed the moment `hermes update`
exited, on success too. Allow BREAKAWAY_OK (not SILENT: ordinary descendants stay bound).
A job that cannot be set up no longer raises out of run_completion after the commit point: it is
logged and the completion runs unbound; the bind sits inside the try whose cleanup kills the
child, so nothing can orphan it.
Windows cell: a real install, a real gateway, a real `hermes update`; the restarted gateway must
still be alive 30 s after the updater exited.
<install>/.hermes-update.lock was a worktree file: in any tree whose
.gitignore lacks it (fixture repos, forks, a branch switch or rollback to
an older tree) it showed as ?? and the updater autostashed its own held
lock (on Windows stash -u of an msvcrt-locked file can fail). Git checkouts
now lock <git common dir>/hermes-update.lock, resolved from .git on disk
(no git process, so -I -S children agree); linked worktrees share the
repository lock. A ZIP install with no .git keeps <install>/.hermes-update.lock.
hermes_cli/update_lock.py implements update-marker contract C1 and the checkout lock (C1.7):
- the marker lives in the profile-tree ROOT home, never profiles/<p> (desktop V9c)
- v2 body pid / started_at / ct:<creation time>; an owner is live while its pid is
alive and its creation time matches (2.0 s) — no age ceiling for v2, the 20-min
ceiling only ages out v1 markers (cli V10/V11, desktop V3, V22)
- O_EXCL claim with one compare-and-delete reclaim of a dead owner; every delete
is compare-and-delete; never truncate-and-write over a marker (desktop V4)
- adopting a hand-off partner's claim writes a line-4 delegate and restores
lines 1-3 byte-identical (or deletes when the partner is dead) on exit
- `hermes update` holds <install root>/.hermes-update.lock (flock / msvcrt) so two
updates of one checkout from different homes exclude each other (cli V3); completion
children inherit the locked fd (pass_fds) on POSIX and run in a kill-on-close job on
Windows, so the lock is never free while the update tree runs
- an unwritable marker dir or install root refuses via exit 2 instead of running unlocked
- process_create_time: psutil when importable, a stdlib probe of the same clock otherwise
- update_in_progress(install_root) for readers: live marker or held checkout lock
Smallest hunks outside the lane: main.py passes install_root=PROJECT_ROOT;
update_completion.py passes the lock fd to both completion children.
`_is_ancestor_pid` asked psutil for the whole parent chain at once:
any(parent.pid == pid for parent in psutil.Process().parents())
`Process.parents()` is eager: it walks all the way to the lowest pid
*before* returning a list, so the generator expression cannot
short-circuit when it reaches the matching ancestor. Its per-link
`parent()` tolerates only `NoSuchProcess`, so any process we may not
inspect anywhere above us raises `AccessDenied` out of the whole call,
and the `except Exception` guard discards every ancestor already found,
including the orchestrator one link down.
Under firejail with `ptrace_scope=1`, and in hardened containers,
`/proc/1` is exactly that unreadable process. The hand-off child then
failed to recognize its own parent's fresh marker, `UpdateLock.acquire`
treated a live orchestrator as a foreign concurrent updater, and the
in-app update exited 2 ("Another Hermes update is already running",
naming the hand-off script's own pid) on every attempt, indefinitely.
Walk the chain one link at a time and test each ancestor as it is
discovered, so a failure above a match can no longer erase it. A
failure encountered before any match still returns False, keeping the
conservative refusal for genuinely unprovable ancestry. The walk is
bounded by `_MAX_ANCESTRY_DEPTH` and skips a repeated pid so an
unexpected chain cannot spin.
Fixes#87514
On Windows, subprocess text=True without an explicit encoding decodes
child output with the ANSI code page (e.g. 'gbk'); non-ASCII bytes then
raise UnicodeDecodeError inside subprocess._readerthread, killing the
Hermes backend before it becomes ready and surfacing as the desktop boot
timeout.
Sweep every hermes_cli text=True subprocess call to encoding='utf-8',
errors='replace', and add an AST-based regression test that fails when a
future text-mode call omits the encoding.
Fixes#55658
Adopting a killed update's marker verbatim kept its started_at. When that
claim was close to the 20-minute ceiling, the retry's own lock expired
seconds into its run and a second updater could start over the same
checkout: live, a detached `hermes update` acquired the lock 6s after the
retry adopted a claim 3s from expiry.
A marker naming our pid can only be a dead predecessor's (nothing
pre-writes one for `hermes update`, which always runs under a parent's
claim), so it is a new attempt and is claimed fresh like any dead holder's.
Only one acquire runs per process, so this cannot renew a wedged update.
A `hermes update` killed after taking the lock leaves
`.hermes-update-in-progress` naming its pid. In a container every restart
starts pid numbering over, so the retry is routinely handed that same pid; the
liveness probe then found the "holder" alive (it is the retry itself) and
refused with "Another Hermes update is already running (process 2)" until the
20-minute age ceiling expired.
No other live process can hold our pid, so `UpdateLock.acquire` now treats a
marker naming `os.getpid()` as ours and adopts it verbatim, the same rule
`UpdateMarkerGuard::acquire` in the desktop updater already applies.
started_at is kept so repeated retries cannot hold a wedged update under the
age ceiling.
Co-authored-by: ZT-Toolkit <296727067+ZT-Toolkit@users.noreply.github.com>
A desktop hand-off on Windows stalled at "Another Hermes update is already
running (process <the hand-off itself>)". The hand-off PowerShell claims the
marker and runs the old `hermes update`, whose _old_updater shim spawns
_update_takeover.py as python -I -S -B. HERMES_UPDATE_HANDOFF_PID names the
old updater, not the marker owner, so adoption relies on the ancestry walk;
without psutil (-S) that walk falls back to /proc or ps, and Windows has
neither, so the grandchild refused its own orchestrator and exited 2.
Read the parent pid from a Toolhelp32 snapshot through stdlib ctypes, and
treat a parent created after its child as a recycled pid, as psutil does.
Reproduced and verified on a real Windows venv: the grandchild now adopts
its ancestor's marker and still refuses an unrelated live holder.
The regression tests were unmarked, and the Windows lane imports only files
carrying a platforms marker, so the Windows half never ran: mark both
stdlib-walk tests for every lane.
Also print a line when the old updater hands off to the new (PM) updater,
so logs show where the switch happened.
The desktop hand-off shim writes the update marker with its own pid and
spawns 'hermes update' as a direct child (adopts via getppid). An
old-updater update into a PM tree hands off again:
_old_updater._run_child spawns _update_takeover.py as 'python -I -S -B',
where psutil cannot import (-S skips site-packages). The psutil-only
ancestry walk then returned False for the two-hops-up shim, so the
takeover child refused its own orchestrator: 'Another Hermes update is
already running (PID <the shim itself>)', exit 2, and the dependency
stage never ran.
Add a stdlib ppid-chain fallback (/proc on Linux, ps on macOS) behind
the ImportError; psutil stays the fast path. Regression test spawns the
real three-process topology and is red on the old code.
Squashed integration of the user-facing message audit for this surface set.
Full per-finding receipts: /tmp/ux-audit/lanes/*-receipt.md (campaign artifacts).
Run historical updater completion in a fresh interpreter so cached imports
cannot revive retired dependency installers. Share Git and ZIP completion,
carry receipt and recovery state, and preserve child exit status.
Route plugin admission, binary acquisition, desktop launch and build paths
through PM. Replace redundant helpers and tests with real worker, package,
publication and launch checks. Keep the shipped compatibility surface fixed.
Targeted Python and desktop checks pass. Native update journeys and fresh
production image qualification remain pending. This is a checkpoint before
those acceptance runs.
Read text files with the encoding utf-8-sig so a BOM at the start of a
file does not cause a Unicode decode error (Windows editors add BOMs).
Reconstructed from ethie/pm commits 48a32b135b + 013219e814 onto the
current upstream/main base: only the utf-8 -> utf-8-sig transforms were
carried (370 exact line pairs across 205 files); pm-rename hunks that
rode in the original commit were left to the pm-store commit, and
utf8sig hunks entangled with content changes ride their owning commit.
Rebuilt on ethie/pm-clean off ac6c8028e0 (upstream/main).
The stale-staged-updater deadlock is not Windows-specific: hermes-setup
under ~/.hermes is only refreshed by a full installer run
(copy_self_to_hermes_home no-ops during --update), so every desktop whose
staged updater predates the HERMES_UPDATE_HANDOFF_PID export (8c76fe19)
runs an old parent that never sends the env var against a new child that
demands it — exit 2 ('Hermes is still running') forever, on macOS and
Linux just as on Windows.
Replace the wmic ancestry walk (deprecated, absent on current Win11,
GBK decode juggling) with psutil.Process().parents() — psutil is already
a hard dependency and is the project's canonical no-kill process probe.
Drop the os.name == 'nt' gate so all platforms heal. Add tests: a marker
owned by our parent process is recognized as our orchestrator; a live
non-ancestor holder is still refused.
On Windows the Tauri updater writes its PID to the update marker, then
spawns 'hermes update' via the venv shim. The child receives
HERMES_UPDATE_HANDOFF_PID to recognize the parent lock, but on some
Windows configs the env var is not inherited through the shim subprocess
chain, deadlocking every GUI update.
Fix: when the env-var handoff fails, fall back to walking the Windows
process tree via wmic /format:csv to collect ancestor PIDs. If the
marker PID is found in the ancestor chain, treat it as our own
orchestrating parent and allow the update.
Also fixes wmic output encoding on localized Windows (GBK/CP936) by
using /format:csv which produces clean UTF-8 output.