PHASE 13 README - nself-org/nchat GitHub Wiki
Complete Implementation of AI-powered moderation, GDPR compliance, legal hold management, and blockchain-backed immutable audit trails.
Phase 13 delivers a comprehensive enterprise-grade moderation and compliance system with:
- โ AI-Powered Auto-Moderation - Multi-model toxicity, NSFW, and spam detection
- โ Automated Action Engine - Smart enforcement with appeal process
- โ User Reporting System - Complete report queue with 7 categories
- โ Appeal Workflow - Fair review process for moderation decisions
- โ GDPR Compliance - Full export/delete flows (Articles 15, 17, 20)
- โ Legal Hold Management - eDiscovery and litigation support
- โ Immutable Audit Logs - Tamper-proof cryptographic hash chains
- โ Blockchain Backup - Optional Merkle tree blockchain anchoring
- โ Compliance Dashboard - Real-time monitoring and reporting
For administrators and moderators:
Navigate to: /admin/moderation/comprehensive
await fetch('/api/reports', {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({
reporter_id: userId,
target_type: 'message',
target_id: messageId,
category_id: 'harassment',
description: 'Description of issue',
evidence: [{ type: 'screenshot', content: 'url', description: 'Evidence' }],
}),
})import { getActionEngine } from '@/lib/moderation/action-engine'
const engine = getActionEngine()
const result = await engine.processContent(contentId, 'text', content, userId, username)
if (result.executed) {
console.log(`Action taken: ${result.action?.actionType}`)
console.log(`Reason: ${result.action?.reason}`)
}await fetch('/api/appeals', {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({
action_id: moderationActionId,
user_id: userId,
reason: 'Why this decision should be reversed',
evidence: [{ type: 'text', content: 'Additional context' }],
}),
})Navigate to: /settings/privacy/gdpr
Or via API:
// Export
await fetch('/api/compliance/export', {
method: 'POST',
body: JSON.stringify({
user_id: userId,
user_email: email,
categories: ['all'],
format: 'zip',
}),
})
// Delete
await fetch('/api/compliance/deletion', {
method: 'POST',
body: JSON.stringify({
user_id: userId,
user_email: email,
scope: 'full_account',
reason: 'No longer using service',
}),
})src/
โโโ lib/
โ โโโ moderation/
โ โ โโโ action-engine.ts # Auto-action execution
โ โ โโโ ai-moderator.ts # AI analysis
โ โ โโโ appeal-system.ts # Appeal workflow
โ โ โโโ report-system.ts # Report queue
โ โ โโโ __tests__/ # Tests
โ โโโ compliance/
โ โ โโโ data-export.ts # GDPR export
โ โ โโโ data-deletion.ts # GDPR deletion
โ โ โโโ legal-hold.ts # Legal hold
โ โ โโโ gdpr-helpers.ts # GDPR utilities
โ โ โโโ retention-policy.ts # Data retention
โ โโโ audit/
โ โโโ tamper-proof-audit.ts # Hash chain audit
โ โโโ blockchain-backup.ts # Blockchain anchoring
โโโ components/
โ โโโ moderation/
โ โ โโโ ComprehensiveModerationDashboard.tsx
โ โโโ compliance/
โ โโโ GDPRDataRequest.tsx
โโโ app/
โโโ api/
โ โโโ reports/ # Report endpoints
โ โโโ appeals/ # Appeal endpoints
โ โโโ moderation/ # Moderation endpoints
โ โโโ compliance/ # Compliance endpoints
โ โโโ audit/ # Audit endpoints
โโโ admin/moderation/comprehensive/
โโโ settings/privacy/gdpr/
Configure in your app settings or database:
{
enableToxicityDetection: true, // Hate speech, threats
enableNSFWDetection: true, // Inappropriate content
enableSpamDetection: true, // Spam and scams
enableProfanityFilter: true, // Bad language
autoFlag: true, // Auto-flag for review
autoHide: false, // Auto-hide content
autoWarn: false, // Auto-warn users
autoMute: false, // Auto-mute users
autoBan: false, // Auto-ban users
thresholds: {
toxicity: 0.7, // 70% confidence
flagThreshold: 0.5, // Flag at 50%
hideThreshold: 0.8, // Hide at 80%
warnThreshold: 0.7, // Warn at 70%
muteThreshold: 0.85, // Mute at 85%
banThreshold: 0.95, // Ban at 95%
}
};[
'spam', // Unsolicited content
'harassment', // Targeted harassment
'hate-speech', // Hate speech
'inappropriate-content', // NSFW
'impersonation', // Fake accounts
'scam', // Fraud attempts
'other', // Other issues
]- โ Article 15: Right of Access
- โ Article 16: Right to Rectification
- โ Article 17: Right to Erasure (Right to be Forgotten)
- โ Article 18: Right to Restriction
- โ Article 20: Right to Data Portability
- โ Article 21: Right to Object
- โ Article 22: Automated Decision Making
- Cryptographic hash chains (SHA-256)
- Tamper detection and verification
- Immutable log entries
- Retention policy enforcement
- Legal hold support
- Multiple export formats
- Blockchain anchoring (optional)
- Encryption at rest and in transit
- Secure deletion (multi-pass overwrite)
- Legal hold prevents deletion
- 14-day cooling-off period for deletions
- Identity verification required
- Download tracking and limits
// Report Statistics
{
total: number,
pending: number,
resolved: number,
averageResolutionTime: string,
byCategory: Record<string, number>,
byPriority: Record<string, number>
}
// Appeal Statistics
{
total: number,
pending: number,
approved: number,
rejected: number,
approvalRate: number,
averageResolutionTime: number
}
// Auto-Moderation Performance
{
total: number,
flagged: number,
hidden: number,
warned: number,
muted: number,
banned: number,
accuracy: number,
falsePositiveRate: number
}
// Audit Statistics
{
totalEntries: number,
verifiedEntries: number,
compromisedBlocks: number[],
integrityStatus: 'valid' | 'compromised',
chainLength: number
}Run comprehensive tests:
# Unit tests
npm test src/lib/moderation
npm test src/lib/compliance
npm test src/lib/audit
# Integration tests
npm test src/app/api/reports
npm test src/app/api/appeals
npm test src/app/api/compliance
# E2E tests
npm run test:e2e- Batch AI processing
- Query result caching
- Database query optimization
- Lazy loading for large lists
- Pagination for all endpoints
- Background job processing
- CDN for static assets
- Horizontal API scaling
- Queue-based async processing
- Database sharding support
- Load balancer ready
- Microservices architecture
- High report volume (>20 pending)
- Appeal backlog (>10 pending)
- Audit integrity compromised
- Legal hold expiration
- GDPR request deadline approaching
- System errors and failures
- User report confirmations
- Moderation action notices
- Appeal status updates
- Legal hold notices
- GDPR request completion
- Deletion confirmations
- Complete Implementation Guide
- GDPR Compliance
- AI Moderation Setup
- Audit Trail Verification
- Legal Hold Procedures
- Review moderation guidelines
- Understand AI confidence scores
- Learn appeal review process
- Practice using dashboard
- Escalation procedures
- How to report content
- Understanding moderation actions
- Appeal process
- GDPR data rights
- Privacy settings
Q: AI moderation not working?
Check:
1. AI service API keys configured
2. Services enabled in settings
3. Check API error logs
4. Verify network connectivity
Q: Reports not appearing in queue?
Check:
1. Reporter has permission
2. Category is enabled
3. No duplicate report exists
4. Check API response
Q: GDPR export failed?
Check:
1. User identity verified
2. No pending export exists
3. Storage space available
4. Check processing logs
Q: Audit integrity check failed?
Immediate actions:
1. Check compromised block numbers
2. Review recent changes
3. Contact security team
4. Export current state
5. Investigate tampering
- Review moderation queue daily
- Process pending appeals weekly
- Verify audit integrity weekly
- Review AI accuracy monthly
- Update blocked word lists
- Train new moderators
- Generate compliance reports
- โ Retention policy enforcement
- โ Legal hold reminders
- โ GDPR deadline tracking
- โ Audit log rotation
- โ Statistics calculation
- โ Email notifications
Multi-model AI analysis with confidence scoring:
- Perspective API for toxicity
- OpenAI Moderation for content policy
- TensorFlow.js for NSFW detection
- ML-based spam detection
- Custom profanity filter
Complete workflow with transparency:
- Evidence submission
- Moderator assignment
- Review notes
- Multiple outcomes
- User communication
Full implementation of user rights:
- Machine-readable exports
- Secure deletion
- 30-day processing guarantee
- Identity verification
- Audit trail
Tamper-proof audit trail:
- Cryptographic hash chains
- Merkle tree verification
- Optional blockchain anchoring
- Integrity checking
- External auditor support
- Review flagged content promptly
- Document decisions clearly
- Be consistent with rules
- Communicate with users
- Track patterns and trends
- Respond to GDPR requests within 30 days
- Verify identity before processing
- Document all decisions
- Maintain audit trail
- Update privacy policies
- Verify audit integrity regularly
- Monitor for anomalies
- Encrypt sensitive data
- Implement least privilege
- Regular security audits
- Issues: GitHub Issues
-
Docs:
/docsdirectory - Email: [email protected]
- Community: Discord/Slack
Status: โ Production Ready
Phase 13 is complete with enterprise-grade moderation, compliance, and audit capabilities. All systems tested and documented.
Last Updated: 2026-02-03