Part of the PolicyTrace series
Documents System note
Two documents, one policy, four disagreements
My first run reported four conflicts between two policy documents. Two were double spaces, and two led to a real merge bug that a quiet merge would have hidden.
• The first full PolicyTrace run on a four-PDF demo pack reported four disagreements between the Schedule and the Certificate.
• Two were double spaces left by PDF text extraction. The other two led to a real merge bug that gave the policy two main drivers, and later turned out not to be disagreements at all.
• The merge rule is plain code, so the bug was visible and could be tested. All of it is fixed, and the same pack now gives no conflicts.
On 17 October I re-ran the PolicyTrace demo after moving it to new models (that swap has its own post). PolicyTrace reads a car insurance policy pack and returns one record, with every value traced to its line in the PDF. The run produced 59 fields, 49 of them traced to a line, and four conflicts: fields where two documents in the pack gave different values.
The conflicts are the interesting part, so this post is about them.
Why two documents can disagree
A UK motor policy usually arrives as a pack of four PDFs. The Schedule is the commercial summary: the car, the drivers, the excesses and the premium. The Certificate of Motor Insurance is the legal document you would show the police. Then there's a Statement of Fact and the policy booklet. They overlap, but each is written for a different job, which is why I trust the Certificate for class of use and for whether you can drive other cars.
PolicyTrace extracts each document separately, then merges the results into one record (the code calls it the Golden Record). The merge doesn't ask the model who is right. It's plain Python in arbiter.py, and the rule fits in one sentence: the Schedule wins, except for class of use and driving other cars, where the Certificate wins. Whenever both documents have a value and the values differ, the arbiter records a conflict with the field, both values and the winner.
I'd rather keep that rule in code than in a prompt. I can test it, someone who knows motor insurance can read it, and changing it doesn't mean re-tuning extraction.
What the four conflicts were
- Insurer name. "Northbridge Mutual Motor Insurance Ltd" against "Northbridge Mutual Motor Insurance Ltd". The difference is a double space left behind by PDF text extraction, so it isn't a real disagreement.
- Class of use. The same story: a double space inside a long sentence.
- Main driver, policyholder. The Schedule says yes, the Certificate says no.
- Main driver, a named driver. The reverse.
So half the conflicts were noise. The comparison lowercased and trimmed both values but didn't collapse the spaces inside them. That was a one-line fix. Left alone, it would have taught reviewers to skim past the conflict panel, which is the worst thing that can happen to a feature whose only job is to get attention. The panel also explained every conflict as "wording differs", even when the conflict was a yes/no flag. It now shows both values side by side.
The bug the conflict panel caught
Both main-driver conflicts said the Schedule won. For the named driver the Schedule said not the main driver, so the record should have held is_main_driver: false. It held true. The record had two main drivers.
This was the line responsible:
is_main_driver=sd.is_main_driver or (cd.is_main_driver if cd else False),Because of the or, a True from either document wins, whatever the conflict entry says. I wrote it to fill a gap when the Schedule didn't mention the main driver. But the schema, the typed form each extraction fills in, gave is_main_driver a default of False, so the code couldn't tell "the Schedule said no" from "the Schedule said nothing". The fix has two parts:
# schema.py
is_main_driver: Optional[bool] = None
# arbiter.py: same rule as every other field, a missing value is None
is_main_driver=_first(sd.is_main_driver, cd.is_main_driver if cd else None),Both changes are in the repo, each with a regression test that fails on the old code. A default that hides a missing value is a pattern I've hit in more than one system; the lesson has its own post.
What I like about this bug is how it surfaced. It was visible only because the arbiter recorded the conflict. If the merge had quietly picked a value, I'd have had a record with two main drivers and nothing pointing at it.
Later that day: the main-driver conflicts weren't real
A closer look showed something worse about conflicts 3 and 4. The Certificate in the demo pack never says who the main driver is, so it had nothing to disagree about. Two things produced the conflicts:
- The model filled a gap. Asked for a main-driver flag, it answered for a document that doesn't state one.
- Drivers were paired with the wrong person. Names are masked before any text reaches the model: replaced with tokens like
MASKED_PERSON_1. The tokens were numbered separately in each document, and the arbiter's fuzzy name matching scored any two tokens as a close match, so the Schedule's second driver could be compared with the Certificate's first.
Both are fixed. The masker now gives one person the same token across the whole pack, and masked names must match exactly. The same pack comes back with no conflicts at all. The is_main_driver fix above still stands: it was a real bug, found through a false alarm.
What I'd still add before real policies
- Normalised values before comparing. Whitespace and case are handled now. Currency isn't: "£200" and "GBP 200.00" would still count as different.
- Business rules the arbiter doesn't know. There should be exactly one main driver, and a provisional licence holder shouldn't normally be one. Nothing checks either yet.
- A test that the record matches the conflict log. For every conflict, the record must hold the winner's value. This one is done, and it would have caught the
orthe day I wrote it.
Limits
All of this comes from one synthetic pack that I generated myself. Real packs have endorsements, mid-term changes and layouts I haven't seen, and the Schedule-wins rule is my reading of how the documents relate, not something an insurer has signed off.
The decision behind it
- Decision: the merge is plain code with a written rule (Schedule wins, except class of use and driving other cars), and every disagreement is logged with both values.
- Alternative rejected: asking the model to reconcile the documents itself. It would have hidden exactly the bug this post is about.
- What it cost: every new field needs a decision about which document wins, and the rule needs someone who knows motor insurance to confirm it.
- When to revisit: when real packs show a third source, such as an endorsement, regularly overriding both documents.
Code:
src/arbiter.py on GitHubDemo: PolicyTrace on Hugging Face loads the synthetic pack in one click
Related: What happens to a PDF inside PolicyTrace · Only one of my PDF problems was in the model
Have you solved the "which document wins" problem differently in your own pipelines? I'd like to hear how.
First published 17 Oct 2026. Updated 25 Oct 2026: the later finding about the main-driver conflicts is now part of the story, not an addendum; new diagram.
Get the next note by email
One short email when something ships or breaks. Free.