The agent that grows with you
Python aiai-agentai-agentsanthropicchatgptclaudeclaude-codecodexhermeshermes-agentllmnous-researchopenai
fix(gateway): a recorded boot epoch that cannot be compared is unprovable
ethernet41cd38cd9ee3
diff --git a/gateway/host_rendezvous.py b/gateway/host_rendezvous.pyindex 7d27571cdc3..2277c421e1f 100644--- a/gateway/host_rendezvous.py+++ b/gateway/host_rendezvous.py@@ -284,7 +284,7 @@ def _host_lock_is_free(role: str) -> Optional[bool]:def _current_boot_epoch() -> str:- """Identity of this boot. Empty when /proc is unreadable — then the check is a no-op."""+ """Identity of this boot. Empty when /proc is unreadable — a recorded epoch is then unprovable."""try:from gateway.drain_control import current_instantiation_epoch@@ -301,16 +301,21 @@ def _record_incarnation_matches(record: HostRecord) -> Optional[bool]:ticks and is immune to wall-clock shifts that move psutil.create_time(). Those ticks areNOT unique across reboots — they reset, and an early-boot PID reused within the drifttolerance looks like the dead owner. A published boot epoch that differs from this boot's is a- mismatch. A gateway record with no epoch (published before ``bootEpoch`` existed, or on any- platform without /proc, where the epoch is always empty) whose create_time predates this boot- is a mismatch only while nobody holds the host lock. Do not infer identity from argv. A record with neither create_time nor start_time proves nothing about- its pid, so it never vouches for one. Legacy records without a start fingerprint keep the- create-time check.+ mismatch; one that cannot be compared (this boot's epoch is unreadable) is unprovable, ``None``.++ A gateway record with no epoch (published before ``bootEpoch`` existed, or on any platform+ without /proc, where the epoch is always empty) whose create_time predates this boot is a+ mismatch only while nobody holds the host lock. A record with neither create_time nor+ start_time proves nothing about its pid, so it never vouches for one. Legacy records without+ a start fingerprint keep the create-time check. Do not infer identity from argv."""recorded_epoch = record.boot_epochepoch = _current_boot_epoch()- if recorded_epoch and epoch and recorded_epoch != epoch:- return False+ if recorded_epoch:+ if not epoch:+ return None # boots can't be compared; matching ticks alone prove nothing+ if recorded_epoch != epoch:+ return Falseif record.start_time is None and record.create_time is None:return Falseif record.start_time is None:diff --git a/tests/gateway/test_host_rendezvous.py b/tests/gateway/test_host_rendezvous.pyindex 5c771b46701..6baf090b22f 100644--- a/tests/gateway/test_host_rendezvous.py+++ b/tests/gateway/test_host_rendezvous.py@@ -225,6 +225,16 @@ def test_boot_epoch_mismatch_rejects_a_tick_match(host_dir):assert hr.record_is_stale(foreign) is True[email protected]("linux")+def test_recorded_epoch_with_unreadable_current_epoch_is_unprovable(host_dir, monkeypatch):+ record = hr.publish_record(hr.ROLE_GATEWAY, profiles=("default",), home=str(host_dir))+ assert record is not None and record.boot_epoch+ monkeypatch.setattr(hr, "_current_boot_epoch", lambda: "")+ assert hr._record_incarnation_matches(record) is None+ assert hr.liveness_is_proven(record) is False+ assert hr.record_is_stale(record) is False++@pytest.mark.platforms("posix")def test_empty_boot_epoch_does_not_stale_a_live_owner(host_dir):record = hr.publish_record(hr.ROLE_GATEWAY, profiles=("default",), home=str(host_dir))