Skip to main content

Witness limits (art. 357.º/4 CT)

InquiryActionsList.tsx enforces a witness cap that cites a statute — the only explicitly-cited rule in the codebase:

"Limite legal de testemunhas (art. 357.º/4 CT)" — Total: {n}/10 · Máx. 3 por facto.

Logic:

const witnessLimitBlocked =
dismissalIntent &&
selectedType === "WITNESS_HEARING" &&
(witnessTotal >= 10 || maxFactReached); // maxFactReached = any fact with ≥ 3 witnesses
  • The cap applies only when dismissal_intent is true (art. 357.º/4 CT governs the contradictory phase where dismissal is intended).
  • 10 total witnesses, 3 per fact. Facts are grouped by (step_data as any)?.fact_id || "_unassigned".

The tacit dangers

  • The limits (10, 3) are hardcoded in a UI component, with no test — a refactor could change them unnoticed.
  • Grouping keys off step_data.fact_id read via as any — witnesses with no fact_id all collapse into one "_unassigned" bucket, which could mis-count the per-fact cap (legal state in JSONB).
  • Enforcement is client-side only — the block is a disabled button, not a server rule.
  • There is no concept here of the arguido's own witness rights vs the instructor's — verify who the cap applies to under 357.º/4.

Rebuild implication

Model facts and witnesses relationally (so "3 per fact" is a real constraint), enforce server-side, keep the statute citation, and test the boundary (10th vs 11th witness, 3rd vs 4th per fact, and the dismissal_intent gate).