deploy(comment-spam): 3-tier telegram alerting to prod (notify-only, curated)#4852
Merged
Conversation
…ify-only)
A high spam score alone can't separate true spam from false positives: on
matters_prod (7-day, >=0.94 band) precision is only ~60% — escort ads (0.996)
score the same as 中文 creative writing (0.992) and short genuine replies.
Account age doesn't separate either (an escort account was 818d old / 883
articles). What cleanly partitions them (ZERO false positives on the real
high-score set) is a compound gate:
Tier A (auto): score>=threshold AND contact-channel AND solicitation-keyword
→ escort / paid-services / account-selling / betting promo.
Tier B (ring): author repeats near-identical content across comments.
Tier C (review): high score but neither → surface to humans, never auto-act
(creative writing / opinions / replies land here).
This wires the gate into detectSpam and surfaces all three tiers to the admin
Telegram chat by reusing the existing report-alert SQS → reportTelegramAlert
pipeline (new source 'spam_detection'). NOTIFY-ONLY: it never hides a comment —
auto-action stays behind the separate, still-off commentSpamAutoCollapse flag —
so we validate the gate's precision in production before enabling enforcement.
Gated by MATTERS_COMMENT_SPAM_ALERT (default off).
Signal logic lives in a pure, fully unit-tested module (commentSpamSignals.ts);
the ring check is one bounded read of the author's recent comments, run only for
the rare high-score comments.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
The ring near-duplicate check only stripped bare digits, so a rotated contact token (sk3826, abc123) left a letter remnant (sk, abc) and otherwise-identical spam templates failed to match. Drop whole alphanumeric tokens containing a digit instead — the IDs/phone numbers spammers rotate — while keeping pure-letter words so English templates still ring-match. Fixes the two failing ring tests. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #4852 +/- ##
==========================================
+ Coverage 72.45% 72.54% +0.08%
==========================================
Files 1056 1057 +1
Lines 20960 21028 +68
Branches 4550 4568 +18
==========================================
+ Hits 15186 15254 +68
+ Misses 5300 5299 -1
- Partials 474 475 +1 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
mashbean
added a commit
that referenced
this pull request
Jun 19, 2026
…-4852 chore: back-merge master → develop (dedup #4852 prod cherry-picks)
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.
Curated cherry-pick of the comment-spam 3-tier telegram alerting (#4851) onto
masterfor production deploy, excluding the seven-day-book features (#4841/#4842) that aren't ready for prod — same decoupling approach as #4849.Cherry-picked commits:
f231f92(feat) +b12c8b(ring-normalize fix). Conflict resolved: dropped theCampaignServiceimport (only present on develop via the seven-day-book branch; unused on master).Behavior-safe deploy: the entire feature is gated behind
MATTERS_COMMENT_SPAM_ALERT(default off) and is notify-only — it never hides a comment. Deploying changes nothing until ops sets the flag.See #4851 for full rationale (the compound gate, validated zero-false-positive on real prod data).
🤖 Generated with Claude Code