Skip to content

deploy(comment-spam): 3-tier telegram alerting to prod (notify-only, curated)#4852

Merged
mashbean merged 2 commits into
masterfrom
deploy/comment-spam-tiering-prod
Jun 16, 2026
Merged

deploy(comment-spam): 3-tier telegram alerting to prod (notify-only, curated)#4852
mashbean merged 2 commits into
masterfrom
deploy/comment-spam-tiering-prod

Conversation

@mashbean

Copy link
Copy Markdown
Contributor

Curated cherry-pick of the comment-spam 3-tier telegram alerting (#4851) onto master for 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 the CampaignService import (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

mashbean and others added 2 commits June 16, 2026 18:53
…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>
@mashbean mashbean requested a review from a team as a code owner June 16, 2026 10:54
@codecov

codecov Bot commented Jun 16, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 94.20290% with 4 lines in your changes missing coverage. Please review.
✅ Project coverage is 72.54%. Comparing base (4b98624) to head (e1879a0).
⚠️ Report is 1 commits behind head on master.

Files with missing lines Patch % Lines
src/connectors/commentService.ts 86.66% 3 Missing and 1 partial ⚠️
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.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@mashbean mashbean merged commit 05e6b20 into master Jun 16, 2026
4 checks passed
mashbean added a commit that referenced this pull request Jun 19, 2026
…-4852

chore: back-merge master → develop (dedup #4852 prod cherry-picks)
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