Files
visaapply/visaapply/state.py
T
2026-09-30 23:38:03 +02:00

26 lines
807 B
Python

"""In-memory availability state (plan §4).
A single bool, lost on process restart by design: re-alerting once after a
restart is a feature, not a bug.
"""
from __future__ import annotations
class AvailabilityState:
"""Tracks the previous cycle's availability (a single bool, in memory)."""
def __init__(self) -> None:
# Starts as False so the first observation of slots fires an alert.
self.prev_available: bool | None = False
def observe(self, is_available: bool) -> bool:
"""Record a new observation.
Returns True exactly on a False -> True transition (re-alert on
every transition; never on True -> True).
"""
fired = self.prev_available is False and is_available
self.prev_available = is_available
return fired