Repository navigation
feat(policy): data licensing policy + CI license gate (#174) - #184
Merged
Merged
Conversation
Lands the licensing policy + automated enforcement that turns the `_sources.<key>.license` field (added in #150) from "parsed" into "required for merge." docs/data-policy.md: - Legal context (Feist, EU sui generis) - Allowed licenses: CC0, PD-USGov, CC-BY-4.0, CC-BY-SA-4.0, proprietary-reference-only (transitional `unknown` blocked at merge) - Off-limits sources: MatWeb, CRC Handbook, ASM Handbook bulk, Engineering ToolBox, vendor PDFs - LICENSES-DATA.md auto-generation contract scripts/check_licenses.py (stdlib-only): - Walks every `[<material>._sources]` entry across src/pymat/data/*.toml (recursively, including nested property-group sub-tables) - Validates `license` field present + in allow-list, blocks merge on missing/unknown/invalid - `--emit-attributions` mode prints LICENSES-DATA.md content to stdout (deterministic, sorted by citation, dedup'd by citation key) .github/license-ratchet.txt: - Empty placeholder for #175 audit window. Lists repo-relative TOML paths exempted from the gate. MUST be deleted as the final step of #175 — ratchet self-deletes rather than feature-flag-on-forever (per ADR-0003 §4). CI wiring: - .pre-commit-config.yaml: new `check-licenses` local hook (stdlib Python, no install needed) on changes to data TOMLs / script / ratchet - .github/workflows/ci.yml: new `check-licenses` job + threaded into `summary.needs` so a failing license check blocks the merge CONTRIBUTING.md: Provenance section rewritten — `_sources` table example with `license` field, link to data-policy.md, off-limits summary. LICENSES-DATA.md: generated initial state (no CC-BY sources yet). Tests: tests/test_check_licenses.py (16 tests) — empty corpus, no-sources, valid license, missing license, unknown license, invalid license, every allowed license, nested sources, ratchet exemption, emit-attributions (no-CC, with-CC, dedup). Closes #174
6 tasks
3 tasks done
gerchowl
added a commit
that referenced
this pull request
May 6, 2026
Bundles four schema-foundation feats merged after 3.9.0 plus the Vis public-API clarification into a single release: - feat(schema): _sources provenance table (#150 / #182) - feat(schema): _stddev sibling sugar + ufloat boundary helper (#149 / #183) - feat(policy): data licensing policy + CI license gate (#174 / #184) - feat(schema): T-dependent property curves (#148 / #185) - fix(vis): declare Vis as public API (#98 / #186) Three feats × one fix → minor version bump per semver. The version 3.9.1 originally proposed for the Vis public-API change alone became inconsistent once the four schema feats had landed on main without their own release cut, so they're rolled into 3.10.0 honestly rather than shipped as a misleading patch. CHANGELOG entry for 3.10.0 covers all five items with PR + issue links. .release-please-manifest.json synced to 3.10.0 so the open release-please PR (#80) recomputes correctly going forward.
gerchowl
added a commit
that referenced
this pull request
May 6, 2026
…) (#203) Adds `scripts/enrich_from_nist_webbook.py`, a comparison + add-only writeback enricher for the five fluids that overlap between `src/pymat/data/{gases,liquids}.toml` and the NIST Chemistry WebBook: water (liquid), nitrogen, argon, helium, co2 (gas). NIST has no JSON API; the script hits the IsoBar TSV endpoint (`fluid.cgi?Action=Data&Type=IsoBar`) at a fixed pressure of 1.01325 bar (1 atm) over a 5 K range straddling the target temperature, then selects the row matching the target. Targets: T=293.15 K for water (liquid phase), T=298.15 K for the gases (STP). The (T, P) point and the `Lemmon REFPROP equation of state` provenance are pinned in every `_sources.note`. Properties enriched (only those already in the schema): * mechanical.density (kg/m³ → g/cm³) * thermal.specific_heat (J/(g·K) → J/(kg·K)) * thermal.thermal_conductivity (W/(m·K), identity) Viscosity is in the WebBook payload but the runtime schema has no viscosity field today — skipped rather than invented. Temperature curves are out of scope (separate Phase-4 follow-up). Behaviour mirrors the other enrichers (#197/#198/#200/#201): * Default: comparison-only (DIFF threshold 2%). * --write: ADD-ONLY; existing values are NEVER overwritten. * --dry-run / --key / --report flags identical to the siblings. * Uses `cached_get_text` (30-day TTL) so NIST's polite-traffic expectations are respected; uses `build_source_row` and `writeback` from `scripts/_curation.py`. `_sources` rows: license = "PD-USGov" (allow-listed since #184), kind = "handbook", citation includes the species, ref pins `webbook.nist.gov:fluid.cgi?ID=<CAS>`. The report footer carries the NIST AS-IS notice. Attribution is not legally required for PD-USGov, and `LICENSES-DATA.md` only enumerates CC-BY/CC-BY-SA sources, so no edit there. Live run against the 5 fluids: 0 MISSING (every field is already curated), 1 DIFF (helium thermal_conductivity at 2.1% vs NIST 0.15531 W/(m·K)). The other 14 cells are within 2% of NIST. All existing values are preserved. Tests: `tests/test_nist_webbook_enrichment.py` (11 cases) covers TSV parsing, fixture-based --dry-run (offline via monkeypatched `cached_get_text`), --write add-only, no-overwrite semantics, comment round-trip, --report file output, and the PD-USGov allow-list canary. Fixture `tests/fixtures/nist_webbook_water.txt` holds a trimmed real WebBook response (header + 2 rows) so the test suite runs fully offline. Closes #159
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Lands the licensing policy + automated enforcement that turns the
_sources.<key>.licensefield (added in #150) from "parsed" into "required for merge."docs/data-policy.md(new)scripts/check_licenses.py(new)_sourcesentry, blocks on missing/unknown/invalid license.github/license-ratchet.txt(new).pre-commit-config.yamlcheck-licenseslocal hook on data/ + script/ + ratchet changes.github/workflows/ci.ymlcheck-licensesjob, threaded intosummary.needsCONTRIBUTING.md_sourcesexample withlicense, off-limits summaryLICENSES-DATA.md(new)tests/test_check_licenses.py(new)Allowed
licensevaluesCC0,PD-USGov,CC-BY-4.0,CC-BY-SA-4.0,proprietary-reference-only. The transitional valueunknownis parseable but blocked at merge.Audit-window strategy (per ADR-0003 §4)
.github/license-ratchet.txtships empty. During #175 (the one-time corpus sweep), entries can be added as work-in-progress markers. The file MUST be deleted as the final step of #175 — ratchet rather than feature-flag-on-forever, so we can't accidentally leave the gate disabled.Failure UX
Each error names
file:material._sources.keyand the offending value:Test plan
pytest tests/test_check_licenses.py— 16 tests passpython scripts/check_licenses.py— passes against current corpus (no_sourcesblocks yet)python scripts/check_licenses.py --emit-attributions— produces deterministic outputruff checkcleanruff formatno diffRisks / regressions considered
Path.relative_to(REPO_ROOT)in tests — handled bytry/except ValueErrorfallback to absolute path so tmp_path test corpora work..github/license-ratchet.txtis read at runtime;# commentsand blank lines ignored; ships empty.needslist andFAILEDchecks so a failing license gate blocks the rollup status check.language: pythonfor the local hook — uses isolated interpreter; no need for pymat install.Closes #174
Part of the schema foundation series: #150 (merged) → #149 (merged) → #148 (queued) → #174.