fix(annotator): correct rate-limiter to 5000/hr and drop redundant bucket (#230)#248
Merged
Merged
Conversation
…cket (#230) The client and the Annotator each built a TokenBucket with refillRate=ceil(5000/3600)=2 per 1000ms — a sustained 7200 req/hr, ~44% over CourtListener's documented 5000/hr cap. And the two buckets double-limited the same HTTP calls, since every request goes through the client. - Add COURTLISTENER_RATE_LIMITER: 1 token every floor(3,600,000/5000)=720ms = exactly 5000/hr, capacity 5000 for burst. Used by the client. - Remove the Annotator's redundant TokenBucket (field, option, and the tryConsume/waitAndConsume check in annotateSection) — the client is the sole HTTP choke point, so one correctly-configured bucket enforces the limit. Adds a test asserting the config sustains exactly RATE_LIMIT_PER_HOUR/hour (the old config computes to 7200 and fails it). Closes #230 Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Both the
CourtListenerClientand theAnnotatorconstructed aTokenBucketwithrefillRate: Math.ceil(5000/3600) = 2per1000ms— a sustained 7200 req/hr, ~44% over CourtListener's documented 5000/hr cap. The two buckets also double-limited the same HTTP calls, since every request flows through the client.Fix
COURTLISTENER_RATE_LIMITER(new constant): refills 1 token everyfloor(3,600,000 / 5000) = 720ms= exactly 5000/hr, withcapacity = 5000for burst. The client uses it.tryConsume/waitAndConsumecheck inannotateSection. The client is the sole HTTP choke point, so one correctly-configured limiter is sufficient (and removes double-limiting).Tests
client.test.ts: asserts the config sustains exactlyRATE_LIMIT_PER_HOUR/hour (the oldrefillRate:2/1000mscomputes to 7200 and fails this) and caps burst at the hourly limit.Annotator package: lint, typecheck, 118 tests green.
Closes #230