Skip to content

The agent that grows with you

fix(update): remote marker judge reads ps lstart in UTC like the Python judge

Tekniumcfc1ff32c307
diff --git a/apps/desktop/electron/remote-update-marker-programs.test.ts b/apps/desktop/electron/remote-update-marker-programs.test.ts
index 8c9dec32049..0663fa54b26 100644
--- a/apps/desktop/electron/remote-update-marker-programs.test.ts
+++ b/apps/desktop/electron/remote-update-marker-programs.test.ts
@@ -132,3 +132,29 @@ test.skipIf(process.platform === 'win32')(
}
}
)
+
+// macOS/BSD remotes read creation time from `ps -o lstart=`. Python's judge asks
+// for it in UTC (TZ=UTC0 + calendar.timegm); a local-time parse of the repeated
+// DST hour lands an hour off and judges a live owner dead (review G2).
+test.skipIf(process.platform === 'win32')('the remote judge reads ps lstart in UTC, not local time', async () => {
+ const root = mkdtempSync(path.join(os.tmpdir(), 'hermes-remote-lstart-'))
+
+ try {
+ // Started 01:30 EST on 2026-11-01 (06:30 UTC): New York local time repeats 01:30.
+ writeFileSync(
+ path.join(root, 'ps'),
+ '#!/bin/sh\nif [ "$TZ" = UTC0 ]; then echo "Sun Nov 1 06:30:00 2026"; else echo "Sun Nov 1 01:30:00 2026"; fi\n',
+ { mode: 0o755 }
+ )
+
+ const driver = `${REMOTE_MARKER_JUDGE_PY}\nsys.platform='darwin'\nprint(repr(marker_ct(4242)))`
+
+ const { stdout } = await execFile('python3', ['-c', driver], {
+ env: { ...process.env, PATH: `${root}:${process.env.PATH}`, TZ: 'America/New_York' }
+ })
+
+ assert.equal(Number(stdout.trim()), Date.UTC(2026, 10, 1, 6, 30) / 1000)
+ } finally {
+ rmSync(root, { recursive: true, force: true })
+ }
+})
diff --git a/apps/desktop/electron/remote-update-marker-programs.ts b/apps/desktop/electron/remote-update-marker-programs.ts
index 42559357b4e..5883347f97d 100644
--- a/apps/desktop/electron/remote-update-marker-programs.ts
+++ b/apps/desktop/electron/remote-update-marker-programs.ts
@@ -89,9 +89,10 @@ def marker_ct(pid):
if sys.platform.startswith('linux'):
with open('/proc/stat') as stat:btime=next(int(line.split()[1]) for line in stat if line.startswith('btime '))
return btime+int(marker_stat(pid)[19])/os.sysconf('SC_CLK_TCK')
- import subprocess
- out=subprocess.check_output(['ps','-o','lstart=','-p',str(pid)],env=dict(os.environ,LC_ALL='C'),universal_newlines=True)
- return time.mktime(time.strptime(out.strip(),'%a %b %d %H:%M:%S %Y'))
+ # UTC like update_lock._stdlib_create_time: a local-time lstart is ambiguous in the repeated DST hour.
+ import calendar,subprocess
+ out=subprocess.check_output(['ps','-o','lstart=','-p',str(pid)],env=dict(os.environ,LC_ALL='C',TZ='UTC0'),universal_newlines=True)
+ return float(calendar.timegm(time.strptime(' '.join(out.split()),'%a %b %d %H:%M:%S %Y')))
except Exception:return None
MARKER_ENV={'our_pid':os.getpid(),'our_ct':lambda:marker_ct(os.getpid()),'alive':marker_alive,'ct':marker_ct,'now':time.time()}