Skip to content

Commit b19b887

Browse files
lesnik512claude
andcommitted
docs(resilience): clarify _purge window boundary + test docstring
- Add a comment to _purge explaining the strict-< window semantics ([now-ttl, now] inclusive). Prevents a future reader (or Hypothesis test in Task 5) from expecting <= and being surprised. - Tighten the test_deposit_after_exhaustion docstring — "floor (int truncation)" used the word "floor" for two different things in one sentence; rephrase to "int() truncates to 0". Pure documentation; no behavior change. 145 tests still pass at 100%. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
1 parent a487e3a commit b19b887

2 files changed

Lines changed: 2 additions & 1 deletion

File tree

‎src/httpware/middleware/resilience/budget.py‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ def __init__(
3535
self._withdrawn: deque[float] = deque()
3636

3737
def _purge(self, now: float) -> None:
38+
# Strict `< cutoff` keeps entries at exactly `now - ttl`: window is [now - ttl, now].
3839
cutoff = now - self._ttl
3940
while self._deposits and self._deposits[0] < cutoff:
4041
self._deposits.popleft()

‎tests/test_budget.py‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ def test_try_withdraw_returns_false_when_exhausted() -> None:
7070

7171

7272
def test_deposit_after_exhaustion_does_not_immediately_unblock() -> None:
73-
"""A single deposit at 20% percent_can_retry contributes 0.2 → floor (int truncation) → 0 new retries."""
73+
"""A single deposit at 20% percent_can_retry contributes 0.2 → int() truncates to 0 → no new retries."""
7474
clock = _Clock()
7575
budget = RetryBudget(ttl=10.0, min_retries_per_sec=1.0, percent_can_retry=0.2, _now=clock.now)
7676
# exhaust the floor (10)

0 commit comments

Comments
 (0)