import time class MonotonicClock: """Single monotonic reference for latency/timeout math (1879 ยง2). Wall-clock (`now_wall`) is only for human-facing timestamps; all elapsed/ timeout math must use `elapsed()` so NTP re-sync can't produce negatives. """ def __init__(self): self._start = time.monotonic() def elapsed(self) -> float: return time.monotonic() - self._start @staticmethod def now_wall() -> float: return time.time()