caelum0x a3377e9fde feat(console): per-app event-volume anomaly classification on Usage page
Adds lib/eventAnomaly.ts: classifies each app's current-period event volume
against its own trailing 30-day baseline (normal_variance / traffic_spike /
traffic_drop, with a severity score) via Evren's /v1/systemone gateway
(model "laya"), same wire contract and module shape as bidstage-tenders'
evren-fit.ts, sahibinden's evren-risk.ts and homeplan's architectFit.ts.

The current/baseline features (current_events, baseline_mean_daily, ratio,
day_of_week, app_age_days) are plain arithmetic over two real
insightsClient.summary() calls, never trusted to the model.
groundEventAnomalyReason/finalizeEventAnomalyReason clamp the model's
claimed reasonCode against that real ratio in both directions (unsupported
spike/drop claim downgraded; a normal_variance call contradicted by a
clearly extreme real ratio upgraded) -- live-verified against the real
gateway (2026-11-05) that this correction is not just defensive: on 6 real
test vectors spanning normal/spike/drop/no-baseline/borderline cases, the
model's own `reason` choice answered `severe_drop` in 5 of 6 regardless of
the real evidence (gateway-reported confidence ~0.04, near-uniform
probabilities every time) -- the ground+finalize pipeline is what makes the
final per-app classification correct in every case, not the raw model call.

Wires into apps/console/lib/config.ts (EVREN_LLM_API_KEY, optional,
fail-open, added to SECRET_ENV) and lib/deps.ts, and surfaces the worst
real per-app anomaly as a badge on the Usage page next to "Events this
month", reusing the existing capMessage/insightsView wiring point.
Additive only: a gateway outage, bad response, or missing key never
changes the existing event count or cap note. Not deployed.
2026-11-05 00:20:01 +03:00
..