Datarobot Model Monitoring receives a time-ordered stream of prediction quality measurements. Implement a memory-efficient function that returns the timestamps when the rolling average first reaches or exceeds a configured threshold.
For each data point (timestamp, value), consider the trailing interval (timestamp - window, timestamp]. A timestamp is an alert transition when the average of all points in that interval is at least threshold, and the previous processed point was not an alert. If the alert condition remains true across multiple points, report only the first timestamp. Processing must use the stream order and must not repeatedly scan earlier points.
Implement process_alerts(points, window, threshold), where points is a list of two-element sequences [timestamp, value] sorted by nondecreasing timestamp. Return a list of timestamps, in processing order, where the alert state changes from false to true. The current point is included in its trailing interval.
def process_alerts(points, window, threshold):