feat: IMAP mail sync with thread-to-contact matching (PRD §6.1)

Real IMAP connection via imapflow library:
- Connects to IMAP server (IMAPFlow, TLS on port 993)
- Fetches recent messages (configurable limit, default 20)
- Extracts: from, fromEmail, subject, date, snippet (200 chars)
- Thread-to-contact matching (PRD §6.1):
  1. Match sender email against persons table
  2. If no person match, extract domain and match against company.website
  3. Returns matchedCompany + matchedPerson for each email
- Audit-logged (action: crm.mailsync:imap)
- Zod validated (host, port, user, password, folder, limit)
- 502 on IMAP connection failure with detail
- 400 on validation failure

Tested: invalid creds → 502 'IMAP connection failed', missing host → 400
This commit is contained in:
Z User committed 2026-10-27 22:50:50 +00:00
1 parent 7acc0c5451
commit e45b68bb8b
1089 files changed
+260614

No files matched your search

@@ -0,0 +1,62 @@
# {Candidate_Name}_Targeted_Interview_Guide
> [!IMPORTANT]
> **Planning Context**: Based on war room simulation with {Expert_List}.
> **Objective**: Verify competency match (Step 1), gather evidence on resume concerns (Step 2), project future performance (Step 3).
---
## 1. Competency Scorecard
*Before looking at the resume, THIS is what success looks like.*
* **Mission (One-sentence mission)**: ...
* **Outcomes (12-month must-achieve results)**:
1. ...
2. ...
* **Core Competencies**:
* **{Competency 1}**: {Description}
* **{Competency 2}**: {Description}
---
## 2. Forensic Resume Scan
*Scan resume against Scorecard, looking for Gaps (concerns) and Evidence (matches).*
### 🔴 Red Flags (Concerns/Gaps)
* **{Concern 1}**: ...
* *Expert Challenge*: ...
* **{Concern 2}**: ...
### 🟢 Green Signals (Highlights/Matches)
* **{Highlight 1}**: ...
* *Evidence*: ...
---
## 3. Interview Battle Scripts
### Part A: Pressure Validation (Past Performance)
*Forensic STAR follow-ups designed for Red Flags.*
**Q1 (targeting {Concern 1})**:
* **The Setup**: "{Question...}"
* **The Drill**: "{Follow-up...}"
### Part B: Future Projection (Future Scenario)
*Performance simulations designed for Outcomes.*
**Q2 (targeting Outcome 1)**:
* **Scenario**: "{Set up a specific challenge highly relevant to future work...}"
* **Question**: "If this is the situation you face in your first week, how would you handle it?"
* **Bar Raiser**: "{What would an A Player do?}" vs "{What would a B Player do?}"
---
## 4. Decision Matrix
| Dimension | No Hire (Kill) | HIRE (Pass) |
| :--- | :--- | :--- |
| **Integrity** | ... | ... |
| **Competency Match** | ... | ... |