feat(process): Hermes processes are positively identified and guaranteed dead at update time - #90777
Merged
Conversation
…ledger, Windows job-object self-attach Every long-lived Hermes process is now positively identifiable so reapers never have to guess lineage from PPID archaeology or cmdline shape: - hermes_cli/process_identity.py (new): HERMES_SPAWN tag build/parse, spawn-ledger.json self-registration keyed on (pid, create_time) — PID reuse cannot forge the pair — with #89298-style corrupt-file quarantine, and a kill-on-close job-object self-attach (BREAKAWAY_OK preserved for the existing CREATE_BREAKAWAY_FROM_JOB escape hatches). - serve/dashboard (web_server.py) and the gateway entry point register themselves at startup and attach to the job; Desktop legacy HERMES_PARENT_PID/winms marker reused as spawner identity so lineage works with every Desktop version. - Desktop stamps HERMES_SPAWN on backend spawns (parent-process-identity.ts). - hermes update gets a positive-identity rung ahead of the heuristic ones: _ledger_reapable_backend_pids reaps holders the ledger PROVES are orphaned backends (purpose reapable + recorded spawner provably dead) in ANY update context. Ledger-unknown holders fall through to the existing rungs. 22 new tests, sabotage-verified.
Contributor
૮ >ﻌ< ა ci reviewran on 77dcae0 — test(desktop): parent watchdog env now carries HERMES_SPAWN
|
…exact-shape assertions The two deepEqual tests pin the exact env object, so the new spawn tag field made them red. Assert the tag in both shapes and add direct spawnTag() coverage (winms-derived seconds, dash fallback, non-winms markers rejected).
This was referenced Aug 20, 2026
19 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Every long-lived Hermes process is now positively identifiable — tagged at spawn, self-registered in a machine spawn ledger, and (on Windows) bound into a kill-on-close job — so
hermes updatereaps leaked backends by proof instead of PPID archaeology, and Hermes reliably dies when we update.Follow-through on the 2026-08-20 Windows incident pair: #90497 stopped the leak factory (ownership-file corruption), #90746 cleaned up hand-off leaks with a contract-gated heuristic. This PR replaces guesswork with identity so the whole class stays dead.
The three layers
HERMES_SPAWN=v1:<install>:<purpose>:<spawner_pid>:<spawner_create>. The Desktop stamps its backend spawns (parent-process-identity.ts); the Python side also accepts legacyHERMES_PARENT_PID+winms:markers as lineage, so it works with every Desktop version.spawn-ledger.jsonat the machine Hermes root) — serve/dashboard backends and the gateway self-register(pid, create_time, purpose, spawner)at startup. The(pid, create_time)pair defeats PID reuse. Dead entries are pruned on every write; a corrupt ledger is quarantined to.corrupt, never rewritten blind (same contract as fix(desktop): corrupt backend-ownership.json no longer erases records of live backends (#89298) #90497 / Desktop-spawnedhermes servebackends leak unbounded (28 live instances); leaked backends' MCP OAuth storms browser login tabs #89298).KILL_ON_JOB_CLOSE, so their whole child tree (launcher→worker chains holding.pydlocks) dies atomically with them.BREAKAWAY_OK+SILENT_BREAKAWAY_OKpreserve every existingCREATE_BREAKAWAY_FROM_JOBescape (gateway respawn watcher, detached relaunch).Updater wiring
hermes updategains a positive-identity rung that runs FIRST, in any update context (no hand-off contract needed):_ledger_reapable_backend_pids()reaps venv holders the ledger proves are orphaned backends — reapable purpose (serve/dashboard/gateway, never interactive) AND recorded spawner provably dead. Ledger-unknown holders fall through to the existing rungs (gateway pause → orphan reap → hand-off reap → refuse), which remain untouched as the compatibility path for processes started by pre-ledger versions.Changes
hermes_cli/process_identity.py(new): tags, ledger, job-object attach — all best-effort/fail-safe, never blocks startup or update.hermes_cli/web_server.py,gateway/run.py: self-registration + job attach at the two long-lived entry points.apps/desktop/electron/parent-process-identity.ts:spawnTag()+HERMES_SPAWNin the watchdog env.hermes_cli/update_cmd.py:_ledger_reapable_backend_pids()+ the new first rung;hermes_cli/main.py: lazy-export.Validation
test_process_identity.pyInfographic