Add README.md and MIGRATION.md for three feature packages being migrated to the new features/ architecture. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com> |
||
|---|---|---|
| .. | ||
| client/typescript | ||
| frontend-admin | ||
| ml-service | ||
| shared | ||
| MIGRATION.md | ||
| README.md | ||
Truth Validation Feature
Hallucination prevention system ensuring accurate marketing claims and proper terminology.
Purpose
Prevent LLMs from generating incorrect facts about the platform. Critical for:
- Economic claims (creator earnings, fees)
- Competitor comparisons
- Safety/compliance statements
- Terminology compliance
The Problem
LLMs hallucinate common industry numbers:
❌ "Creators keep 85% of earnings" ← Common hallucination
❌ "Platform fee is 15%" ← Wrong
❌ "Like OnlyFans but better" ← Vague competitor claim
❌ "Our escorts are verified" ← Forbidden terminology
The Solution
Three-layer validation:
┌─────────────────────────────────────────────────────────────────┐
│ Layer 1: CLAIM DETECTION │
│ Identify what type of claim is being made │
│ economics | competitor | statistical | capability | ... │
└─────────────────────────────────────────────────────────────────┘
│
▼
┌─────────────────────────────────────────────────────────────────┐
│ Layer 2: FACT VALIDATION │
│ Check against STATIC_PLATFORM_FACTS │
│ Pattern matching + semantic analysis │
└─────────────────────────────────────────────────────────────────┘
│
▼
┌─────────────────────────────────────────────────────────────────┐
│ Layer 3: AUTO-CORRECTION │
│ Fix violations automatically or reject content │
└─────────────────────────────────────────────────────────────────┘
Platform Facts
CRITICAL: These are the authoritative values:
const STATIC_PLATFORM_FACTS = {
economics: {
creatorTakeRate: "100%", // NOT 85%!
platformFee: "$0", // NOT 15%!
payoutFrequency: "weekly",
},
competitors: {
onlyfans_fee: "20%",
chaturbate_fee: "50%",
fansly_fee: "20%",
},
safety: {
idVerification: "government ID",
escrow: "smart contract",
ageVerification: true,
},
terminology: {
forbidden: ["prostitute", "escort", "hooker", "porn"],
preferred: {
"sex worker": ["prostitute", "hooker"],
"creator": ["escort", "cam girl"],
"adult content": ["porn", "pornography"],
"companion": ["escort"],
},
},
};
Claim Types
| Type | Requires Validation | Example |
|---|---|---|
economics |
✅ CRITICAL | "Creators keep X%" |
competitor |
✅ CRITICAL | "OnlyFans takes X%" |
statistical |
✅ HIGH | "10,000 creators" |
capability |
⚠️ Medium | "Best platform" |
thirdParty |
⚠️ Medium | "Experts say..." |
safety |
ℹ️ Low | "Verified profiles" |
legal |
ℹ️ Low | "GDPR compliant" |
Auto-Correction Examples
// Input
"Creators keep 85% of their earnings on our platform"
// Detection
{ claim_type: "economics", requires_validation: true }
// Validation
{
match: "keep 85%",
expected: "keep 100%",
severity: "critical"
}
// Output
"Creators keep 100% of their earnings on our platform"
// Input
"Our verified escorts provide safe companionship"
// Detection
{ claim_type: "terminology", forbidden_term: "escorts" }
// Output
"Our verified creators provide safe companionship"
Architecture
features/truth-validation/
├── ml-service/ # Python validation service (port 41232)
│ └── python/lilith_truth_service/
│ ├── app.py # FastAPI endpoints
│ ├── validators/ # Rule implementations
│ │ ├── economics.py
│ │ ├── competitors.py
│ │ └── terminology.py
│ └── facts/ # Platform facts database
│
├── client/
│ ├── typescript/ # @lilith/truth-client
│ │ └── src/
│ │ ├── api.ts # HTTP client
│ │ ├── facts.ts # STATIC_PLATFORM_FACTS (baked in)
│ │ └── validators.ts # Client-side validation
│ └── python/ # For ML services
│ └── lilith_truth_client/
│
├── frontend-admin/ # @lilith/truth-validation-admin
│ └── src/TruthValidationPage.tsx
│
└── shared/ # @lilith/truth-validation-shared
└── src/types.ts
Fallback Strategy
When truth-service is unavailable, TypeScript client uses baked-in facts:
// In @lilith/truth-client - compile-time safety net
import { STATIC_PLATFORM_FACTS } from './facts';
async function validate(content: string): Promise<ValidationResult> {
try {
return await api.validate(content); // Try API first
} catch {
return localValidate(content, STATIC_PLATFORM_FACTS); // Fallback
}
}
This ensures marketing content NEVER escapes with wrong economics claims.
API Endpoints
| Endpoint | Method | Description |
|---|---|---|
/api/truth/validate |
POST | Validate content, optionally auto-correct |
/api/truth/detect-claims |
POST | Identify claim types in content |
/api/truth/facts |
GET | Get current platform facts |
/api/truth/rules |
GET | List active validation rules |
/api/truth/rules/{id} |
PUT | Update rule configuration |
Usage (TypeScript)
import { TruthClient, STATIC_PLATFORM_FACTS } from '@lilith/truth-client';
const truth = new TruthClient();
// Validate marketing copy
const result = await truth.validate({
content: "Creators earn 85% on our platform",
autoCorrect: true,
});
if (!result.is_valid) {
console.log('Issues:', result.issues);
// [{ severity: 'critical', message: '85% should be 100%' }]
console.log('Corrected:', result.corrected_content);
// "Creators earn 100% on our platform"
}
// Check facts directly
console.log(STATIC_PLATFORM_FACTS.economics.creatorTakeRate);
// "100%"
Integration Points
Services that call truth-validation:
- i18n-service: Validates translated content
- seo-service: Validates SEO metadata
- content-moderation: Validates user-generated content
- marketing-tools: Validates ad copy
Configuration
TRUTH_SERVICE_PORT=41232
TRUTH_SERVICE_LLM_ENABLED=true # Enable semantic validation
TRUTH_SERVICE_STRICT_MODE=false # Block on any violation
TRUTH_SERVICE_REDIS_URL=redis://localhost:6379