# Data Model — Unified Badge System (Single Source of Truth) v1

This feature is UI-only. It introduces no database schema changes.

## Entities (existing)

### Tenant
- **Role**: scope boundary for all queries and UI rendering.
- **Status-like fields used**:
  - `status` (for example, `active`, `archived`)
  - `is_current` (boolean)

### OperationRun
- **Role**: canonical operations/run observability.
- **Status-like fields used**:
  - `status` (`queued|running|completed`)
  - `outcome` (for example, `pending|succeeded|partial|failed|cancelled|...`)

### InventorySyncRun
- **Role**: inventory synchronization history and last-sync indicators.
- **Status-like fields used**:
  - `status` (`pending|running|success|partial|failed|skipped`)

### BackupScheduleRun
- **Role**: scheduled backup history and status indicators.
- **Status-like fields used**:
  - `status` (`running|success|partial|failed|canceled|skipped`)

### EntraGroupSyncRun
- **Role**: Entra group cache synchronization history.
- **Status-like fields used**:
  - `status` (`pending|running|succeeded|partial|failed`)
  - `safety_stop_triggered` (boolean)

### RestoreRun
- **Role**: restore orchestration progress and outcomes.
- **Status-like fields used**:
  - `status` (enum-like string; see `RestoreRunStatus`)

### Finding
- **Role**: drift/risk indicators and triage workflow.
- **Status-like fields used**:
  - `status` (`new|acknowledged`)
  - `severity` (`low|medium|high`)

## Entities (code-only)

### Badge Domain
- **Role**: a named namespace for status-like values that must render consistently (for example, “inventory sync run status”, “drift finding severity”).
- **Uniqueness**: domain name is unique within the application.

### Badge Definition
- **Role**: the central mapping for a domain’s values → badge meaning.
- **Behavior**:
  - Must be pure (no DB queries, no HTTP, no side effects).
  - Must provide a safe default for unknown values.

## State transitions (existing)

### RestoreRunStatus (selected)
The restore run lifecycle is defined in code and must not be changed by this feature:
- Pre-flight states: draft → scoped → checked → previewed
- Execution: pending/queued → running → completed/partial/failed/cancelled

This feature standardizes how these values render; it does not change transitions.

