feat(ai-moderation): add user profile self-learning system

Add user_profiles table, store, and background learner worker
that summarizes user communication style, topics, and personality.

- New user_profiles table (user_id PK, guild_id, profile_summary, last_analyzed_at)
- userProfileStore.ts — CRUD (get/update) following channelCultureStore pattern
- userProfileLearner.ts — background worker: queries 100 recent msgs per user,
  calls LLM for personality summary, updates every 12h
- Inject <user_profile> XML tag per-message in moderation prompt
- Start worker alongside cultureLearner in aiAnalyzer.ts
- Migration 0008 for user_profiles table

Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
MythEclipse
2026-06-12 20:11:34 +07:00
co-authored by Claude
parent 6effb51b5d
commit fbc2184c6e
8 changed files with 270 additions and 2 deletions
@@ -133,6 +133,9 @@ export function startPendingAIAnalysisWorker(
import("./cultureLearner.js")
.then((m) => m.startCultureLearnerWorker())
.catch(console.error);
import("./userProfileLearner.js")
.then((m) => m.startUserProfileLearnerWorker())
.catch(console.error);
setInterval(() => {
revertStuckProcessingMessages(300000).catch((err: unknown) => {