jsonl-contract-check
Validate JSONL records against lightweight field contracts from the command line or from Python.
Problem
JSONL is a convenient format for prompt runs, eval traces, data cleanup jobs, and batch API results, but small shape problems can hide until a downstream script fails. This tool gives you a fast local check for required fields, basic types, nested paths, and JSON strings embedded inside a record.
Install
pip install jsonl-contract-check
For local development:
python -m venv .venv
source .venv/bin/activate
pip install -e .
Contract Format
Create a contract JSON file with a fields array:
{
"fields": [
{ "path": "id", "type": "str" },
{ "path": "metrics.score", "type": "number" },
{ "path": "choices[0].message.content", "type": "str" },
{ "path": "raw_response", "type": "object", "parse_json": true },
{ "path": "notes", "type": "str", "required": false }
]
}
Supported types are any, array, bool, float, int, null, number, object, and str.
Use dotted paths for nested objects and [index] notation for array items, such as choices[0].message.content.
CLI Usage
jsonl-contract-check --contract contract.json results.jsonl
Validate multiple files:
jsonl-contract-check -c contract.json runs/*.jsonl
Emit a machine-readable report:
jsonl-contract-check -c contract.json --format json results.jsonl
The command exits with:
0when every checked row passes1when one or more records fail2when the contract or input files cannot be read
Python Usage
from jsonl_contract_check import audit_paths, load_contract
rules = load_contract("contract.json")
result = audit_paths(["results.jsonl"], rules)
if not result.ok:
for issue in result.issues:
print(issue)
Example Output
Status: FAIL
Files: 1
Records: 2
Embedded JSON parsed: 1
Field coverage:
- id: 2/2 (str, required)
- metrics.score: 1/2 (number, required)
Issues:
- results.jsonl:2 [missing-field] Missing required field: metrics.score.
Development
Run tests:
PYTHONPATH=src python -m unittest discover -s tests
Build the package:
python -m build
Contributing
Issues and pull requests are welcome. Keep changes focused, include tests for behavior changes, and update the README when command behavior changes.
Metadata
Release files for jsonl-contract-check 0.2.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| jsonl_contract_check-0.2.0.tar.gz | 7.6 kB | Without provenance | Details for jsonl_contract_check-0.2.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| jsonl_contract_check-0.2.0-py3-none-any.whl | Python 3 | none | any | Details for jsonl_contract_check-0.2.0-py3-none-any.whl |
Total release size: 15.0 kB
Release files / jsonl_contract_check-0.2.0.tar.gz
| Download URL | jsonl_contract_check-0.2.0.tar.gz |
|---|---|
| Size | 7.6 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
fd86bcc4e8004332d59720302d5ef0623f2766cc39eddb316fdc8a6022d4dd23
|
|
BLAKE2b-256 checksum How to use checksums |
8c99f28b480c449ed1b0054a6df74b9286595fe5ad98be2a3e0516b9f7a1c34b
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.14.5
|
Release files / jsonl_contract_check-0.2.0-py3-none-any.whl
| Download URL | jsonl_contract_check-0.2.0-py3-none-any.whl |
|---|---|
| Size | 7.4 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
e446f71c98b9ecd8b29385fd36a212b5ddab90e186f260a8dabe35756cc7027e
|
|
BLAKE2b-256 checksum How to use checksums |
e1895efc3c01aada39d5ffc4afbef0a3ac4b01e8c2ede7257992207a848d37a9
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.14.5
|
Security for jsonl-contract-check 0.2.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.