# Kuan Yin — Monitoring & Observability

> Technical doc 32.16.1.14. Target stack in §32.17.2; signals from
> `@kuanyin/dharma-analytics` and `performance-sla.ts`.

Two classes of signal must be watched: **system health** (is the platform up and
fast?) and **community health** (is the platform doing its job — keeping people
safe and helping them grow?). Kuan Yin is unusual in treating the second as a
first-class, alertable metric.

## System metrics (Prometheus)

- Latency percentiles per path (intent, toxicity, live-stream protection) from
  `computeLatencyPercentiles`; alert on SLA breach (`slaAlert`).
- Throughput, error rate, circuit-breaker state, degradation level.
- Event-bus health (`evtImplementEventBusIntegration` → `healthScore`,
  `latencyP99Ms`, `deadLetterQueueSize`).
- Cache hit rate (`CacheRepository.getStats`), rate-limit throttle rate.
- Model inference latency and drift (PSI/KL/JS) from the evaluation harness.

## Community-health metrics

From `dharma-analytics/community-health-metrics.ts`: compassion index,
mindfulness score, connection depth, conflict-resolution rate, rehabilitation
success rate, community coherence, positive/harmful ratio, newcomer retention
correlation, creator satisfaction. Surfaced on dharma dashboards (materialized
views) and in `analytics.report` events.

## Tracing & logs

Distributed tracing (Jaeger) spans the gateway → engine → repository path so a
single moderation decision can be followed end-to-end. Logs are structured and
correlation-id stamped; **decision logs** record the rationale
(`InterventionRecord.contextSnapshot`, `AuditLog.description`) for transparency
and appeals.

## Alerting

| Condition                                            | Severity |
| ---------------------------------------------------- | -------- |
| Crisis detected, not routed to a human               | P1       |
| Shield failed to activate for a flagged target       | P1       |
| Intent/protection SLA breached sustained             | P2       |
| Community temperature crosses intervention threshold | P2       |
| Drift exceeds threshold on a live model              | P2       |
| Dead-letter queue growing                            | P3       |

Predictive wellness (`predictive-wellness.ts`) raises proactive
`community.alert` events for users- or communities-at-risk before an incident,
so on-call can intervene early rather than clean up after.

## Dashboards

The performer wellness dashboard, community temperature dashboard, and dharma
analytics dashboard are the operator-facing views; see the user docs for the
performer- and moderator-facing equivalents.
