Build a request-quota service that decides which requests fit within each client’s rolling time window.
Requirements
Input requests have a unique id, a client_id, and a nonnegative integer at (milliseconds), in nondecreasing time order. limit and window_ms must be positive integers, not booleans. Raise ValueError containing limit, window, or time for invalid values or order.
Return one {id, allowed, remaining, retry_after_ms} per request. Quotas are separate for each client_id.
Only accepted requests in the interval (at - window_ms, at] count. An accepted request consumes one slot; a denied request does not consume a slot.
For a denied request, remaining is 0 and retry_after_ms is the earliest accepted timestamp + window_ms - at. For an accepted request, retry_after_ms is 0. Do not mutate input. This is a single-process model, not a distributed gateway.