63 lines
2.5 KiB
Markdown
63 lines
2.5 KiB
Markdown
# SLA implementation tracking
|
||
|
||
This folder tracks **SRS §9.4 SLA Configuration & Escalation Management** against the codebase.
|
||
|
||
| Document | Purpose |
|
||
|----------|---------|
|
||
| [IMPLEMENTATION_STATUS.md](./IMPLEMENTATION_STATUS.md) | What is built vs SRS (by capability) |
|
||
| [ONBOARDING_SLA_RULES.md](./ONBOARDING_SLA_RULES.md) | Applicant steps vs internal SLA (Submitted, Questionnaire, etc.) |
|
||
| [STAGE_CONFIGURATION_MATRIX.md](./STAGE_CONFIGURATION_MATRIX.md) | Every approval stage vs SLA config row |
|
||
| [PENDING_WORK.md](./PENDING_WORK.md) | Ordered backlog to reach full compliance |
|
||
|
||
## Source of truth (code)
|
||
|
||
| Area | Location |
|
||
|------|----------|
|
||
| Activity catalog (all modules) | `backend/src/common/config/slaStageCatalog.ts` |
|
||
| Seed script | `backend/scripts/seed-sla-configs.ts` |
|
||
| Admin “Initialize defaults” API | `POST /api/master/sla-configs/initialize` |
|
||
| Runtime engine | `backend/src/services/SLAService.ts` |
|
||
| BullMQ worker | `backend/src/common/queues/sla.worker.ts` (`ENABLE_REDIS=true`) |
|
||
| Stage sync on transition | `backend/src/common/utils/slaWorkflowSync.ts` |
|
||
|
||
## Apply / refresh configuration
|
||
|
||
```bash
|
||
cd backend
|
||
npx tsx scripts/seed-sla-configs.ts
|
||
```
|
||
|
||
Or use **Master → SLA Configuration → Initialize defaults** in the UI.
|
||
|
||
## Environment
|
||
|
||
| Variable | Effect |
|
||
|----------|--------|
|
||
| `ENABLE_REDIS=true` | Runs SLA breach checker on schedule |
|
||
| `DEBUG_SLA_FAST_MODE=true` | 1 hour TAT ≈ 1 minute (dev only) |
|
||
|
||
## DB note
|
||
|
||
If `sla_tracking.metadata` (or `entityType` / `entityId`) is missing on an older database, run:
|
||
|
||
```bash
|
||
npx tsx scripts/migrate-sla-tracking-schema.ts
|
||
```
|
||
|
||
### SLA notification dispatch log (idempotency + audit)
|
||
|
||
Table `sla_notification_dispatches` records **one row per threshold per active track** (pre-breach reminder, breach, escalation L1–L3, repeat overdue window). Unique on `(trackingId, thresholdKey)` prevents duplicate emails even if the worker runs every minute.
|
||
|
||
```bash
|
||
npx tsx scripts/migrate-sla-notification-dispatches.ts
|
||
```
|
||
|
||
| `dispatchType` | `thresholdKey` example | Sends |
|
||
|----------------|------------------------|--------|
|
||
| `pre_breach_reminder` | `reminder:<uuid>` | Once per T−1d / T−4h config |
|
||
| `breach` | `breach` | Once when TAT exceeded |
|
||
| `escalation` | `escalation:L1` | Once per level |
|
||
| `repeat_overdue` | `repeat_overdue:<bucket>` | Daily (or fast-mode window) |
|
||
|
||
`sla_tracking.metadata` is still used for **pause/resume** timers only; legacy `reminder_sent_*` flags are honored until migrated.
|