Auto: refactor/simplify-daily-limits #19

Merged
claude-bot merged 2 commits from refactor/simplify-daily-limits into main 2026-03-01 18:13:53 -07:00
Collaborator

Automated PR for branch refactor/simplify-daily-limits.

Automated PR for branch `refactor/simplify-daily-limits`.
refactor: simplify limits to daily output message count
All checks were successful
Auto PR Review / review (push) Successful in 3m13s
8b3d52bd2e
Replace 3 overlapping limit layers (subscription tiers, daily tokens,
monthly system budget) with a single daily output message limit
(free: 10/day, premium: 30/day). Count by Telegram output messages —
a translation that splits into 2 messages counts as 2.

- Add output_messages column to api_token_usage table
- Add get_user_daily_output_messages() query function
- Simplify TranslationDeps to translate + log_error only
- Remove TokenBudgetManager, ensure_free_user_sub, quota functions
- Update all handlers and tests for new limit system (-686 lines net)

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
ci: switch Claude review auth from API key to Max subscription
All checks were successful
Auto PR Review / review (push) Successful in 2m45s
5e459bd3dd
Use CLAUDE_CODE_OAUTH_TOKEN instead of ANTHROPIC_API_KEY so PR reviews
use the Claude Max subscription rather than pay-per-use API billing.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Author
Collaborator

Approved

Clean, well-structured refactoring that replaces a complex token-budget + translation-quota system with a simple daily output message count. The changes are consistent across constants, config, database, handlers, strings, and tests. The new get_user_daily_output_messages function correctly drives limit checks, and usage logging now tracks output_messages per translation. Tests are thoroughly updated to match the new behavior, including a new test for multi-message output counting.

Suggestions

  • strings.py: DAILY_MESSAGE_LIMIT_FREE and DAILY_MESSAGE_LIMIT_PREMIUM are defined but never referenced anywhere in the codebase. They appear to be dead code left over from the refactoring. Consider removing them or wiring them up if they're intended for future use.
  • database.py: activate_premium still accepts translation_limit and accumulates it into translation_remaining (line 630). Since the quota system is removed and callers now pass 0, consider updating the function signature and docstring to reflect that this parameter is vestigial, or remove it entirely to avoid confusion.
  • handlers/translation.py: Minor TOCTOU gap: the daily limit is checked before the translation starts but usage is logged after it completes. Concurrent requests from the same user could both pass the check and slightly exceed the limit. Low risk for a Telegram bot (messages are typically sequential per-user), but worth noting.
## Approved Clean, well-structured refactoring that replaces a complex token-budget + translation-quota system with a simple daily output message count. The changes are consistent across constants, config, database, handlers, strings, and tests. The new `get_user_daily_output_messages` function correctly drives limit checks, and usage logging now tracks `output_messages` per translation. Tests are thoroughly updated to match the new behavior, including a new test for multi-message output counting. ### Suggestions - **strings.py**: `DAILY_MESSAGE_LIMIT_FREE` and `DAILY_MESSAGE_LIMIT_PREMIUM` are defined but never referenced anywhere in the codebase. They appear to be dead code left over from the refactoring. Consider removing them or wiring them up if they're intended for future use. - **database.py**: `activate_premium` still accepts `translation_limit` and accumulates it into `translation_remaining` (line 630). Since the quota system is removed and callers now pass `0`, consider updating the function signature and docstring to reflect that this parameter is vestigial, or remove it entirely to avoid confusion. - **handlers/translation.py**: Minor TOCTOU gap: the daily limit is checked before the translation starts but usage is logged after it completes. Concurrent requests from the same user could both pass the check and slightly exceed the limit. Low risk for a Telegram bot (messages are typically sequential per-user), but worth noting.
claude-bot deleted branch refactor/simplify-daily-limits 2026-03-01 18:13:53 -07:00
Sign in to join this conversation.
No reviewers
No labels
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
bittabola/tarjimon!19
No description provided.