# Candidate Performance

Figma Candidate Matching cards / profile AI Screening panel.

Unified like Create Job — **one path**, query `action` selects the facet.

## Ownership

| Layer | Owns |
|-------|------|
| **Platform** | Candidate CRM, filters, invite / reject / contact, application timeline |
| **TJ AI Gateway** | Persisted AI evaluation snapshots + assessment attempts; read rollups |

GET endpoints **never** call LLMs. Scores are written by:

- `POST /interviews/sessions/{id}/final-evaluation` when `candidate_id` is set
- `POST /ai/evaluate` (`kind=assessment|mcq|…`) when `candidate_id` is set
- `POST /candidates/{id}/performance?action=ai|assessments` (Platform ingest)

## APIs

Auth: `X-Internal-Token`. Tenant: `X-Company-Id` (optional).

### Read — `GET /api/v1/candidates/{candidate_id}/performance`

| Query `action` | Response |
|----------------|----------|
| `overall` (default) | Combined 0–100 rollup + AI/assessment cards |
| `ai` | Dimensions, strengths, growth areas, recommendation |
| `assessments` | History, retakes, status |

### Write — `POST /api/v1/candidates/{candidate_id}/performance`

| Query `action` | Body schema |
|----------------|-------------|
| `ai` | `AiPerformanceIngestBody` |
| `assessments` | `AssessmentAttemptIngestBody` |

Legacy nested paths `/performance/ai` and `/performance/assessments` were removed.

### Removed earlier

| Old API | Replacement |
|---------|-------------|
| `POST /candidate-scoring` | Performance GETs + final-evaluation / hiring-fit / confidence / skill-gap |

## Scoring policy (0–100)

| Metric | Rule |
|--------|------|
| **AI Performance** | Latest stored snapshot; Technical / Confidence / Communication / Culture Fit |
| **Assessment** | `(total / max_total) * 100`; status `not_started` \| `in_progress` \| `passed` \| `failed` \| `expired` |
| **Overall** | mock **0.35** + recruiter **0.40** + assessment **0.25** (missing sources dropped; weights renormalized) |
| **Retakes** | Auto-increment `attempt_number`; rollups use **latest** per `assessment_id` |

## Tables

- `candidate_ai_evaluations`
- `candidate_assessment_attempts`
