Our citations had never named a clause
What we found when we measured the corpus instead of reading the changelog — and why a document’s structure is citation data, not parser trivia.
In August we upgraded the document parser that sits at the bottom of Trovato's ingestion pipeline. Before reading the release notes, we did something that turned out to be more useful: we counted what our existing citations actually contained.
Across the development corpus there were 3,514 citation anchors. Twenty-one had a section. None had a multi-level section trail. None had a clause number. And the twenty-one "sections" were all the same word — Table — a label the parser assigns to every table.
Every Trovato citation is supposed to resolve to a page, a section and, where there is one, a clause. In practice, across 195 documents, the label had only ever rendered its page.
Two quiet failures
There were two causes, and neither raised an error.
Most of the documents were Word files. For those, the code that walks the headings ran, built a correct trail — Article 7 › Rent Review — and then dropped it before it reached the citation. For PDFs, every heading arrived at the same level, so a trail with more than one level was structurally impossible.
Both were fixed in the same release, and we wrote the principle down so it would stay fixed: a document's structure is citation data. A citation that names the wrong section is not a cosmetic issue; it sends a lawyer to the wrong place. After the fix:
| Before | After | |
|---|---|---|
| Word passages with a section | 0% | 96.4% |
| Word passages with a multi-level trail | 0% | 73.0% |
| Word passages with a clause number | 0% | 36.2% |
| PDF passages with a multi-level trail | 0% | 88.5% |
A citation now reads the way a lawyer would write it — Share purchase agreement.pdf · p. 41 · 14.3, Warranties › Tax — and View in document opens the page with the passage highlighted.
[Screenshot to add: citation-section-trail.png]
Twenty public matters, 227 documents
The structure fix made us suspicious of everything else the parser was quietly doing, so we built an open test corpus: twenty matters' worth of public filings, 227 documents, chosen to be awkward — scanned exhibits, pricing schedules, rotated pages, regulator forms.
It was humbling. Optical character recognition had overwritten a pricing grid with a two-by-two grid of vertical bars, even though the PDF's own text layer held all forty-nine prices. Upright pages were read upside down. The comb-box dates on a Companies House form came out as a run of brackets and pipes. A reference to "ECF No. 37" in a court filing opened a new clause 37. One definitions passage ran to 1,849 words.
The rule we adopted is simple to state: the text layer is the source of every character it holds. OCR, orientation detection and layout analysis may only add what the text layer does not have; a step that drops text is not allowed. Page orientation is now decided by reading the page both ways and keeping the more confident reading.
| On the open corpus | Before | After |
|---|---|---|
| Passages whose page is not where their text starts | 47 of 533 | 3 of 526 |
| Garbled tables | 2 | 0 |
| Heading-only passages | 9 | 0 |
| Passages over the size limit | 2 | 0 |
One amendment taught us the most. An over-eager clean-up step swallowed an underlined heading and misread a figure as 148,048,993 instead of 148,045,993. We reined it in so it can no longer touch a character the text layer holds. A wrong digit is worse than a missing comma.
Context that helps find a passage but is never quoted
Some passages are hard to find because they do not say what they are. A plea agreement's signature page names defence counsel but never uses the word "plea". A governing-law clause reads like every other governing-law clause. In our tests, about one answerable question in ten had its correct passage outside every search's top hundred.
Each passage is now indexed with a short line of context — the document's title and type, and where the passage sits in it. That context is used to find the passage. It is never shown, never quoted and never cited: citations and quote checks use the passage's own text alone. We also tried a richer variant, measured it through the whole search pipeline, found it was worse, and reverted it.
[Screenshot to add: diagram-structure-to-citation.png]
Gaps with names
The same discipline reached Tabular Review. Previously a review with a handful of unreadable cells reported itself as failed — eight of twenty reviews in one test round read "failed" while 95–98% of their cells were extracted. A review now finishes as Completed with errors, names the cells that need attention, and offers Retry N errored cells. A cell whose source cannot be read says Source unreadable: a finished answer, not an error. Date and party columns now also read the cover page and the signature pages, where those facts actually live.
Parties and concepts
Two smaller additions build on the same structure. Each document is now tagged with its type and areas of law from FOLIO, the open legal-concept vocabulary, so a share purchase agreement is labelled as one. The tags help people filter; they are never evidence and never reach a model's prompt.
And a matter's Parties page reads the parties, defined terms and their roles from the documents, including court roles such as Claimant and Respondent. We spent the past few weeks on its accuracy. Early on, "Natera, Inc. ("Tenant")" filed the tenant under a party called "Inc" — and so did several unrelated companies. Mentions filed under a bare legal form went from 4,011 to zero. Rules propose that two names are the same party; only a person merges them.
The lesson
None of these failures announced itself. Each produced output that looked like success: a citation with a page number, a table with cells, a review with a status. The only way we found them was to measure the corpus, document by document, before trusting the code that built it. We now do that for every change to the pipeline.
