Experimental scientific model contracts and evidence links
Model Contracts and Evidence Graphs (MCEG) is a framework for making the claims, assumptions, applicability domains, and supporting evidence of computational scientific models explicit, traceable, and auditable by both humans and AI systems.
By systematically representing what a scientific model claims, under which conditions those claims hold, and what evidence supports them, MCEG facilitates scientifically informed decisions throughout model development, validation, and use.
Rather than automatically guaranteeing the correctness of scientific models, MCEG provides a transparent foundation for humans and AI systems to continuously examine their scientific validity, limitations, and supporting evidence.
Human and LLM reviewers also use these records to resume investigations, compare sources and justify model changes. The investigation design describes this workflow and the proposed next improvements.
Two design commitments guide that workflow: an LLM without the previous conversation must be able to follow the evidence and resume an investigation; humans must also be able to inspect the evidence and model contracts themselves. MCEG Viewer provides a small bilingual interface for that inspection. It consumes exported Graph JSON; MCEG itself does not depend on it.
After installing MCEG, start by inspecting your scientific package:
mceg explain --package exogibbs This shows all models and evidence records indexed by the installed package, including documented differences, limitations and open questions. You do not need to know a model ID or suspect a particular molecule first.
Once you find a topic to investigate, narrow the report:
mceg explain --package exogibbs --species HCN From a provider checkout, gather a selected record's related sources, completed reviews and remaining tasks in one report:
mceg explain mceg/contracts/model.yaml --evidence source_review --investigation --json Use the contract path and Evidence ID reported by your provider. See the investigation guide for selection boundaries and the distinction between completed work and scientific support.
The package commands above work from any directory and require a provider version that includes an evidence catalog. For editable installations or explicit catalog files, see packaged evidence catalogs. The report describes recorded evidence, not an evaluation of your calculation's conditions. ExoGibbs itself works without MCEG installed.
If your package has no MCEG records yet, start with LLM or manual setup.
The package command above reads an installed distribution. Run the repository commands below from a provider checkout after installing MCEG.
Use mceg COMMAND -h for options. check, explain and coverage offer JSON reports; check and explain also accept --lang ja. The Graph JSON API exports contracts, scoped judgments, investigation records and calculation connections for viewers and other tools.
Packaged evidence catalogs let users inspect a provider's model/species records without cloning its repository or importing its code. The provider supplies the catalog as data and need not depend on MCEG. This reports recorded evidence; it does not evaluate a user's run conditions.
python -m pip install mceg For development from this checkout:
python -m venv .venv source .venv/bin/activate python -m pip install -e . Runtime dependencies are Pydantic 2 and PyYAML 6. The mceg command is equivalent to python -m mceg.
Work in the scientific package's source checkout (the provider), with the MCEG environment active. Keep MCEG as an optional authoring tool, outside the provider's runtime dependencies. Start with one model.
Give a coding assistant access to both checkouts and replace the placeholders:
Add MCEG to , starting with . Follow /docs/en/initialization.md and provider_onboarding.md in the same directory. Inspect code, data, docs and tests to identify model boundaries and choices, then use mceg init to create a v0.2 draft and inventory. Document model conventions and evidence from inspected sources; record only tests actually run. Keep missing support unknown and list concrete follow-ups. Expand source_roots to the intended package scope and keep review_pending true until human review. Preserve numerical behavior and keep MCEG optional. Run mceg check, mceg explain and mceg coverage . from the provider root. Summarize changed files, checks, remaining gaps and required human review. Manually Choose the model boundary and its local Python definition after reading the code, data, docs and tests. Replace the example names and choices with your own:
cd /path/to/provider mceg init mypkg.water.power_law \ --source src/mypkg/water.py --symbol gibbs_j \ --setting water_model=power_law init creates a v0.2 draft under mceg/contracts/ and adds its code/contract mapping to mceg/models.yaml. Edit the draft's TODO fields to describe units, assumptions, model choices and inspected evidence. Run relevant provider tests separately and retain their results before recording numerical support; leave missing scientific support unknown with follow-ups.
The initial inventory scans the selected file only. Expand source_roots to cover the intended package, classify and hash reviewed files, and clear review_pending only after human review of model boundaries and links. Then run:
mceg check mceg/contracts/mypkg.water.power_law.yaml mceg explain mceg/contracts/mypkg.water.power_law.yaml --evidence implementation mceg coverage . coverage returns 1 while review or registration gaps remain. Structural validation does not establish scientific support. Save the records and link them from the provider's docs. See the setup guide for both workflows and the provider workflow for evidence review. Installed-package discovery additionally needs a packaged catalog.
check and explain discover YAML contracts under mceg/contracts/ or contracts/. Filter by name or give an explicit path:
mceg check -k water mceg explain -k water --lang ja mceg check mceg/contracts/water.yaml --json A PASS applies to the named check and its scope. UNKNOWN identifies missing support or an unresolved review. Numerical agreement, registered model mappings and physical accuracy are separate questions. A stored result is not a fresh solver run. For a recorded v0.2 Assessment, --assessment ID --root . also checks its selected source and artifact hashes; see the check guide.
From this MCEG checkout, export a model's evidence and judgments or a calculation's component connections:
mceg graph examples/v02/h2_solubility.yaml --provider mceg > model-graph.json mceg graph --case examples/html/case.yaml --provider mceg > case-graph.json For an installed provider with an evidence catalog:
mceg graph --package exogibbs > package-graph.json To select the catalog directly from an ExoGibbs checkout:
mceg graph --catalog /path/to/exogibbs/src/exogibbs/data/mceg/index.json > package-graph.json To run MCEG directly from its checkout, prepend its src directory to PYTHONPATH, keeping any existing entries:
PYTHONPATH="/path/to/mceg/src${PYTHONPATH:+:$PYTHONPATH}" \ python -m mceg graph --package exogibbs > package-graph.json Package lookup also handles source-manifest paths in legacy src-layout editable installs. Use mceg graph --catalog PATH for an explicit catalog or editable installs whose metadata does not list the catalog. Local contract and case paths resolve from --root, which defaults to the current directory. JSON retains source identities, scoped judgments and explicit selections for viewers and LLM tools. See the Graph JSON API for Python examples and relationship meanings.
For interactive inspection, run the standalone viewer (Node.js 22.12+):
cd viewer npm ci npm run dev Open the printed local URL, choose Open graph JSON, and select an export from mceg graph. The bundled H2 example can also be opened from the welcome screen. Switch between English and Japanese in the header. See the viewer guide for navigation and interpretation boundaries.
To publish the viewer on a static web server, run this from the same viewer/ directory:
npm run build Upload all contents of viewer/dist/ (index.html, assets/, viewer-export.json and example-graph.json) to the server's public directory. PHP, Node.js, Python and MCEG are not required on the server. Visitors open their graph JSON in the browser; the build does not bundle a graph previously opened in the viewer. See static hosting instructions for deployment and local preview.
To publish a specific graph, open it in the viewer and click Save as HTML. Upload the downloaded file to the server; it includes the complete graph and interactive viewer, so visitors do not need to select a JSON file. See the HTML export guide.
For a browsable model catalog and linked calculation/evidence graphs, see the HTML guide. Build it with Graphviz installed:
python -m pip install -e '.[docs]' ./update_doc.sh -W --keep-going Open docs/_build/html/index.html and select Calculation cases for the H2 connection. The build reads saved records; it runs no scientific calculation. Run mceg docs --config mceg/docs.yaml to generate RST and CSS for a provider. Each repository builds HTML with its own Sphinx configuration and update script.
Browse example contracts and saved examples. The current package release is 0.1.1. It reads both v0.1 and v0.2 contracts; package versions and schema versions are separate. The frozen v0.1.0 baseline remains unchanged, and the v0.2 schema remains experimental. See the changelog for changes and the release guide for publishing instructions.
python -m pip install -e '.[test]' python -m pytest Project links Data verified by PyPI on Nov 7, 2026 Data provided by the project maintainers, verified at the time the release was uploaded to PyPI. Documentation Homepage Issues Key dates PyPI data Data sourced directly from PyPI's database. Released: Nov 7, 2026 Latest release 1 maintainer PyPI data Data sourced directly from PyPI's database. HajimeKawahara Credits Author: Hajime Kawahara
Both files in this release have provenance metadata.
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
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 verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Nov 7, 2026.
Both files in this release have been uploaded with provenance metadata.
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.




