Generalise enum-grounding guard to every grounded enum (auto-discovery) - #209
Merged
Merged
Conversation
A survey found only 3 enums carry `meaning:` groundings: MetalElementEnum (17
CHEBI), RareEarthElementEnum (16 CHEBI), and CultivationSystemEnum (1 OBI —
BIOREACTOR_UNSPECIFIED -> OBI:0001046 "bioreactor"). The validate-terms-all
blocker cited when deferring this is about data-level term.id bindings across
community files, a different surface, so it does not block an enum-meaning guard.
Rename tests/test_element_enum_groundings.py -> tests/test_enum_groundings.py and
make it auto-discover every grounded enum from the schema (rather than hardcoding
the two element enums), so a newly grounded enum/value is covered automatically or
fails until registered in EXPECTED:
- full discovered {enum: {value: meaning}} must equal the frozen EXPECTED;
- no two values inside one enum share an ontology id (catches swaps/dupes);
- each id resolves to a non-obsolete term whose canonical label fits (element name
must appear for the element enums), per prefix, skipped when that ontology's
sqlite isn't cached locally so CI never pulls multi-GB.
Now covers CHEBI + OBI. 200 tests pass; lint clean.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
realmarcin
force-pushed
the
test/generalise-enum-grounding-guard
branch
from
July 19, 2026 20:28
1b60aa6 to
1876415
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
Follow-up to #208. That guard was scoped to the two element enums. The deferred
"generalise it" item was noted as blocked by the same limitation that defers
validate-terms-all— but that blocker is about data-levelterm.idbindingsacross community files, a different surface. Enum
meaning:groundings are asmall, closed set and can be guarded directly.
Survey
Only 3 enums carry
meaning:at all:MetalElementEnumRareEarthElementEnumCultivationSystemEnumBIOREACTOR_UNSPECIFIED→ OBI:0001046 "bioreactor")What
Renamed
tests/test_element_enum_groundings.py→tests/test_enum_groundings.pyand made it auto-discover every grounded enum from the schema instead of
hardcoding the element enums. Runs in the
validate-strictpytest step (already ablocking gate), no network:
test_all_meanings_match_expected— full discovered{enum: {value: meaning}}must equal the frozenEXPECTED. A changed id, a new/removedgrounded value, or a whole new grounded enum all fail here until registered
and re-verified.
test_no_shared_meaning_within_enum— no two values inside one enum sharean ontology id (catches the swap/dup pattern directly).
test_meanings_resolve_canonically— each id resolves to a non-obsoleteterm whose canonical label fits (element name must appear for element enums),
per ontology prefix, skipped when that prefix's OAK sqlite isn't cached
locally so CI never pulls multi-GB. Now covers CHEBI and OBI.
Scope note
A full LinkML-native gate over term.id data bindings (
validate-terms-all)remains deferred — unchanged, and genuinely blocked by the no-exceptions residuals
(see
NEXT_TASKS.md§1). This PR only concerns enum-meaning groundings.Verification
just test— 200 passedjust lint— black + ruff + mypy clean🤖 Generated with Claude Code