mintmatter 0.1.0__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 (197) hide show
  1. mintmatter-0.1.0/.claude-plugin/marketplace.json +31 -0
  2. mintmatter-0.1.0/.gitignore +52 -0
  3. mintmatter-0.1.0/CHANGELOG.md +24 -0
  4. mintmatter-0.1.0/CONTRACTS.md +454 -0
  5. mintmatter-0.1.0/GEMINI.md +35 -0
  6. mintmatter-0.1.0/LICENSE +21 -0
  7. mintmatter-0.1.0/PKG-INFO +309 -0
  8. mintmatter-0.1.0/README.md +266 -0
  9. mintmatter-0.1.0/evals/matter_bench/REPORT.md +174 -0
  10. mintmatter-0.1.0/evals/matter_bench/corpus.py +1036 -0
  11. mintmatter-0.1.0/evals/matter_bench/report.json +10485 -0
  12. mintmatter-0.1.0/evals/matter_bench/run_bench.py +345 -0
  13. mintmatter-0.1.0/gallery/README.md +95 -0
  14. mintmatter-0.1.0/gallery/plate_a_three_surfaces.py +315 -0
  15. mintmatter-0.1.0/gallery/plate_b_file_to_figure.py +330 -0
  16. mintmatter-0.1.0/gallery/plate_c_reviewer.py +138 -0
  17. mintmatter-0.1.0/gallery/plate_d_mlip_benchmark.py +282 -0
  18. mintmatter-0.1.0/gallery/plate_e_battery_life.py +281 -0
  19. mintmatter-0.1.0/gallery/plate_f_microscopy.py +435 -0
  20. mintmatter-0.1.0/gallery/plate_g_operando.py +385 -0
  21. mintmatter-0.1.0/gallery/plate_h_campaign.py +424 -0
  22. mintmatter-0.1.0/gallery/showcase/__init__.py +53 -0
  23. mintmatter-0.1.0/gallery/showcase/common.py +215 -0
  24. mintmatter-0.1.0/gallery/showcase/p01_perovskite.py +124 -0
  25. mintmatter-0.1.0/gallery/showcase/p02_catalysis.py +84 -0
  26. mintmatter-0.1.0/gallery/showcase/p03_battery.py +126 -0
  27. mintmatter-0.1.0/gallery/showcase/p04_xps_mlip.py +85 -0
  28. mintmatter-0.1.0/gallery/showcase/p05_molecules.py +53 -0
  29. mintmatter-0.1.0/gallery/showcase/p06_structures.py +59 -0
  30. mintmatter-0.1.0/gallery/showcase/p07_dark_slide.py +29 -0
  31. mintmatter-0.1.0/gallery/showcase/p08_periodic.py +51 -0
  32. mintmatter-0.1.0/gallery/showcase/p09_journals.py +119 -0
  33. mintmatter-0.1.0/gallery/showcase/p10_mof5.py +97 -0
  34. mintmatter-0.1.0/gallery/showcase/p11_coordination.py +66 -0
  35. mintmatter-0.1.0/gallery/showcase/p12_basepair.py +64 -0
  36. mintmatter-0.1.0/gallery/showcase/p13_dark_triptych.py +41 -0
  37. mintmatter-0.1.0/gallery/showcase/p14_operando.py +82 -0
  38. mintmatter-0.1.0/gallery/showcase/p15_moire.py +90 -0
  39. mintmatter-0.1.0/gallery/showcase/p16_ashby_pareto.py +72 -0
  40. mintmatter-0.1.0/gallery/showcase/p17_sar.py +72 -0
  41. mintmatter-0.1.0/gallery/showcase/sheets.py +153 -0
  42. mintmatter-0.1.0/gallery/showcase.py +70 -0
  43. mintmatter-0.1.0/gallery/slide_targets.py +199 -0
  44. mintmatter-0.1.0/gemini-extension.json +17 -0
  45. mintmatter-0.1.0/llms.txt +38 -0
  46. mintmatter-0.1.0/plugins/claude-code/.claude-plugin/plugin.json +19 -0
  47. mintmatter-0.1.0/plugins/claude-code/.mcp.json +8 -0
  48. mintmatter-0.1.0/plugins/claude-code/skills/mintmatter/SKILL.md +134 -0
  49. mintmatter-0.1.0/pyproject.toml +112 -0
  50. mintmatter-0.1.0/skills/mintmatter/SKILL.md +134 -0
  51. mintmatter-0.1.0/src/mintmatter/__init__.py +219 -0
  52. mintmatter-0.1.0/src/mintmatter/_core.py +1202 -0
  53. mintmatter-0.1.0/src/mintmatter/_geometry.py +731 -0
  54. mintmatter-0.1.0/src/mintmatter/_render3d.py +1004 -0
  55. mintmatter-0.1.0/src/mintmatter/_style.py +756 -0
  56. mintmatter-0.1.0/src/mintmatter/_text.py +424 -0
  57. mintmatter-0.1.0/src/mintmatter/advanced.py +1098 -0
  58. mintmatter-0.1.0/src/mintmatter/agent.py +1041 -0
  59. mintmatter-0.1.0/src/mintmatter/audit.py +198 -0
  60. mintmatter-0.1.0/src/mintmatter/battery.py +1356 -0
  61. mintmatter-0.1.0/src/mintmatter/catalysis.py +513 -0
  62. mintmatter-0.1.0/src/mintmatter/cli.py +486 -0
  63. mintmatter-0.1.0/src/mintmatter/crystallography.py +220 -0
  64. mintmatter-0.1.0/src/mintmatter/diffraction.py +442 -0
  65. mintmatter-0.1.0/src/mintmatter/dynamics.py +1034 -0
  66. mintmatter-0.1.0/src/mintmatter/eds.py +762 -0
  67. mintmatter-0.1.0/src/mintmatter/electrochem.py +825 -0
  68. mintmatter-0.1.0/src/mintmatter/electronic.py +393 -0
  69. mintmatter-0.1.0/src/mintmatter/examples.py +803 -0
  70. mintmatter-0.1.0/src/mintmatter/fix.py +122 -0
  71. mintmatter-0.1.0/src/mintmatter/insitu.py +624 -0
  72. mintmatter-0.1.0/src/mintmatter/io/__init__.py +143 -0
  73. mintmatter-0.1.0/src/mintmatter/io/_elements.py +103 -0
  74. mintmatter-0.1.0/src/mintmatter/io/_errors.py +28 -0
  75. mintmatter-0.1.0/src/mintmatter/io/adapters.py +71 -0
  76. mintmatter-0.1.0/src/mintmatter/io/cif.py +449 -0
  77. mintmatter-0.1.0/src/mintmatter/io/datasets.py +319 -0
  78. mintmatter-0.1.0/src/mintmatter/io/echem.py +211 -0
  79. mintmatter-0.1.0/src/mintmatter/io/jcamp.py +216 -0
  80. mintmatter-0.1.0/src/mintmatter/io/patterns.py +184 -0
  81. mintmatter-0.1.0/src/mintmatter/io/tiff.py +89 -0
  82. mintmatter-0.1.0/src/mintmatter/io/vasp_xyz.py +206 -0
  83. mintmatter-0.1.0/src/mintmatter/journals.py +620 -0
  84. mintmatter-0.1.0/src/mintmatter/kinetics.py +717 -0
  85. mintmatter-0.1.0/src/mintmatter/mcp.py +458 -0
  86. mintmatter-0.1.0/src/mintmatter/microscopy.py +502 -0
  87. mintmatter-0.1.0/src/mintmatter/ml.py +836 -0
  88. mintmatter-0.1.0/src/mintmatter/mlip.py +222 -0
  89. mintmatter-0.1.0/src/mintmatter/periodic.py +289 -0
  90. mintmatter-0.1.0/src/mintmatter/phase.py +855 -0
  91. mintmatter-0.1.0/src/mintmatter/review.py +1275 -0
  92. mintmatter-0.1.0/src/mintmatter/rules/__init__.py +145 -0
  93. mintmatter-0.1.0/src/mintmatter/rules/_base.py +407 -0
  94. mintmatter-0.1.0/src/mintmatter/rules/battery.py +96 -0
  95. mintmatter-0.1.0/src/mintmatter/rules/crosspanel.py +449 -0
  96. mintmatter-0.1.0/src/mintmatter/rules/diffraction.py +219 -0
  97. mintmatter-0.1.0/src/mintmatter/rules/electrochem.py +167 -0
  98. mintmatter-0.1.0/src/mintmatter/rules/electronic.py +86 -0
  99. mintmatter-0.1.0/src/mintmatter/rules/general.py +171 -0
  100. mintmatter-0.1.0/src/mintmatter/rules/microscopy.py +240 -0
  101. mintmatter-0.1.0/src/mintmatter/rules/parity.py +98 -0
  102. mintmatter-0.1.0/src/mintmatter/rules/spectroscopy.py +182 -0
  103. mintmatter-0.1.0/src/mintmatter/rules/thermo.py +68 -0
  104. mintmatter-0.1.0/src/mintmatter/schema.py +264 -0
  105. mintmatter-0.1.0/src/mintmatter/slides.py +337 -0
  106. mintmatter-0.1.0/src/mintmatter/spectroscopy.py +742 -0
  107. mintmatter-0.1.0/src/mintmatter/structures.py +2132 -0
  108. mintmatter-0.1.0/src/mintmatter/thermo.py +963 -0
  109. mintmatter-0.1.0/src/mintmatter/xas.py +891 -0
  110. mintmatter-0.1.0/tests/conftest.py +16 -0
  111. mintmatter-0.1.0/tests/fixtures/LiCoO2.cif +70 -0
  112. mintmatter-0.1.0/tests/fixtures/NaCl.cif +218 -0
  113. mintmatter-0.1.0/tests/fixtures/NaCl.extxyz +10 -0
  114. mintmatter-0.1.0/tests/fixtures/NaCl_CuKa.xy +1504 -0
  115. mintmatter-0.1.0/tests/fixtures/NaCl_CuKa.xye +1501 -0
  116. mintmatter-0.1.0/tests/fixtures/NaCl_cart.vasp +17 -0
  117. mintmatter-0.1.0/tests/fixtures/NaCl_no_symops.cif +17 -0
  118. mintmatter-0.1.0/tests/fixtures/NaCl_q.csv +1503 -0
  119. mintmatter-0.1.0/tests/fixtures/POSCAR_SrTiO3 +13 -0
  120. mintmatter-0.1.0/tests/fixtures/Si_diamond.cif +213 -0
  121. mintmatter-0.1.0/tests/fixtures/SrTiO3.cif +82 -0
  122. mintmatter-0.1.0/tests/fixtures/TiO2_rutile.cif +41 -0
  123. mintmatter-0.1.0/tests/fixtures/benzene.xyz +14 -0
  124. mintmatter-0.1.0/tests/fixtures/cv_biologic.mpt +412 -0
  125. mintmatter-0.1.0/tests/fixtures/cv_gamry.DTA +416 -0
  126. mintmatter-0.1.0/tests/fixtures/eis_gamry.DTA +56 -0
  127. mintmatter-0.1.0/tests/fixtures/fringes_cm.tif +0 -0
  128. mintmatter-0.1.0/tests/fixtures/fringes_imagej.tif +0 -0
  129. mintmatter-0.1.0/tests/fixtures/gcd_biologic_capacity.mpt +523 -0
  130. mintmatter-0.1.0/tests/fixtures/gcd_biologic_nocapacity.mpt +522 -0
  131. mintmatter-0.1.0/tests/fixtures/gcpl_biologic.mpt +246 -0
  132. mintmatter-0.1.0/tests/fixtures/make_fixtures.py +611 -0
  133. mintmatter-0.1.0/tests/fixtures/make_gcd_fixtures.py +62 -0
  134. mintmatter-0.1.0/tests/fixtures/peis_biologic.mpt +56 -0
  135. mintmatter-0.1.0/tests/fixtures/photo_72dpi.tif +0 -0
  136. mintmatter-0.1.0/tests/fixtures/polystyrene_affn.jdx +229 -0
  137. mintmatter-0.1.0/tests/fixtures/polystyrene_difdup.jdx +188 -0
  138. mintmatter-0.1.0/tests/fixtures/polystyrene_peaks.jdx +9 -0
  139. mintmatter-0.1.0/tests/test_advanced.py +173 -0
  140. mintmatter-0.1.0/tests/test_agent.py +177 -0
  141. mintmatter-0.1.0/tests/test_all_kinds.py +127 -0
  142. mintmatter-0.1.0/tests/test_battery.py +269 -0
  143. mintmatter-0.1.0/tests/test_catalysis.py +93 -0
  144. mintmatter-0.1.0/tests/test_claims.py +202 -0
  145. mintmatter-0.1.0/tests/test_cli.py +128 -0
  146. mintmatter-0.1.0/tests/test_core.py +195 -0
  147. mintmatter-0.1.0/tests/test_core_hooks.py +102 -0
  148. mintmatter-0.1.0/tests/test_crystallography.py +90 -0
  149. mintmatter-0.1.0/tests/test_dynamics.py +202 -0
  150. mintmatter-0.1.0/tests/test_eds.py +205 -0
  151. mintmatter-0.1.0/tests/test_electrochem.py +222 -0
  152. mintmatter-0.1.0/tests/test_electronic.py +102 -0
  153. mintmatter-0.1.0/tests/test_extensions.py +59 -0
  154. mintmatter-0.1.0/tests/test_fix.py +109 -0
  155. mintmatter-0.1.0/tests/test_geometry_and_render.py +386 -0
  156. mintmatter-0.1.0/tests/test_geometry_tools.py +324 -0
  157. mintmatter-0.1.0/tests/test_insitu.py +151 -0
  158. mintmatter-0.1.0/tests/test_io_instruments.py +312 -0
  159. mintmatter-0.1.0/tests/test_io_structures.py +361 -0
  160. mintmatter-0.1.0/tests/test_journals_render.py +174 -0
  161. mintmatter-0.1.0/tests/test_kinetics.py +234 -0
  162. mintmatter-0.1.0/tests/test_literal_lint.py +71 -0
  163. mintmatter-0.1.0/tests/test_matter_bench.py +35 -0
  164. mintmatter-0.1.0/tests/test_mcp_tools.py +136 -0
  165. mintmatter-0.1.0/tests/test_microscopy.py +141 -0
  166. mintmatter-0.1.0/tests/test_ml.py +252 -0
  167. mintmatter-0.1.0/tests/test_mlip.py +80 -0
  168. mintmatter-0.1.0/tests/test_periodic.py +80 -0
  169. mintmatter-0.1.0/tests/test_phase.py +179 -0
  170. mintmatter-0.1.0/tests/test_plate_a.py +37 -0
  171. mintmatter-0.1.0/tests/test_plate_b.py +30 -0
  172. mintmatter-0.1.0/tests/test_plate_d.py +30 -0
  173. mintmatter-0.1.0/tests/test_plate_e.py +31 -0
  174. mintmatter-0.1.0/tests/test_plate_f.py +30 -0
  175. mintmatter-0.1.0/tests/test_plate_g.py +30 -0
  176. mintmatter-0.1.0/tests/test_plate_h.py +30 -0
  177. mintmatter-0.1.0/tests/test_readme.py +76 -0
  178. mintmatter-0.1.0/tests/test_review.py +130 -0
  179. mintmatter-0.1.0/tests/test_rules_battery.py +49 -0
  180. mintmatter-0.1.0/tests/test_rules_crosspanel.py +101 -0
  181. mintmatter-0.1.0/tests/test_rules_diffraction.py +61 -0
  182. mintmatter-0.1.0/tests/test_rules_electrochem.py +49 -0
  183. mintmatter-0.1.0/tests/test_rules_electronic.py +49 -0
  184. mintmatter-0.1.0/tests/test_rules_general.py +101 -0
  185. mintmatter-0.1.0/tests/test_rules_microscopy.py +49 -0
  186. mintmatter-0.1.0/tests/test_rules_parity.py +49 -0
  187. mintmatter-0.1.0/tests/test_rules_spectroscopy.py +56 -0
  188. mintmatter-0.1.0/tests/test_rules_thermo.py +49 -0
  189. mintmatter-0.1.0/tests/test_schema.py +90 -0
  190. mintmatter-0.1.0/tests/test_showcase.py +55 -0
  191. mintmatter-0.1.0/tests/test_slides.py +198 -0
  192. mintmatter-0.1.0/tests/test_spectroscopy.py +145 -0
  193. mintmatter-0.1.0/tests/test_structures.py +174 -0
  194. mintmatter-0.1.0/tests/test_text.py +104 -0
  195. mintmatter-0.1.0/tests/test_thermo.py +172 -0
  196. mintmatter-0.1.0/tests/test_xas.py +203 -0
  197. mintmatter-0.1.0/tests/test_xrd.py +149 -0
@@ -0,0 +1,31 @@
1
+ {
2
+ "name": "mintmatter",
3
+ "owner": {
4
+ "name": "Ben Blaiszik"
5
+ },
6
+ "metadata": {
7
+ "description": "Journal-grade materials and chemistry figures for coding agents and scientists, built on mintfig: 39 data-carrying panel kinds, computed facts, a 45-rule domain audit, and exact-millimetre plates.",
8
+ "version": "0.1.0"
9
+ },
10
+ "plugins": [
11
+ {
12
+ "name": "mintmatter",
13
+ "source": "./plugins/claude-code",
14
+ "description": "Journal-grade materials and chemistry figures for coding agents and scientists, built on mintfig: 39 data-carrying panel kinds, computed facts, a 45-rule domain audit, and exact-millimetre plates.",
15
+ "version": "0.1.0",
16
+ "author": {
17
+ "name": "Ben Blaiszik"
18
+ },
19
+ "license": "MIT",
20
+ "repository": "https://github.com/blaiszik/mintmatter",
21
+ "keywords": [
22
+ "materials-science",
23
+ "chemistry",
24
+ "matplotlib",
25
+ "scientific-figures",
26
+ "agents",
27
+ "publication"
28
+ ]
29
+ }
30
+ ]
31
+ }
@@ -0,0 +1,52 @@
1
+ # Python
2
+ __pycache__/
3
+ *.py[cod]
4
+ *$py.class
5
+ *.so
6
+ .Python
7
+ build/
8
+ develop-eggs/
9
+ dist/
10
+ downloads/
11
+ eggs/
12
+ .eggs/
13
+ lib/
14
+ lib64/
15
+ parts/
16
+ sdist/
17
+ var/
18
+ wheels/
19
+ *.egg-info/
20
+ .installed.cfg
21
+ *.egg
22
+
23
+ # Virtual environments
24
+ .venv/
25
+ venv/
26
+ ENV/
27
+
28
+ # Testing & linting
29
+ .pytest_cache/
30
+ .ruff_cache/
31
+ .coverage
32
+ htmlcov/
33
+
34
+ # OS / Editors
35
+ .DS_Store
36
+ .vscode/
37
+ .idea/
38
+ *.swp
39
+ *.swo
40
+
41
+ # Generated gallery bundles and scratch artifacts (curated PNGs stay tracked)
42
+ gallery/output/*_bundle/
43
+ gallery/output/*.json
44
+ gallery/output/*.tif
45
+ gallery/output/*.mpt
46
+ gallery/output/*.txt
47
+ gallery/output/showcase/*.json
48
+
49
+ # Local only
50
+ .archive/
51
+ .claude/
52
+ .serena/
@@ -0,0 +1,24 @@
1
+ # Changelog
2
+
3
+ All notable changes to `mintmatter` are documented in this file.
4
+
5
+ The format follows [Keep a Changelog](https://keepachangelog.com/en/1.1.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html) once 1.0 is reached.
6
+
7
+ ## [0.1.0] - 2026-11-29
8
+
9
+ ### Added
10
+ - **39 data-carrying materials & chemistry panel kinds (`matter.*`)** registered through `mintfig.panels` entry points:
11
+ - Structure & phase: `xrd`, `pattern_stack`, `operando_contour`, `crystal`, `molecule3d`, `molecule`
12
+ - Spectroscopy: `spectrum`, `xps`, `xanes`, `exafs`
13
+ - Electronic structure & dynamics: `band_dos`, `phonon`, `rdf`, `msd`
14
+ - Thermodynamics: `convex_hull`, `ternary`, `phase_diagram`, `pourbaix`, `isotherm`, `arrhenius`
15
+ - Electrochemistry & batteries: `cv`, `nyquist`, `lsv`, `tafel`, `gcd`, `dqdv`, `cycling`, `rate_capability`
16
+ - Catalysis: `reaction_profile`, `volcano`
17
+ - Microscopy: `micrograph`, `eds_map`, `line_profile`
18
+ - Screening & MLIPs: `ashby`, `chem_space`, `periodic_table`, `parity`, `parity_density`, `learning_curve`
19
+ - **Computed facts & strict claim verification:** Every panel computes structured facts from its data (`Fact`, `mm.facts()`) and feeds `Panel.quantities` into `mintfig`'s epistemic audit so contradicted headline numbers block `ship` by default (`claim_number_mismatch`).
20
+ - **45-rule domain audit, reviewer sheet & mechanical fixer:** `mm.check_matter()`, `mm.review()`, `mm.review_text()`, and `mm.fix()` across both data-backed `mintmatter` panels and third-party Matplotlib figures, including cross-panel consistency checks (cell vs. XRD vs. HRTEM d-spacing, EXAFS vs. structure bonds, battery capacities). Evaluated on `evals/matter_bench` (74/74 seeded defects caught, 0/68 clean false positives).
21
+ - **Exact-millimetre journal & slide targets:** `mm.render(..., journal=..., columns=..., mode="explain"|"manuscript")` for `nature`, `science`, `acs` (`jacs`), `wiley` (`adv_mater`), `rsc`, `aps` (`prb`), plus `slide_16x9` and `slide_4x3` regions (`full`, `two_thirds`, `half`, `third`) with slide overflow and stroke-width gates.
22
+ - **Built-in scientific file readers (`mm.read`, `mm.inspect`, `mm.auto`):** Zero-extra-dependency parsers for CIF (with symmetry operations), POSCAR/CONTCAR, XYZ/extXYZ, `.xy`/`.xye`/CSV diffraction patterns, JCAMP-DX spectra, BioLogic `.mpt`, Gamry `.DTA`, and calibrated TIFF micrographs; optional `mintmatter[io]` adapters for pymatgen, ASE, RDKit, and RosettaSciIO.
23
+ - **Agent-first CLI & MCP tools:** `mintmatter` CLI (`inspect`, `plot`, `edit`, `check`, `schema`, `kinds`, `--json`, `--version`) and 4 MCP tools (`matter_inspect`, `matter_figure`, `matter_check`, `matter_edit`) auto-registered into `mintfig mcp` via the `mintfig.mcp` entry point.
24
+ - **Agent skill & extensions:** `skills/mintmatter/SKILL.md`, `llms.txt`, Gemini CLI / Antigravity extension (`gemini-extension.json`, `GEMINI.md`), and Claude Code plugin manifests.
@@ -0,0 +1,454 @@
1
+ # mintmatter contracts
2
+
3
+ Authoritative for every lane. Lanes do not negotiate these with each other; if one is wrong or
4
+ blocks you, say so in your report and work around it inside your own files.
5
+
6
+ Background and the reasons for all of this: `prototypes/mintmatter/PLAN.md`.
7
+ `prototypes/mintmatter/` is the frozen baseline. Read it, never edit it.
8
+
9
+ ## Layout
10
+
11
+ ```
12
+
13
+ pyproject.toml entry point: mintfig.panels -> matter = "mintmatter"
14
+ CONTRACTS.md
15
+ src/mintmatter/
16
+ __init__.py public API (owner: foundation lane; others report additions)
17
+ _core.py Fact, MatterCtx, matter_kind, matter_panel, validation, JSON codec
18
+ _text.py chem() text formatter
19
+ _style.py axis helpers (legacy make_matter_panel shim stays until all kinds convert)
20
+ journals.py profiles, render(), Manuscript
21
+ <domain>.py one module per panel family
22
+ examples.py demo structure builders (moved out of structures.py)
23
+ io/ readers and typed datasets
24
+ _geometry.py bonding, polyhedra, boundary completion, view selection
25
+ audit.py, rules/ check_matter, rule registry
26
+ tests/
27
+ gallery/
28
+ ```
29
+
30
+ The package is installed editable into `.venv` (`uv pip install -e packages/mintmatter --no-deps`).
31
+ Run tests from the repo root: `.venv/bin/python -m pytest tests/<file> -q -p no:xdist`.
32
+
33
+ ## C1. mintfig extension API
34
+
35
+ In `src/mintfig/_explain/layout.py`, re-exported from `mintfig.explainer`:
36
+
37
+ ```python
38
+ def register_kind(
39
+ name: str,
40
+ builder: Callable[..., Panel],
41
+ *,
42
+ positional: Sequence[str] = (),
43
+ replace: bool = False,
44
+ ) -> None: ...
45
+ def registered_kinds() -> tuple[str, ...]: ... # built-ins first, then extensions sorted
46
+ ```
47
+
48
+ - Extension names are namespaced with one dot: `matter.xrd`. A name without a dot, or one that
49
+ shadows a built-in, raises `ExplainError`. Registering a taken name raises unless `replace=True`.
50
+ - `panel_from_spec` on an unknown `ns.kind` loads the entry point named `ns` in group
51
+ `mintfig.panels` (once per process), then retries. An unknown kind's `fix_hint` lists
52
+ `registered_kinds()`.
53
+ - `mint.load`, `mint.edit`, `Explanation.to_spec`, PNG spec embedding, `mint.pub.to_publication`,
54
+ `Explanation.bundle` and the MCP server's kind enum all accept extension kinds. Anywhere mintfig
55
+ special-cases `"custom"` as a free-form panel, an extension kind gets the same treatment.
56
+ - `mint.edit` operations that do not understand an extension panel's contents pass its spec through
57
+ unchanged; figure-level edits (takeaway, style, palette, width, target, drop_panel) work.
58
+
59
+ ## C2. Panel tag style
60
+
61
+ `JournalSpec.panel_label_style: Literal["plain", "paren"] = "plain"` (added by the journal-specs
62
+ lane). `"paren"` renders tags as `(a)` / `(A)`. mintfig's layout, `Plate.label_panels` and the
63
+ bundle caption honour it; read it with `getattr(spec, "panel_label_style", "plain")`.
64
+
65
+ Canonical keys added to `mintfig.specs.JOURNALS`: `acs`, `wiley`, `rsc`, `aps`.
66
+ mintmatter aliases: `jacs`, `chem_mater`, `acs_nano` -> `acs`; `adv_mater`, `angew`, `am` -> `wiley`;
67
+ `ees`, `chem_sci` -> `rsc`; `prb`, `prl` -> `aps`; `nature_materials`, `nature_energy`,
68
+ `nature_catalysis` -> `nature`.
69
+
70
+ ## C3. Panel kinds
71
+
72
+ Every builder is a registered, data-carrying kind named `matter.<name>`:
73
+
74
+ `xrd`, `band_dos`, `spectrum`, `xps`, `cv`, `nyquist`, `reaction_profile`, `volcano`,
75
+ `convex_hull`, `ternary`, `isotherm`, `arrhenius`, `ashby`, `operando_contour`, `chem_space`,
76
+ `parity`, `periodic_table`, `micrograph`, `crystal`, `molecule`, `molecule3d`.
77
+
78
+ ```python
79
+ @matter_kind("xrd", positional=("two_theta", "intensity"), example=_example_xrd)
80
+ def xrd(two_theta, intensity, *, ...) -> Panel:
81
+ ...validate, compute facts...
82
+ return matter_panel("xrd", _draw, title=..., label=..., unit=..., height_mm=...,
83
+ describe=..., facts=[Fact(...)], measure_note=..., data={...})
84
+ ```
85
+
86
+ `matter_kind` (in `_core.py`):
87
+ - turns unknown or mis-passed arguments into `ExplainError` naming the valid ones;
88
+ - decodes `$array` / `$file` values in incoming arguments, so a loaded spec works;
89
+ - records the bound arguments as the panel's JSON spec (`panel.to_spec()` then round-trips);
90
+ - registers `matter.<name>` with mintfig;
91
+ - stores `example`, a zero-argument callable returning small, deterministic, valid keyword
92
+ arguments for the kind. The generic tests, the schema command and the docs all use it.
93
+
94
+ Existing public signatures stay backward compatible: add parameters, do not rename or remove.
95
+
96
+ ### Acceptance for a converted kind (enforced by `tests/test_all_kinds.py`, which discovers kinds)
97
+
98
+ 1. `mint.load(mint.explain("t", panel).to_spec())` rebuilds a figure whose panel spec is equal.
99
+ 2. Renders with `ship: true` and no `font_sizes` or `text_overlaps` issue at
100
+ `target="nature"` `width="single"` (89 mm) and `width="double"` (183 mm). The slow matrix adds
101
+ Science `single`, ACS `single` (84.6 mm) and the `obsidian` style. Always resolve widths by
102
+ preset name from `mintfig.specs.JOURNALS`; never hard-code a millimetre value for a journal.
103
+ 3. Bad input (a missing required argument, empty arrays, mismatched lengths, all-NaN data, wrong
104
+ types) raises `ExplainError` with a `fix_hint`, at construction, never another exception type.
105
+ 4. No rendered figure text shows raw markup (`E_g`, `R_wp`, `cm^-1`).
106
+ 5. The module passes the literal lint: no numeric literal passed as `fontsize=`, `labelsize=`,
107
+ `linewidth=`, `lw=`, `markersize=`, `ms=` or scatter `s=`. Sizes come from `MatterCtx`.
108
+
109
+ ## C4. Drawing context
110
+
111
+ ```python
112
+ @dataclass(frozen=True)
113
+ class MatterCtx:
114
+ theme: Theme
115
+ sizes: _Sizes # mintfig type scale for the active target
116
+ ctx: _Ctx # escape hatch
117
+ width_mm: float # width of this panel's cell
118
+ dark: bool
119
+ label_pt: float # axis labels = sizes.body
120
+ tick_pt: float # tick labels, legends = sizes.small
121
+ annot_pt: float # in-plot annotation, callouts
122
+ fine_pt: float # smallest permitted text = sizes.foot
123
+ def lw(self, pt: float) -> float # linewidth authored at screen scale, floored at the spec minimum
124
+ def ms(self, pt: float) -> float # marker size (points)
125
+ def area(self, pt2: float) -> float # scatter area (points squared)
126
+ def chem(self, text: str) -> str # mathtext form for in-axes text
127
+ ```
128
+
129
+ Draw callbacks have the signature `draw(ax: Axes, m: MatterCtx) -> None`. A panel may simplify
130
+ itself when `m.width_mm` is small (drop an inset or a secondary annotation); it may not shrink
131
+ text below `m.fine_pt`.
132
+
133
+ ## C5. Facts
134
+
135
+ ```python
136
+ @dataclass(frozen=True)
137
+ class Fact:
138
+ quantity: str # snake_case id: "band_gap", "r_wp", "mae"
139
+ value: float | str
140
+ unit: str = ""
141
+ item: str | None = None # the named thing it describes: phase, sample, series
142
+ method: str = "" # how it was obtained, one phrase
143
+ provenance: Literal["computed", "supplied"] = "computed"
144
+ text: str | None = None # sentence override; default is built from the fields
145
+ def sentence(self) -> str: ...
146
+ def to_dict(self) -> dict[str, Any]: ...
147
+ ```
148
+
149
+ - `panel.facts` (the strings mintfig reads out) are `[f.sentence() for f in facts]`.
150
+ - **Compute, do not accept.** If a quantity can be computed from the data passed in, compute it.
151
+ If the caller also supplies it, keep the supplied value as a second fact with
152
+ `provenance="supplied"`, and attach a `matter_fact_mismatch` issue (warning, `blocks_ship: False`,
153
+ message naming both values, a `fix_hint`) when they disagree beyond a stated tolerance.
154
+ - `mm.facts(exp)` returns every panel's structured facts.
155
+
156
+ ## C6. What the audit reads
157
+
158
+ `matter_panel(..., data=...)` attaches the validated arrays and derived values. After drawing, the
159
+ primary axes carries `ax._mintmatter`, an object with `.kind`, `.data` and `.facts`. Audit rules
160
+ for mintmatter panels read `ax._mintmatter.data`. The prototype's `_mintchem_*` flags are removed
161
+ as each module converts; nothing sets a "passed" flag for the audit to find.
162
+
163
+ ## C7. JSON codec
164
+
165
+ `to_jsonable` / `from_jsonable` in `_core.py`:
166
+ - arrays up to 20,000 elements become nested lists;
167
+ - larger arrays become `{"$array": {"dtype": ..., "shape": [...], "zlib_b64": "..."}}`, exact;
168
+ - a path argument becomes `{"$file": {"path": "...", "sha256": "..."}}`; loading verifies the hash
169
+ and raises `ExplainError` if the file is missing or changed.
170
+
171
+ ## C8. Rendering and modes
172
+
173
+ ```python
174
+ def render(takeaway, *panels, journal=None, columns="double", mode="explain",
175
+ style=None, palette=None, width=None, kicker=None, subtitle=None, source=None,
176
+ layout=None, density="regular") -> mint.Explanation | Manuscript
177
+ ```
178
+
179
+ - With `journal=`, the figure is built at that journal's exact column width
180
+ (`mint.explain(target=<JournalSpec>, width=columns)`), in its type scale. No journal: screen
181
+ target, `width` is a mintfig preset.
182
+ - `mode="explain"` keeps headline, kicker and source line. `mode="manuscript"` returns a
183
+ `Manuscript` (`.fig`, `.explanation`, `.caption`, `.save(path)`, `.bundle(out_dir)`,
184
+ `.summary()`, `.preflight()`): panel tags only, takeaway moved into the caption.
185
+ - No journal name or width is injected into the kicker.
186
+
187
+ ## C9. Text
188
+
189
+ `chem(text, form="mathtext" | "unicode" | "plain")` in `_text.py` formats formulae, sub/superscripts,
190
+ charges and units from a light markup (`CsPbI3`, `E_g`, `R_wp`, `E_{1/2}`, `cm^-1`, `Li^+`).
191
+ Rendered figure text never shows the raw markup. Text surfaces (`to_text`, alt text, captions,
192
+ fact sentences) use the plain form.
193
+
194
+ ## C10. Datasets and readers (`mintmatter.io`)
195
+
196
+ `mm.read(path, kind=None)` returns one of the frozen dataclasses below, sniffing by extension and
197
+ content. Unreadable or unrecognised input raises `ExplainError` with a `fix_hint`.
198
+
199
+ ```python
200
+ Structure(symbols, cart, cell, frac, spacegroup, formula, source) # cell is 3x3 or None
201
+ Pattern(x, y, sigma, x_kind, wavelength, calculated, background, reflections, source)
202
+ Spectrum(x, y, x_kind, x_unit, y_unit, source)
203
+ Echem(potential, current, time, cycle, capacity, mode, reference, source)
204
+ Impedance(frequency, z_real, z_imag, source)
205
+ Image(data, nm_per_px, meta, source)
206
+ ```
207
+
208
+ Built in: CIF (with symmetry operations), POSCAR/CONTCAR, XYZ/extXYZ, `.xy`/`.xye`/two-column
209
+ CSV, JCAMP-DX, BioLogic `.mpt`, Gamry `.DTA`, TIFF with resolution tags.
210
+ `_geometry.py`: `guess_bonds`, `find_polyhedra`, `complete_boundary`, `supercell`, `best_view`,
211
+ `reduced_formula`.
212
+
213
+ ## Rules for every lane
214
+
215
+ - Machine memory budget (24 GB): at most two heavy processes (test runner, production build,
216
+ headless browser, high-dpi gallery render) at once across all lanes. Delegated lanes do not
217
+ type-check. Test runners run single-worker (`-p no:xdist`). At most three build lanes run at once.
218
+ - Run only the named test files, never the whole mintfig suite, never the 17-plate showcase.
219
+ - Do not commit, stash, reset or check out. The tree is shared with other lanes.
220
+ - Scratch files go to the scratchpad path in your prompt, not the repo.
221
+ - Raise `mintfig.ExplainError` (via `_core.fail`) for user-facing errors.
222
+ - New data in fixtures is either authored from published parameters (cite the source in a comment)
223
+ or synthetic and named as such. Do not download datasets.
224
+
225
+ ## C11. Datasets as arguments
226
+
227
+ A builder with a natural dataset takes it, or a path to a file holding it, as its first positional
228
+ argument, through `matter_kind(..., expand=fn)`:
229
+
230
+ | Kind | Accepts | Kind | Accepts |
231
+ | :--- | :--- | :--- | :--- |
232
+ | `xrd` | `Pattern` (done; see `diffraction._expand_pattern`) | `micrograph` | `Image` |
233
+ | `spectrum` | `Spectrum` | `crystal` | `Structure` |
234
+ | `cv` | `Echem` | `molecule3d` | `Structure` |
235
+ | `nyquist` | `Impedance` | | |
236
+
237
+ `expand(value)` receives the path or dataset and returns keyword arguments (use
238
+ `_core.load_dataset(value, <Type>, "<arg name>")`). The recorded spec holds the expanded arrays,
239
+ so a saved figure does not depend on the file. Units follow `mintmatter.io` conventions (Å, V, mA,
240
+ s; `Impedance.z_imag` is signed, so Nyquist plots `-z_imag`).
241
+
242
+ ## Core API as built (authoritative signatures)
243
+
244
+ ```python
245
+ # mintmatter._core
246
+ class Fact: quantity, value, unit="", item=None, method="", provenance="computed", text=None
247
+ .sentence() -> str ; .to_dict() -> dict
248
+ QUANTITY_LABELS: dict[str, str] # quantity -> plain label used by sentence(); kinds add theirs
249
+ class MatterCtx: theme, sizes, ctx, width_mm, dark, label_pt, tick_pt, annot_pt, fine_pt, min_lw, cell_rect
250
+ .scale ; .width_em # cell width in label-size ems: ~36 at 89 mm, ~20 at 57 mm
251
+ .lw(pt) ; .ms(pt) ; .area(pt2) ; .chem(text) ; .accent(i=0)
252
+ .text_mm(text, pt, weight="normal") -> float
253
+ .refit(ax) ; .axes_mm(ax) -> (w, h)
254
+ MatterInfo(kind, data, facts) # ax._mintmatter
255
+ matter_kind(name, *, positional=(), example=None, expand=None)
256
+ matter_panel(kind, draw, *, title=None, label=None, unit=None, height_mm=64.0, min_height_mm=None,
257
+ describe=..., facts=(), measure_note=None, data=None, issues=(), stretch=True) -> Panel
258
+ matter_kinds() -> dict[str, builder] ; facts(exp) -> dict[str, list[Fact]]
259
+ fail(message, fix_hint, *, rule="matter_bad_input") -> NoReturn
260
+ as_1d(value, name, *, min_len=2, allow_nan=False, positive=False) -> ndarray
261
+ as_2d(value, name, *, min_shape=(1, 2), allow_nan=False) -> ndarray
262
+ as_float(value, name, *, positive=False, minimum=None, maximum=None) -> float
263
+ as_range(value, name, *, increasing=True) -> (lo, hi)
264
+ as_pairs(value, name, *, second=str, within=None) -> list[tuple[float, Any]]
265
+ one_of(value, name, choices) -> str ; same_length(**arrays) -> int
266
+ check_supplied(computed: Fact, value, *, rel_tol=0.1, abs_tol=0.0, method=...) -> (Fact, issue | None)
267
+ is_dataset_like(value) -> bool ; load_dataset(value, expected, name) -> dataset
268
+ to_jsonable(value) ; from_jsonable(value)
269
+
270
+ # mintmatter._text
271
+ chem(text, form="mathtext" | "unicode" | "plain", *, formulas=True) -> str
272
+
273
+ # mintmatter._style
274
+ clean_axes(ax, m, ...) ; annotate_box(...) # read the module for the exact options
275
+ ```
276
+
277
+ ## Converting a panel module (distilled from `diffraction.py`, the reference)
278
+
279
+ 1. Write `_example_<kind>()` returning small, deterministic, JSON-friendly keyword arguments
280
+ (lists, not arrays). Synthetic data is named as synthetic.
281
+ 2. Decorate with `@matter_kind("<kind>", positional=(...), example=_example_<kind>)`. Keep every
282
+ existing parameter name and default; only add.
283
+ 3. Validate first with the `as_*` helpers and `fail(msg, fix_hint)` for domain rules. NumPy and
284
+ Matplotlib must never be the one to raise.
285
+ 4. Compute facts from the data. For each caller-supplied value of a computable quantity, call
286
+ `check_supplied(computed_fact, value, rel_tol=...)`, keep the returned supplied `Fact`, and pass
287
+ any issue into `issues=`.
288
+ 5. `_draw(ax, m)` starts with `clean_axes(ax, m, ...)`. Set limits, ticks and axis labels
289
+ (`fontsize=m.label_pt`), then call `m.refit(ax)`; only after that measure with
290
+ `m.axes_mm(ax)` / `m.text_mm(...)` to place text.
291
+ 6. Every size comes from the context: `lw=m.lw(x)`, `ms=m.ms(x)`, `s=m.area(x)`,
292
+ `fontsize=m.annot_pt | m.tick_pt | m.label_pt`, never below `m.fine_pt`. No numeric literal for
293
+ those keywords, including `lw=0` (use `edgecolor="none"`).
294
+ 7. In-axes text goes through `m.chem(...)`. Title, label, unit and `measure_note` may carry the
295
+ light markup; `matter_panel` converts them. Headers cannot hold mathtext (mintfig blocks `$`),
296
+ so letter subscripts are written inline there (`Rwp`, `Eg`).
297
+ 8. Put the series key in `measure_note` ("observed (circles), calculated (line)"), not in a boxed
298
+ in-plot legend. `measure_note` describes the science and the encoding, never the renderer.
299
+ Coloured text uses `m.ctx.text_color(colour)`.
300
+ 9. Pass `data={...}` with the validated arrays and derived values. Remove the module's
301
+ `_mintchem_*` flags; the audit lane rewrites `audit.py` afterwards, so leave that file alone and
302
+ list in your report what each kind now exposes in `data`.
303
+ 10. When the cell is narrow (`m.width_em` below about 24), simplify: drop insets and secondary
304
+ annotations, shorten labels, switch crowded labels to vertical. Look at the 57 mm and 89 mm
305
+ renders, not only the test result.
306
+
307
+ ## C12. Agent surface
308
+
309
+ All of it works from JSON and file paths, returns structured results, and raises
310
+ `ExplainError` with a `fix_hint`. Exit codes follow mintfig: `0` ship, `1` fix, `2` error.
311
+
312
+ ```python
313
+ # mintmatter.agent (re-exported from mintmatter)
314
+ inspect(path) -> dict # what a file holds: dataset type, the numbers an agent can cite
315
+ # (formula, space group, cell, atom count; x range, point count,
316
+ # strongest peaks; cycles, scan range ...), suggested kind and call
317
+ auto(path_or_dataset, **kwargs) -> Panel # picks the kind from the dataset type
318
+ figure(spec_or_panels, *, files=None, takeaway=None, journal=None, columns="double",
319
+ mode="explain", style=None, out=None, bundle=None) -> dict
320
+ # {ship, issues, facts, alt_text, caption, spec, paths, size_mm}
321
+ edit(figure, *, takeaway=None, journal=None, columns=None, mode=None, style=None,
322
+ panels=None, drop=None, out=None) -> dict
323
+ # figure: spec dict, spec .json, or a PNG with an embedded spec;
324
+ # panels={"a": {"zone_axis": [0, 0, 1]}} re-runs that builder with
325
+ # the stored arguments patched
326
+ # mintmatter.schema
327
+ schema(kind=None) -> dict # JSON Schema per kind from the builder signature, with its example
328
+ ```
329
+
330
+ - CLI `mintmatter`: `inspect <file>`, `plot <files...>`, `schema [kind]`, `kinds`, `check <target>`
331
+ (`--review OUT [--fixed]` for specs and PNGs), `edit <figure>`; every command takes `--json`.
332
+ `figure`/`edit` (and `plot`/`edit`, the MCP tools) also take `width` (no journal), `source`,
333
+ `kicker`, `subtitle`, `layout`, kept in the spec.
334
+ - MCP: four tools, `matter_inspect`, `matter_figure`, `matter_check` (optional `review`,
335
+ `review_fixed`), `matter_edit`, registered into
336
+ mintfig's server through a new entry-point group `mintfig.mcp` (mintfig gains
337
+ `register_tool(definition, handler)`; mintmatter provides `mintmatter.mcp:register`).
338
+ - Skill: `skills/mintmatter/SKILL.md`, under 12 kB, with a picker keyed by the
339
+ question being asked; `llms.txt`.
340
+
341
+ ## C13. New panel kinds (Phase 4)
342
+
343
+ Same acceptance as C3. New kinds live in new modules, one family per module; they are not added to
344
+ existing panel modules. Each also needs at least one test that checks a computed fact against a
345
+ value known from how the fixture data was made.
346
+
347
+ | Module | Kinds |
348
+ | :--- | :--- |
349
+ | `battery.py` | `gcd` (voltage vs capacity by cycle), `dqdv`, `cycling` (capacity retention and coulombic efficiency), `rate_capability` |
350
+ | `kinetics.py` | `lsv` (polarisation curves), `tafel` |
351
+ | `xas.py` | `xanes`, `exafs` (k-space and R-space) |
352
+ | `insitu.py` | `pattern_stack` (stacked or waterfall patterns, in-situ series) |
353
+ | `eds.py` | `eds_map` (composite elemental map), `line_profile` |
354
+ | `dynamics.py` | `phonon` (dispersion with DOS), `rdf`, `msd` |
355
+ | `ml.py` | `learning_curve`, `parity_density` (10⁵–10⁶ points, rasterised density) |
356
+ | `phase.py` | `phase_diagram` (binary T–x), `pourbaix` |
357
+
358
+ ## C14. `Panel.quantities` (what the claim check binds)
359
+
360
+ `matter_panel` sets `panel.quantities = [fact_quantity(f) for f in facts]` (numeric facts only):
361
+
362
+ ```python
363
+ {"name": "Charge-transfer resistance Rct", "value": 42.18, "unit": "Ω cm²", "item": "Bare Ni foam",
364
+ "aliases": ["Rct", "charge transfer", ...], "provenance": "computed" | "supplied",
365
+ "how": "value" | "relative" | "difference" | "ratio", "quantity": "r_ct"}
366
+ ```
367
+
368
+ - `name` is the `QUANTITY_LABELS` label; `aliases` are `CLAIM_ALIASES[quantity]` plus the
369
+ label's head and symbol. A kind adds words with `CLAIM_ALIASES.update(...)`.
370
+ - mintfig's claim check (`src/mintfig/epistemic.py`, extension pools only) binds a takeaway
371
+ number to a quantity its clause names, else by item and unit, else by unit when one computed
372
+ quantity in the figure has that unit. A number stated as a condition ("at 0.90 V", "after 2 h")
373
+ never binds by unit alone; a number followed by a count noun ("30,000 components") binds only
374
+ to a count. "X per Y" reads as the unit X Y⁻¹ (decade → dec, gram → g, second → s, atom,
375
+ cycle, formula unit → f.u.).
376
+ - A bound number that disagrees is `claim_number_mismatch` (blocks `ship` under strict claims,
377
+ the mintmatter default); an unbound one is `claim_number_unverified`, never passed. A supplied
378
+ value cannot confirm what the computed one contradicts.
379
+
380
+ ## C15. Core hooks (`_core.py`)
381
+
382
+ ```python
383
+ matter_kind(name, *, positional=(), example=None, expand=None, spec=None)
384
+ matter_panel(..., height_mm=float | f(w) | f(w, sizes) | f(w, sizes, text_mm), frames=None, ...)
385
+ rebuild(kind, arguments) -> Panel # the builder again from stored (patched) arguments
386
+ kind_arguments(kind) -> tuple[str, ...] # the argument names it accepts
387
+ data(panel_or_figure) -> dict # a panel's audit data (public view of matter_data)
388
+ ```
389
+
390
+ - `expand(value)` receives a dataset, a path, or a list of them (`is_dataset_series`) and
391
+ returns keyword arguments, or `None` to leave the call alone.
392
+ - `spec(recorded, panel) -> dict` rewrites the recorded spec once the panel is built (a compact
393
+ form: `parity_density`'s binned counts, `micrograph`'s image at its natural integer width).
394
+ It must return arguments the builder accepts.
395
+ - Required spec keys (mintfig's loader and `schema()["required"]`) are the positional arguments
396
+ without a default; `parity_density` (`binned=`) and `line_profile` (`maps=`) have none.
397
+ - `height_mm` as a callable gets the cell width in screen mm (multiply by `sizes.scale` for
398
+ print) and returns screen mm; the three-argument form also gets `text_mm(text, pt,
399
+ weight="normal")`, the printed width of text as `MatterCtx.text_mm` measures it.
400
+ - `frames(ctx, ax, rect) -> [(axes, bbox), ...]` lists extra axes mintfig refits with the panel.
401
+ - A stretching panel with no `min_height_mm` may be compressed to max(`MIN_READABLE_MM` = 30,
402
+ half its natural height) screen mm when the figure is too tall for its target.
403
+ - Draw callbacks report an advisory with `m.advise(message, fix_hint, rule=...)`, never by
404
+ appending to `m.ctx.issues`; `_style.advise_dropped(m, label, what)` for a dropped label.
405
+ - Modules do not import each other's private helpers; shared ones live in `_style.py` / `_core.py`.
406
+
407
+ ## C16. Where a finding points (`where`)
408
+
409
+ An audit issue may carry `where = {"part": "xaxis" | "yaxis" | "image" | "colorbar" | "text" |
410
+ "inset" | "axes", "text": ..., "axes_compared": [i, j, ...]}` (any subset). A rule registered
411
+ with `rule(..., part=...)` gives every finding that part; a message built with
412
+ `rules.finding(message, part=, text=, axes_compared=)` carries its own. `mm.review` anchors a
413
+ marker from `where` and falls back to reading the message when it is absent. `check_matter`
414
+ reports a mintfig finding that repeats a mintmatter one (`audit.SAME_DEFECT`) once, as the
415
+ mintmatter finding, with the other listed under `duplicates`.
416
+
417
+ ## C17. Label placement (`_style.py`)
418
+
419
+ - `LabelPlacer(ax, m, pt=None, *, margin_mm=0.5)`: build after limits are final and `m.refit`
420
+ has run. Obstacles in canvas mm: `add_points(x, y, r_mm)`, `add_line(x, y, r_mm)`,
421
+ `add_path(x, y, width_mm)`, `add_zero_line()`, `add_box_mm(box)`.
422
+ - `place(Label(x, y, text, color, weight, prefs, gap_mm, optional, leaders), tiers=...) -> Spot`
423
+ tries `prefs` (names in `LABEL_DIRS`) at growing distances, then (nothing usable near) up to
424
+ three label heights further; draw it with `draw_label(ax, m, spot, pt)`. `None` for an
425
+ optional label with no clear spot, and for any label whose least-bad spot would cover another
426
+ label (the placer reports that one as `matter_label_dropped`).
427
+ - `place_offsets(anchor, lines, pt, offsets, *, weight, leader_from) -> (x, y, ha, va, leader)`
428
+ takes the first clear caller-ordered offset (`ring_offsets(step_mm)`); `None` when none is clear.
429
+ - `place_peak_tags(ax, m, x, curves, tags, ylim, xlim)` puts reflection labels over peaks.
430
+ - A label with no clear spot is not drawn; report it with `advise_dropped`. `NARROW_EM`
431
+ (24 label ems) is where a panel simplifies.
432
+
433
+ ## C18. Slide targets (`slides.py`)
434
+
435
+ - `slide_16x9` (`16x9`, `16:9`, `widescreen`; 338.67 × 190.5 mm, 1920 px at 1x) and `slide_4x3`
436
+ (`4x3`, `4:3`, `standard`; 254 × 190.5 mm, 1440 px) are `JournalSpec`s built in mintmatter and
437
+ registered as profiles (default style `mintfig`); mintfig's `JOURNALS` is not touched. The bare
438
+ word `slide` is not an alias (mintfig's 240 mm `width="slide"`).
439
+ - Regions (width presets) are computed: 4% side margins, 3% gutters; `full`, `two_thirds`,
440
+ `half`, `third`. The default region is `two_thirds`: `double` -> `two_thirds`, `single` ->
441
+ `half`. `max_height_mm` = height × 0.74 (title band 20%, bottom margin 6%);
442
+ `max_page_height_mm` = height × 0.88. `slide_regions(target)` returns widths in mm and 1x px.
443
+ - Type and strokes (house defaults): body 18, tick and legend 16, panel label 20 bold, min 14,
444
+ max 28 pt; axes 1.25, data 2.5, min 0.75 pt; PNGs at 288 dpi (2x).
445
+ - An explain figure is laid out on `SlideTarget.headline_spec` (`max_height_mm` = the page
446
+ height: its headline is the slide's title); a manuscript figure on the registered spec. On a
447
+ slide target the render result also has `.title` (takeaway), `.notes` (caption) and `.size_px`
448
+ (1x); the agent payload adds `size_px`.
449
+ - The gate (`slides.slide_findings`, called by `check_matter`, so `Manuscript.audit` and the
450
+ payload apply it): `matter_slide_overflow` (blocking; the height the content needs, the
451
+ manuscript strip's squeeze undone) replaces mintfig's chat-worded `too_tall`;
452
+ `hairline_strokes` blocks; more than three panels is `matter_slide_many_panels` (warning;
453
+ mintfig's `many_panels` folds into it). Panels never special-case a slide: they respond to
454
+ `m.width_em` and `m.scale`.
@@ -0,0 +1,35 @@
1
+ # mintmatter — Materials & Chemistry Figures for Coding Agents
2
+
3
+ Use `mintmatter` whenever the data are materials or chemistry results (crystal structures, CIF/POSCAR/XYZ files, XRD/Rietveld or in-situ patterns, FTIR/Raman/UV-vis/NMR/XPS/XAS spectra, CV/LSV/Tafel/EIS/GCD/dQ/dV/cycling electrochemistry, micrographs and EDS maps, convex hulls and phase diagrams, catalysis free-energy or volcano plots, MD/phonons, or MLIP parity/learning curves) and a person needs a figure, an exact-millimetre journal/slide figure, a domain review of a Matplotlib plot, or citable facts from a file.
4
+
5
+ ## Escalation Rules
6
+
7
+ - **1–3 scalar numbers or routine coding tasks** → reply in prose. Do **not** plot.
8
+ - **Inline word-sized sparklines, intervals, or terminal/PR tables** → use `mintchip`.
9
+ - **General charts (benchmarks, ablations, business metrics)** → use `mintfig`.
10
+ - **Materials & chemistry figures, scientific files, journal plates (`nature`, `science`, `acs`/`jacs`, `wiley`/`adv_mater`, `rsc`, `aps`/`prb`), or reviewer sheets** → use `mintmatter`.
11
+
12
+ ## MCP Tools (`uvx --from mintmatter mintfig mcp`)
13
+
14
+ Installing `mintmatter` automatically registers 4 materials tools into `mintfig mcp` via the `mintfig.mcp` entry point:
15
+
16
+ - **`matter_inspect`** — Read a data file (CIF, POSCAR/CONTCAR, XYZ/extXYZ, `.xy`/`.xye`/CSV, JCAMP-DX, BioLogic `.mpt`, Gamry `.DTA`, TIFF) and return citable `facts`, unstated conditions, `suggested_kind`, and a ready panel spec without drawing anything.
17
+ - **`matter_figure`** — Build and check a figure from `files` and/or `panels` specs (`takeaway`, `journal`, `columns`, `mode`, `style`, `out`, `bundle`, `strict_claims`). Returns `ship`, `issues` with `fix_hint`, `facts`, `alt_text`, `caption`, `spec`, PNG, and `ui://mintfig/figure` App view.
18
+ - **`matter_check`** — Rebuild and audit a saved `.json`/`.png` figure (optionally writing a reviewer sheet with `review=` / `review_fixed=true`), or execute a `.py`/`.ipynb` script in a subprocess (timeout, closed stdin, user permissions — not a sandbox).
19
+ - **`matter_edit`** — Re-render a saved figure from its spec with changes (`figure`, `panels` argument patches, `journal`, `columns`, `mode`, `style`, `takeaway`, `drop`, `out`) without resending data.
20
+
21
+ ## CLI Quick Reference
22
+
23
+ - `mintmatter inspect LiCoO2.cif --json`
24
+ - `mintmatter plot LiCoO2.cif scan.xye --journal nature --columns double --takeaway "..." --out fig.png`
25
+ - `mintmatter edit fig.png --set 'a.zone_axis=[0,0,1]' --journal jacs --columns single --out fig_acs.png`
26
+ - `mintmatter check fig.png --review review.png --fixed`
27
+ - `mintmatter kinds` / `mintmatter schema xrd` / `mintmatter --version`
28
+
29
+ ## Non-Negotiable Quality Rules
30
+
31
+ 1. **Quote computed `facts`:** Never invent or retype a number the panel computes.
32
+ 2. **Strict claims by default:** A takeaway number that contradicts a computed fact blocks `ship` (`claim_number_mismatch`).
33
+ 3. **Never treat `claim_number_unverified` as passed:** Verify unbound numbers against `facts` before citing them.
34
+ 4. **Never guess missing conditions:** Report unstated wavelength, pixel size, reference electrode, or scan rate rather than assuming defaults.
35
+ 5. **Respect `ship: true`:** Fix `blocks_ship` issues via `fix_hint` before delivering.
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Ben Blaiszik
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.