The agent that grows with you
Python aiai-agentai-agentsanthropicchatgptclaudeclaude-codecodexhermeshermes-agentllmnous-researchopenai
fix(update): consume the start attestation only after the cold-start is ready
kshitijk4poorccc335cdbad3
diff --git a/hermes_cli/update_cmd_windows.py b/hermes_cli/update_cmd_windows.pyindex 2751cf36492..379841978df 100644--- a/hermes_cli/update_cmd_windows.py+++ b/hermes_cli/update_cmd_windows.py@@ -949,13 +949,14 @@ def _cold_start_windows_gateway_after_update() -> bool:pid = gateway_windows._spawn_detached()if not pid:raise RuntimeError("Windows gateway cold-start did not return a process ID")- # The dead attestation has now done its job (it authorized this spawn under Desktop ownership).- # Consume it the same way check_start_attestation does, so a stale crash marker cannot- # re-authorize a cold start on a later update if this one never becomes ready.- gateway_windows._clear_start_attestation()ready_pids = gateway_windows._wait_for_gateway_ready()if not ready_pids:raise RuntimeError(f"Windows gateway cold-start PID {pid} did not become ready")+ # The dead attestation has done its job (it authorized this spawn under Desktop ownership). Consume+ # it only now: a spawn that never became ready leaves it in place, so the registered retry still+ # holds its recovery obligation instead of seeing Desktop ownership with no marker and returning+ # success without a gateway (#110020 review).+ gateway_windows._clear_start_attestation()print(f"\n✓ Gateway started via cold-start after update (PID: {', '.join(map(str, ready_pids))})")with suppress(Exception):gateway_windows._write_start_attestation(ready_pids, "cold-start after update")diff --git a/tests/hermes_cli/test_update_cold_start_gateway_liveness.py b/tests/hermes_cli/test_update_cold_start_gateway_liveness.pyindex cac4ae3a0b4..c7b2a4309a3 100644--- a/tests/hermes_cli/test_update_cold_start_gateway_liveness.py+++ b/tests/hermes_cli/test_update_cold_start_gateway_liveness.py@@ -48,6 +48,20 @@ def test_cold_start_raises_when_process_does_not_survive(monkeypatch, capsys):assert "✓ Starting Windows gateway after update" not in capsys.readouterr().out+def test_failed_readiness_keeps_the_dead_attestation_for_the_retry(monkeypatch, tmp_path, capsys):+ """#110020 review: the attestation is the retry's only authority to spawn under Desktop+ ownership, so a spawn that returns a PID but never becomes ready must NOT consume it —+ otherwise the registered retry sees ownership with no marker and "succeeds" with no gateway."""+ monkeypatch.setattr("hermes_cli.config.get_hermes_home", lambda: str(tmp_path))+ gateway_windows._write_start_attestation([555], "direct spawn (PID 555)")+ marker = tmp_path / "state" / "gateway.start-attestation.json"++ with pytest.raises(RuntimeError, match="did not become ready"):+ _run_cold_start(monkeypatch, capsys, surviving_pids=[])+ assert marker.exists()+ assert gateway_windows.attested_gateway_died(current_pids=[]) is True++def test_cold_start_reports_success_when_process_survives(monkeypatch, capsys):out = _run_cold_start(monkeypatch, capsys, surviving_pids=[4242])