- ValidatorChain: Orchestrates multiple validators sequentially
- CitationRequired: Ensures answers include citations
[1],[2], etc. - EvidenceOverlap: Checks answer overlaps with RAG context (ngram-based, threshold: 8%)
- NumericUnitsBasic: Detects numbers and suggests citations
- SchemaFormat: Validates answer format/sections (optional, endpoint-specific)
- EthicsAdapter: Wraps existing ethics guard (if available)
- ValidationMetrics: Collects metrics (pass rate, overlap scores, reasons histogram)
- IdentityInjector: Injects StillMe identity into prompts
- STILLME_IDENTITY: System prompt ensuring brand consistency
- ToneAligner: Normalizes response tone to StillMe style
- New endpoint:
GET /api/validators/metrics- Returns validation metrics - Enhanced endpoint:
POST /api/chat/rag- Now supports validation chain (if enabled) - Error response: Returns 422 with validation reasons if validation fails
- New page: "Validation" - Shows validation metrics, pass rate, overlap scores, failure reasons histogram, and recent logs
ENABLE_VALIDATORS=true|false- Enable/disable validators globally (default: false)ENABLE_TONE_ALIGN=true|false- Enable/disable tone alignment (default: true)VALIDATOR_EVIDENCE_THRESHOLD=0.08- Minimum overlap threshold (default: 0.08)VALIDATOR_CITATION_REQUIRED=true|false- Require citations (default: true)STILLME_TONE_STYLE=neutral|friendly|scholarly- Tone style (default: neutral, future)
tests/test_validators_chain.py- Tests for ValidatorChain (5 tests)tests/test_identity_injector.py- Tests for IdentityInjector (4 tests)tests/test_evidence_overlap.py- Tests for EvidenceOverlap (9 tests)- All tests passing ✅
docs/CODEBASE_MAP_VALIDATORS.md- Codebase map for validators integrationdocs/INTEGRATION_VALIDATORS.md- Integration plan and pipeline flow- Updated
README.mdwith validator chain section
backend/api/main.py:- Enhanced
/api/chat/ragendpoint with validation chain - Added identity injection before model calls
- Added tone alignment after validation
- Added metrics recording
- Enhanced
Pipeline Flow:
User Request → RAG Retrieval → Identity Injection → Model Call →
Validator Chain → Tone Alignment → Metrics → Response
Validator Chain Order:
- CitationRequired
- EvidenceOverlap
- NumericUnitsBasic
- SchemaFormat (optional)
- EthicsAdapter
Rollback Strategy:
- Set
ENABLE_VALIDATORS=falseto disable all validators - All validators are wrapped in try-catch with fallback to raw response
- No breaking changes to existing API (backward compatible)
None. All changes are backward compatible and can be disabled via environment variables.
-
Enable validators (optional):
export ENABLE_VALIDATORS=true export ENABLE_TONE_ALIGN=true
-
Monitor metrics:
- Visit dashboard → "Validation" page
- Or call
GET /api/validators/metrics
-
Rollback if needed:
export ENABLE_VALIDATORS=false
- EthicsAdapter currently has no-op guard (TODO: wire existing ethics guard if available)
- Validation adds ~100-200ms latency (acceptable for quality improvement)
- Some validators may have false positives (can be tuned via thresholds)
- Wire existing ethics guard into EthicsAdapter
- Add RetrievalCoverage validator (check if entities exist in RAG docs)
- Async validation for better performance
- Caching validation results
- More sophisticated tone alignment rules
- Per-endpoint validator configuration