This release is a pre-release and may not be stable for production use.
KernelContract
Local-first, read-only diagnostics for Jupyter kernels, kernelspecs, and notebook environments.
KernelContract inspects registered Jupyter kernelspecs, checks whether their configured executables resolve, probes Python kernel environments, and compares notebook kernel metadata with the kernels available to the current Jupyter CLI. It reports likely configuration mismatches, missing interpreters, and safe next steps without modifying the machine.
Alpha Software — Candidate 0.1.0a3 (Latest tagged pre-release: v0.1.0a2). KernelContract is an early-stage diagnostic tool under active development. The latest published GitHub pre-release is
v0.1.0a2, and the current default branch is preparing candidate0.1.0a3for PyPI Trusted Publishing. It has not yet been published to PyPI. The project name is provisional and has not been trademark- or registry-cleared.
Quick start
Prerequisites
- Python 3.10 or newer.
- Jupyter CLI on PATH: KernelContract has zero external runtime dependencies (it uses the Python standard library only), but it requires that the
jupytercommand is available on yourPATH(such as viajupyter-core) to discover registered kernels viajupyter kernelspec list --json.
End-user installation (pre-release)
Install the tagged alpha pre-release directly from GitHub using pip:
python -m pip install "git+https://github.com/Ayushxsingh100/kernelcontract.git@v0.1.0a3"
Or install the latest development snapshot from the default master branch:
python -m pip install "git+https://github.com/Ayushxsingh100/kernelcontract.git"
Note on PyPI: The command
pip install kernelcontractis reserved for future distribution once the package is officially published to the Python Package Index.
Core usage
1. Diagnose registered Jupyter kernels
Run the doctor command to inspect all discovered kernelspecs, verify their executables, and check the active Python environment:
kernelcontract doctor
2. Validate notebook kernel metadata
Inspect whether a .ipynb file's declared kernel exists and matches currently registered kernelspecs:
kernelcontract notebook path/to/notebook.ipynb
If the notebook requests an unavailable kernel or if the kernel's stored display name has drifted from disk, KernelContract reports the issue with actionable next steps.
3. Machine-readable JSON output
Produce structured, versioned JSON suitable for automated tooling, pre-commit hooks, or CI pipelines:
kernelcontract doctor --json
kernelcontract notebook path/to/notebook.ipynb --json
The JSON schema output includes schema_version, status (PASS, WARN, FAIL), check details, and specific remediation suggestions.
4. Strict CI mode
By default, FAIL makes the command exit with status 1, while warnings exit with status 0. To fail CI on warnings as well as failures, pass --strict:
kernelcontract doctor --strict
5. Probing external Python kernels (opt-in)
kernelcontract doctor --probe-python
- Security Note: By default, KernelContract only executes package inspection on the current control interpreter and kernels that resolve to the exact same executable. Interpreters outside the current environment are not executed unless you pass
--probe-python. Use--probe-pythononly with kernelspecs and environments you trust.
What it checks
- CLI Discovery: Whether the Jupyter CLI can enumerate kernelspecs using
jupyter kernelspec list --json. - JSON Structure Safety: Whether kernelspec outputs have valid root structures and dictionary objects.
- Executable Resolution: Whether each registered kernelspec has a resolvable
argv[0]executable (including WindowsPATHEXTresolution for.exe,.cmd,.bat, quoted paths with spaces, and environment variable expansion). - Environment Integrity: Whether the control Python (and, when opted in, external Python kernels) can start and whether
ipykernelis installed in that interpreter. - Environment Drift: Whether a probed kernel's Python prefix differs from the control interpreter.
- Widget Companion Check: A narrow check for presence of
jupyterlab_widgetswhen the control environment contains JupyterLab and a probed kernel containsipywidgets. - Notebook Metadata Check: Whether a notebook file declares a kernel name that is currently registered and whether the recorded display name matches the kernelspec on disk.
Server vs. kernel environments
KernelContract cannot reliably infer which Python interpreter belongs to an already-running Jupyter server across diverse setups (e.g. systemd services, Docker containers, remote SSH tunnels, JupyterHub). By default, it uses the Python interpreter launching KernelContract as its control environment.
If you know the specific Python interpreter running the Jupyter server, pass it explicitly:
kernelcontract doctor --server-python /absolute/path/to/server/python
Safety and privacy guarantees
- Strictly Read-Only: KernelContract modifies no packages, rewrites no files, and changes no configuration.
- No Telemetry: Zero analytics, telemetry, or network calls are made by KernelContract.
- Bounded Subprocesses: Subprocess probes use strict execution timeouts to avoid hanging indefinitely.
- No Shell Execution: Commands are executed directly with argument lists (
shell=False).
Development
To contribute or run the test suite locally from source:
git clone https://github.com/Ayushxsingh100/kernelcontract.git
cd kernelcontract
python -m venv .venv
# Activate .venv (Windows: .venv\Scripts\activate | Unix: source .venv/bin/activate)
python -m pip install -e ".[test]"
python -m unittest discover -s tests -v
python -m pytest -q
Status
- Version:
0.1.0a3(alpha candidate; latest tagged pre-release:v0.1.0a2) - Repository: https://github.com/Ayushxsingh100/kernelcontract
- Pre-release Notes: v0.1.0a2 Release
- License: MIT
- Stability: Alpha
Metadata
Release files for kernelcontract 0.1.0a3
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 | |
|---|---|---|---|---|
| kernelcontract-0.1.0a3.tar.gz | 22.8 kB | With provenance | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| kernelcontract-0.1.0a3-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 39.5 kB
Release files / kernelcontract-0.1.0a3.tar.gz
| Download URL | kernelcontract-0.1.0a3.tar.gz |
|---|---|
| Size | 22.8 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
0ecc1a514bbc831e5052ace32e1d206d7100c9be436dc9c69cdb27e6eec03a4d
|
|
BLAKE2b-256 checksum How to use checksums |
caf310caa5247e93a325529f5f5f532df39b32c4e908e4b131862f2139f2c3d8
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
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.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Oct 25, 2026.
Transparency logRelease files / kernelcontract-0.1.0a3-py3-none-any.whl
| Download URL | kernelcontract-0.1.0a3-py3-none-any.whl |
|---|---|
| Size | 16.7 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
9a5bed8e1716300a77498f497c7c6b61595d1ef974cb0a86a5819f01b8498f7b
|
|
BLAKE2b-256 checksum How to use checksums |
299bba193425be6a2d9abf96fc41ffa9ee02d9a470b386e70229b22b21df46f9
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
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.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Oct 25, 2026.
Transparency logSecurity for kernelcontract 0.1.0a3
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.
Full provenance
All 2 files in this release have been uploaded with provenance metadata.
Attestation for kernelcontract-0.1.0a3.tar.gz
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Oct 25, 2026.
Transparency logA 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.