You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
refactor(rate-limit): window failure policy on the canonical limiter; a2a, openai-compat and the integration limiter ride it (#18087) - #21823
This PR was opened for an existing branch that never had one (triage status UNFINISHED). The branch carries 5ahead commit(s) of work not on main, linked to #18087 (refactor(mcp): four copy-paste rate limiters should fold into the canonical RateLimiter). It still needs a conflict sync with main and a review before it can merge. Acceptance criteria have not been verified against this branch.
No actionable comments were generated in the recent review.
Walkthrough
The change adds shared window-quota handling with configurable Redis-failure policies. API endpoints adopt scoped quotas, and the integration limiter separates provider pauses from local request windows. Tests and repository checks cover the new behaviour and canonical limiter use.
The canonical limiter adds Redis-failure policies, local window tracking, and usage reporting. WindowQuota and its tests are added. The local-key-cap environment variable is registered and documented. The legacy IPRateLimiter and its tests are removed.
API limiter migration autobot-backend/api/a2a.py, autobot-backend/a2a/a2a_security_test.py, autobot-backend/api/openai_compat.py, autobot-backend/api/openai_compat_test.py, autobot-backend/api/rum_ingest_bounds.py, autobot-backend/tests/api/test_rum_access_16375.py
The A2A, OpenAI-compatible, and RUM ingest endpoints use scoped WindowQuota instances. Their tests check quota configuration, local fallback, and RUM rejection logging.
Integration request windows and provider pauses autobot-backend/integrations/rate_limiter.py, autobot-backend/integrations/rate_limiter_test.py
The integration limiter uses separate local minute and hour counters and tracks provider pauses independently. Retry-After accepts delta-seconds or an HTTP date. Tests cover limits, expiry, and pause handling.
A repository test scans production Python for selected rate-limiter implementation shapes and checks its allowlist. Reach-scope records and an existing reach test include the scan.
Merge Risk: Moderate · previous review 8daf2
This change consolidates several rate limiters onto one canonical implementation. During a Redis outage, the in-process fallback can grow memory without bound under many distinct clients, and the fallback logs noisily. Smaller defects remain in window eviction, zero-limit handling, provider pause handling, and the repository guard. They should be fixed before merging, since the PR reports no CI results yet.
Pre-merge checks: 4
Check name
Status
Explanation
Description Check
Check skipped - CodeRabbit’s high-level summary is enabled.
Title check
The title names a refactor that moves rate limiting onto the canonical limiter with a window failure policy, and says the a2a, OpenAI-compat and integration limiters now use it. The diff matches this.…
Linked Issues check
Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check
Check skipped because no linked issues were found for this pull request.
Full details: Title check
Explanation
The title names a refactor that moves rate limiting onto the canonical limiter with a window failure policy, and says the a2a, OpenAI-compat and integration limiters now use it. The diff matches this. It adds WindowFailurePolicy and WindowQuota, switches a2a, openai-compat, RUM ingest and the integration limiter to them, and removes IPRateLimiter. The title is specific and tied to the main change. It is long (133 characters) and includes the issue number, but it stays accurate.
Finishing Touches
Generate unit tests (beta)
Commit to this branch
Create a new PR
Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.
Reviewing files that changed from the base of the PR and between 570b1e5 and 8daf2b5.
Files ignored due to path filters: 1
.test_durations is excluded by !**/.test_durations*
Files selected for processing: 5
autobot_shared/env_registry_rate_limit.py
docs/developer/ENV_VARS.md
repo_tests/_reach_declared_scopes.py
repo_tests/_reach_roots_record.py
repo_tests/one_rate_limiter_18087_test.py
Included review availability: This review used your included allowance. Your plan provides up to 1 included review per hour; 0 remain after this review.
Auto-sync: merging main into issue-18087-rate-limiter-forks conflicts
The sync aborted the merge and pushed nothing. Conflicts are information, so it never resolves one itself. Below, for each conflicted file, are the commits that touched it on each side since the merge base 38c62a97b8. Merge main in yourself and push; the label clears on the first run that finds this branch 0 behind.
.test_durations
side
commit
subject
issue refs
main
025ef8daa7
fix(agents): product code no longer reads dev agents; real tier-map validation (#21718)
fix(train): train-8b CI reds on the merged tree — SLM generated types, #18441 needless spread, #18462 heartbeat test's document_sources, password- and entity-derived log text (#17618)
fix(llm-auth): scope and reset the LLM principal, explicit scope on disconnect, registry-checked status/revoke, exact callback path, non-burnable state, one principal id (#19241)
fix(train): train-60 — #18812 extended: LLMService uses the configured routing strategy via get_active_router(), chat_completions split into helpers that resolve the router once, every strategy honours config.enabled through one disabled_route and supports reset_metrics (#18297)
fix(security): the MCP-server quota key hashes the whole token; limiter error logs never carry the key; lock assertions follow the canonical limiter (#18087)
fix(security): record, get_retry_after and get_remaining log the exception class only, and their fail-open paths go through the rate-limited warning (#18617)
fix(security): the MCP-server quota key hashes the whole token; limiter error logs never carry the key; lock assertions follow the canonical limiter (#18087)
…dow policy and per-IP fold onto main label-only limiter (#18087)
mrveiss
changed the title
fix(integrations): a GitHub rate-limit reset is measured on the wall clock, not the monotonic one (#18087)
refactor(rate-limit): window failure policy on the canonical limiter; a2a, openai-compat and the integration limiter ride it (#18087)
Nov 18, 2026
Merged main. The MCP-server and auth limiter work this branch also did already landed on main (label-only logging, whole-token quota key), so main's versions are kept. The rest is reworked on top of main's limiter: window_failure_policy (OPEN/LOCAL/CLOSED) and get_window_usage on RateLimiter alongside main's log_label and fail-open warning, the new window companion module, the a2a and OpenAI-compat limiters, the integration limiter's windows, and the guard (relative floor, parse cache, MCP check now asserts the canonical RateLimiter). The new window warnings name the limiter only, never the key. The one env var moved to its own registry sibling (the backend-services file was at the size ceiling).
Needs a decision (a deletion in this branch): the branch deletes autobot_shared/rate_limit.py (IPRateLimiter) and its test. I kept both: main added a new consumer after this branch was written (api/rum_ingest_bounds.py, plus tests/api/test_rum_access_16375.py), and the guard lists the module as a pending entry.
Options:
Wire in: migrate rum_ingest_bounds and its test to WindowQuota, then delete the module (the guard entry goes with it).
Keep IPRateLimiter as a deliberate second limiter with a stated reason (then it belongs in the guard's distinct-concept list).
Split: land this PR as is, migrate and delete in a follow-up.
Not verified locally (no test runs): the guard's detector against modules added to main since this branch was cut.
Decision (owner, 2026-11-18): migrate the RUM ingest bounds (api/rum_ingest_bounds.py, tests/api/test_rum_access_16375.py) onto the canonical limiter in this PR, then remove autobot_shared/rate_limit.py (IPRateLimiter) once it has no caller — one limiter. Rework follows here.
Notice: 29 open PRs — past the runaway threshold (25)
This is not a request to defer this PR. There is no cap on open PRs (#19397) -- nothing blocks opening or pushing a PR.
This notice only means the count is high enough to be worth a glance for a runaway — something opening PRs in a loop, or a merge pipeline that has stalled so nothing is draining.
If the queue is draining normally, ignore this. Otherwise:
Check whether CI is dispatching at all — see the ci-dispatch-watchdog status on these PRs
Approved PRs land through the merge train the coordinator sequences (merge commits, never squash) -- check the open chore(merge-train) PR is moving, not each PR on its own
Look for a loop opening near-identical PRs
Warn-only runaway detector — .github/workflows/pr-queue-gate.yml. It never blocks a merge.
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 6
Caution
Some comments are outside the diff and can’t be posted inline due to GitHub limitations.
⚠️ Outside diff range comments (1)
Minor · Parse HTTP-date Retry-After on the 429 path too. · github_integration.py:356
autobot-backend/integrations/github_integration.py:356 Minor · Stability & Availability · Quick win
Parse HTTP-date Retry-After on the 429 path too.
apply_response_headers now accepts Retry-After as delta-seconds or an HTTP-date. The 429 branch in _retry_delay still calls float() on the raw header. An HTTP-date value raises ValueError here. _request does not catch that exception, so the call raises instead of returning the structured result or waiting and retrying.
Make the 429 wait use the same parsing contract as apply_response_headers. Keep the 120-second cap and the 60-second default used when the header is absent.
Included review availability: This review used your included allowance. Your plan provides up to 1 included review per hour; 0 remain after this review.
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
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.
Thinking Path
This PR was opened for an existing branch that never had one (triage status UNFINISHED). The branch carries 5ahead commit(s) of work not on main, linked to #18087 (refactor(mcp): four copy-paste rate limiters should fold into the canonical RateLimiter). It still needs a conflict sync with main and a review before it can merge. Acceptance criteria have not been verified against this branch.
What Changed
Commits on the branch (not on main):
Diff summary: 29 files changed, 1159 insertions(+), 986 deletions(-)
Verification
Not yet verified. No CI evidence: this is a draft; no CI has run on it yet, and it needs a conflict sync with main and a review first.
Model Used
Branch authored by earlier Claude sessions; PR opened by Claude Sonnet 5.5.
Refs #18087
🤖 Generated with Claude Code
Summary by CodeRabbit
New Features
Bug Fixes
Retry-Aftervalues provided as either a delay or an HTTP date; invalid values are ignored.Documentation