Repository navigation
Fix Vahter autoban karma leaking across identical message text - #557
Merged
Merged
Conversation
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.
A historical “not spam” correction for one message made every sender using identical text earn positive karma, even when their messages were deleted as spam. Calculate karma from each of the last ten received messages’ current snapshot verdict instead, honoring later corrections and counting each message once. Temporary user protection and ML training remain unchanged; no migration is required.
Adds regressions for cross-user text reuse, corrected-message karma, later spam verdicts, duplicate delivery, the ten-message window, and autoban after protection budget exhaustion. Existing consecutive-spam tests now send identical text with separate Telegram message IDs.
Validation: reproduced the regression against the original query. Final CI passed all 317 Vahter integration tests, 133 unit tests, 51 serialization compatibility tests, and 34 BotInfra tests; multipod and lint/security checks also passed. Local validation initially hit a Podman teardown conflict, then passed 316/317 and exposed a warning test reusing a message ID; that test was corrected before the successful final CI run. Commit hooks passed.
Read-only production EXPLAIN (ANALYZE, BUFFERS), warm-cache spot checks: old/new execution times were 1.388/0.117 ms for a spammer and 0.824/0.116 ms for an active user with 11,711 historical messages. Buffer accesses fell from 152 to 14 and 126 to 12. The new query uses the existing user/time index and scans 11 rows to return 10, with a 25 KB incremental sort for deterministic ties. These are spot measurements, not a load test.