# Deal Win Probability + Risk Signals

_AI Features_

Every open deal in your pipeline gets a persistent health score (0–100) and a list of risk + success signals refreshed daily. Pipeline cards show colored health dots, the deal editor surfaces the signal list, and "Deals at Risk" widgets surface the bottom of the funnel.

## Steps
1. No setup required — the daily worker (6am UTC) scores every open PipelineItem in every active pipeline.
2. On the Kanban board, each deal card shows a small green/amber/red dot in the corner. Hover for the top signal (e.g., "Stalled deal — no activity in 14 days").
3. Click a deal to open the editor and see the full Deal Health card: score, win probability %, risk signals (red/amber), success signals (green).
4. Use the "Deals at Risk" widget above the Kanban (or the /ai/deal-health/at-risk endpoint) to triage the worst-health deals across all pipelines at once.
5. Pipeline Forecast page now has an "AI Forecast" tab combining deal health + win probability into a monthly revenue prediction.
6. On stage change, the deal is re-scored within minutes (queued via the deal-autopsy worker). No manual rescoring needed for most cases.

## Tips
- Risk signals are rule-based, not AI — "stalled", "no meetings planned", "deal value shrinking" are deterministic checks. AI is only used for the win-probability narrative on the Forecast page.
- A deal flipping from "healthy" to "at_risk" sends a Socket.io event + in-app notification to the deal owner. Configure who gets notified under Settings > Account > Notifications.
- If a deal's healthScore disagrees with your gut, expand the signal list — every signal has a severity number so you can see what the engine weighted heaviest.

## Example
An AE notices the "Trellis Robotics — $48K" card has gone amber. He hovers: "Stage stagnation — 12 days in Demo Booked vs 4-day average". The Deal Health card lists three more risks (engagement dropping, no follow-up sent, close date pushed twice). He picks up the phone instead of waiting another week — closes the deal 9 days later.

## Troubleshooting
- **No health dot on a deal card** — The deal hasn't been scored yet (newly created deals wait for the next worker pass) or the deal is in a "closed won/lost" stage (terminal stages are skipped). Fix: Wait for the next 6am UTC scan, or open the deal — the editor triggers an on-demand score.
- **All my deals are "at_risk" or "critical"** — Brand-new orgs / pipelines with little activity history fail many of the success signals (engagement, momentum, multi-threading) by default. Severity is calibrated to mature pipelines. Fix: Run the pipeline for 2–3 weeks with normal activity logging before reading too much into the colors. Or disable the feature entirely under Settings > AI Usage > AI Features (key: deal_health) until you have history.
- **Win probability seems off** — Probability blends stage-based defaults (early=20%, mid=50%, late=75%, proposal=85%) with healthScore — a healthy proposal-stage deal can show 60-70%, not 85%, because health pulls it down. Fix: This is by design — Salesforce-style "stage-only" probabilities are usually too rosy. If you want stage-only, override on the deal manually; it persists.

## Plans
Included in every plan. Daily scoring is mostly rule-based (low AI cost); the AI Forecast tab calls the standard-tier model on demand. Toggleable per-org under Settings > AI Usage > AI Features (key: deal_health).
