fix(moderation): allow running evaluation on drafts#1376
Open
slint wants to merge 5 commits into
Open
Conversation
slint
force-pushed
the
moderation-fixes
branch
2 times, most recently
from
June 2, 2026 12:51
9ed8929 to
35df394
Compare
Better handles cases where only `draft` is passed to an moderation evaluation run.
Rules are now `Rule` subclasses that return a RuleResult holding typed Reason objects explaining how each score was reached, instead of a bare integer. Each rule's reason types are nested in the rule that produces them, so a rule reads as one self-contained unit. Reasons are narrated even when they score zero, so a rule expected to fire but that didn't can still be inspected. base.py holds the contract: the Rule base class (whose __call__ resolves the draft/record and delegates to evaluate), Reason, and RuleResult. Context is typed per reason kind (flat, one type per field) so the serialized output indexes cleanly as application logs, with a stable code for cross-record aggregation and a human label for single-record reading. The handler totals the per-rule scores and serializes results via asdict.
The emoji regex used a trailing '+', so a consecutive run of emoji matched as a single hit. Dense emoji spam (a wall of emoji) thus counted as 1 and slipped under the >3 threshold, while sparse emoji interleaved with text counted as many and tripped it -- backwards from the spam intent. Drop the quantifier so each emoji is counted individually.
The automated comment on a user moderation request previously showed only the total evaluation. It now lists the reasons that moved the score, grouped by rule with each rule's subtotal, so a reviewing admin sees why the user was flagged rather than a bare number. Reason labels are HTML-escaped since they embed record-derived text (domains, query notes).
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.
Better handles cases where only
draftis passed to an moderationevaluation run.