Best Practices
Production Best Practices
Reliable, low-risk production rollout
Event Contract Stability
Keep event contracts stable:
- Don't change
eventtype names - Maintain field semantics
- Add new fields rather than changing existing
- Version changes in
mapping_version
Masking and Redaction
Always redact PII:
// Phone: 9876543210 → 98****3210
// PAN: ABCDE1234F → ABCDE****F
// Aadhaar: 1234-5678-9012 → ****-****-9012
AI.reportComponentInput(
componentId = "phone_field",
hint = maskPhone(phone), // Redacted
masked = true // Always true for PII
)Never send raw values in hints.
Feature Flag Control
Use feature flags for rollout:
# backend/config/kycis.yaml
feature_flags:
trigger.v2_scoring: false # Start disabled
trigger.policy_engine: false
trigger.intervention_modes: falsePhase rollout:
- Phase 1: Voice session only (triggers off)
- Phase 2: Enable
trigger.v2_scoring - Phase 3: Enable
trigger.policy_engine - Phase 4: Enable
trigger.intervention_modes
Configuration Management
Non-secret config in YAML:
- Feature flags
- Thresholds
- Timeouts
Secrets in env:
- API keys
- LiveKit credentials
- Database passwords
E2E Validation
Before each rollout:
- Verify events in
/api/activity - Test trigger decisions
- Validate voice session flow
- Check reengagement activity
Rollback Plan
Keep previous config version:
# Backup before changes
cp backend/config/kycis.yaml backend/config/kycis.yaml.backup
# Quick rollback
mv backend/config/kycis.yaml.backup backend/config/kycis.yaml
# Restart backendMonitoring
Track key metrics:
- Event ingestion rate
- Trigger evaluation rate
- Voice session success rate
- Error rates by type
Use /api/activity and backend logs.
Security Checklist
- API keys not in source code
- Secrets in environment/Keychain
- SSL certificates valid
- ProGuard/R8 obfuscation enabled
- Backend auth enforced on
/v1/*
Performance
- Keep payloads lean
- Debounce component input (300-500ms)
- Use lazy schema push
- Enable config refresh (don't poll excessively)
Documentation
Maintain:
- Screen ID mapping (app ↔ backend)
- Event emission points in code
- Known issues and workarounds
- Contact for escalation