feat(vps): ship durable ARNavi host with reproducible install and recovery
This commit is contained in:
@@ -0,0 +1,30 @@
|
||||
"""Observe return after a restart request without claiming CPU/power-cycle proof."""
|
||||
|
||||
import time
|
||||
|
||||
|
||||
def observe(value, raw, session, started):
|
||||
if (
|
||||
value.get("kind") != "restart"
|
||||
or value["state"] != "dispatched"
|
||||
or value["expires_at"] < time.time()
|
||||
or session in value["restart_sessions"]
|
||||
or started <= value["monotonic"]
|
||||
):
|
||||
return False
|
||||
# Only type-1 telemetry measured after dispatch establishes fresh return.
|
||||
# A new header, old archive, text reply or token ACK cannot complete this.
|
||||
offset = 2
|
||||
while offset < len(raw) - 1:
|
||||
size = int.from_bytes(raw[offset + 1 : offset + 3], "little")
|
||||
measured = int.from_bytes(raw[offset + 3 : offset + 7], "little")
|
||||
if raw[offset] == 1 and value["dispatched_at"] < measured <= time.time() + 5:
|
||||
value.update(
|
||||
state="reconnected",
|
||||
reconnected_at=time.time(),
|
||||
reconnect_seconds=time.monotonic() - value["monotonic"],
|
||||
telemetry_measured_at=measured,
|
||||
)
|
||||
return True
|
||||
offset += size + 8
|
||||
return False
|
||||
Reference in New Issue
Block a user