refactor(automod): remove regex classifier — LLM is the sole judge
Build & Deploy (Nix) / build-and-deploy (backend) (push) Successful in 3m2s
Build & Deploy (Nix) / build-and-deploy (discord-gateway) (push) Successful in 2m20s
Build & Deploy (Nix) / build-and-deploy (proxy) (push) Successful in 2m26s

Delete fastClassifier.ts (manual regex patterns for phone/email/IP/crypto/
spam/toxicity) and simpleFallback.ts. These hardcoded patterns were the
source of false positives (Discord emoji snowflakes matched phone_number,
URL digits matched phone, etc.) and produced heuristic verdicts whenever
the LLM failed.

New flow: Message → LLM (with conversation context, media evidence, user
reputation) → verdict. On LLM failure the message is marked 'error' and
retried by the recovery worker — no heuristic verdicts, ever.

Discord markdown tokens (custom emoji/mentions/timestamps) are normalized
to readable placeholders ([emoji:name], @user, @role, #channel, [time])
before reaching the LLM via discordTokens.ts.
This commit is contained in:
Developer
2026-07-31 17:55:02 +07:00
parent a2cda745f7
commit 0bd4369ae9
8 changed files with 112 additions and 797 deletions
@@ -1,9 +1,12 @@
export { startPendingAIAnalysisWorker } from "./aiAnalyzer.js";
export { runModerationAnalysis } from "./moderationOrchestrator.js";
export { buildSystemPrompt } from "./moderationPrompt.js";
export { runSimpleTextFallback } from "./simpleFallback.js";
export { sanitizeDiscordTokens } from "./discordTokens.js";
// ── New two-pass pipeline exports ──────────────────────────────────────────
export { classifyMessage } from "./fastClassifier.js";
export type { Layer1Result } from "./fastClassifier.js";
export type { AnalysisInput, AnalysisResult, WorkerConfig, MessageBatch } from "./ai-analysis-worker.js";
// ── Single-pass LLM pipeline exports ─────────────────────────────────────
export type {
AnalysisInput,
AnalysisResult,
WorkerConfig,
MessageBatch,
} from "./ai-analysis-worker.js";