Classify heartbeat lease failures

Assistant: codex
Assistant-Model: gpt-5.6-sol
Assistant-Session: 01a02b6f-7db1-7222-918b-e813a6bda38d
This commit is contained in:
tegwick 2026-08-23 14:42:30 +02:00
parent ad4074c20a
commit 84b4089f8a
6 changed files with 84 additions and 14 deletions

View file

@ -50,7 +50,7 @@ def test_concurrent_loss_still_notifies_once() -> None:
def test_heartbeat_publishes_loss_without_raw_exception_text() -> None:
client = MagicMock()
client.heartbeat.side_effect = OpsRunError("secret provider response")
client.heartbeat.side_effect = OpsRunError("secret provider response", status_code=409)
heartbeat = _Heartbeat(client, "run-1", lease_seconds=90)
with patch("rein_aharness.claim_loop._heartbeat_interval", return_value=0.01):
@ -63,3 +63,16 @@ def test_heartbeat_publishes_loss_without_raw_exception_text() -> None:
assert heartbeat.monitor.lost is True
assert heartbeat.monitor.evidence is not None
assert "secret" not in heartbeat.monitor.evidence.error_type
def test_heartbeat_transport_error_does_not_immediately_mark_loss() -> None:
client = MagicMock()
client.heartbeat.side_effect = OpsRunError("connection reset")
heartbeat = _Heartbeat(client, "run-1", lease_seconds=90)
with patch("rein_aharness.claim_loop._heartbeat_interval", return_value=0.01):
heartbeat.start()
time.sleep(0.04)
heartbeat.stop()
assert heartbeat.monitor.lost is False