The agent that grows with you
Python aiai-agentai-agentsanthropicchatgptclaudeclaude-codecodexhermeshermes-agentllmnous-researchopenai
test(desktop-update-e2e): find the packaged app by its install dir, not its environment
Tekniumcd897884d906
diff --git a/apps/desktop/e2e/core/process-census.ts b/apps/desktop/e2e/core/process-census.tsindex 2611c49385e..2201825ab5d 100644--- a/apps/desktop/e2e/core/process-census.ts+++ b/apps/desktop/e2e/core/process-census.ts@@ -132,6 +132,32 @@ export function sandboxProcessesOf(hermesHome: string, exclude = process.pid): Preturn all.filter(proc => members.has(proc.pid) && proc.pid !== exclude)}+/**+ * Every live process whose executable lives under `dir` (Linux /proc only).+ *+ * The HERMES_HOME census cannot see Electron 44+ processes: Chromium's process-title+ * rewrite zeroes the browser's and every child's /proc/<pid>/environ right after start+ * (Electron 40 kept it readable). A packaged app's install directory names its processes+ * just as precisely, whatever their environment shows.+ */+export function processesRunningFrom(dir: string): ProcInfo[] {+ let root: string++ try {+ root = fs.realpathSync(dir) + path.sep+ } catch {+ return []+ }++ return listProcesses().filter(proc => {+ try {+ return proc.pid !== process.pid && fs.readlinkSync(`/proc/${proc.pid}/exe`).startsWith(root)+ } catch {+ return false+ }+ })+}+/** True while `pid` is still a live member of the sandbox (a recycled pid never matches). */export function isSandboxProcess(pid: number, hermesHome: string): boolean {return sandboxProcessesOf(hermesHome).some(proc => proc.pid === pid)diff --git a/apps/desktop/e2e/update/harness.ts b/apps/desktop/e2e/update/harness.tsindex 47a449f5148..01bcb3a9734 100644--- a/apps/desktop/e2e/update/harness.ts+++ b/apps/desktop/e2e/update/harness.ts@@ -20,6 +20,7 @@ import * as path from 'node:path'import { _electron, type ElectronApplication, expect, type Page } from '@playwright/test'import { type CoreSandbox, type ProcInfo, providerConfigYaml, sandboxProcesses } from '../core/harness'+import { processesRunningFrom } from '../core/process-census'import { type ScriptedProvider, startScriptedProvider } from '../core/provider'import { gatedOn, KNOWN } from './gates'@@ -255,8 +256,15 @@ export async function launchInstalledApp(facts: InstallFacts, env: Record<string// ─── Observation ───────────────────────────────────────────────────────+/**+ * Processes carrying this install's HERMES_HOME, plus every process of its packaged app:+ * Electron 44 zeroes the app's /proc environ, so only the executable path names those.+ */export function installProcesses(facts: InstallFacts): ProcInfo[] {- return sandboxProcesses({ hermesHome: facts.hermesHome } as CoreSandbox)+ const census = sandboxProcesses({ hermesHome: facts.hermesHome } as CoreSandbox)+ const known = new Set(census.map(proc => proc.pid))++ return [...census, ...processesRunningFrom(releaseDir(facts)).filter(proc => !known.has(proc.pid))]}function exeOf(pid: number): string {@@ -267,13 +275,16 @@ function exeOf(pid: number): string {}}-/** Live Desktop main processes of this install (the packaged exe, not its zygote/renderer/gpu children). */+/**+ * Live Desktop main processes of this install (the packaged exe, not its zygote/renderer/gpu+ * children). A child between fork and exec still shows the main's exe and argv, so a candidate+ * whose parent is itself a candidate is that child, not a second app.+ */export function desktopMainProcesses(facts: InstallFacts): ProcInfo[] {- const exe = fs.realpathSync(path.dirname(packagedExe(facts)))+ const candidates = processesRunningFrom(releaseDir(facts)).filter(proc => !/--type=/.test(proc.cmdline))+ const pids = new Set(candidates.map(proc => proc.pid))- return installProcesses(facts).filter(- proc => exeOf(proc.pid).startsWith(exe + path.sep) && !/--type=/.test(proc.cmdline)- )+ return candidates.filter(proc => !pids.has(proc.ppid))}/** The `hermes serve` backend(s) of this install (children of the backend excluded). */diff --git a/apps/desktop/e2e/update/harness.unit.test.ts b/apps/desktop/e2e/update/harness.unit.test.tsnew file mode 100644index 00000000000..dc14217db6d--- /dev/null+++ b/apps/desktop/e2e/update/harness.unit.test.ts@@ -0,0 +1,37 @@+import { spawn } from 'node:child_process'+import * as fs from 'node:fs'+import * as os from 'node:os'+import * as path from 'node:path'++import { expect, test } from 'vitest'++import { desktopMainProcesses, type InstallFacts, installProcesses, releaseDir } from './harness'++// Electron 44 zeroes its processes' /proc/<pid>/environ, so the installed app shows no+// HERMES_HOME. A copy of node under the install's release dir, started with an empty+// environment, is that process.+test.skipIf(process.platform !== 'linux')(+ 'the install census still sees the packaged app when its environment names no HERMES_HOME',+ async () => {+ const root = fs.mkdtempSync(path.join(os.tmpdir(), 'update census '))++ const facts = {+ hermesHome: path.join(root, 'home', '.hermes'),+ checkout: path.join(root, 'checkout')+ } as InstallFacts++ fs.mkdirSync(releaseDir(facts), { recursive: true })+ const exe = path.join(releaseDir(facts), 'Hermes')+ fs.copyFileSync(process.execPath, exe)+ const app = spawn(exe, ['-e', 'setTimeout(() => {}, 60_000)'], { env: {}, stdio: 'ignore' })++ try {+ await expect.poll(() => installProcesses(facts).map(proc => proc.pid)).toContain(app.pid)+ expect(desktopMainProcesses(facts).map(proc => proc.pid)).toEqual([app.pid])+ } finally {+ app.kill('SIGKILL')+ await expect.poll(() => installProcesses(facts).length).toBe(0)+ fs.rmSync(root, { recursive: true, force: true })+ }+ }+)