One contract for the build and live data, with fast validation and compatibility checks when the definition changes.
The order application has passed its tests and is ready for production. It was built against a specific version of the Order contract. Every new order inserted into the collection still raises a question: does this document meet those same requirements?
Project Delphi’s validator work is about making that check practical as part of normal application processing. Performance matters because a contract should not become too expensive to check once the application leaves the test environment.
As AI creates and changes more applications, testing the generated code is only part of the job. A successful build does not guarantee that every order, request, or document it later receives will be valid. The actual data still needs to be checked.

Three ideas guide the design:
- use the same contract during development and production
- use the same validation technology to check whether new contract versions meet their compatibility policy
- and make document validation efficient enough for routine use across use cases
The goal is simple: check the definition when it changes and check the data as the application runs.
The broader ecosystem is introduced in AI Can Write the App. Now It Needs to Build Against the Data. This article focuses on the engine that checks structural rules and schema compatibility.
We will use the same simplified order application: capture an item and quantity, use a customer’s phone number for delivery updates, and generate a printable confirmation.
The examples describe the intended design. Result formats are illustrative; integration details and supported compatibility coverage are not finalized interfaces.
Check the definition when it changes
Order 1.0.0 requires a positive integer quantity. An author proposes Order 2.0.0, raising the minimum from one to two. The new schema is valid as a schema, but that does not mean it is an acceptable evolution.
Suppose the compatibility policy says that the new version must still accept every document allowed by the previous one. An order with quantity one shows the problem:
| Check | Order 1.0.0 | Proposed Order 2.0.0 |
| Minimum quantity | 1 | 2 |
| Order with quantity 1 | Accepted | Rejected |
When Order 2.0.0 is proposed, the repository asks the validation engine whether it meets the contract’s compatibility policy. The engine compares 2.0.0 with 1.0.0—or older versions too, when required—and explains any problems. The repository uses that result to allow or block activation. Just creating a new version number does not bypass the policies set.
Authors can also run the compatibility check while preparing a change to catch problems early. It must also pass before publication. A failed candidate can remain a draft for revision, and each result applies only to the exact definitions that were checked.
Testing sample orders is not enough. Suppose 2.0.0 raises the minimum quantity from one to two. Samples with larger quantities will pass both schemas, hiding the fact that previously valid orders with quantity one now fail. The engine therefore compares the schema rules, not just sample data. If it cannot determine whether the change meets the policy, it reports that clearly—not as a pass.
The policy and publication workflow are explained in From JSON Schema to a Versioned Software Dependency.
Validate the data as the application runs
The proposed change has not been approved, so the application stays bound to Order 1.0.0. Here is the structural part of that contract:
JSON
{
"$schema": "https://json-schema.org/draft/2020-12/schema",
"$id": "https://contracts.example.com/order?version=1.0.0",
"title": "Order",
"type": "object",
"properties": {
"item": {
"type": "string",
"minLength": 1
},
"quantity": {
"type": "integer",
"minimum": 1
},
"phoneNumber": {
"type": "string",
"minLength": 1
}
},
"required": ["item", "quantity", "phoneNumber"],
"additionalProperties": false
}
The schema requires all three properties and rejects additional ones. The validator reads these rules directly; the application does not need a separate handwritten copy of the same checks. [1]
The full Delphi contract also describes meaning and application behavior. This example shows only the structure that the document validator checks.
Validate each document without calling the repository
Validate each document without calling the repository
The repository is not in the per-document request path. It supplies the authoritative contract, but the runtime does not call it every time an order needs to be checked.
During preparation, the integration retrieves the pinned contract version and its referenced definitions. It checks that the engine supports the required features, then prepares a reusable validator.
Each incoming order is checked against that prepared validator. The runtime does not fetch or reinterpret the schema for every order, and it does not need a network round trip just to check that a quantity is positive.
The prepared validator is tied to the exact contract content and referenced versions, along with the JSON Schema dialect, validation settings, and engine version. Referenced definitions cannot silently change the rules.
This prepared form executes the contract; it is not a separate source of truth. A change to the contract, its dependencies, or the relevant settings or engine version requires a validator prepared for that configuration.
Fetch and prepare the definition once. Check each document with the prepared validator.
Check the actual values
An order with quantity 2 passes:
JSON
{
"item": "SKU-1234",
"quantity": 2,
"phoneNumber": "+1-202-555-0100"
}
An order with quantity 0 fails:
JSON
{
"item": "SKU-1234",
"quantity": 0,
"phoneNumber": "+1-202-555-0100"
}
Both documents are well-formed JSON. The second fails because zero is below the required minimum. A quantity written as the string “2” would also fail: the schema requires an integer, not text. [2]
No AI model is needed to decide whether each quantity is acceptable. The validator checks the declared rule directly.
The validator will not turn “2” into 2, fill in missing fields, or remove unexpected ones just to make an order pass. If an application transforms the input, that should be a separate, explicit step, with validation applied at the appropriate point.
The phone-number rule is deliberately basic: it requires a nonempty string. Passing that check does not prove the number is reachable or verified. It also does not prove the application uses it correctly.
Explain a rejected order
For a valid order, the application may only need a pass result. For an invalid one, the AI agent as well as the developer need to know what failed and where.
The design should make the usual decision inexpensive and provide detailed diagnostics when needed. That does not remove required audit or evidence collection; it avoids an extensive report for every successful order.
Here is an illustrative report for quantity zero:
JSON
{
"check": "document-validation",
"contract": {
"id": "https://contracts.example.com/order?version=1.0.0",
},
"result": "INVALID",
"findings": [
{
"instanceLocation": "/quantity",
"keywordLocation": "/properties/quantity/minimum",
"message": "Value must be at least 1."
}
]
}
The report identifies the contract version and the failed rule without copying the whole order, including its phone number, into a log. The caller can also record which exact contract content, engine version, and settings produced the result.
A validation failure is different from a check that could not run. If a required definition is missing, a feature is unsupported, or the engine encounters an error, the result must say so. The application must follow its defined failure policy, not treat an incomplete check as a pass.
This is not a hypothetical concern. In our benchmark, a valid 24-character string checked against the pattern ^(?:(a+)+b|a+)$ was reported invalid by two widely used validators: MongoDB’s $jsonSchema and Blaze. Both use backtracking regular-expression engines that stop after a fixed amount of matching work. When that limit was reached, the result came back as a rejection rather than as a check that could not finish. The fast validator, jsonschema-rs and boon reported the string valid in 26 to 51 nanoseconds. AJV also reported it valid, but took 31 milliseconds. (Details in the post here)

At a write boundary, the application might reject an invalid order before storing it. In a batch, it might quarantine the record for correction. The validator provides the result; the integration applies the configured response.
Use the same checks from build to production
An order generated by an AI agent and an order submitted by a customer should be checked against the same selected definition. The place where validation runs changes; the contract should not.
| Setting | What validation contributes |
| AI development | Checks generated payloads against the contract selected for the application. |
| CI/CD | Runs positive and negative tests against the pinned definition and reports specific failures. |
| Production | Checks the actual order documents arriving at the configured data boundary. |
In a GitHub Actions integration, the workflow could resolve the application’s contract bindings and run document checks alongside its other tests. Deployment would carry the same bindings into production, where the runtime prepares and uses the selected validator.
These environments do not need to call one central validation service. They can execute locally and cache the prepared definition. What needs to match is the contract version, its referenced definitions, and the relevant validation behavior.
The settings matter too. JSON Schema 2020-12 can treat format as an annotation rather than a check. Under the Format-Annotation vocabulary, checking formats is off by default. If CI/CD checks formats but production does not, identical schema text can lead to different results. [2]
Before preparing a validator, the integration must check that the engine supports the schema’s dialect and required vocabularies. An unrecognized required vocabulary must cause the engine to refuse to process that dialect, not silently skip it. [3]
When Order 2.0.0 is eventually published, an application pinned to 1.0.0 keeps using 1.0.0. Adopting v2 means changing the binding, testing it, and deploying the change. An engine upgrade that changes supported features or execution options also needs the appropriate testing and rollout.
Keep behavioral checks distinct
An order can pass validation and still be mishandled. Logging the whole valid document would violate our restriction on the customer’s phone number without changing the document’s structure.
Nomos checks that behavior and supports enforcement at the relevant operations. A new masking rule can also leave structural compatibility unchanged while requiring the application to change. Neither a valid document nor a compatible schema proves that those behavioral rules are implemented.That role is explained in Valid Data Can Still Be Used Wrong: Introducing Nomos.
Show the cost of checking every order
For the order application, performance comes down to a practical question: what does validating every incoming order add to processing time, CPU use, and memory?
That question needs an answer for the workload people will run, not just a tiny document in an isolated test. Results should show what happens as traffic increases, documents grow, and schemas use more references or complex conditions.
The measurements should make three things clear:
- Preparation versus repeated checks. Report the cost of resolving and preparing the contract separately from checking orders with an already prepared validator. A fast result after startup does not mean startup was free.
- Equivalent work. Say whether the engine receives JSON text or already-parsed data, which checks are enabled, and whether it returns a pass/fail decision or a detailed report.
- Representative inputs. Publish schema and document sizes, valid and invalid cases, dependency complexity, engine settings, hardware, and concurrency. Include latency and memory use as well as documents processed per second.
Compatibility checks need separate measurements. Comparing two schema versions is not the same job as processing orders. Results should show which comparisons the engine can resolve, how long they take, and how useful the explanations are.
Those results should be reproducible. Turning off required checks to improve a benchmark would miss the point of this work.
What we measured
We measured the fast validator, the jznschema engine written by Patrick Meredith, against six other validators. The engine was measured in two forms: an interpreted validator that is ready as soon as the schema is prepared, and a compiled form that is generated and built for one schema. The other six were MongoDB’s built-in $jsonSchema, Blaze, jsonschema-rs, boon, AJV, and a replica of Postgres’s pg_jsonschema. All eight ran on the same machine (AMD Ryzen 7 9700X, Linux), one at a time, on one pinned processor core. The harness, schemaBench, and every result are published with the full report. Here is how the results meet the three requirements above.
Preparation versus repeated checks. Each engine prepares the schema once and then checks documents with the prepared validator. We report the two separately. Across all 160 cases, preparing a schema took a median of 150 µs for the fast validator, against 56 µs for MongoDB, 182 µs for Blaze, 0.87 ms for jsonschema-rs, 1.5 ms for boon and 26 ms for AJV. MongoDB prepares faster. At the per-document savings we measured, the difference is recovered after about 330 orders (median across cases; about 1,100 at the 90th percentile). The compiled form is prepared at build time, so its build cost is reported separately and not counted here. (Preparation details.)

Equivalent work. Every engine receives the same schema and the same document, parsed into its own in-memory form before timing starts. Every engine returns a pass/fail decision without a detailed report, with default settings (formats are annotations, not checks). An engine that returns the wrong answer is not timed on that case; the mismatch is reported instead. We also ran the engine author’s own benchmark on the same machine and compared it with ours case by case. They agree to within 2%. That check found two problems in our own harness, both of which had been making the fast validator look better than it is. Both were fixed before these results were taken.
Representative inputs. The suite has 160 cases, each with a valid or an invalid document. They cover:
- required and typed properties;
- numeric and length bounds;
- arrays;
- unions;
- static and dynamic references;
- unevaluated properties;
- 24 cases built around regular-expression patterns.
Each result is the median of five trials, with the 95th percentile kept. Two complete runs agree to within about 1% for every engine. Schema sizes, document sizes and every per-case number are in the report.
What we have not measured yet. This round does not cover memory use, throughput under concurrent load, the cost of schema compatibility checks, or the cost of producing detailed error reports. Those are the next measurements, and they will be published the same way (what is not yet covered).
Full results, methodology and reproduction steps: schemaBench: Fast Validator Benchmark Report.
The goal is not zero-cost validation, or checking the same unchanged document on every line of code. It is to make the required checks affordable where data enters, changes, or leaves a system.
Fast enough to keep the checks in the application, not just in the test plan.
Make the engine available where applications run
Speed alone is not enough. Developers also need to be able to use the engine in the tools and environments where they build and run applications.
We plan to contribute validator technology to open source so coding frameworks, build systems, application runtimes, and databases can integrate it. Using the contract should not require one deployment environment.
When more than one tool checks the same contract, shared tests help show whether they agree. The public JSON Schema Test Suite supplies language-independent tests of expected behavior. Bowtie runs multiple implementations and reports their results. Both help make differences visible. [4][5]
Compatibility checking also needs tests of its own: two schemas, the policy to apply, and the expected result. Tests must include cases the engine cannot determine. An unsupported comparison should never become a pass.
A database integration can apply the same contract to the data it stores and processes. That is another place to run validation, not a reason to limit the engine to one database or coding framework.
The Oracle integration direction and the opportunity for other platforms are explored in The Database AI Builds From – Not Just the Place It Stores Data.
Related reading: Overview – link | Vocabulary and repository – link | Nomos – link | Database integration – link.
One definition, checked throughout
In our order application, the engine checks a proposed rule change before publication. The build uses the selected contract to test generated data. Production uses the same version to validate the orders that arrive.
Performance is intended to make those production checks practical. Openness makes the technology available to the tools and platforms that need it. The contract stays the authority in every setting.
Delphi provides one contract to build against. The fast validators are designed to make checking it part of normal application processing, and to check compatibility when that definition changes.
Public references
[1] JSON Schema: Understanding JSON Schema – Objects. https://json-schema.org/understanding-json-schema/reference/object
[2] JSON Schema Validation, Draft 2020-12: type, minimum, and format behavior. https://json-schema.org/draft/2020-12/json-schema-validation
[3] JSON Schema Core, Draft 2020-12: dialects and required vocabularies. https://json-schema.org/draft/2020-12/json-schema-core
[4] JSON Schema Test Suite. https://github.com/json-schema-org/JSON-Schema-Test-Suite
[5] Bowtie documentation. https://docs.bowtie.report/en/stable/
