Spaces:
Running
Running
Commit History
-
feat(phase11): Langfuse LLM tracing + Constitutional Policy Engine
Saibalaji NamburiLangfuse Observability (src/monitoring/langfuse_tracer.py): - TriageTrace: trace/span/generation hierarchy per triage request - Graceful no-op degradation when LANGFUSE_PUBLIC_KEY not set - LiteLLM callback registration (auto-traces all LLM calls) - Quality scores: constitutional_compliance, resolution_quality, rag_grounding - Wired into API lifespan startup and triage background task Constitutional Policy Engine (src/responsible_ai/constitutional_policy.py): - 7 constitutional rules: PII_PROTECTION, AI_IDENTITY, TOXICITY_GUARD, NO_COMMITMENTS, SCOPE_LIMITATION, LANGUAGE_CONSISTENCY, COMPETITOR_NEUTRAL - 3 severity levels: CRITICAL (block), VIOLATION (regenerate/redact), WARNING (warn) - Fast regex-based checks (<5ms) for all rules - PolicyVerdict with score (0-1), action, violations, warnings, safe_fallback - Critical violations auto-trigger HITL escalation - Runtime rule addition/removal support Tests: 38 new tests, all passingbf95443