You're right, and it's a better fix than what I wrote. The weighted estimate frees capacity gradually, so sending every refused client to the window boundary rebuilds the exact edge burst the sliding window was supposed to remove, just through the retry path. Returning (estimate - limit) * window / prev from the script, rounded up with a 1-second floor and capped at the time left in the window, gives each client an honest wait. Good catch on int() too, math.ceil it is. Adding a bit of client-side jitter on top would spread the retries out further. I'll update the post and credit you. Thanks, Mike.
