Skip to content

Fix PALLADIUM CHEBI enum: CHEBI:33373 (promethium) → CHEBI:33363 (palladium) - #206

Merged
realmarcin merged 1 commit into
mainfrom
fix/palladium-chebi-enum
Jul 19, 2026
Merged

Fix PALLADIUM CHEBI enum: CHEBI:33373 (promethium) → CHEBI:33363 (palladium)#206
realmarcin merged 1 commit into
mainfrom
fix/palladium-chebi-enum

Conversation

@realmarcin

Copy link
Copy Markdown
Contributor

Problem

MetalElementEnum.PALLADIUM in the LinkML schema was grounded to CHEBI:33373, which is actually promethium atom — not palladium. The id sits in a run of sequential CHEBI ids shared with the lanthanides (NEODYMIUM 33372, TERBIUM 33374, GADOLINIUM 33375…), a classic copy-paste / off-by-one grounding error. The correct term is CHEBI:33363 ("palladium"), confirmed via OAK.

Fix

  • src/communitymech/schema/communitymech.yamlPALLADIUM meaning: CHEBI:33373CHEBI:33363
  • src/communitymech/datamodel/communitymech.py — regenerated (just gen-python)
  • src/communitymech/metal_extraction.py — corrected the parallel METAL_CHEBI_MAP key

The curated community YAMLs already cited the correct CHEBI:33363 in their term.{id,label} pairs, so no data records needed editing — the bug was confined to the schema's authoritative enum grounding.

Verification

  • just validate-all — clean (exit 0)
  • just test — 197 passed

🤖 Generated with Claude Code

MetalElementEnum.PALLADIUM was grounded to CHEBI:33373, which is actually
"promethium atom" — one of a run of sequential CHEBI ids shared with the
lanthanides, a copy-paste/off-by-one grounding error. The correct term is
CHEBI:33363 ("palladium"), confirmed via OAK.

- schema/communitymech.yaml: PALLADIUM meaning -> CHEBI:33363
- datamodel/communitymech.py: regenerated (just gen-python)
- metal_extraction.py: fix parallel METAL_CHEBI_MAP key

Community YAMLs already cited CHEBI:33363 in their term.{id,label} pairs, so
no data records needed changing. validate-all clean; 197 tests pass.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Copilot AI review requested due to automatic review settings July 7, 2026 21:09

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

@realmarcin
realmarcin merged commit 5e1d9f8 into main Jul 19, 2026
4 checks passed
@realmarcin
realmarcin deleted the fix/palladium-chebi-enum branch July 19, 2026 01:58
realmarcin added a commit that referenced this pull request Jul 19, 2026
…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 added a commit that referenced this pull request Jul 19, 2026
…tion) (#207)

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 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>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants