Skip to content

The agent that grows with you

test(gateway): state-file fallback test follows the verified-identity contract

teknium1134829503622
diff --git a/tests/gateway/test_control_socket.py b/tests/gateway/test_control_socket.py
index 7dba7588f36..b4034ebb0c6 100644
--- a/tests/gateway/test_control_socket.py
+++ b/tests/gateway/test_control_socket.py
@@ -303,6 +303,13 @@ def test_collect_fleet_versions_prefers_socket(tmp_path: Path, monkeypatch):
def test_collect_fleet_versions_falls_back_to_state_file(tmp_path: Path, monkeypatch):
+ """Without a socket answer the state file is a fallback claim, not an identity.
+
+ A live PID that is not the home's verified gateway (here: this pytest
+ process wrote the record) stays visible as ``unknown`` with no
+ self-reported sha; only the verified gateway PID is classified
+ ``current``/``stale`` from the file (#110420).
+ """
import os
import hermes_cli.update_receipt as ur
@@ -336,7 +343,19 @@ def test_collect_fleet_versions_falls_back_to_state_file(tmp_path: Path, monkeyp
fleet = ur.collect_fleet_versions()
assert len(fleet) == 1
assert fleet[0]["pid"] == os.getpid()
+ assert fleet[0]["state"] == "unknown"
+ assert fleet[0]["code_sha"] is None
+ assert "source" not in fleet[0]
+
+ # Same file, but the profile's identity resolver verifies this PID as the
+ # gateway: the fallback may now classify from the stamped sha.
+ monkeypatch.setattr(
+ "gateway.status.live_gateway_pid_for_home", lambda h: os.getpid()
+ )
+ fleet = ur.collect_fleet_versions()
+ assert len(fleet) == 1
assert fleet[0]["state"] == "stale"
+ assert fleet[0]["code_sha"] == "OLDSHA"
assert "source" not in fleet[0]