Skip to content

The agent that grows with you

fix(update): own-incarnation check never probes our own pid

Teknium86afd649c3db
diff --git a/apps/bootstrap-installer/src-tauri/src/marker.rs b/apps/bootstrap-installer/src-tauri/src/marker.rs
index df35c60732e..88d6abf4280 100644
--- a/apps/bootstrap-installer/src-tauri/src/marker.rs
+++ b/apps/bootstrap-installer/src-tauri/src/marker.rs
@@ -240,9 +240,10 @@ const OWN_CT_EPSILON_SECS: f64 = 0.005;
/// unbounded; a v1 record, or a live pid whose creation time cannot be read, is live only while
/// the marker is within the v1 age ceiling.
fn identity_live(pid: u32, recorded_ct: Option<f64>, age_secs: u64, world: &World) -> bool {
- if pid == 0 || !(world.alive)(pid) {
+ if pid == 0 {
return false;
}
+ // We are alive by definition: only our incarnation is in question.
if pid == world.pid {
return match (recorded_ct, world.ct) {
(Some(recorded), Some(own)) => (recorded - own).abs() <= OWN_CT_EPSILON_SECS,
@@ -251,6 +252,9 @@ fn identity_live(pid: u32, recorded_ct: Option<f64>, age_secs: u64, world: &Worl
_ => false,
};
}
+ if !(world.alive)(pid) {
+ return false;
+ }
let within_ceiling = age_secs <= UPDATE_MARKER_MAX_AGE_SECS;
let Some(recorded) = recorded_ct else {
return within_ceiling;
diff --git a/hermes_cli/update_lock.py b/hermes_cli/update_lock.py
index 82ef4fc75d8..ebbef66ba50 100644
--- a/hermes_cli/update_lock.py
+++ b/hermes_cli/update_lock.py
@@ -260,7 +260,7 @@ def incarnation_live(pid: int, recorded_ct=None) -> bool | None:
pid = int(pid)
except (TypeError, ValueError):
return False
- if pid <= 0 or not _pid_alive(pid):
+ if pid <= 0:
return False
recorded = _as_ct(recorded_ct)
if pid == os.getpid():
@@ -268,6 +268,8 @@ def incarnation_live(pid: int, recorded_ct=None) -> bool | None:
if own is None:
return None # degraded: we cannot tell our incarnations apart
return recorded is not None and abs(own - recorded) <= _OWN_CREATE_TIME_EPSILON
+ if not _pid_alive(pid):
+ return False
if recorded is None:
return None
actual = process_create_time(pid)
@@ -299,13 +301,15 @@ def _identity_live(pid: int, create_time: float | None, age: float, world: _Worl
bounds it. Our own pid follows :func:`incarnation_live` (exact creation time, no-ct = dead).
"""
w = world or _real_world()
- if pid <= 0 or not w.alive(pid):
+ if pid <= 0:
return False
- if pid == w.pid:
+ if pid == w.pid: # we are alive by definition: only the incarnation is in question
if w.ct is None:
# Degraded: our own creation time is unreadable, so our claims are v1 too.
return create_time is None
return create_time is not None and abs(w.ct - create_time) <= _OWN_CREATE_TIME_EPSILON
+ if not w.alive(pid):
+ return False
actual = None if create_time is None else w.ct_of(pid)
if actual is None:
return age <= UPDATE_MARKER_MAX_AGE_SECONDS