PHASE_DEADLINES — the legally-anchored deadline catalogue
src/lib/workflow-config.ts declares deadline rules per phase. Each rule is type,
label, days, kind (CALENDAR_DAYS | WORKING_DAYS), base (NOW | CASE_FIELD),
baseField, and source (legal | internal). computeDueAt (date-utils.ts) turns a
rule + case record into a due date; a missing base field skips the deadline silently
(logged to console only).
| Phase | Rule | Days | Kind | Anchored to | Source |
|---|---|---|---|---|---|
| PRELIMINARY_INQUIRY | Start Inquérito Prévio | 30 | calendar | suspicion_date | legal |
| PRELIMINARY_INQUIRY | Notify Nota de Culpa after IP | 30 | calendar | ip_concluded_at | legal |
| RESPONSE_WINDOW | Employee response window | 10 | working | charges_delivered_at | legal |
| FINAL_REPORT | Internal decision deadline | 30 | calendar | last_evidence_act_at | legal |
| BODIES_OPINION | Internal opinion deadline (configurable) | 10 | calendar | NOW | internal |
The base-date columns (suspicion_date, ip_concluded_at, charges_delivered_at,
last_evidence_act_at, plus knowledge_date, ip_first_diligence_at) exist on cases.
What to verify
Every source: "legal" figure is asserted in code without a statute citation. Confirm each
against the Código do Trabalho — especially the 10 working days for the employee's
response and the day-kind of each 30-day window (the code mixes calendar and working days
deliberately, so the distinction is load-bearing). Note the separate, undocumented 60-day
prescrição from knowledge of the infraction — is it modelled anywhere? (knowledge_date
exists but no deadline rule uses it.)
Gotchas
- Deadlines are computed and stored client-side during a transition; a missing base
field skips the deadline with only a
console.warn. computeDueAt's working-day math ignores Portuguese holidays (naive deadline math).- The
BODIES_OPINION5-working-day CT/Sindicato wait is enforced by a separate, hand-rolled calc insideuseWorkflow— a second source of truth (bodies opinion).
Rebuild implication
Model deadlines as first-class, server-computed, statute-cited rules with an explicit day-kind and a holiday-aware calculator. One calculator, not three.