feat(comment): auto-collapse spam comments behind env flag#4843
Merged
Conversation
Comments are scored by the dedicated comment spam model (#4838) but nothing acts on the score yet. Articles already auto-demote via excludeSpam; this adds the comment equivalent, using the softer 'collapsed' state (folded but still expandable in-thread) per the '不刪除,只是不再被看見' governance principle. When MATTERS_COMMENT_SPAM_AUTO_COLLAPSE=true, detectSpam collapses an active comment whose spamScore reaches the tunable system spam threshold, skipping authors on the bypassSpamDetection whitelist (same carve-out as articles). Default off → scoring stays observe-only until ops opts in (zero-downtime, same rollout pattern as #4838). Collapse is reversible; no deletion. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## develop #4843 +/- ##
===========================================
+ Coverage 72.82% 73.04% +0.21%
===========================================
Files 1054 1066 +12
Lines 21263 21659 +396
Branches 4671 4816 +145
===========================================
+ Hits 15485 15821 +336
+ Misses 5706 5357 -349
- Partials 72 481 +409 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
Integration tests for the spam auto-collapse path: collapses an active comment at/above the system threshold, leaves it active below threshold, and skips bypassSpamDetection-whitelisted authors. Sets the spam_detection feature flag and toggles commentSpamAutoCollapse around each case. Raises diff coverage.
This was referenced Jun 15, 2026
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.
What
Comments are scored by the dedicated comment spam model (#4838), and ops has set
MATTERS_COMMENT_SPAM_DETECTION_API_URLin dev+prod — but nothing yet acts on the storedspamScore. This wires the action.Articles already auto-demote spam from listings via the
excludeSpammodifier + the tunable system spam threshold. This adds the comment equivalent, using the softercollapsedstate (folded but still expandable in-thread) rather than removal — per the platform's 「不刪除,只是不再被看見」 governance principle.How
In
commentService.detectSpam, after storing the score, whenMATTERS_COMMENT_SPAM_AUTO_COLLAPSE=true:SystemService.getSpamThreshold),activeand its score reaches the threshold,bypassSpamDetectionwhitelist (same carve-out as articles).Gated behind a new env flag, default off → scoring stays observe-only until ops opts in. Zero-downtime, same rollout pattern as #4838. Collapse is reversible; no deletion.
Design notes / open questions for review
reasons.py(conformal work,spam-detection-serverless#feat/conformal-abstention) produces DSA Art.17 statements; a follow-up could persist one on collapse.Test plan
🤖 Generated with Claude Code