# AI Lead Intelligence — Overview

**Document Version:** 1.0.0 (Phase 12)  
**Status:** Implemented, Tested & Verified (377 Automated Test Assertions)

---

## 1. Core Mission

LeadPilot's AI Lead Qualification is **decision support, not autonomous sales automation**.

Its job is to answer:

> **Which enquiries deserve attention first, and what should the sales rep do next?**

```
Lead Ingestion (Any Channel)
            │
            ▼
Extract Structured Data
            │
            ▼
LeadQualificationService (Provider Abstraction)
            │
  ┌─────────┴─────────┐
  ▼                   ▼
OpenAI / Provider   Fallback Rules
  └─────────┬─────────┘
            ▼
Schema Validation & Score Clamping (0–100)
            │
            ▼
Centralized Temperature & Urgency Mapping
            │
  ┌─────────┼─────────┐
  ▼         ▼         ▼
Lead      AiScore   AiUsageLog
Record    History   (Tokens/Cost)
            │
            ▼
Lead Inbox / Lead Detail / Attention Center
```

---

## 2. Key Principles

1. **Advisory Decision Support:** AI scores and recommendations guide human sales reps. AI never unilaterally moves leads through pipeline stages or modifies contract terms.
2. **Deterministic Thresholds:** Temperature mapping and attention center logic are governed by centralized deterministic code, not probabilistic LLM outputs.
3. **Graceful Fallback:** An AI provider failure, timeout, or rate limit never halts lead creation or follow-up sequences. Inbound leads remain completely usable.
4. **Untrusted Data Isolation:** All user-submitted lead inquiry text is sandboxed inside delimited tags (`<untrusted_lead_content>`) to prevent prompt injection.
5. **Traceable Scoring History:** Every analysis and re-analysis is logged in `ai_scores` for auditability and version tracking.
