docs(auth): update API key touch throttle map cap and eviction docs#247
Merged
veverkap merged 1 commit intoMay 11, 2026
Merged
Conversation
The apiKeyLastTouchedAt map now uses FIFO eviction capped at defaultAPIKeyTouchMaxEntries (10,000) instead of the old sweep-at-100 approach. Update the middleware reference to reflect: - Bounded cap of 10,000 entries (matches DefaultRateLimiterMaxVisitors) - FIFO eviction semantics when the cap is reached - Renewals update in-place without triggering eviction Fixes stale documentation introduced by PR #236. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Contributor
Contributor
|
Yes—different context. #246 documented the earlier cap behavior (sweep-before-insert + skip touch when still full, plus benchmark docs). This PR updates that same section again to match the newer logic from #236: capped at 10,000 with FIFO eviction and renewal updates in place (no unrelated eviction on renewal). |
Contributor
There was a problem hiding this comment.
Pull request overview
Updates the authentication middleware documentation to match the current API key last_used_at touch throttling implementation (post-#236), specifically how the in-process throttle map is bounded and how entries are evicted under load.
Changes:
- Document the 10,000-entry cap for the API key touch throttle map (bounded memory usage).
- Document FIFO eviction behavior when the cap is reached.
- Clarify renewal semantics and the effect of sustained load above the cap (earlier-than-5-minute touches for evicted keys).
Show a summary per file
| File | Description |
|---|---|
| docs/auth/middleware.md | Updates API key last_used_at throttle documentation to reflect the capped FIFO-eviction behavior and its operational implications. |
Copilot's findings
Tip
Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
- Files reviewed: 1/1 changed files
- Comments generated: 0
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.
What changed
The
apiKeyLastTouchedAtthrottle map now uses FIFO eviction capped at 10,000 entries (defaultAPIKeyTouchMaxEntries = DefaultRateLimiterMaxVisitors) instead of the old sweep-at-100-entries behaviour introduced before PR #236.This PR updates
docs/auth/middleware.mdto accurately describe:Why
The previous docs stated:
This was no longer accurate after the fix landed in #236.
Testing
Documentation-only change; no code modified.
Greptile Summary
This documentation-only PR updates
docs/auth/middleware.mdto accurately describe the API key touch throttle map, replacing the outdated sweep-at-100-entries description with the current FIFO-eviction-at-10,000-entries behaviour introduced in #236.defaultAPIKeyTouchMaxEntries = DefaultRateLimiterMaxVisitors), FIFO eviction semantics, and in-place renewal behaviour, all of which match the implementation inauth/middleware.go.Confidence Score: 5/5
Documentation-only change with no code modifications; the new text accurately matches the implementation in auth/middleware.go.
All claims in the updated paragraph — the 10,000-entry cap, FIFO eviction via the insertion-order queue, and in-place renewal without evicting an unrelated entry — were verified against the shouldTouchAPIKeyLastUsed implementation. The removed bullet about sweep-at-100-entries no longer exists in the code.
No files require special attention.
Important Files Changed
Flowchart
%%{init: {'theme': 'neutral'}}%% flowchart TD A[Incoming API key request] --> B{Key in throttle map AND within 5-min window?} B -- Yes --> C[Return false: Skip TouchAPIKeyLastUsed] B -- No --> D[Run compactOrderLocked on apiKeyTouchOrder] D --> E{Key already in map? isRenewal check} E -- Yes renewal --> F[Skip eviction, update entry in-place, append new orderEntry] E -- No new key --> G{len map >= 10,000 cap?} G -- No --> F G -- Yes --> H{apiKeyTouchOrder non-empty?} H -- Yes --> I[Pop oldest orderEntry, FIFO evict that key] H -- No fallback --> J[Evict arbitrary map entry] I --> F J --> F F --> K[Return true: Call TouchAPIKeyLastUsed]Reviews (1): Last reviewed commit: "docs(auth): update API key touch throttl..." | Re-trigger Greptile