Fix 13 wrong REE/INDIUM CHEBI enum groundings - #207
Merged
Conversation
…tion) Auditing MetalElementEnum + RareEarthElementEnum after the PALLADIUM fix (#206) found 13 more wrong `meaning:` groundings — the ids had drifted off-by-one within the CHEBI:333xx lanthanide block, plus a couple of digit transpositions (e.g. INDIUM CHEBI:49464 = aluminium trifluoride; YTTRIUM CHEBI:49976 = zinc dichloride; SAMARIUM<->TERBIUM and THULIUM<->DYSPROSIUM swaps). Same class of copy/paste error as PALLADIUM. Ground every rare-earth element to its (3+) cation, matching each enum `description:` "X(3+) cation" (this also normalises the previously atom-grounded Nd/Gd/Lu/Sc to their cation ids). Dy/Er/Tm have no (3+) term in ChEBI, so they stay atom-grounded with descriptions annotated to say so. - schema/communitymech.yaml: 13 REE + INDIUM meanings repointed - datamodel/communitymech.py: regenerated (just gen-python) - metal_extraction.py: REE_CHEBI_MAP + METAL_CHEBI_MAP (INDIUM) mirror fixed - NEXT_TASKS.md: log the finding; item 1 (this fix) done, item 2 (a guard test validating enum meanings against canonical labels) left deferred Shipped records ground REEs via their own term.{id,label} pairs and were already correct, so the KGX export was unaffected; the bug lived in the schema enum + the mirror map. Re-audit: 0 mismatches. validate-all clean; 197 tests pass. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
realmarcin
force-pushed
the
fix/ree-indium-chebi-groundings
branch
from
July 19, 2026 02:49
d345f10 to
b627208
Compare
realmarcin
added a commit
that referenced
this pull request
Jul 19, 2026
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
added a commit
that referenced
this pull request
Jul 19, 2026
… (#208) 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>
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.
Problem
Follow-up to #206 (PALLADIUM). Auditing the full
MetalElementEnum+RareEarthElementEnum(eachmeaning:id vs its current ChEBI label) found thepalladium bug was not isolated — 13 more wrong groundings, almost all in
the rare-earth block. The ids had drifted off-by-one within the
CHEBI:333xxlanthanide range, plus a couple of digit transpositions:
¹ ChEBI has no
(3+)cation term for Dy/Er/Tm — grounded to the atom, description annotated.Decision
Ground REEs as the
(3+)cation to match every enumdescription:"X(3+)cation". This also normalises the four entries that happened to already resolve
(Nd/Gd/Lu/Sc) from the atom form to their cation ids, making the enum internally
consistent.
Why it drifted undetected
Enum
meaning:groundings are not covered byvalidate-products, which onlychecks record-level
term.{id,label}pairs. The shipped REE records ground viatheir own (correct) term pairs — e.g.
Ion_Adsorption_REE_Indigenous_Community.yamluses
CHEBI:33377/CHEBI:49962— so the KGX export was unaffected; the buglived purely in the schema enum + the
metal_extraction.pymirror map. Closingthat gate gap (a test validating enum meanings against canonical labels) is logged
as a deferred follow-up in
NEXT_TASKS.md§0 item 2.Changes
schema/communitymech.yaml— 13 REE + INDIUMmeaning:ids repointeddatamodel/communitymech.py— regenerated (just gen-python)metal_extraction.py—REE_CHEBI_MAP+METAL_CHEBI_MAP(INDIUM) mirrorNEXT_TASKS.md— finding logged; this fix marked done, guard-test follow-up deferredVerification
linkml-validateon all REE-using records: cleanjust test— 197 passed🤖 Generated with Claude Code