Skip to content

fix(moderation): allow running evaluation on drafts#1376

Open
slint wants to merge 5 commits into
zenodo:masterfrom
slint:moderation-fixes
Open

fix(moderation): allow running evaluation on drafts#1376
slint wants to merge 5 commits into
zenodo:masterfrom
slint:moderation-fixes

Conversation

@slint

@slint slint commented May 31, 2026

Copy link
Copy Markdown
Member

Better handles cases where only draft is passed to an moderation
evaluation run.

@slint
slint force-pushed the moderation-fixes branch 2 times, most recently from 9ed8929 to 35df394 Compare June 2, 2026 12:51
slint added 5 commits June 9, 2026 18:17
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).
@slint
slint force-pushed the moderation-fixes branch from 2ff2914 to 50becca Compare June 9, 2026 16:17
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