# Health Engine — Hardcoded Values Audit

Audit date: 2026-06-05  
Search terms: `74`, `healthScore`, `health_score`, `attention`, `needs_attention`, `at_risk`

---

## Summary

**No literal hardcoded score of `74` exists in application code.** The previous "74 / Needs Attention" behavior on empty projects was a **computed artifact** of the old equal-weight model where `completionPercentage() === 0` pulled the average to 74.

---

## Removed / fixed behaviors

| Issue | Location | Resolution |
|-------|----------|------------|
| Empty project scored ~74 | Old `ProjectHealthService` | Replaced with `initializing` state (`score: null`) |
| False health alerts on create | `ProjectHealthSnapshotService`, `NotifyOnHealthUpdated` | Skip snapshots/events when `level === initializing` |
| Monitor fired alerts without factors | `AgileNotificationMonitorService` | Uses `shouldAlert()` gate |

---

## Intentional constants (scoring model)

These are **thresholds and neutral defaults**, not placeholder production scores.

### `ProjectHealthService`

| Value | Purpose |
|-------|---------|
| 75 / 60 | Healthy / attention level thresholds |
| 60 | Alert threshold (`shouldAlert`) |
| 25/15/20/15/15/10% | Component weights |
| 75, 65, 70, 40 | Neutral sprint/velocity defaults when data sparse |
| 25, 12, 5 | Risk score deductions (critical / high / low) |
| 20 per blocker | Dependency penalty |
| 25 per overdue milestone | Milestone penalty |

### `SprintHealthEngineService`

| Value | Purpose |
|-------|---------|
| 80 / 60 / 40 | good / warning / at_risk / critical thresholds |
| 8 / 6 / 20 / 10 | Blocked / overdue / sprint-overdue / velocity penalties |

### `ExecutiveDashboardService`

Maps UI labels `at_risk` ↔ backend `attention` for sprint attention items only.

---

## Frontend / test mocks (non-production)

| File | Value | Notes |
|------|-------|-------|
| `resources/js/src/__tests__/e2e/helpers/project-mocks.ts` | `health_level: 'healthy'`, mock `at_risk` | E2E fixtures only |
| `ProjectCard.test.tsx`, `ProjectsPage.test.tsx` | `health_level: 'healthy'` | Unit test fixtures |

---

## Notification templates

Templates use `{{health_score}}` placeholders — not hardcoded values. Rendering validated in `NotificationTemplate::render()`; unresolved placeholders throw `UnresolvedTemplatePlaceholderException`.

---

## Demo / seed data

`EnterpriseAgileDemoSeeder` creates projects whose health scores are **computed by the real engine** from seeded sprints, risks, dependencies, and milestones — not injected scores.

---

## Items checked — no issues found

- No `score = 74` assignment in PHP/TS application code
- No fallback `health_score: 74` in API resources
- `ProjectResource` calls live `ProjectHealthService::calculate()` for `health_level`

---

## Recommendation

When adding new health consumers, always handle:

```typescript
score: number | null
level: 'initializing' | 'healthy' | 'attention' | 'critical'
```

Never substitute a numeric default when `score === null`.
