feat(api): add rate limit config CRUD with hot-reload and audit trail - #247
Merged
elizabetheonoja-art merged 1 commit intoAug 19, 2026
Conversation
Persist global, service-tier, and per-user rate limits in PostgreSQL and apply changes to live limiters without restart, with tamper-evident audit logging.
elizabetheonoja-art
merged commit Aug 19, 2026
de79bca
into
Utility-Protocol:main
3 of 8 checks passed
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
Adds a REST API to manage rate limit configurations across global, service-tier, and per-user scopes. Configurations persist in PostgreSQL, hot-reload into in-memory limiters without a service restart, and every mutation is recorded in the tamper-evident
audit_eventshash chain.What changed
rate_limit_configstable (db/rate_limits.sql)/api/v1/rate-limits/configs/api/v1/rate-limits/configs/auditServiceRateLimitermiddleware forX-Service-IDtier limitsDynamicRateLimiter::set_global_limit()/reset_global_limit()for hot-reloadsrc/audit/store.rs) with transactional hash-chain appendmain.rsdb/rate_limits.sqlanddb/audit_events.sqlAPI endpoints
GET/api/v1/rate-limits/configs?scope_type=global|service|user)GET/api/v1/rate-limits/configs/:idPOST/api/v1/rate-limits/configsPUT/api/v1/rate-limits/configs/:idDELETE/api/v1/rate-limits/configs/:id?actor=...GET/api/v1/rate-limits/configs/audit?limit=50Key implementation details
global→ global IP limiter;user→ tenant limiter viaX-Tenant-ID;service→ service tier viaX-Service-ID/api/v1/rate-limits/configs/*paths are exempt from rate limitingTest plan
db/rate_limits.sql,db/audit_events.sqlcargo test rate_limit_config --all-featurescargo clippy --all-targets -- -D warningsNotes
/api/v1/rate-limiter/status,/api/v1/tenant-rate-limiter/status) remain for runtime observability; this API is the configuration source of truth.Related Issue
Closes #241