NAMMU

← Blog
EngineeringLegal AI

How Nammu knows which law applies: automatic jurisdiction and process-type detection

Before any AI analysis runs, Nammu must answer two questions: which legal branch governs this case, and which procedural track is it on? Here is the three-tier waterfall that gets it right — and auditably explains why.

IP

Inventum P5

Engineering · Galictis-Legal

July 10, 2026

8 min read

Every downstream capability in Nammu — which legal schema applies, which Trayectorias timeline renders, which AI prompts fire, which deadlines get computed — depends on answering two questions correctly before anything else runs: which legal branch governs this case, and which procedural track is it on? Get these wrong and everything downstream is wrong. This is how Nammu gets them right, and how it proves it.

The two questions

Costa Rican legal expedientes are not labeled in a single obvious place. The signal is scattered: a case-number suffix, a court letterhead, the type of pleading that opened the case, a judge's resolution citing the governing procedural code. Nammu's classifier reads all of that the way an experienced legal assistant would — weighing multiple sources, trusting the more authoritative ones first, and being explicit whenever it is not sure.

The two questions it must answer are:

  • Jurisdiction (materia): civil, penal, laboral, familia, notarial, tránsito, contencioso-administrativo…
  • Process type (tipo de proceso): the specific procedural track within that jurisdiction — ordinario, monitorio, querella, divorcio, violencia doméstica, and so on.

Jurisdiction is resolved first — because process-type vocabulary is jurisdiction-specific. “Ordinario” means something different in civil, laboral, and penal. There is no shared vocabulary table.

The three-tier waterfall

Classification is structured as three tiers that fire in order of how early they can produce a trustworthy answer. Each tier is a fallback for the one before it.

T3↑

Manual override

Sticky — always wins on reprocessing

Lawyer's pick is permanent and re-read on every future rebuild

fallback ↓

T1

Carátula probe

First 3 pages of lead document

Fires seconds after upload — only commits when confidence is high

fallback ↓

T2

Case-level roll-up

All document_index.json sidecars

Ranked evidence across every document in the workspace

fallback ↓

T3↓

Manual needed

UI prompts the lawyer

Genuinely ambiguous — honest uncertainty, not a guess

The design answers a real constraint: a case's jurisdiction is usually visible on the very first page of the lead document, but the full multi-document pipeline may not be done yet. Waiting for everything to finish before showing a jurisdiction means the Trayectorias tab stays blank for minutes on a large expediente. Tier 1 is a cheap targeted shortcut — read only the carátula of the most likely document, seconds after upload, without waiting for the rest of the case.

Tier 1 only commits when confidence is high. A low-confidence carátula read is deliberately left for Tier 2 to corroborate — it is never used to make a shaky early guess that the rest of the system inherits.

Detecting jurisdiction: the expediente number always wins

Every Costa Rican judicial expediente number ends in a two-letter materia code that is immutable for the life of the case. This is a legal fact, not a heuristic.

SuffixJurisdiction
CICivil
PEPenal
LALaboral
FAFamilia
CAContencioso-administrativo
NONotarial
TRTránsito
AGAgrario
TCConstitucional

A regex scans for the pattern (e.g. 14-000031-0183-CI) anywhere in the sampled text. Any single document bearing the number settles jurisdiction for the whole case. It is not re-litigated by weaker signals.

When no suffix is found — common for individual party filings that never quote the full expediente number — the classifier falls back to scanning court letterhead names for known court phrases: “juzgado de trabajo” → laboral, “fiscalia” → penal, “violencia doméstica” → familia.

The “civil” problem

The word “civil” appears constantly in text that has nothing to do with a civil court: Registro Civil, Código Civil, Estado Civil, Sociedad Civil. A naive substring match produced a real false positive: a familia violencia-doméstica case with a TSE marriage-registry attachment got mis-tagged jurisdiction=civil purely because that attachment's letterhead contained “Registro Civil.”

The fix: The classifier requires “JUZGADO” to directly govern “CIVIL” — adjacent or separated only by a closed set of Costa Rican court-qualifier words (“de”, “menor”, “mayor”, “cuantía”, “primera”, “instancia”…). “JUZGADO CIVIL DE MENOR CUANTÍA” matches. “REGISTRO CIVIL” and “CÓDIGO CIVIL” do not. “Tribunal … Civil” is also explicitly excluded to avoid false positives from “Tribunal Supremo de Elecciones … Registro Civil” patterns.

Detecting process type: the 5-rank waterfall

Once jurisdiction is fixed, process type resolution uses a strict-priority waterfall. The classifier stops at the first rank that produces a hit. Higher ranks always beat lower ones regardless of how many lower-rank signals exist.

RankSignalExampleConfidence
1Outer manifest proceso_typeTier-1 carátula probe resultHigh
2Court act that fixes the trackresolucion_intimatoria → monitorioHigh
3Initiating party pleadingdemanda → ordinario; querella → querellaHigh / Medium
4Court-header echo (generic act)sentencia without specific trackMedium
5Filename hint…monitorio…pdfCorroborator only

At the case level, every document's recognized doc_kind labels are pooled into one set, and each rank's table is checked against that pool — so a court-act document anywhere in the case can pin the type even if it is not the document currently being processed.

Explicit tracks vs. residual defaults

Every jurisdiction follows the same shape: a short list of explicit track tokens that pin a specific process (checked first), and one residual default for everything else. This mirrors exactly how a lawyer reads a carátula: some case types announce themselves unmistakably, while most filings fall into a generic catch-all track that the law itself treats as the default when nothing more specific is claimed.

Critically, every residual default cites the specific legal article that defines it — not “we don't know, so we'll guess ordinario” but “this is ordinario because CPC Art. 101 says an unspecified knowledge-action is ordinario.”

JurisdictionExplicit tracksResidual defaultLegal basis
Civilejecución, monitorio, sucesorio, concursal…ordinarioCPC Art. 101
Penalabreviado, flagrancia, querellaprocedimiento_ordinarioCPP Ley 7594
Laboralfuero_especial_y_proceso_sumarisimoproceso_ordinario_laboralReforma Procesal Laboral Ley 9343
Familiaviolencia doméstica, pensión alimentaria, custodia, unión de hecho…divorcioCPF Art. 14 (Ley 9747)
Contenciosolesividad, medidas cautelares, responsabilidad, sumarioproceso_ordinario_contenciosoCPCA Ley 8508
Notarial(single track)proceso_disciplinario_notarialCódigo Notarial Art. 169
Tránsito(single track)proceso_transito_colisionLey 9078 Arts. 167–191

Guardrails: why this design was built the way it was

Each guardrail was added after a concrete misclassification. Removing any one would reintroduce the failure it was built to prevent.

Never keyword-scan loose body text for process type

Only labeled carátula fields (Descripción, Clase de Asunto) are read. A body mention of "ejecución de sentencia" inside an ordinario case's narrative, or a payment receipt mentioning "prenda", would otherwise misfire.

Never infer type from the expediente number suffix

The suffix encodes materia (jurisdiction), never tipo de proceso. A -CI suffix says "civil" — it never says "ordinario".

Homonym guard across jurisdictions

Each jurisdiction’s rank tables are jurisdiction-constrained. A laboral case can never silently inherit civil’s ordinario mapping from a generic sentencia echo. This was tightened four separate times after real near-misses.

Estado (phase) is never conflated with process type

"EN ETAPA DE EJECUCIÓN" describes where an ordinario case currently stands — not that it became an "ejecución" case. Phase is extracted and reported completely separately.

Conflicting signals default to honesty

When Clase de Asunto and Descripción disagree, the result is confidence=low + needs_fallback=True rather than picking one arbitrarily. The caller gets a chance to corroborate with more evidence.

Special cases the waterfall alone can't handle

Monitorio → ordinario transition

Under CPC Art. 116, when a monitorio case is opposed, it transitions to an ordinario. If Nammu detects a resolucion_intimatoria (the court act that opens a monitorio) alongside a subsequent contestacion or oposicion, the case is reclassified to ordinario with a prior_process_type=monitorio and transition_flag=True — not permanently labeled by its opening act.

Bisagra: jurisdictional transfer

A contencioso-administrativo case that a court declares itself incompetent for and transfers to civil (“declinatoria”, “remite a civil”) is promoted to process_type=ordinario even though contencioso has no loaded schema. This “jurisdictional hinge” ensures the Trayectorias tab can render a timeline instead of leaving the case permanently unclassified.

Governing procedural code: Ley 7130 vs. Ley 9342

Costa Rica's 2018 procedural reform is not retroactive — an old case can still be open today and legitimately governed by the legacy code. Nammu scans full document text for explicit citations of either code number. A document citing the old code (Ley 7130) by number wins, even alongside a same-page mention of 9342, because it is the case itself admitting what actually governs it.

Every classification is auditable

Every result written to case_index.json carries the full reasoning chain alongside the answer: confidence level, corroboration source, evidence string naming the exact document and field, and classification source (carátula / full-document / manual). A lawyer reviewing a case can always see not just what Nammu decided, but which specific document and field it decided from.

Why this matters: A wrong jurisdiction means a wrong timeline, wrong deadlines, wrong AI prompts. In a legal context, a wrong deadline can be a missed deadline. Nammu never presents a classification it cannot explain, and a lawyer's manual correction is always permanent — re-read and honored on every future reprocessing of the case.

The guiding principle

Across every layer: prefer a structured, authoritative signal over a guess. Corroborate when possible. Be explicit about uncertainty instead of hiding it. Every default is a cited legal article, not a shrug. Court-issued signals outrank party-authored ones. Disagreement between signals produces low confidence, not a coin-flip.

That is what lets Nammu classify a case in seconds rather than minutes — without asking a lawyer to trust a result it cannot explain.

Want to see this on your practice areas?

Request early access and we will run a live session on real expedientes from your jurisdiction.

Request a demo →