fix(ai-moderation): implement prompt analysis recommendations

- Expand IMPHNEN domain rule to cover wildcard (*.imphnen.*)
- Trim redundant SARA examples from TEXT_ONLY_MODE (save ~950 tokens)
- Add debugging logs for channel culture injection into prompt
- Sync flag validation set with missing flags: potential_evasion, unclear_context

Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
MythEclipse
2026-06-12 23:40:25 +07:00
co-authored by Claude
parent b508a39ff7
commit 12f9b55000
5 changed files with 37 additions and 22 deletions
+1
View File
@@ -18,6 +18,7 @@
"db:generate": "drizzle-kit generate",
"db:migrate": "drizzle-kit migrate",
"db:studio": "drizzle-kit studio",
"db:truncate": "psql \"$DATABASE_URL\" -f scripts/truncate-all.sql",
"install:yt-dlp": "sh scripts/install-yt-dlp.sh"
},
"devDependencies": {
+22
View File
@@ -0,0 +1,22 @@
-- Truncate all tables in correct order (respecting FK dependencies)
-- attachments FK → messages (CASCADE), others are independent
-- Use CASCADE to handle any remaining FK chains automatically
TRUNCATE TABLE
messages,
attachments,
ui_state,
ai_analysis_runs,
voice_recordings,
user_reputations,
channel_cultures,
message_reviews,
moderation_actions,
retention_policies,
text_analysis_cache,
sticker_cache,
corrected_moderations,
user_profiles,
mascot_chat_messages,
muxer_jobs
CASCADE;
@@ -298,6 +298,8 @@ const VALID_PRIMARY_AI_FLAGS = new Set([
"self_promo",
"conflict_instigation",
"offensive_username",
"potential_evasion",
"unclear_context",
]);
function normalizeFlag(value: string): string | null {
@@ -756,6 +756,11 @@ async function runTextOnlyBatch(
? channelCultureObj.culture_summary
: undefined;
// Log channel culture & user profiles for debugging
if (channelCulture) {
log.debug({ channelId, culturePreview: channelCulture.slice(0, 120) }, "Injected channel culture into prompt");
}
// Run sub-batches sequentially to avoid rate limits
for (let i = 0; i < subBatches.length; i++) {
const batch = subBatches[i];
@@ -1092,6 +1097,11 @@ async function runMediaBatch(
? channelCultureObj.culture_summary
: undefined;
// Log channel culture for debugging
if (channelCulture) {
log.debug({ channelId, culturePreview: channelCulture.slice(0, 120) }, "Injected channel culture into prompt (media path)");
}
const correctedExamples = await buildCorrectedFewShotExamples();
const systemText = buildSystemPromptModular({
contextText,
File diff suppressed because one or more lines are too long