feat: fixed calendar windows for day/week/month rate limits #1951 - #1954
Merged
Merged
Conversation
Converts day/week/month token/cost/request-count rate limit windows from a floating (rolling) model to fixed calendar windows anchored to a new deployment-wide rateLimitSchedule setting (timezone, week start day, daily reset time). Minute/hour limits keep their existing floating behavior. The bulk limits/usage endpoints now report a resetsAt instant for each fixed window. Pre-rollout floating-window records are implicitly treated as zero usage on first read, with no explicit migration step.
This comment has been minimized.
This comment has been minimized.
Oleksii-Klimov
approved these changes
Sep 11, 2026
Collaborator
Author
|
/deploy-review
|
Contributor
Dependency Review✅ No vulnerabilities or license issues or OpenSSF Scorecard issues found.Scanned FilesNone |
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.
Converts DAY/WEEK/MONTH token, cost, and request-count rate limit windows from a floating (rolling) model to fixed calendar windows anchored to a new deployment-wide
rateLimitSchedulesetting (timezone, week start day, daily reset time). MINUTE/HOUR keep their existing floating behavior unchanged.Applicable issues
Description of changes
rateLimitScheduletop-level config setting (config/RateLimitSchedule.java,WeekDay.java,@ValidTimezonevalidator) — defaults to UTC/Monday/00:00 if omitted, reproducing today's implicit UTC-midnight day/month behavior.CalendarPeriod/CalendarWindowCalculatorfor DST-safe (ZonedDateTime-based) computation of DAY/WEEK/MONTH period boundaries.FixedRateBucket/CostFixedRateBucket(periodStart+count), replacing the sliding-windowRateBucket/CostRateBucketfor DAY/WEEK/MONTH inTokenRateLimit,CostRateLimit, and the request-count limit's DAY tier;RateWindowis trimmed to MINUTE/HOUR only. Both new bucket types tolerate old floating-window JSON (ignoreUnknown = true), so previously-persisted counters are implicitly reset to zero on first read after rollout — no explicit migration step.resetsAt(ISO-8601 offset instant) toItemLimitStats/CostItemLimitStats, populated only for the fixed windows (DAY/WEEK/MONTH) and omitted (not null) for MINUTE/HOUR, computable even for a deployment with zero usage.RateLimiternow takes aConfigStoredependency soincrease()can resolve the schedule internally without needing aProxyContext.docs/dynamic-settings/roles.md, regenerateddocs/open_api_core.yamlvia the project's own OpenAPI generator, and added arateLimitScheduleexample tosample/aidial.config.json.Checklist
By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.