# 02 - Milestone 2.2 Revision & Verification

## Key Takeaways

1. **Database Schema:** `conversations` (thread metadata & status) and `messages` (chat messages with role `"user"`, `"agent"`, or `"assistant"`).
2. **State-Based Message Routing:** `POST /api/v1/message` inspects session status:
   - `RINGING`: Returns `"Please wait while we connect you to an agent."` without generating Echo replies.
   - `IN_CHAT`: Returns `"Message delivered to agent."`.
   - `ENDED`: Rejects with `HTTP 400 Bad Request`.
3. **Agent Reply Transport:** `POST /api/v1/handoff/message` saves agent messages (`role: "agent"`) and pushes real-time WebSocket events.

---

## Verification & Test Results

Run backend test suite:
```bash
cd backend
.\venv\Scripts\python.exe -m pytest
```

Result:
```text
======================= 22 passed, 4 warnings in 0.42s ========================
```
