Contract Lineage & Consolidation Engine
An engine that reconstructs the current state of a heavily amended commercial agreement — producing a consolidated document with complete change lineage, where AI proposes typed operations and deterministic code applies them.
A base agreement plus fifteen amendments, reconstructed into current truth with full lineage — and the discipline to refuse when evidence is thin.
The architecture separates judgement from execution: the model reads and proposes typed operations, and deterministic code applies them. The model never writes the document.
The base document is loaded and its underlying document tree is mutated in place, then written back. Anything not explicitly changed survives byte-for-byte, because regenerating the document would fail the structure-retention requirement outright.
Every claim in the output references its evidence by identifier. Unattributed statements are rejected by a verifier rather than shipped.
The engine can refuse. Where amendments conflict or evidence does not support a conclusion, it says so instead of producing a confident answer — and any change that removes the ability to refuse is treated as a bug.
A master services agreement amended fifteen times over several years has no single readable current state. Answering 'what are the payment terms today' means reading the base contract and every amendment in sequence, hoping nothing was missed.
Reconstructing it by hand takes days of legal time and is error-prone in exactly the places that matter most commercially.
The obvious AI approach — asking a model to produce the consolidated contract — is unusable. A generated legal document cannot be trusted, and a hallucinated clause in a contract is a commercial liability.
An engine that reconstructs the current state of a heavily amended commercial agreement — producing a consolidated document with complete change lineage, where AI proposes typed operations and deterministic code applies them.
This is the pattern for AI on documents that carry legal or financial weight — policies, contracts, regulatory filings — where a plausible-sounding answer is worse than no answer.
Reconstruction depth
Base agreement + 15 amendments
Structure retention
100% of untouched content
Attribution
Every claim carries an evidence id
Domain packs
2 domains on one shared engine
The constraint that shaped it
100% structure retention — so never regenerate
The requirement was that anything not explicitly amended must survive untouched — formatting, numbering, defined terms, everything. That single constraint rules out the entire generate-the-document approach and forces in-place mutation of the document tree. It is the decision the whole engine is built around.
AI proposes, code applies
The model never generates the artefact and never computes a final value. It emits typed operations that deterministic code validates and executes — which is what makes the output defensible.
A domain-agnostic core, enforced in CI
The shared engine contains no domain vocabulary at all, enforced by an automated check. When a domain concept needs to reach the core, that signals the schema is wrong — so a second, completely different domain plugged into the same engine.
'Strength', never 'confidence'
With no calibration data, displaying a confidence percentage would imply a statistical property the system does not have. The vocabulary was constrained deliberately to avoid implying false precision.
- Shaped the architecture separating model judgement from deterministic execution
- Defined the hard rules the implementation was held to, including the refusal requirement
- Designed how lineage and evidence surface to a legal reader
- Built and validated against real amended agreements
How We Solved the Problem
Baseline + event chain ingestion
The base agreement is treated as a baseline and each amendment as an event, so current state is a reconstruction over an ordered chain rather than a document comparison.
AI proposes typed operations
The model reads the amendment and emits structured operations — replace this clause, insert this schedule, supersede this term — never prose intended for direct insertion.
Deterministic application
Code validates and applies those operations against the document tree in place, so output is a function of typed instructions rather than generated text.
Lineage capture
Every applied change records which amendment produced it and why, so the consolidated document can be read backwards to its source.
Verification gate
A verifier rejects unattributed claims and surfaces conflicts. Where evidence is insufficient, the gate refuses rather than resolving the ambiguity silently.