oliver-zehentleitner / maity

hub: read_limits uses the shared window estimate, errors.rate_limited and limits.resolve

Sign in to report

tsk-a62a06pakm2m Open

Audit round 3 (tsk-hgnbapyw7hnh), read at 588f911b. Kind: design / duplication. Neighbour of tsk-5sfts81hr516 (one counter and breaker layer); merge there if it fits.

What is wrong

  • hub/src/maity_hub/read_limits.py:86 inlines the two-window estimate (current + previous*(1-elapsed)) of shared_counts.Window.estimate (shared_counts.py:52); only the copy has a +1e-9 tolerance, so the rule is written two ways.
  • read_limits.refusal (:189-195) builds its own 429 because errors.rate_limited (errors.py:124-130) takes no message.
  • instance_value (:128-145) resolves max_reads_per_minute itself beside limits.of (limits.py:82-85).

Proposal: one estimate function; a message argument on errors.rate_limited; instance_value calls limits.resolve behind its cache.

Effort / risk: S. Low risk.