PRD-008: Case Workflow — Resposta do Arguido & Fase de Prova
Author: MLT backend team | Date: 2026-08-19 | Status: Draft | Version: v0.1.0
Revision History
| Version | Date | Author | Description of Change |
|---|---|---|---|
| v0.1.0 | 2026-08-19 | MLT backend team | Initial draft — phases 5 & 6 (joined), backfilled from the rebuild roadmap (interim PRD). |
1. Context & Business Rationale
Two legal phases, one epic. Resposta do Arguido (5/8, RESPONSE_WINDOW) and Fase de Prova
(6/8, EVIDENCE_PHASE) are distinct legal phases but sequential and small, so we build them as a
single slice: the worker's defence often carries the requerimento de prova the evidence phase then
produces, so the two flow into each other. Both remain distinct canonical CaseStatus values —
the merge is at epic/story level only.
Part of the Case Workflow theme (theme: case-workflow, label workflow: resposta & prova (5-6/8)).
Sourcing: the firm brief (_poc/firm-qa.md). PoC autopsy:
witness limits,
phase deadlines,
naive deadline math,
JSONB legal state.
2. Problem Statement
There is no server-side way to run the response window off charges_delivered_at, capture the
arguido's defence (with witnesses and procuração) under the statutory witness cap, run the
evidence-phase diligências, or consolidate a factual timeline with an evidence-integrity check.
3. Goals, Non-Goals, and Success Metrics
3.1 Goals
- Compute the response deadline per régime (10 working days CT / 15 public) via the holiday-aware calculator, and detect expiry.
- Record the defence (text, files, witnesses, procuração), enforcing the art. 357.º/4 witness cap
where
dismissal_intentapplies. - Run evidence-phase diligências (reusing the inquiry-action model), produce the auto de diligências, and consolidate the factual timeline with an evidence-integrity check.
3.2 Non-Goals
- The mandatory-opinions consult (7/8).
- The final report and decision (8/8).
3.3 Success Metrics
| Metric Type | Metric Definition | Baseline | Target |
|---|---|---|---|
| Primary | Defence captured + evidence phase run as typed, deadline-driven data | PoC: JSONB/none | 100% typed |
| Guard Rail | Response accepted after the window | PoC: uncontrolled | Rejected/flagged late |
| Guard Rail | Witness list beyond the statutory cap | PoC: partial | Rejected |
4. User Personas & Actors
4.1 Arguido / counsel (Primary, external)
- Role: submit the written defence, witnesses, and procuração within the window.
4.2 Instrutor (Primary)
- Role: run the evidence-phase diligências, produce the auto, consolidate the timeline.
5. User Stories
- As an arguido (or the case manager on their behalf), I want the response window computed from the charges-delivery date and my defence (text, files, witnesses, procuração) recorded — with my witness list capped per art. 357.º/4 when dismissal is intended — so the defence is lawful and time-bounded. → #64
- As an instrutor, I want to run the requested + additional diligências (reusing the inquiry-action model), produce the auto de diligências, and consolidate the factual timeline with an evidence-integrity check before advancing. → #65
6. System Requirements
6.1 Response window & defence
- SYS-REQ-101: The response deadline shall be computed from
charges_delivered_atper régime (10 working days CT / 15 public) using the holiday-aware calculator; expiry shall be detectable. - SYS-REQ-102: The defence (text, attachments, witnesses, counsel flag) shall be recordable via the portal (E08) or internally.
- SYS-REQ-103: When
dismissal_intentapplies, the arguido's witness list shall be capped at art. 357.º/4 (3 per fact); a list exceeding it shall be rejected. - SYS-REQ-104: A response after the window closes shall be rejected or flagged late per the guard.
6.2 Evidence phase
- SYS-REQ-201: Evidence-phase diligências shall reuse the same typed inquiry-action model; each shall produce an auto (deliverable) and notify arguido/counsel of hearing date/place.
- SYS-REQ-202: A consolidated factual timeline shall be produced from response + diligências.
- SYS-REQ-203: Evidence integrity (hash match, via the audit ledger) shall be checked before the phase advances.
7. Workflow
(from Consulta)
│
▼
RESPONSE_WINDOW ── deadline = charges_delivered_at + 10 wd (CT) / 15 (public)
│ record defence { text, attachments, witnesses (≤3/fact if dismissal), procuração }
│ late/after-window → rejected or flagged
▼
EVIDENCE_PHASE ── run diligências (typed inquiry-action model) → auto de diligências
│ consolidate timeline; verify evidence integrity (hashes)
▼
BODIES_OPINION (7/8, conditional) or FINAL_REPORT (8/8)
8. Open Questions
- Whether a 10-total witness cap applies in addition to the 3-per-fact cap (art. 357.º/4) — open in the source; confirm with counsel.
9. Edge Cases & Exception Handling
- No response filed before expiry — the phase can still advance (expiry detectable).
- Witness list over the cap — rejected (422).
- Evidence hash mismatch — advance blocked until resolved.
10. Given-When-Then Acceptance Criteria
Open the response window & record the defence (#64)
- The response deadline is computed per régime (CT vs public) using the holiday-aware calculator; expiry is detectable so the phase can advance whether or not a response arrived.
- A response is recorded with its defence text, witnesses, and counsel flag.
- When dismissal_intent applies, the arguido's witness list is capped at art. 357.º/4 (3 per fact); a list exceeding it is rejected.
- A response after the window closes is rejected (or flagged late per the guard).
Run evidence-phase diligências & consolidate the timeline (#65)
- Evidence-phase diligências are recorded via the same typed model as the inquiry; each produces an auto (deliverable), and arguido/counsel are notified of hearing date/place.
- A consolidated timeline is produced from response + evidence.
- Evidence integrity is checked (hash match) before the phase advances.
11. Technical Constraints & Dependencies
- Blocked by: "Notify the arguido + proof of receipt" (3/8, anchors
charges_delivered_at) and "Conduct & conclude the inquiry" (2/8, #49 — the shared inquiry-action model). - Reuses the holiday-aware deadline calculator (Abertura) and the audit ledger (#44) for integrity.