Commit Graph
255 Commits
Author SHA1 Message Date
MythEclipseandClaude Opus 4.8 bda8304bb9 fix(analytics): align flag counts and violation score math
- Count only flagged messages in the active users Flag column
- Coerce PostgreSQL count results to numbers before calculating violation_score
- Prevent string concatenation in flagged*3 + warned scoring

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-06-01 19:23:46 +07:00
MythEclipseandClaude Opus 4.8 80f1069e2f fix(moderation): remove unsupported chat_template_kwargs and reasoning_budget
API provider returns 400 error for these params. Removed from all LLM calls
in llmModerationClient.ts and indonesianTextNormalizer.ts.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-06-01 19:05:06 +07:00
MythEclipseandClaude Opus 4.8 13efb576d6 fix(moderation): remove manual badword list and fix deferral regex false positives
- Remove LOCAL_BADWORDS array (25 hardcoded words) and FALSE_POSITIVE_WHITELISTS
- Remove detectLocalBadwords function — all detection now goes through API pipeline
- Fix DEFERRAL_ANALYSIS_PATTERN: remove overly broad patterns (admin perlu, bisa berpotensi, maaf/sorry, saya tidak yakin)
- Expand DEFERRAL_EXCEPTION_PATTERN to catch more decisive-deferral variations
- Update tests to reflect API-only detection (local fallback removed)

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-06-01 19:00:16 +07:00
MythEclipseandClaude Opus 4.8 a643125c7b refactor(moderation): improve LLM moderation client - 10 recommendations
- Add XML delimiters to prevent prompt injection (R1)
- Use JSON Schema response format instead of json_object (R2)
- Add concurrency limiter via p-limit (R3)
- Add timeout per media analysis call (R4)
- Resize images with sharp before vision API (R5)
- Split text batches when exceeding batch size limit (R6)
- Add few-shot examples to system prompt (R7)
- Modularize system prompt builder (R8)
- Enhance deferral detection regex with exception patterns (R9)
- Sanitize error messages to avoid leaking internals (R10)

New files: concurrencyLimiter.ts, imageResizer.ts, moderationPrompt.ts
Updated: llmModerationClient.ts, config.ts, package.json, tests

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-06-01 18:50:05 +07:00
MythEclipseandClaude Opus 4.8 4117f83c1b fix(dashboard): infinite scroll, auto-refetch, analytics cache invalidation, remove topic row cap
Frontend:
- Cursor pagination (100/page) replacing hardcoded 80 message limit
- Removed .slice(0,200) cap on mergeMessages
- IntersectionObserver infinite scroll with skeleton loading
- 15s periodic refetch for message list sync

Backend:
- Removed LIMIT 2000 from topic trends SQL query
- Added invalidateAnalyticsCache on message capture (messageCreated)
- Added invalidateAnalyticsCache on batch analysis completion

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-06-01 18:14:32 +07:00
MythEclipse 5078b34ac2 fix: render custom emoji as images and feed to AI vision pipeline
- Extract custom emoji metadata with Discord CDN URLs
- Download and send emoji images to vision model for moderation analysis
- Render custom emoji as inline images in dashboard instead of raw <:name:id> text
- Add emoji vision cache with deterministic keying by emoji ID
- Add custom emoji vision prompt for context-aware moderation
2026-06-01 17:23:46 +07:00
MythEclipse 8310e58239 feat(config): add API route for app configuration and update related logic for monitor guild 2026-06-01 11:16:07 +07:00
MythEclipse 49e9197ce0 feat(deploy): update deployment workflow and remove obsolete Docker publish workflow 2026-06-01 11:07:25 +07:00
MythEclipse c2d5bde633 feat(database): update migration command to use migrateCli and separate migration logic 2026-05-31 23:10:28 +07:00
MythEclipse 7607282db2 feat(database): add automatic migration on startup and enhance text analysis cache source 2026-05-31 23:01:38 +07:00
MythEclipse 96cd0cfc62 refactor(moderation): clean up code formatting for improved readability 2026-05-31 22:05:50 +07:00
MythEclipse 331076a540 feat(moderation): enhance media analysis with separate handling for images and text 2026-05-31 22:01:42 +07:00
MythEclipse 47e7e8e549 feat(moderation): implement media analysis caching with deterministic keys and database integration 2026-05-31 20:57:01 +07:00
MythEclipse d63e34d259 feat(moderation): refactor word analysis caching to text analysis caching with improved context handling 2026-05-31 20:33:27 +07:00
MythEclipse 7e58741b5c feat(moderation): implement per-word analysis caching for improved performance 2026-05-31 20:27:19 +07:00
MythEclipse 34c4e3e017 feat(moderation): add support for vision model in moderation analysis 2026-05-31 20:12:16 +07:00
MythEclipse 47bac6ff8f feat: add Groq Llama Prompt Guard moderation integration
- Updated .env.example to include Groq API configuration.
- Enhanced config schema in config.ts to support Groq API keys and settings.
- Implemented Groq moderation API call in indonesianTextNormalizer.ts as a fallback for badword detection.
- Removed the Indonesian slang normalization function and related tests to streamline moderation logic.
- Updated tests to reflect changes in moderation strategy, focusing on emoji normalization and badword detection.
2026-05-31 19:42:39 +07:00
MythEclipse c30785a978 feat(moderation): add additional channel to skip in message capture logic 2026-05-31 19:04:03 +07:00
MythEclipse 4bb90153b0 feat(analytics): add support for selected analytics guild and channel in App component
fix(redis): enhance Redis connection handling with fallback to in-memory storage
chore(sql): create missing messages and attachments tables with necessary constraints and indexes
2026-05-31 17:19:24 +07:00
MythEclipse 30ce607d88 style: format code for improved readability and consistency across multiple files 2026-05-31 16:54:15 +07:00
MythEclipse f224be2a66 Refactor test database setup and add migrations
- Updated test files to use a separate test database configuration.
- Introduced a new helper module for managing test database operations.
- Added a setup file to configure the environment for tests.
- Created new database migration scripts to optimize message indexing.
- Added a sample environment file for test database configuration.
2026-05-31 16:32:38 +07:00
MythEclipse 8a712cff9b Refactor database handling to exclusively support PostgreSQL
- Removed SQLite support from the configuration and database initialization logic.
- Updated database migration scripts to focus solely on PostgreSQL migrations.
- Simplified logging messages to reflect PostgreSQL usage.
- Adjusted database schema definitions to remove SQLite-specific types and structures.
- Modified tests to ensure compatibility with PostgreSQL, including changes to table creation and data types.
- Cleaned up unused imports and code related to SQLite.
2026-05-31 15:46:18 +07:00
MythEclipse d1ef036358 feat(redis): integrate Redis for job queue management and persistent storage 2026-05-31 14:21:43 +07:00
MythEclipse ce945c8af0 fix(analytics): simplify GROUP BY and ORDER BY clauses in getDailyTrend function 2026-05-31 01:34:35 +07:00
MythEclipse 71e240c1e7 feat(analytics): add daily trend and activity heatmap endpoints, and implement corresponding frontend components
- Added new API endpoints for daily trend data and activity heatmap in analyticsRoutes.ts.
- Created new frontend components: ActivityChart, ControlBar, Heatmap, SummaryCards, TopicList, TrendChart, UserTable, and ViolatorTable for displaying analytics data.
- Implemented loading and empty states in the new components.
- Enhanced the existing moderation tests with remote fallback handling for Indonesian text normalization.
2026-05-31 00:41:34 +07:00
MythEclipse 4e9e370eb1 feat: enhance getTopViolators query to use conditional counts for improved accuracy in moderation stats 2026-05-30 21:29:16 +07:00
MythEclipse 10f44138bc feat: implement age restriction handling in message analysis and metadata 2026-05-30 21:12:25 +07:00
MythEclipse c9e79c8c7c feat: refactor database access in analyticsStore to use executeAll and executeGet for improved query handling 2026-05-30 20:40:33 +07:00
MythEclipse b19529f135 feat: enhance logging and moderation response handling with improved serialization and error management 2026-05-30 20:13:44 +07:00
MythEclipse b105f9748a refactor: optimize database queries and enhance caching for analytics 2026-05-30 17:28:27 +07:00
MythEclipseandClaude Opus 4.8 a00a5a508f refactor: remove unused AI columns from messages table
Drop 3 columns that were written but never read:
- ai_moderation_raw: raw LLM JSON response (~KB per message, never consumed)
- ai_policy_version: hardcoded 'default-2026-05-30', never used for decisions
- ai_evidence: JSON evidence array, never read after write

Changes:
- schema.ts: remove columns from both Postgres and SQLite table definitions
- messageStore.ts: remove from AIAnalysisUpdate interface and SET clauses
- aiAnalyzer.ts: remove from individual fallback update calls
- aiAnalysisWorker.ts: remove raw write, add missing fields (categories, severity, etc.)
- types.ts: remove from MessageRecord interface
- analysisRoutes.ts: remove from reset analysis call
- New migration: src/database/migrations/001_drop_unused_ai_columns.sql
- Migration applied to live DB: 27 columns → 24 columns

Kept ai_error (useful for future debugging, currently 0 non-null)
Kept metadata (1.9MB total, used for AI sticker/embed evidence analysis)

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-05-30 16:06:37 +07:00
MythEclipse 551d11ba82 Refactor code for improved readability and consistency
- Adjusted formatting in conversationContext.ts for better token estimation readability.
- Enhanced readability in indonesianTextNormalizer.ts by formatting multiline replacements.
- Reformatted badword lists and whitelists in indonesianTextNormalizer.ts for consistency.
- Improved function signatures in messageStore.ts for clarity.
- Reformatted messageCapture.ts to enhance readability of channel ID checks.
- Cleaned up error logging in messageStore.ts and retentionManager.ts for better clarity.
- Reformatted indonesianSlangLexicon.ts for consistent object formatting.
- Enhanced URL fetching regex patterns in urlFetcher.ts for better readability.
- Simplified query parameter destructuring in analyticsRoutes.ts for cleaner code.
- Improved test readability in autoDeleteManager.test.ts and indonesianTextNormalizer.test.ts by formatting expectations.
- Cleaned up whitespace in messageCaptureFilter.test.ts for consistency.
2026-05-30 15:55:01 +07:00
MythEclipseandClaude Opus 4.8 4fa7875b80 feat: add sticker context to LLM prompts + sticker image cache
- New sticker-specific vision prompt that tells LLM stickers are cartoon/meme art, not real photos
- New text-only warning for stickers that fail to download — prevents flagging based on name alone
- Updated system prompt with dedicated sticker guidance section (looser standards for cartoon content)
- Filesystem-backed sticker cache (keyed by name, 7-day TTL, 100MB max with LRU eviction)
- Config: STICKER_CACHE_DIR and STICKER_CACHE_MAX_SIZE_MB with defaults
- Updated .env.example with auto-delete + sticker config docs

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-05-30 15:54:37 +07:00
MythEclipseandClaude Opus 4.8 202ea311a5 feat: lower auto-delete confidence threshold to 0.50, add allowed severities to defaults
- AUTO_DELETE_MIN_CONFIDENCE default 0.92 -> 0.50
- AUTO_DELETE_ALLOWED_SEVERITIES default 'critical' -> 'critical,high,medium'
- Add auto-delete config section to .env.example

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-05-30 15:35:07 +07:00
MythEclipse 8f6a35f591 feat: integrate NVIDIA Nemotron-3 Content Safety API for Indonesian badword detection
- Added configuration options for NVIDIA Nemotron API key, model, and base URL.
- Refactored badword detection to utilize NVIDIA API, with a fallback to a local badword list.
- Updated moderation functions to handle asynchronous operations for text evidence generation.
- Removed dependency on the `indonesian-badwords` package and implemented custom detection logic.
- Enhanced tests to accommodate asynchronous behavior and validate new detection methods.
2026-05-30 14:48:50 +07:00
MythEclipseandClaude Opus 4.6 3cc6b7a924 fix(auto-delete): derive severity/action from legacy fields, log at info level
- Derive severity from status/score when ai_severity missing
- Derive recommended_action from severity/status when field missing
- Upgrade skip logs from debug to info so skip reasons are visible
- Allow both 'flagged' and 'warn' status for eligibility

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-05-30 03:40:26 +07:00
MythEclipse 6eb83b864f feat(moderation): update auto-delete logic to include 'warn' status for message eligibility 2026-05-30 02:48:27 +07:00
MythEclipse d082cd850b Merge branch 'worktree-agent-acd4fe7096dc8d6e4' 2026-05-30 01:04:43 +07:00
MythEclipseandClaude Opus 4.6 c894e5cd75 feat: expand AI moderation with structured analysis, review workflow, and guardrails
- Add structured AI moderation fields (categories, severity, confidence,
  recommended_action, policy_version, evidence) to messages table
- Add moderation_reviews, moderation_actions, and retention_policies tables
- Upgrade LLM response parsing to support structured metadata with backwards
  compatibility for legacy responses
- Implement public AI evaluation review UI with decision controls
  (approve, false positive + reanalyze, escalate)
- Add auto-delete guardrails requiring high confidence, severity, and
  allowed categories; log all attempts to moderation_actions
- Add retention manager scaffolding for messages/attachments/voice
- Add action executor for moderation actions (mute, warn, kick, ban)
- Add review routes: GET/POST/PATCH /api/reviews, GET/POST/PATCH /api/actions
- Preserve auth separation: voice/media/recordings gated, review public

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-05-30 01:02:51 +07:00
MythEclipse 394bd5a471 feat(moderation): skip message capture for specific channels in shouldCaptureMessageLocation 2026-05-30 00:37:20 +07:00
MythEclipse b938420eb3 feat(moderation): enhance Indonesian slang lexicon with additional profanity normalization and expand badword detection logic 2026-05-30 00:14:28 +07:00
MythEclipse d03244a0ae feat(moderation): update lexicon to include sexual deviation topics and clarify analysis guidelines 2026-05-30 00:01:09 +07:00
MythEclipse 81606f49a5 feat(moderation): enhance Indonesian slang lexicon with profanity normalization 2026-05-29 23:59:38 +07:00
MythEclipse 9ed50bc8ed feat(ui): add "analytics" tab to activeTabs and defaultSharedUIState 2026-05-29 21:10:00 +07:00
MythEclipse 687fcec62c chore: add comment to clarify app initialization process 2026-05-29 20:54:57 +07:00
MythEclipse 8c3bb77984 feat: add analytics hooks and routes for moderation statistics
- Implemented `useAnalytics` hook for fetching and managing analytics data.
- Created `analyticsStore.ts` to handle database queries for hourly stats, topic trends, user leaderboard, and moderation stats.
- Added Express routes for analytics endpoints including overview, hourly stats, topic trends, user leaderboard, moderation stats, and top violators.
- Introduced a utility function `filterHits` for filtering specific terms in text.
2026-05-29 19:37:08 +07:00
MythEclipseandClaude Opus 4.8 fb09ac81c5 feat(moderation): Indonesian slang normalizer and false-positive prevention
- Add indonesian-badwords dependency for local lexical signal
- Add Indonesian slang lexicon with woy/woi/hadeh as safe casual terms
- Normalize Discord custom emoji <:name:id> to [emoji:name] in prompts
- Wire normalization evidence into both conversationContext and llmModerationClient prompts
- Harden system prompt: woy/woi are casual greetings, not SARA/hate
- Add tests for emoji normalization, slang mapping, badword detection

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-05-29 18:39:10 +07:00
MythEclipse b96fb619c9 feat(config): change default value of boolean to false in config schema 2026-05-29 18:12:28 +07:00
MythEclipseandClaude Opus 4.8 7da83387ee feat(moderation): auto-delete flagged messages
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-05-29 18:04:42 +07:00
MythEclipse 649283a3bc feat(moderation): enhance media analysis handling and integrate image evidence 2026-05-29 17:43:34 +07:00