Chris GarreApplied AI · Engineering
Production AI systems · GTM intelligence · workflow automation
20 May 2026 · BOG
§ 04 · 2026
Panamanian legal corpus · OCR and attribution

Citation accuracy over a scanned archive.

I am building a search and monitoring product over Panama's Gaceta Oficial, the government's journal of record. Decades of issues, most of them scanned rather than born digital. The hard problem was never search. It was deciding which law a passage belongs to, and then the harder problem underneath it: knowing whether that decision was right.

Client
Own product
Role
Solo design + build
Domain
Panamanian law
Surface
Search and monitoring
Status
Pre-launch
Scope
Ingestion · attribution · measurement
§ Readouts
Number-only locate36.00% wrongtype-aware: 0.69%
True misattribution6.40%instrument said 0.34%
False contamination97.7%was lawful citation
Calibration300/300planted found0/295 false positives
§ 05

The problem

The number is the one thing you cannot read

Every norm in this corpus is identified by a number. Resolución 525. Decreto 174. That number is how citizens cite it, how lawyers argue about it, and how any sane database keys it.

It is also the part of the page that scanning reliably destroys. Digits carry no linguistic context to fall back on, so the same scan that renders legal Spanish almost perfectly turns the heading number into noise. Three real headings from this corpus: RESOLUCIÓN NÚMERO JETA is Resolución 525, RESOLUCIÓN NÚMERO GP? is 526, and RESOLUCIÓN NÚMERO 1/4 is 174. Meanwhile the prose alongside them reads cleanly: EXPEDIR CARTA DE NATURALEZA a favor de YENEANSKI IVÁN CABRERA.

Supplying the number from outside does not rescue this. Knowing from the publisher that Resolución 525 sits in the issue does not help you find NÚMERO JETA, because there is nothing legible in the target to match it against.

This is era-dependent, and worth being precise about. For the years where the entire issue is born-digital text, locating a norm by type and number on a line-anchored heading works well: 0.62% inclusion error, 0.62% exclusion error, and zero misattributions across 53 edge cases. The failure is specific to scanned bodies, which is most of the archive.

Which leaves the problem that shaped everything else. A wrong crop is indistinguishable from a right one downstream. Nothing further along the pipeline can tell you which one you produced, so accuracy has to be established at the point of attribution or not at all.

§ 06

What I built

Measure first, then choose
01Alignment

Ordered and monotonic

The contents page is an ordered list and the bodies appear in that order, so each norm is searched for only after the previous one has been placed. A number appearing inside an earlier body cannot drag a boundary backwards.

02Matching

Type-aware headings

Locating a body by number alone misattributed 36.00%, because in a municipal issue the digit 9 is a date, an article, a lot number and a sum long before it is Acuerdo 9. Requiring the declared type word at the start of the line took that to 0.69%.

03Policy

Abstention as an outcome

If the next declared norm cannot be located, this body's end is unknown, so it is not emitted. A body containing a foreign heading is refused outright. Ambiguity costs a document rather than producing a citation.

04Selection

Unique, rare, positional

Title tokens are restricted to those appearing in exactly one title in the issue, filtered again for rarity in the body text, then tested by position. Distinctive-looking words fail all three tests routinely.

05Calibration

Planted positives before belief

Known misattributions are planted and the instrument has to find them. Current standing is 300 of 300 detected against 0 of 295 false positives. An instrument that cannot report the defect will report none.

06Documentation

The field guide

Every finding, every trap and its measured cost lives in one document that anyone reads before touching ingestion.

§ 07

Engineer's notes

Mostly about instruments that lied
§ 08

Outcome and next.

The instrument was the deliverable

The instrument was the deliverable.

The engineering result I would defend anywhere is type-awareness: 36.00% misattribution down to 0.69%, by requiring the declared type word at the head of a line instead of hunting for a number that means five other things in a municipal document.

The methodological result matters more, and it is less flattering. My own instrument reported 0.34% misattribution on the scanned path. The honest figure, once I measured exclusion instead of only inclusion, was 6.40%. Nothing in the output looked wrong either time. Finding that gap was the work, and it is why calibration against planted positives is now a precondition here rather than a nicety.

I am not claiming the corpus is solved. The pre-2006 era is out of reach today. The titles-not-numbers locator for the largest era of the archive is specified and not yet built. There are documents the pipeline declines to attribute rather than guess at, and those abstentions are the design rather than a coverage gap.

Next: build the titles-not-numbers locator for the scanned-body era, which is the largest part of the archive and currently unserved. Then a public accuracy page, because a legal search product that will not state its own misattribution rate is asking for trust it has not earned.

Have a system like this to ship?

For focused AI systems architecture or production workflow work, write directly. I take on limited, non-conflicting fractional builds.

hello@chrisgarre.com

Directhello@chrisgarre.com
Cadence2 business days
EngagementsFractional · 6-12 wk
CapacitySelective · 1-2 d/wk
Set in IBM Plex Sans Condensed · IBM Plex Mono[ CG · 001 ] · © 2026 Chris Garre · Build 2026.07.27