Question
Implement a per-key limiter with one shared token limit and fixed window length. Commands are:
- `("ALLOW", key, cost, timestamp)`: accept if the key's usage plus `cost` does not exceed the limit; a rejected request consumes nothing.
- `("RESET", key, timestamp)`: clear that key's usage in the fixed window containing `timestamp`.
The window containing time `t` starts at `(t // window) * window`.
```python
def run_limiter(limit: int, window: int, commands: list) -> list: ...
```
Costs are non-negative integers; zero is allowed. Preserve input order. Return one result per command, using booleans for `ALLOW` and a consistent acknowledgment for `RESET`.
## Assumption
For this practice interface, `RESET` returns the string `"ok"`; `ALLOW` returns a Python boolean, not a string. Limit/cost/timestamps are non-negative non-boolean integers and window is a positive non-boolean integer; invalid numeric arguments raise `ValueError`. Keys are strings. Timestamps are non-decreasing per key in assessed inputs; arbitrary historical timestamps require a different retention contract. Do not modify commands. The supplied `run_case` is fixture glue.
## Design discussion (not graded)
1. Replace fixed windows with an exact sliding-window policy.
2. Give each key a different limit and window.
3. Make updates atomic across multiple servers and expire inactive keys.
4. Explain burst behavior at a fixed-window boundary.