Skip to content

feat: v0.16.0 rate limiting — token-bucket admission control - #21

Merged
SoundMatt merged 1 commit into
mainfrom
feat/v0.16.0-rate-limiting
Jul 27, 2026
Merged

feat: v0.16.0 rate limiting — token-bucket admission control#21
SoundMatt merged 1 commit into
mainfrom
feat/v0.16.0-rate-limiting

Conversation

@SoundMatt

Copy link
Copy Markdown
Owner

Summary

  • Ports cpp-RCP's ratelimit.hpp: a token-bucket admission-control decorator (same generic-wrapper vtable pattern used since v0.9.0).
  • rcp_ratelimit_config_t carries rate (tokens/second refill), burst (max accumulation), and exempt_critical (bypass the bucket for RCP_PRIORITY_CRITICAL, default true).
  • Tokens refill lazily on each send() based on elapsed wall time (via rcp_monotonic_ms()) — no background thread needed for this milestone.
  • tests/test_ratelimit.c ports all 7 of cpp-RCP's test_ratelimit.cpp cases.

Test plan

Signed-off-by: Matt matt@jellybaby.com

Ports cpp-RCP's ratelimit.hpp: a token-bucket admission-control decorator
(same generic-wrapper vtable pattern used since v0.9.0). rcp_ratelimit_config_t
carries rate (tokens/second refill), burst (max accumulation), and
exempt_critical (bypass the bucket for RCP_PRIORITY_CRITICAL, default true,
so watchdog kicks and emergency actuation are never throttled). Tokens
refill lazily on each send() based on elapsed wall time (via
rcp_monotonic_ms()), matching cpp-RCP's own steady_clock-based lazy refill
-- no background thread needed for this milestone.

tests/test_ratelimit.c ports all 7 of cpp-RCP's test_ratelimit.cpp cases.

Verification performed:
  - Full test suite: 17/17 passing (added rcp_ratelimit).
  - cfusa trace --req-coverage 100: Metric 2 100% (163/163, hard gate).
  - cfusa check/lint: only known/ticketed CFUSA-L004 false positives
    (SoundMatt/c-FuSa#59, DISP-0001), unchanged count (3).
  - cfusa analyze/cyber/qualify/vuln: clean (0 errors).
  - ASan/UBSan build+test pass: clean, no leaks/UB detected.

Signed-off-by: Matt <matt@jellybaby.com>
Signed-off-by: Matt Jones <47545907+SoundMatt@users.noreply.github.com>
@SoundMatt
SoundMatt merged commit a2c56be into main Jul 27, 2026
18 checks passed
@SoundMatt
SoundMatt deleted the feat/v0.16.0-rate-limiting branch July 27, 2026 17:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant