Skip to main content

What to preserve

The PoC got a lot right at the domain level. These are the things the rebuild should carry forward deliberately — the accumulated domain knowledge, not the implementation.

The domain model & workflow shape

  • The 8-macrophase state machine (workflow-config.ts) — it is expressive and correct as a representation. Keep the phases, labels, and the transition graph.
  • The conditional branching on has_preliminary_inquiry and the dismissal/union flags (branching) — the rules are right even if the encoding (free booleans) should change.
  • The legally-anchored deadline catalogue (PHASE_DEADLINES) — the set of deadlines and their anchor dates, once statute-verified.
  • The caducidade guard and the CT/Sindicato consultation requirement (caducidade, bodies-opinion).
  • The witness limits (art. 357.º/4 CT) — the one cited rule (witness limits).
  • The outcomes/sanctions vocabulary and the instructor proposal decision point (outcomes).

Legally-motivated data

  • evidence_items.sha256_hash — evidence chain-of-custody.
  • Append-only history tables (workflow_transitions, audit, suppressed_emails).
  • The dossier manifest concept (hashes + snapshot metadata) — the idea is good even though the current output is an unsanitised ZIP.
  • The portal visibility-window model (portal_items.visible_from/until) and the portal access log.

Content & copy

  • The Portuguese legal document templates (relatório, nota de culpa, ata) — the prose is a real starting point; give them provenance and versioning.
  • The phase checklists (DEFAULT_CHECKLISTS) — a decent first draft of what each phase requires.

Email semantics

  • The queue's priority / retry / DLQ / TTL / idempotency / rate-limit behaviour (email queue) — reimplement the semantics on the new stack even though the Lovable coupling goes.