mceg 0.1.1__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (57) hide show
  1. mceg-0.1.1/LICENSE +21 -0
  2. mceg-0.1.1/PKG-INFO +314 -0
  3. mceg-0.1.1/README.md +289 -0
  4. mceg-0.1.1/pyproject.toml +42 -0
  5. mceg-0.1.1/setup.cfg +4 -0
  6. mceg-0.1.1/src/mceg/__init__.py +11 -0
  7. mceg-0.1.1/src/mceg/__main__.py +84 -0
  8. mceg-0.1.1/src/mceg/_curated.py +171 -0
  9. mceg-0.1.1/src/mceg/_display.py +268 -0
  10. mceg-0.1.1/src/mceg/_sources.py +182 -0
  11. mceg-0.1.1/src/mceg/_static/mceg.css +12 -0
  12. mceg-0.1.1/src/mceg/assessment.py +107 -0
  13. mceg-0.1.1/src/mceg/catalog.py +297 -0
  14. mceg-0.1.1/src/mceg/check.py +369 -0
  15. mceg-0.1.1/src/mceg/coverage.py +276 -0
  16. mceg-0.1.1/src/mceg/curated.py +81 -0
  17. mceg-0.1.1/src/mceg/data/curated_gas/context.json +11 -0
  18. mceg-0.1.1/src/mceg/data/curated_gas/review.json +16 -0
  19. mceg-0.1.1/src/mceg/documentation.py +662 -0
  20. mceg-0.1.1/src/mceg/explain.py +689 -0
  21. mceg-0.1.1/src/mceg/graph.py +304 -0
  22. mceg-0.1.1/src/mceg/initialization.py +243 -0
  23. mceg-0.1.1/src/mceg/integrity.py +65 -0
  24. mceg-0.1.1/src/mceg/investigation.py +138 -0
  25. mceg-0.1.1/src/mceg/migration.py +88 -0
  26. mceg-0.1.1/src/mceg/provenance.py +46 -0
  27. mceg-0.1.1/src/mceg/schema.py +156 -0
  28. mceg-0.1.1/src/mceg/schema_v02.py +287 -0
  29. mceg-0.1.1/src/mceg/validator.py +58 -0
  30. mceg-0.1.1/src/mceg.egg-info/PKG-INFO +314 -0
  31. mceg-0.1.1/src/mceg.egg-info/SOURCES.txt +55 -0
  32. mceg-0.1.1/src/mceg.egg-info/dependency_links.txt +1 -0
  33. mceg-0.1.1/src/mceg.egg-info/entry_points.txt +2 -0
  34. mceg-0.1.1/src/mceg.egg-info/requires.txt +9 -0
  35. mceg-0.1.1/src/mceg.egg-info/top_level.txt +1 -0
  36. mceg-0.1.1/tests/test_assessment_lifecycle.py +230 -0
  37. mceg-0.1.1/tests/test_catalog.py +290 -0
  38. mceg-0.1.1/tests/test_check.py +101 -0
  39. mceg-0.1.1/tests/test_coverage.py +236 -0
  40. mceg-0.1.1/tests/test_curated_assessment.py +281 -0
  41. mceg-0.1.1/tests/test_explain.py +233 -0
  42. mceg-0.1.1/tests/test_graph.py +324 -0
  43. mceg-0.1.1/tests/test_h2_assessment.py +161 -0
  44. mceg-0.1.1/tests/test_h2_example.py +80 -0
  45. mceg-0.1.1/tests/test_html_docs.py +527 -0
  46. mceg-0.1.1/tests/test_initialization.py +331 -0
  47. mceg-0.1.1/tests/test_integrity.py +223 -0
  48. mceg-0.1.1/tests/test_investigation.py +244 -0
  49. mceg-0.1.1/tests/test_language.py +62 -0
  50. mceg-0.1.1/tests/test_provider_h2.py +96 -0
  51. mceg-0.1.1/tests/test_provider_workflow.py +93 -0
  52. mceg-0.1.1/tests/test_review_lifecycle.py +287 -0
  53. mceg-0.1.1/tests/test_solubility_quantities.py +87 -0
  54. mceg-0.1.1/tests/test_v02.py +200 -0
  55. mceg-0.1.1/tests/test_v02_curated.py +98 -0
  56. mceg-0.1.1/tests/test_validator.py +338 -0
  57. mceg-0.1.1/tests/test_virial_example.py +73 -0
mceg-0.1.1/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Hajime Kawahara
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
mceg-0.1.1/PKG-INFO ADDED
@@ -0,0 +1,314 @@
1
+ Metadata-Version: 2.4
2
+ Name: mceg
3
+ Version: 0.1.1
4
+ Summary: Experimental scientific model contracts and evidence links
5
+ Author: Hajime Kawahara
6
+ License-Expression: MIT
7
+ Project-URL: Homepage, https://github.com/HajimeKawahara/mceg
8
+ Project-URL: Documentation, https://github.com/HajimeKawahara/mceg/blob/main/README.md
9
+ Project-URL: Issues, https://github.com/HajimeKawahara/mceg/issues
10
+ Classifier: Development Status :: 3 - Alpha
11
+ Classifier: Intended Audience :: Science/Research
12
+ Classifier: Programming Language :: Python :: 3
13
+ Classifier: Operating System :: OS Independent
14
+ Requires-Python: >=3.10
15
+ Description-Content-Type: text/markdown
16
+ License-File: LICENSE
17
+ Requires-Dist: pydantic<3,>=2
18
+ Requires-Dist: PyYAML<7,>=6
19
+ Provides-Extra: test
20
+ Requires-Dist: pytest>=8; extra == "test"
21
+ Provides-Extra: docs
22
+ Requires-Dist: sphinx<10,>=7; extra == "docs"
23
+ Requires-Dist: myst-parser<6,>=4; extra == "docs"
24
+ Dynamic: license-file
25
+
26
+ # MCEG: Model Contracts and Evidence Graphs
27
+
28
+ **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.
29
+
30
+ 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.
31
+
32
+ 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.
33
+
34
+ Human and LLM reviewers also use these records to resume investigations, compare
35
+ sources and justify model changes. The [investigation design](https://github.com/HajimeKawahara/mceg/blob/main/docs/en/design_questions.md#investigations-by-human-and-llm-reviewers)
36
+ describes this workflow and the proposed next improvements.
37
+
38
+ Two design commitments guide that workflow: an LLM without the previous
39
+ conversation must be able to follow the evidence and resume an investigation;
40
+ humans must also be able to inspect the evidence and model contracts themselves.
41
+ [MCEG Viewer](https://github.com/HajimeKawahara/mceg/blob/main/viewer/README.md) provides a small bilingual interface for that
42
+ inspection. It consumes exported Graph JSON; MCEG itself does not depend on it.
43
+
44
+ ## Start with the package you use
45
+
46
+ After [installing MCEG](#install), start by inspecting your scientific package:
47
+
48
+ ```bash
49
+ mceg explain --package exogibbs
50
+ ```
51
+
52
+ This shows all models and evidence records indexed by the installed package,
53
+ including documented differences, limitations and open questions. You do not
54
+ need to know a model ID or suspect a particular molecule first.
55
+
56
+ Once you find a topic to investigate, narrow the report:
57
+
58
+ ```bash
59
+ mceg explain --package exogibbs --species HCN
60
+ ```
61
+
62
+ From a provider checkout, gather a selected record's related sources, completed
63
+ reviews and remaining tasks in one report:
64
+
65
+ ```bash
66
+ mceg explain mceg/contracts/model.yaml --evidence source_review --investigation --json
67
+ ```
68
+
69
+ Use the contract path and Evidence ID reported by your provider. See the
70
+ [investigation guide](https://github.com/HajimeKawahara/mceg/blob/main/docs/en/checks.md#resume-an-investigation) for selection
71
+ boundaries and the distinction between completed work and scientific support.
72
+
73
+ The package commands above work from any directory and require a provider version that
74
+ includes an evidence catalog. For editable installations or explicit catalog
75
+ files, see [packaged evidence catalogs](https://github.com/HajimeKawahara/mceg/blob/main/docs/en/package_evidence.md).
76
+ The report describes recorded evidence, not an evaluation of your calculation's
77
+ conditions. ExoGibbs itself works without MCEG installed.
78
+
79
+ If your package has no MCEG records yet, start with
80
+ [LLM or manual setup](#add-mceg-to-an-existing-package).
81
+
82
+ ## Main commands
83
+
84
+ The package command above reads an installed distribution. Run the repository
85
+ commands below from a provider checkout after installing MCEG.
86
+
87
+ | Task | Command |
88
+ | --- | --- |
89
+ | Start a model contract and inventory entry | `mceg init MODEL_ID --source PATH --symbol NAME` |
90
+ | Check discovered contracts and saved evidence | `mceg check` |
91
+ | Explain gaps and the next review steps | `mceg explain` |
92
+ | Discover an installed provider's model evidence | `mceg explain --package exogibbs` |
93
+ | Resume a recorded investigation | `mceg explain CONTRACT --evidence EVIDENCE_ID --investigation --json` |
94
+ | Find inventory, contract and source-review gaps | `mceg coverage .` |
95
+ | Generate RST for repository documentation | `mceg docs --config mceg/docs.yaml` |
96
+ | Export an installed provider's graph | `mceg graph --package exogibbs` |
97
+ | Export one contract's graph | `mceg graph CONTRACT` |
98
+ | Export a calculation's graph | `mceg graph --case CASE` |
99
+ | Validate one contract's structure | `mceg path/to/contract.yaml` |
100
+ | Compare recorded conditions with a context | `mceg assess CONTRACT --context CONTEXT --subject ID --output NEW_FILE` |
101
+ | Preserve a v0.1 contract in v0.2 format | `mceg migrate CONTRACT --output NEW_FILE` |
102
+ | Trace an evidence record's sources | `mceg --trace EVIDENCE_ID CONTRACT` |
103
+
104
+ Use `mceg COMMAND -h` for options. `check`, `explain` and `coverage` offer JSON
105
+ reports; `check` and `explain` also accept `--lang ja`.
106
+ The [Graph JSON API](https://github.com/HajimeKawahara/mceg/blob/main/docs/en/graph.md) exports contracts, scoped judgments,
107
+ investigation records and calculation connections for viewers and other tools.
108
+
109
+ [Packaged evidence catalogs](https://github.com/HajimeKawahara/mceg/blob/main/docs/en/package_evidence.md) let users inspect a
110
+ provider's model/species records without cloning its repository or importing its
111
+ code. The provider supplies the catalog as data and need not depend on MCEG.
112
+ This reports recorded evidence; it does not evaluate a user's run conditions.
113
+
114
+ ## Install
115
+
116
+ Install from PyPI using Python 3.10+:
117
+
118
+ ```bash
119
+ python -m pip install mceg
120
+ ```
121
+
122
+ For development from this checkout:
123
+
124
+ ```bash
125
+ python -m venv .venv
126
+ source .venv/bin/activate
127
+ python -m pip install -e .
128
+ ```
129
+
130
+ Runtime dependencies are Pydantic 2 and PyYAML 6. The `mceg` command is equivalent
131
+ to `python -m mceg`.
132
+
133
+ ## Add MCEG to an existing package
134
+
135
+ Work in the scientific package's source checkout (the **provider**), with the
136
+ [MCEG environment](#install) active. Keep MCEG as an optional authoring tool,
137
+ outside the provider's runtime dependencies. Start with one model.
138
+
139
+ ### With an LLM
140
+
141
+ Give a coding assistant access to both checkouts and replace the placeholders:
142
+
143
+ ```text
144
+ Add MCEG to <provider checkout>, starting with <model or module>.
145
+ Follow <MCEG checkout>/docs/en/initialization.md and provider_onboarding.md
146
+ in the same directory. Inspect code, data, docs and tests to identify model
147
+ boundaries and choices, then use mceg init to create a v0.2 draft and inventory.
148
+ Document model conventions and evidence from inspected sources; record only
149
+ tests actually run. Keep missing support unknown and list concrete follow-ups.
150
+ Expand source_roots to the intended package scope and keep review_pending true
151
+ until human review. Preserve numerical behavior and keep MCEG optional.
152
+ Run mceg check, mceg explain and mceg coverage . from the provider root.
153
+ Summarize changed files, checks, remaining gaps and required human review.
154
+ ```
155
+
156
+ ### Manually
157
+
158
+ Choose the model boundary and its local Python definition after reading the code,
159
+ data, docs and tests. Replace the example names and choices with your own:
160
+
161
+ ```bash
162
+ cd /path/to/provider
163
+ mceg init mypkg.water.power_law \
164
+ --source src/mypkg/water.py --symbol gibbs_j \
165
+ --setting water_model=power_law
166
+ ```
167
+
168
+ `init` creates a v0.2 draft under `mceg/contracts/` and adds its code/contract
169
+ mapping to `mceg/models.yaml`. Edit the draft's `TODO` fields to describe units,
170
+ assumptions, model choices and inspected evidence. Run relevant provider tests
171
+ separately and retain their results before recording numerical support; leave
172
+ missing scientific support `unknown` with follow-ups.
173
+
174
+ The initial inventory scans the selected file only. Expand `source_roots` to
175
+ cover the intended package, classify and hash reviewed files, and clear
176
+ `review_pending` only after human review of model boundaries and links. Then run:
177
+
178
+ ```bash
179
+ mceg check mceg/contracts/mypkg.water.power_law.yaml
180
+ mceg explain mceg/contracts/mypkg.water.power_law.yaml --evidence implementation
181
+ mceg coverage .
182
+ ```
183
+
184
+ `coverage` returns **1** while review or registration gaps remain. Structural
185
+ validation does not establish scientific support. Save the records and link them
186
+ from the provider's docs. See the [setup guide](https://github.com/HajimeKawahara/mceg/blob/main/docs/en/initialization.md) for both
187
+ workflows and the [provider workflow](https://github.com/HajimeKawahara/mceg/blob/main/docs/en/provider_onboarding.md) for evidence
188
+ review. Installed-package discovery additionally needs a
189
+ [packaged catalog](https://github.com/HajimeKawahara/mceg/blob/main/docs/en/package_evidence.md).
190
+
191
+ ## Inspect existing contracts
192
+
193
+ `check` and `explain` discover YAML contracts under `mceg/contracts/` or
194
+ `contracts/`. Filter by name or give an explicit path:
195
+
196
+ ```bash
197
+ mceg check -k water
198
+ mceg explain -k water --lang ja
199
+ mceg check mceg/contracts/water.yaml --json
200
+ ```
201
+
202
+ A **PASS** applies to the named check and its scope. **UNKNOWN** identifies missing
203
+ support or an unresolved review. Numerical agreement, registered model mappings
204
+ and physical accuracy are separate questions. A stored result is not a fresh
205
+ solver run. For a recorded v0.2 Assessment, `--assessment ID --root .` also checks
206
+ its selected source and artifact hashes; see the [check guide](https://github.com/HajimeKawahara/mceg/blob/main/docs/en/checks.md).
207
+
208
+ ## Export relationship graphs
209
+
210
+ From this MCEG checkout, export a model's evidence and judgments or a calculation's
211
+ component connections:
212
+
213
+ ```bash
214
+ mceg graph examples/v02/h2_solubility.yaml --provider mceg > model-graph.json
215
+ mceg graph --case examples/html/case.yaml --provider mceg > case-graph.json
216
+ ```
217
+
218
+ For an installed provider with an evidence catalog:
219
+
220
+ ```bash
221
+ mceg graph --package exogibbs > package-graph.json
222
+ ```
223
+
224
+ To select the catalog directly from an ExoGibbs checkout:
225
+
226
+ ```bash
227
+ mceg graph --catalog /path/to/exogibbs/src/exogibbs/data/mceg/index.json > package-graph.json
228
+ ```
229
+
230
+ To run MCEG directly from its checkout, prepend its `src` directory to
231
+ `PYTHONPATH`, keeping any existing entries:
232
+
233
+ ```bash
234
+ PYTHONPATH="/path/to/mceg/src${PYTHONPATH:+:$PYTHONPATH}" \
235
+ python -m mceg graph --package exogibbs > package-graph.json
236
+ ```
237
+
238
+ Package lookup also handles source-manifest paths in legacy `src`-layout editable
239
+ installs. Use `mceg graph --catalog PATH` for an explicit catalog or editable
240
+ installs whose metadata does not list the catalog. Local contract and case paths
241
+ resolve from `--root`, which defaults to the current directory. JSON retains
242
+ source identities, scoped judgments and explicit selections for viewers and LLM tools. See the
243
+ [Graph JSON API](https://github.com/HajimeKawahara/mceg/blob/main/docs/en/graph.md) for Python examples and relationship meanings.
244
+
245
+ ## Documentation and examples
246
+
247
+ For interactive inspection, run the standalone viewer (Node.js 22.12+):
248
+
249
+ ```bash
250
+ cd viewer
251
+ npm ci
252
+ npm run dev
253
+ ```
254
+
255
+ Open the printed local URL, choose **Open graph JSON**, and select an export
256
+ from `mceg graph`. The bundled H2 example can also be opened from the welcome
257
+ screen. Switch between English and Japanese in the header. See the
258
+ [viewer guide](https://github.com/HajimeKawahara/mceg/blob/main/viewer/README.md) for navigation and interpretation boundaries.
259
+
260
+ To publish the viewer on a static web server, run this from the same `viewer/`
261
+ directory:
262
+
263
+ ```bash
264
+ npm run build
265
+ ```
266
+
267
+ Upload **all contents of `viewer/dist/`** (`index.html`, `assets/`,
268
+ `viewer-export.json` and `example-graph.json`) to the server's public directory.
269
+ PHP, Node.js, Python and MCEG are not required on the server. Visitors open their graph JSON in the
270
+ browser; the build does not bundle a graph previously opened in the viewer.
271
+ See [static hosting instructions](https://github.com/HajimeKawahara/mceg/blob/main/viewer/README.md#static-hosting) for deployment
272
+ and local preview.
273
+
274
+ To publish a specific graph, open it in the viewer and click **Save as HTML**.
275
+ Upload the downloaded file to the server; it includes the complete graph and
276
+ interactive viewer, so visitors do not need to select a JSON file. See the
277
+ [HTML export guide](https://github.com/HajimeKawahara/mceg/blob/main/viewer/README.md#save-a-graph-as-a-standalone-html-page).
278
+
279
+ For a browsable model catalog and linked calculation/evidence graphs, see the
280
+ [HTML guide](https://github.com/HajimeKawahara/mceg/blob/main/docs/en/html.md). Build it with Graphviz installed:
281
+
282
+ ```bash
283
+ python -m pip install -e '.[docs]'
284
+ ./update_doc.sh -W --keep-going
285
+ ```
286
+
287
+ Open `docs/_build/html/index.html` and select **Calculation cases** for the H2
288
+ connection. The build reads saved records; it runs no scientific calculation.
289
+ Run `mceg docs --config mceg/docs.yaml` to generate RST and CSS for a provider.
290
+ Each repository builds HTML with its own Sphinx configuration and update script.
291
+
292
+ | Topic | Guides |
293
+ | --- | --- |
294
+ | Model registration | [LLM and manual setup](https://github.com/HajimeKawahara/mceg/blob/main/docs/en/initialization.md), [inventory coverage](https://github.com/HajimeKawahara/mceg/blob/main/docs/en/coverage.md), [provider workflow](https://github.com/HajimeKawahara/mceg/blob/main/docs/en/provider_onboarding.md) |
295
+ | Checks and source review | [CLI checks](https://github.com/HajimeKawahara/mceg/blob/main/docs/en/checks.md), [provenance](https://github.com/HajimeKawahara/mceg/blob/main/docs/en/provenance.md), [evidence audit](https://github.com/HajimeKawahara/mceg/blob/main/docs/en/evidence_audit.md) |
296
+ | Relationship graphs | [Graph JSON API](https://github.com/HajimeKawahara/mceg/blob/main/docs/en/graph.md), [HTML documentation](https://github.com/HajimeKawahara/mceg/blob/main/docs/en/html.md) |
297
+ | Contract formats | [v0.2](https://github.com/HajimeKawahara/mceg/blob/main/docs/en/v02.md), [v0.1](https://github.com/HajimeKawahara/mceg/blob/main/docs/en/schema.md), [compatibility](https://github.com/HajimeKawahara/mceg/blob/main/docs/en/versioning.md) |
298
+ | Worked connections | [H2 solubility](https://github.com/HajimeKawahara/mceg/blob/main/docs/en/h2_solubility.md), [provider trials](https://github.com/HajimeKawahara/mceg/blob/main/docs/en/provider_trials.md), [provider-owned pilot](https://github.com/HajimeKawahara/mceg/blob/main/docs/en/provider_pilot.md) |
299
+ | Evidence studies | [H2 sources](https://github.com/HajimeKawahara/mceg/blob/main/docs/en/h2_primary_audit.md), [curated gas](https://github.com/HajimeKawahara/mceg/blob/main/docs/en/curated_assessment.md), [assessment lifecycle](https://github.com/HajimeKawahara/mceg/blob/main/docs/en/assessment_lifecycle.md) |
300
+ | Design questions | [English](https://github.com/HajimeKawahara/mceg/blob/main/docs/en/design_questions.md), [Japanese](https://github.com/HajimeKawahara/mceg/blob/main/docs/ja/design_questions.md) |
301
+
302
+ Browse [example contracts](https://github.com/HajimeKawahara/mceg/tree/main/contracts) and [saved examples](https://github.com/HajimeKawahara/mceg/tree/main/examples).
303
+ The current package release is **`0.1.1`**. It reads both v0.1 and v0.2 contracts;
304
+ package versions and schema versions are separate. The frozen `v0.1.0` baseline
305
+ remains unchanged, and the v0.2 schema remains experimental.
306
+ See the [changelog](https://github.com/HajimeKawahara/mceg/blob/main/CHANGELOG.md) for changes and the
307
+ [release guide](https://github.com/HajimeKawahara/mceg/blob/main/docs/en/releasing.md) for publishing instructions.
308
+
309
+ ## Development
310
+
311
+ ```bash
312
+ python -m pip install -e '.[test]'
313
+ python -m pytest
314
+ ```
mceg-0.1.1/README.md ADDED
@@ -0,0 +1,289 @@
1
+ # MCEG: Model Contracts and Evidence Graphs
2
+
3
+ **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.
4
+
5
+ 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.
6
+
7
+ 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.
8
+
9
+ Human and LLM reviewers also use these records to resume investigations, compare
10
+ sources and justify model changes. The [investigation design](https://github.com/HajimeKawahara/mceg/blob/main/docs/en/design_questions.md#investigations-by-human-and-llm-reviewers)
11
+ describes this workflow and the proposed next improvements.
12
+
13
+ Two design commitments guide that workflow: an LLM without the previous
14
+ conversation must be able to follow the evidence and resume an investigation;
15
+ humans must also be able to inspect the evidence and model contracts themselves.
16
+ [MCEG Viewer](https://github.com/HajimeKawahara/mceg/blob/main/viewer/README.md) provides a small bilingual interface for that
17
+ inspection. It consumes exported Graph JSON; MCEG itself does not depend on it.
18
+
19
+ ## Start with the package you use
20
+
21
+ After [installing MCEG](#install), start by inspecting your scientific package:
22
+
23
+ ```bash
24
+ mceg explain --package exogibbs
25
+ ```
26
+
27
+ This shows all models and evidence records indexed by the installed package,
28
+ including documented differences, limitations and open questions. You do not
29
+ need to know a model ID or suspect a particular molecule first.
30
+
31
+ Once you find a topic to investigate, narrow the report:
32
+
33
+ ```bash
34
+ mceg explain --package exogibbs --species HCN
35
+ ```
36
+
37
+ From a provider checkout, gather a selected record's related sources, completed
38
+ reviews and remaining tasks in one report:
39
+
40
+ ```bash
41
+ mceg explain mceg/contracts/model.yaml --evidence source_review --investigation --json
42
+ ```
43
+
44
+ Use the contract path and Evidence ID reported by your provider. See the
45
+ [investigation guide](https://github.com/HajimeKawahara/mceg/blob/main/docs/en/checks.md#resume-an-investigation) for selection
46
+ boundaries and the distinction between completed work and scientific support.
47
+
48
+ The package commands above work from any directory and require a provider version that
49
+ includes an evidence catalog. For editable installations or explicit catalog
50
+ files, see [packaged evidence catalogs](https://github.com/HajimeKawahara/mceg/blob/main/docs/en/package_evidence.md).
51
+ The report describes recorded evidence, not an evaluation of your calculation's
52
+ conditions. ExoGibbs itself works without MCEG installed.
53
+
54
+ If your package has no MCEG records yet, start with
55
+ [LLM or manual setup](#add-mceg-to-an-existing-package).
56
+
57
+ ## Main commands
58
+
59
+ The package command above reads an installed distribution. Run the repository
60
+ commands below from a provider checkout after installing MCEG.
61
+
62
+ | Task | Command |
63
+ | --- | --- |
64
+ | Start a model contract and inventory entry | `mceg init MODEL_ID --source PATH --symbol NAME` |
65
+ | Check discovered contracts and saved evidence | `mceg check` |
66
+ | Explain gaps and the next review steps | `mceg explain` |
67
+ | Discover an installed provider's model evidence | `mceg explain --package exogibbs` |
68
+ | Resume a recorded investigation | `mceg explain CONTRACT --evidence EVIDENCE_ID --investigation --json` |
69
+ | Find inventory, contract and source-review gaps | `mceg coverage .` |
70
+ | Generate RST for repository documentation | `mceg docs --config mceg/docs.yaml` |
71
+ | Export an installed provider's graph | `mceg graph --package exogibbs` |
72
+ | Export one contract's graph | `mceg graph CONTRACT` |
73
+ | Export a calculation's graph | `mceg graph --case CASE` |
74
+ | Validate one contract's structure | `mceg path/to/contract.yaml` |
75
+ | Compare recorded conditions with a context | `mceg assess CONTRACT --context CONTEXT --subject ID --output NEW_FILE` |
76
+ | Preserve a v0.1 contract in v0.2 format | `mceg migrate CONTRACT --output NEW_FILE` |
77
+ | Trace an evidence record's sources | `mceg --trace EVIDENCE_ID CONTRACT` |
78
+
79
+ Use `mceg COMMAND -h` for options. `check`, `explain` and `coverage` offer JSON
80
+ reports; `check` and `explain` also accept `--lang ja`.
81
+ The [Graph JSON API](https://github.com/HajimeKawahara/mceg/blob/main/docs/en/graph.md) exports contracts, scoped judgments,
82
+ investigation records and calculation connections for viewers and other tools.
83
+
84
+ [Packaged evidence catalogs](https://github.com/HajimeKawahara/mceg/blob/main/docs/en/package_evidence.md) let users inspect a
85
+ provider's model/species records without cloning its repository or importing its
86
+ code. The provider supplies the catalog as data and need not depend on MCEG.
87
+ This reports recorded evidence; it does not evaluate a user's run conditions.
88
+
89
+ ## Install
90
+
91
+ Install from PyPI using Python 3.10+:
92
+
93
+ ```bash
94
+ python -m pip install mceg
95
+ ```
96
+
97
+ For development from this checkout:
98
+
99
+ ```bash
100
+ python -m venv .venv
101
+ source .venv/bin/activate
102
+ python -m pip install -e .
103
+ ```
104
+
105
+ Runtime dependencies are Pydantic 2 and PyYAML 6. The `mceg` command is equivalent
106
+ to `python -m mceg`.
107
+
108
+ ## Add MCEG to an existing package
109
+
110
+ Work in the scientific package's source checkout (the **provider**), with the
111
+ [MCEG environment](#install) active. Keep MCEG as an optional authoring tool,
112
+ outside the provider's runtime dependencies. Start with one model.
113
+
114
+ ### With an LLM
115
+
116
+ Give a coding assistant access to both checkouts and replace the placeholders:
117
+
118
+ ```text
119
+ Add MCEG to <provider checkout>, starting with <model or module>.
120
+ Follow <MCEG checkout>/docs/en/initialization.md and provider_onboarding.md
121
+ in the same directory. Inspect code, data, docs and tests to identify model
122
+ boundaries and choices, then use mceg init to create a v0.2 draft and inventory.
123
+ Document model conventions and evidence from inspected sources; record only
124
+ tests actually run. Keep missing support unknown and list concrete follow-ups.
125
+ Expand source_roots to the intended package scope and keep review_pending true
126
+ until human review. Preserve numerical behavior and keep MCEG optional.
127
+ Run mceg check, mceg explain and mceg coverage . from the provider root.
128
+ Summarize changed files, checks, remaining gaps and required human review.
129
+ ```
130
+
131
+ ### Manually
132
+
133
+ Choose the model boundary and its local Python definition after reading the code,
134
+ data, docs and tests. Replace the example names and choices with your own:
135
+
136
+ ```bash
137
+ cd /path/to/provider
138
+ mceg init mypkg.water.power_law \
139
+ --source src/mypkg/water.py --symbol gibbs_j \
140
+ --setting water_model=power_law
141
+ ```
142
+
143
+ `init` creates a v0.2 draft under `mceg/contracts/` and adds its code/contract
144
+ mapping to `mceg/models.yaml`. Edit the draft's `TODO` fields to describe units,
145
+ assumptions, model choices and inspected evidence. Run relevant provider tests
146
+ separately and retain their results before recording numerical support; leave
147
+ missing scientific support `unknown` with follow-ups.
148
+
149
+ The initial inventory scans the selected file only. Expand `source_roots` to
150
+ cover the intended package, classify and hash reviewed files, and clear
151
+ `review_pending` only after human review of model boundaries and links. Then run:
152
+
153
+ ```bash
154
+ mceg check mceg/contracts/mypkg.water.power_law.yaml
155
+ mceg explain mceg/contracts/mypkg.water.power_law.yaml --evidence implementation
156
+ mceg coverage .
157
+ ```
158
+
159
+ `coverage` returns **1** while review or registration gaps remain. Structural
160
+ validation does not establish scientific support. Save the records and link them
161
+ from the provider's docs. See the [setup guide](https://github.com/HajimeKawahara/mceg/blob/main/docs/en/initialization.md) for both
162
+ workflows and the [provider workflow](https://github.com/HajimeKawahara/mceg/blob/main/docs/en/provider_onboarding.md) for evidence
163
+ review. Installed-package discovery additionally needs a
164
+ [packaged catalog](https://github.com/HajimeKawahara/mceg/blob/main/docs/en/package_evidence.md).
165
+
166
+ ## Inspect existing contracts
167
+
168
+ `check` and `explain` discover YAML contracts under `mceg/contracts/` or
169
+ `contracts/`. Filter by name or give an explicit path:
170
+
171
+ ```bash
172
+ mceg check -k water
173
+ mceg explain -k water --lang ja
174
+ mceg check mceg/contracts/water.yaml --json
175
+ ```
176
+
177
+ A **PASS** applies to the named check and its scope. **UNKNOWN** identifies missing
178
+ support or an unresolved review. Numerical agreement, registered model mappings
179
+ and physical accuracy are separate questions. A stored result is not a fresh
180
+ solver run. For a recorded v0.2 Assessment, `--assessment ID --root .` also checks
181
+ its selected source and artifact hashes; see the [check guide](https://github.com/HajimeKawahara/mceg/blob/main/docs/en/checks.md).
182
+
183
+ ## Export relationship graphs
184
+
185
+ From this MCEG checkout, export a model's evidence and judgments or a calculation's
186
+ component connections:
187
+
188
+ ```bash
189
+ mceg graph examples/v02/h2_solubility.yaml --provider mceg > model-graph.json
190
+ mceg graph --case examples/html/case.yaml --provider mceg > case-graph.json
191
+ ```
192
+
193
+ For an installed provider with an evidence catalog:
194
+
195
+ ```bash
196
+ mceg graph --package exogibbs > package-graph.json
197
+ ```
198
+
199
+ To select the catalog directly from an ExoGibbs checkout:
200
+
201
+ ```bash
202
+ mceg graph --catalog /path/to/exogibbs/src/exogibbs/data/mceg/index.json > package-graph.json
203
+ ```
204
+
205
+ To run MCEG directly from its checkout, prepend its `src` directory to
206
+ `PYTHONPATH`, keeping any existing entries:
207
+
208
+ ```bash
209
+ PYTHONPATH="/path/to/mceg/src${PYTHONPATH:+:$PYTHONPATH}" \
210
+ python -m mceg graph --package exogibbs > package-graph.json
211
+ ```
212
+
213
+ Package lookup also handles source-manifest paths in legacy `src`-layout editable
214
+ installs. Use `mceg graph --catalog PATH` for an explicit catalog or editable
215
+ installs whose metadata does not list the catalog. Local contract and case paths
216
+ resolve from `--root`, which defaults to the current directory. JSON retains
217
+ source identities, scoped judgments and explicit selections for viewers and LLM tools. See the
218
+ [Graph JSON API](https://github.com/HajimeKawahara/mceg/blob/main/docs/en/graph.md) for Python examples and relationship meanings.
219
+
220
+ ## Documentation and examples
221
+
222
+ For interactive inspection, run the standalone viewer (Node.js 22.12+):
223
+
224
+ ```bash
225
+ cd viewer
226
+ npm ci
227
+ npm run dev
228
+ ```
229
+
230
+ Open the printed local URL, choose **Open graph JSON**, and select an export
231
+ from `mceg graph`. The bundled H2 example can also be opened from the welcome
232
+ screen. Switch between English and Japanese in the header. See the
233
+ [viewer guide](https://github.com/HajimeKawahara/mceg/blob/main/viewer/README.md) for navigation and interpretation boundaries.
234
+
235
+ To publish the viewer on a static web server, run this from the same `viewer/`
236
+ directory:
237
+
238
+ ```bash
239
+ npm run build
240
+ ```
241
+
242
+ Upload **all contents of `viewer/dist/`** (`index.html`, `assets/`,
243
+ `viewer-export.json` and `example-graph.json`) to the server's public directory.
244
+ PHP, Node.js, Python and MCEG are not required on the server. Visitors open their graph JSON in the
245
+ browser; the build does not bundle a graph previously opened in the viewer.
246
+ See [static hosting instructions](https://github.com/HajimeKawahara/mceg/blob/main/viewer/README.md#static-hosting) for deployment
247
+ and local preview.
248
+
249
+ To publish a specific graph, open it in the viewer and click **Save as HTML**.
250
+ Upload the downloaded file to the server; it includes the complete graph and
251
+ interactive viewer, so visitors do not need to select a JSON file. See the
252
+ [HTML export guide](https://github.com/HajimeKawahara/mceg/blob/main/viewer/README.md#save-a-graph-as-a-standalone-html-page).
253
+
254
+ For a browsable model catalog and linked calculation/evidence graphs, see the
255
+ [HTML guide](https://github.com/HajimeKawahara/mceg/blob/main/docs/en/html.md). Build it with Graphviz installed:
256
+
257
+ ```bash
258
+ python -m pip install -e '.[docs]'
259
+ ./update_doc.sh -W --keep-going
260
+ ```
261
+
262
+ Open `docs/_build/html/index.html` and select **Calculation cases** for the H2
263
+ connection. The build reads saved records; it runs no scientific calculation.
264
+ Run `mceg docs --config mceg/docs.yaml` to generate RST and CSS for a provider.
265
+ Each repository builds HTML with its own Sphinx configuration and update script.
266
+
267
+ | Topic | Guides |
268
+ | --- | --- |
269
+ | Model registration | [LLM and manual setup](https://github.com/HajimeKawahara/mceg/blob/main/docs/en/initialization.md), [inventory coverage](https://github.com/HajimeKawahara/mceg/blob/main/docs/en/coverage.md), [provider workflow](https://github.com/HajimeKawahara/mceg/blob/main/docs/en/provider_onboarding.md) |
270
+ | Checks and source review | [CLI checks](https://github.com/HajimeKawahara/mceg/blob/main/docs/en/checks.md), [provenance](https://github.com/HajimeKawahara/mceg/blob/main/docs/en/provenance.md), [evidence audit](https://github.com/HajimeKawahara/mceg/blob/main/docs/en/evidence_audit.md) |
271
+ | Relationship graphs | [Graph JSON API](https://github.com/HajimeKawahara/mceg/blob/main/docs/en/graph.md), [HTML documentation](https://github.com/HajimeKawahara/mceg/blob/main/docs/en/html.md) |
272
+ | Contract formats | [v0.2](https://github.com/HajimeKawahara/mceg/blob/main/docs/en/v02.md), [v0.1](https://github.com/HajimeKawahara/mceg/blob/main/docs/en/schema.md), [compatibility](https://github.com/HajimeKawahara/mceg/blob/main/docs/en/versioning.md) |
273
+ | Worked connections | [H2 solubility](https://github.com/HajimeKawahara/mceg/blob/main/docs/en/h2_solubility.md), [provider trials](https://github.com/HajimeKawahara/mceg/blob/main/docs/en/provider_trials.md), [provider-owned pilot](https://github.com/HajimeKawahara/mceg/blob/main/docs/en/provider_pilot.md) |
274
+ | Evidence studies | [H2 sources](https://github.com/HajimeKawahara/mceg/blob/main/docs/en/h2_primary_audit.md), [curated gas](https://github.com/HajimeKawahara/mceg/blob/main/docs/en/curated_assessment.md), [assessment lifecycle](https://github.com/HajimeKawahara/mceg/blob/main/docs/en/assessment_lifecycle.md) |
275
+ | Design questions | [English](https://github.com/HajimeKawahara/mceg/blob/main/docs/en/design_questions.md), [Japanese](https://github.com/HajimeKawahara/mceg/blob/main/docs/ja/design_questions.md) |
276
+
277
+ Browse [example contracts](https://github.com/HajimeKawahara/mceg/tree/main/contracts) and [saved examples](https://github.com/HajimeKawahara/mceg/tree/main/examples).
278
+ The current package release is **`0.1.1`**. It reads both v0.1 and v0.2 contracts;
279
+ package versions and schema versions are separate. The frozen `v0.1.0` baseline
280
+ remains unchanged, and the v0.2 schema remains experimental.
281
+ See the [changelog](https://github.com/HajimeKawahara/mceg/blob/main/CHANGELOG.md) for changes and the
282
+ [release guide](https://github.com/HajimeKawahara/mceg/blob/main/docs/en/releasing.md) for publishing instructions.
283
+
284
+ ## Development
285
+
286
+ ```bash
287
+ python -m pip install -e '.[test]'
288
+ python -m pytest
289
+ ```
@@ -0,0 +1,42 @@
1
+ [build-system]
2
+ requires = ["setuptools>=77"]
3
+ build-backend = "setuptools.build_meta"
4
+
5
+ [project]
6
+ name = "mceg"
7
+ version = "0.1.1"
8
+ description = "Experimental scientific model contracts and evidence links"
9
+ authors = [{name = "Hajime Kawahara"}]
10
+ readme = "README.md"
11
+ requires-python = ">=3.10"
12
+ license = "MIT"
13
+ license-files = ["LICENSE"]
14
+ dependencies = ["pydantic>=2,<3", "PyYAML>=6,<7"]
15
+ classifiers = [
16
+ "Development Status :: 3 - Alpha",
17
+ "Intended Audience :: Science/Research",
18
+ "Programming Language :: Python :: 3",
19
+ "Operating System :: OS Independent",
20
+ ]
21
+
22
+ [project.urls]
23
+ Homepage = "https://github.com/HajimeKawahara/mceg"
24
+ Documentation = "https://github.com/HajimeKawahara/mceg/blob/main/README.md"
25
+ Issues = "https://github.com/HajimeKawahara/mceg/issues"
26
+
27
+ [project.optional-dependencies]
28
+ test = ["pytest>=8"]
29
+ docs = ["sphinx>=7,<10", "myst-parser>=4,<6"]
30
+
31
+ [project.scripts]
32
+ mceg = "mceg.__main__:main"
33
+
34
+ [tool.setuptools.packages.find]
35
+ where = ["src"]
36
+
37
+ [tool.setuptools.package-data]
38
+ mceg = ["data/curated_gas/*.json", "_static/*.css"]
39
+
40
+ [tool.pytest.ini_options]
41
+ testpaths = ["tests"]
42
+ pythonpath = ["src"]