All timestamps and numeric settings are integers excluding booleans. limit and window must be positive; now must be nonnegative. Invalid values raise ValueError before mutation. Time units are arbitrary but must be consistent.
Prototype: implement allow_request(recent, limit, window, now). recent is a list of previously accepted nonnegative timestamps, in nondecreasing order and no later than now; duplicates are valid. Invalid histories raise ValueError. Return (allowed, new_history), filtering to timestamps strictly greater than now - window, then appending now only when the filtered length is less than limit. Do not mutate recent; it may contain more than limit entries, in which case deny while retaining all unexpired entries.
Final: implement SlidingWindowLimiter(limit, window). allow(client_id, now) returns a boolean using the same active interval. Client identifiers are nonempty strings; invalid identifiers raise ValueError. A client's timestamps must never move backward, including after a denial; backward calls raise ValueError and leave history and observed time unchanged. Different clients may supply unrelated timestamps. Denials add no accepted timestamp but advance that client's observed time. history(client_id) returns a fresh list of accepted timestamps retained after the client's most recent valid allow call; it does not advance time or expire anything. An unseen valid client returns []. Keep instances independent.
Complete the starter code, then run the checks.
Results and errors will appear here.