Skip to content

Guard element-enum CHEBI groundings (close the gate gap from #206/#207) - #208

Merged
realmarcin merged 1 commit into
mainfrom
test/element-enum-grounding-guard
Jul 19, 2026
Merged

Guard element-enum CHEBI groundings (close the gate gap from #206/#207)#208
realmarcin merged 1 commit into
mainfrom
test/element-enum-grounding-guard

Conversation

@realmarcin

Copy link
Copy Markdown
Contributor

Why

Enum meaning: groundings are not covered by any id↔label gate —
validate-products only checks record-level term.{id,label} pairs. That blind
spot 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 the validate-strict
pytest step
(already a blocking CI gate) with no network:

  1. test_meanings_match_expected — freezes the verified-correct meaning: id
    for every MetalElementEnum + RareEarthElementEnum value, so any future
    hand-edit that changes an id must consciously update the golden map.
  2. test_no_shared_meaning — asserts no two element PVs share a CHEBI id; an
    ontology-free invariant that directly catches the swap/dup pattern (THULIUM and
    DYSPROSIUM both CHEBI:33377, etc.).
  3. test_meanings_resolve_to_element_label — resolves each id against its
    canonical 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:

enum wrong id ChEBI label flagged
PALLADIUM CHEBI:33373 promethium atom
INDIUM CHEBI:49464 aluminium trifluoride
YTTRIUM CHEBI:49976 zinc dichloride

Scope / follow-up

Deliberately scoped to the two element enums (kept clean + exception-free). A
KB-wide guard over every enum meaning: via linkml-term-validator validate-schema is still blocked by the same no-exceptions limitation that defers
validate-terms-all (it fails on obsolete/unminted meanings elsewhere) — logged
in NEXT_TASKS.md §0.

Verification

  • just test201 passed (was 197)
  • just lint — black + ruff + mypy clean

🤖 Generated with Claude Code

Copilot AI review requested due to automatic review settings July 19, 2026 03:34

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.

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
realmarcin force-pushed the test/element-enum-grounding-guard branch from ea9f3e0 to 1e4648c Compare July 19, 2026 03:34
@realmarcin
realmarcin merged commit e4adfaf into main Jul 19, 2026
2 checks passed
@realmarcin
realmarcin deleted the test/element-enum-grounding-guard branch July 19, 2026 03:36
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