Skip to content

Generalise enum-grounding guard to every grounded enum (auto-discovery) - #209

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

Generalise enum-grounding guard to every grounded enum (auto-discovery)#209
realmarcin merged 1 commit into
mainfrom
test/generalise-enum-grounding-guard

Conversation

@realmarcin

Copy link
Copy Markdown
Contributor

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-level term.id bindings
across community files, a different surface. Enum meaning: groundings are a
small, closed set and can be guarded directly.

Survey

Only 3 enums carry meaning: at all:

enum grounded values ontology
MetalElementEnum 17 CHEBI
RareEarthElementEnum 16 CHEBI
CultivationSystemEnum 1 (BIOREACTOR_UNSPECIFIED → OBI:0001046 "bioreactor") OBI

What

Renamed tests/test_element_enum_groundings.pytests/test_enum_groundings.py
and made it auto-discover every grounded enum from the schema instead of
hardcoding the element enums. Runs in the validate-strict pytest step (already a
blocking gate), no network:

  1. test_all_meanings_match_expected — full discovered {enum: {value: meaning}} must equal the frozen EXPECTED. A changed id, a new/removed
    grounded value, or a whole new grounded enum all fail here until registered
    and re-verified.
  2. test_no_shared_meaning_within_enum — no two values inside one enum share
    an ontology id (catches the swap/dup pattern directly).
  3. test_meanings_resolve_canonically — each id resolves to a non-obsolete
    term 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 test200 passed
  • just lint — black + ruff + mypy clean
  • Canonical-label check exercised against both CHEBI and OBI locally

🤖 Generated with Claude Code

Copilot AI review requested due to automatic review settings July 19, 2026 20:28

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.

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>
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