Enhanced rate limiting for message edits #42

Closed
opened 2026-02-15 03:53:09 +03:00 by NiXTheDev · 0 comments
NiXTheDev commented 2026-02-15 03:53:09 +03:00 (Migrated from github.com)

Description

Improve rate limiting to handle message edits more intelligently with graduated penalties.

Current Behavior

  • Message edits are completely exempt from rate limiting
  • Users can bypass limits by editing messages repeatedly
  • No penalty for failed/abusive attempts

Proposed Behavior

  1. Apply rate limiting to edits

    • Count edits toward rate limit
    • Use half a point (0.5) per edit instead of full point
  2. Error-based penalties

    • If previous attempt produced an error: apply half point (0.5)
    • If previous attempt succeeded: apply normal edit rate (0.5)
    • Track error state per user
  3. Small change exemption (with abuse protection)

    • Changes < 10 characters: skip rate limit point
    • BUT still track the edit
    • If abuse detected (> 5 small edits in 1 minute): apply retroactive penalties
    • Retroactive: apply full points for all small edits in that window
  4. Implementation approach

    • Store edit history per user (timestamp, size, success/fail)
    • Track consecutive small edits
    • Calculate dynamic penalty based on pattern
    • Clean old edit records periodically

Implementation Plan

  1. Track edit metadata

    • Add edit tracking to rate limiter
    • Store: timestamp, char change count, error occurred
  2. Implement graduated penalties

    • Calculate penalty: base (0.5) + error bonus (0.5 if previous failed)
    • Small change logic with abuse detection
  3. Abuse detection

    • Count small edits in 1-minute window
    • Threshold: 5 small edits triggers retroactive penalties
    • Apply full points retroactively
  4. Update user messaging

    • Clear error messages explaining edit limits
    • Show penalty breakdown if retroactive applied

Acceptance Criteria

  • Edits count toward rate limit (0.5 points)
    • Failed previous attempts add penalty
    • Small changes (<10 chars) initially exempt
    • Abuse detection triggers retroactive penalties
    • User-friendly error messages
    • Tests for all scenarios

Part of Epic #38

## Description Improve rate limiting to handle message edits more intelligently with graduated penalties. ## Current Behavior - Message edits are completely exempt from rate limiting - Users can bypass limits by editing messages repeatedly - No penalty for failed/abusive attempts ## Proposed Behavior 1. **Apply rate limiting to edits** - Count edits toward rate limit - Use half a point (0.5) per edit instead of full point 2. **Error-based penalties** - If previous attempt produced an error: apply half point (0.5) - If previous attempt succeeded: apply normal edit rate (0.5) - Track error state per user 3. **Small change exemption (with abuse protection)** - Changes < 10 characters: skip rate limit point - BUT still track the edit - If abuse detected (> 5 small edits in 1 minute): apply retroactive penalties - Retroactive: apply full points for all small edits in that window 4. **Implementation approach** - Store edit history per user (timestamp, size, success/fail) - Track consecutive small edits - Calculate dynamic penalty based on pattern - Clean old edit records periodically ## Implementation Plan 1. **Track edit metadata** - Add edit tracking to rate limiter - Store: timestamp, char change count, error occurred 2. **Implement graduated penalties** - Calculate penalty: base (0.5) + error bonus (0.5 if previous failed) - Small change logic with abuse detection 3. **Abuse detection** - Count small edits in 1-minute window - Threshold: 5 small edits triggers retroactive penalties - Apply full points retroactively 4. **Update user messaging** - Clear error messages explaining edit limits - Show penalty breakdown if retroactive applied ## Acceptance Criteria - [ ] Edits count toward rate limit (0.5 points) - [ ] Failed previous attempts add penalty - [ ] Small changes (<10 chars) initially exempt - [ ] Abuse detection triggers retroactive penalties - [ ] User-friendly error messages - [ ] Tests for all scenarios ## Related Part of Epic #38
Sign in to join this conversation.
No description provided.