Skip to content

docs: per-chat resend rate limiter (whatsapp-rust PR #871) - #334

Closed
jlucaso1 wants to merge 5 commits into
mainfrom
claude/eager-cerf-gs8tvl
Closed

docs: per-chat resend rate limiter (whatsapp-rust PR #871)#334
jlucaso1 wants to merge 5 commits into
mainfrom
claude/eager-cerf-gs8tvl

Conversation

@jlucaso1

@jlucaso1 jlucaso1 commented Jun 15, 2026

Copy link
Copy Markdown
Collaborator

Documents the per-chat token-bucket resend rate limiter introduced in oxidezap/whatsapp-rust#871.

Changes

  • changelog/2026-06-15-per-chat-resend-rate-limit.mdx (new): Changelog entry covering the problem (PN-to-LID migration fan-out storms), fix mechanics (token bucket, drop semantics, monotonic clock, fail-open eviction, group-only), defaults, and all new API surface.
  • docs.json: Registered the new changelog entry immediately after changelog/overview.
  • api/bot.mdx: Added BotBuilder::with_resend_rate_limit(burst, refill_per_min) section and resend_rate_limiter_capacity row in the cache config table.
  • api/client.mdx: Added Client::set_resend_rate_limit and Client::resends_throttled_total method docs, plus two new rows in the MemoryDiagnostics table (resend_rate_limiter_chats, resends_throttled_total).

Defaults

Parameter Default
Burst 20 resends
Refill rate 10 resends/min
Cache capacity 4,096 chats

Applies to group chats only — DMs retain unconditional resend (bounded by MAX_RETRY_COUNT).


Generated by Claude Code


Summary by cubic

Adds docs for the per-chat token-bucket resend rate limiter on group retry resends, with build-time and live tuning, metrics, defaults, and cache capacity. Reduces AccountLocked risk during PN-to-LID fan-out storms in oxidezap/whatsapp-rust.

  • New Features

    • Changelog: covers limiter mechanics (token bucket, drop-not-queue, monotonic refill, fail-open eviction) and group-only scope.
    • Bot API: BotBuilder::with_resend_rate_limit(burst, refill_per_min); cache config adds resend_rate_limiter_capacity.
    • Client API: Client::set_resend_rate_limit, Client::resends_throttled_total; MemoryDiagnostics adds resend_rate_limiter_chats, resends_throttled_total.
    • Defaults: burst 20, refill 10/min, cache 4,096 chats.
    • docs.json: registers the new changelog entry.
  • Bug Fixes

    • Fixed api/client.mdx anchor for BotBuilder::with_resend_rate_limit (snake_case #with_resend_rate_limit).
    • Edited api/bot.mdx to fix a sentence fragment in with_resend_rate_limit.
    • Changelog readability tweaks: split a run-on sentence and converted API subheadings to bold.

Written for commit bfb2294. Summary will update on new commits.

Review in cubic

Summary by CodeRabbit

  • Documentation
    • Added documentation for per-chat resend rate limiting, including build-time configuration via a new builder method.
    • Documented new runtime APIs to adjust rate limit parameters and monitor throttled resends.
    • Added cache configuration options for the rate limiter.
    • Extended memory diagnostics to expose rate limiter activity and capacity metrics.

@coderabbitai

coderabbitai Bot commented Jun 15, 2026

Copy link
Copy Markdown

Review Change Stack

📝 Walkthrough

Walkthrough

Documentation-only PR adding a per-chat outbound resend token-bucket rate limiter across three files: a new changelog entry, the BotBuilder API reference (with_resend_rate_limit, resend_rate_limiter_capacity cache setting), and the Client API reference (set_resend_rate_limit, resends_throttled_total, two new MemoryDiagnostics fields). A nav entry is added to docs.json.

Changes

Per-chat resend rate limiter documentation

Layer / File(s) Summary
Changelog entry and nav registration
changelog/2026-06-15-per-chat-resend-rate-limit.mdx, docs.json
New changelog page documents the AccountLocked motivation, token-bucket design (drop-not-queue, lazy refill, fail-open eviction, groups-only scope), default parameters (burst 20, refill 10/min), all new APIs, CacheConfig::resend_rate_limiter_capacity, and MemoryDiagnostics extensions. The docs.json nav entry registers the page under Changelog.
BotBuilder API reference
api/bot.mdx
Adds a with_resend_rate_limit(burst, refill_per_min) builder method section covering parameter semantics, burst=0 disable behavior, defaults when omitted, and a note about runtime retuning. Adds the resend_rate_limiter_capacity row to the Cache configuration table.
Client API reference and MemoryDiagnostics
api/client.mdx
Documents set_resend_rate_limit and resends_throttled_total methods on Client, and extends the memory_diagnostics output table with resend_rate_limiter_chats and resends_throttled_total fields.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Poem

🐇 Hippity-hop, the tokens flow,
A bucket per chat keeps retries low,
Burst twenty messages, refill at ten,
AccountLocked won't trouble us again!
The docs are fresh, the changelog bright—
This bunny rates the limits right. ✨

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title accurately summarizes the main change: documentation of a per-chat resend rate limiter, with reference to the upstream PR for context.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch claude/eager-cerf-gs8tvl

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@mintlify

mintlify Bot commented Jun 15, 2026

Copy link
Copy Markdown
Contributor

Preview deployment for your docs. Learn more about Mintlify Previews.

Project Status Preview Updated (UTC)
whatsapp-rust 🟢 Ready View Preview Jun 15, 2026, 1:28 PM

💡 Tip: Enable Workflows to automatically generate PRs for you.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 4f84a1d86a

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread api/client.mdx Outdated
```

<Tip>
Configure at build time via [`BotBuilder::with_resend_rate_limit`](/api/bot#with-resend-rate-limit). Use this method only to tune live without restarting.

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Fix the BotBuilder anchor link

This new cross-link points to #with-resend-rate-limit, but the target section added in api/bot.mdx is headed ### with_resend_rate_limit, matching the repo's existing snake_case anchor style for Rust methods. When readers click this tip, the fragment will not jump to the new builder method and link checks for this internal anchor will fail; point it at /api/bot#with_resend_rate_limit instead.

Useful? React with 👍 / 👎.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 3

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@api/bot.mdx`:
- Line 557: The second sentence in the paragraph starting with "Can also be
retuned live after build via" is a sentence fragment missing an explicit
subject. Add a clear subject (such as "The rate limit" or "It") at the beginning
of this sentence to make it a complete, direct statement that explicitly
identifies what can be retuned.

In `@changelog/2026-06-15-per-chat-resend-rate-limit.mdx`:
- Line 33: In the changelog/2026-06-15-per-chat-resend-rate-limit.mdx file,
replace the `###` subheadings for API entry titles with bold text formatting
instead. At lines 33, 45, 57, 68, and 72, convert each `###
BotBuilder::with_resend_rate_limit` and similar API entry headings into bold
titles (e.g., `**BotBuilder::with_resend_rate_limit**`). Keep the section-level
headings at `##` format, and use bold formatting only for the individual API
entry names nested under the `## New API` section to follow the changelog
convention.
- Line 10: The sentence starting with "During a mass PN-to-LID migration..."
contains multiple distinct ideas and should be split into shorter, more concise
statements to improve readability in the changelog. Break this run-on sentence
into 3-4 separate sentences, where each sentence conveys one main idea: first
explain the migration scenario and device failure, then describe the library's
resend behavior, then explain the rate-limiting issue, and finally state the
resulting error. This will align with documentation guidelines that require one
idea per sentence.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: 2e6ed39f-16d0-4893-afcb-73b239c779db

📥 Commits

Reviewing files that changed from the base of the PR and between a35417b and 4f84a1d.

📒 Files selected for processing (4)
  • api/bot.mdx
  • api/client.mdx
  • changelog/2026-06-15-per-chat-resend-rate-limit.mdx
  • docs.json

Comment thread api/bot.mdx Outdated
Comment thread changelog/2026-06-15-per-chat-resend-rate-limit.mdx Outdated
Comment thread changelog/2026-06-15-per-chat-resend-rate-limit.mdx Outdated

@cubic-dev-ai cubic-dev-ai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

1 issue found across 4 files

Reply with feedback, questions, or to request a fix.

Fix all with cubic | Re-trigger cubic

Comment thread api/client.mdx Outdated
- api/bot.mdx: fix sentence fragment in with_resend_rate_limit description
  ("Defaults apply..." → "If you do not call this method, defaults apply...")
- changelog: split run-on sentence in Problem section into shorter statements
- changelog: convert ### API subheadings to bold per changelog conventions
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