Guard element-enum CHEBI groundings (close the gate gap from #206/#207) - #208
Merged
Conversation
Enum `meaning:` groundings aren't covered by validate-products (which only checks
record-level term.{id,label} pairs), which is why PALLADIUM→promethium (#206) and
13 REE/INDIUM mis-groundings (#207) drifted undetected.
Add tests/test_element_enum_groundings.py, which runs in the validate-strict
pytest step (already a blocking CI gate) with no network:
- freezes the verified meaning: ids for MetalElementEnum + RareEarthElementEnum
so a bad hand-edit fails;
- asserts no two element PVs share a CHEBI id (catches the swap/dup pattern);
- resolves each id against its canonical ChEBI label (element name must appear),
but only when the ChEBI sqlite is already cached locally, so it never forces a
multi-GB download in CI.
Verified the label check flags all three historical bugs (PALLADIUM CHEBI:33373
promethium, INDIUM CHEBI:49464 aluminium trifluoride, YTTRIUM CHEBI:49976 zinc
dichloride). A KB-wide guard over every enum via linkml-term-validator remains
deferred (same no-exceptions blocker as validate-terms-all) — noted in NEXT_TASKS.
201 tests pass (was 197); lint clean.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
realmarcin
force-pushed
the
test/element-enum-grounding-guard
branch
from
July 19, 2026 03:34
ea9f3e0 to
1e4648c
Compare
This was referenced Jul 31, 2026
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.
Why
Enum
meaning:groundings are not covered by any id↔label gate —validate-productsonly checks record-levelterm.{id,label}pairs. That blindspot is exactly why PALLADIUM → promethium (#206) and 13 rare-earth/INDIUM
mis-groundings (#207) drifted in undetected. This closes the gap for the element
enums so the class can't regress.
What
New
tests/test_element_enum_groundings.py, running in thevalidate-strictpytest step (already a blocking CI gate) with no network:
test_meanings_match_expected— freezes the verified-correctmeaning:idfor every
MetalElementEnum+RareEarthElementEnumvalue, so any futurehand-edit that changes an id must consciously update the golden map.
test_no_shared_meaning— asserts no two element PVs share a CHEBI id; anontology-free invariant that directly catches the swap/dup pattern (THULIUM and
DYSPROSIUM both
CHEBI:33377, etc.).test_meanings_resolve_to_element_label— resolves each id against itscanonical ChEBI label (the element name must appear), but only when the
ChEBI sqlite is already cached locally, so it never forces a multi-GB download
in CI. This is the check that catches a wrong id at source.
Verified check #3 flags all three historical bugs:
Scope / follow-up
Deliberately scoped to the two element enums (kept clean + exception-free). A
KB-wide guard over every enum
meaning:vialinkml-term-validator validate-schemais still blocked by the same no-exceptions limitation that defersvalidate-terms-all(it fails on obsolete/unminted meanings elsewhere) — loggedin
NEXT_TASKS.md§0.Verification
just test— 201 passed (was 197)just lint— black + ruff + mypy clean🤖 Generated with Claude Code