Skip to content

Fix controlled term base activation for schema versions#89

Merged
ehennestad merged 17 commits intomainfrom
codex-controlled-term-version-tolerant
Apr 28, 2026
Merged

Fix controlled term base activation for schema versions#89
ehennestad merged 17 commits intomainfrom
codex-controlled-term-version-tolerant

Conversation

@ehennestad
Copy link
Copy Markdown
Collaborator

@ehennestad ehennestad commented Apr 28, 2026

Summary

  • Add private versioned controlled-term base classes for controlledTerms v2 and v3
  • Activate the mapped base when selecting an openMINDS model version
  • Clear MATLAB class definitions on version switches so the copied superclass is reloaded
  • Add focused unit coverage for controlled-term construction and version-specific properties

Verification

  • /Applications/MATLAB_R2025b.app/bin/matlab -batch "addpath(fullfile(pwd,'code')); startup('latest'); addpath(genpath(fullfile(pwd,'tools','tests'))); results = runtests('tools/tests/unitTests/ControlledTermTest.m'); assertSuccess(results);"
  • Same-session smoke: latest controlledTerms v3 -> v4 controlledTerms v2 -> latest

Stacked on #90. Note: AGENTS.md was intentionally not included in this PR.

"contactInformation", contacts(person.email) };

if ommtest.oneoffs.currentSchemaMajorVersion() >= 5
personArguments = [personArguments, { ...
@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented Apr 28, 2026

Test Results (R2021b)

700 tests  +5   692 ✅ +2   2m 4s ⏱️ -7s
 17 suites +1     0 💤 ±0 
  1 files   ±0     0 ❌ ±0   8 🔥 +3 

For more details on these errors, see this check.

Results for commit f23a74e. ± Comparison against base commit 674e240.

♻️ This comment has been updated with latest results.

@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented Apr 28, 2026

Test Results (R2024b)

700 tests  +5   695 ✅ +5   2m 3s ⏱️ +14s
 17 suites +1     0 💤 ±0 
  1 files   ±0     0 ❌ ±0   5 🔥 ±0 

For more details on these errors, see this check.

Results for commit f23a74e. ± Comparison against base commit 674e240.

♻️ This comment has been updated with latest results.

@ehennestad ehennestad changed the base branch from main to codex-fix-tests-for-v5 April 28, 2026 12:49
@ehennestad ehennestad changed the base branch from codex-fix-tests-for-v5 to main April 28, 2026 16:55
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR fixes controlled-term base-class activation across openMINDS schema versions by introducing versioned controlled-term base templates and activating the correct one during model version selection, with accompanying unit tests.

Changes:

  • Add a shared ControlledTermBase and split version-specific ControlledTerm base templates (v2/v3) under a private folder.
  • Activate the correct controlled-term base during selectOpenMindsVersion, and clear MATLAB class caches on version switches.
  • Add unit tests covering controlled-term construction and version-specific property presence/absence.

Reviewed changes

Copilot reviewed 8 out of 8 changed files in this pull request and generated 4 comments.

Show a summary per file
File Description
tools/tests/unitTests/ControlledTermTest.m Adds unit coverage for controlled-term construction and property sets.
code/internal/+openminds/selectOpenMindsVersion.m Activates controlled-term base on version selection; clears cached class definitions.
code/internal/+openminds/+internal/activateControlledTermBase.m Implements controlled-term base activation by copying the correct versioned template.
code/internal/+openminds/+abstract/private/controlledTerms/v3/ControlledTerm.m Adds v3 controlled-term base template (newer cross-reference properties).
code/internal/+openminds/+abstract/private/controlledTerms/v2/ControlledTerm.m Adds v2 controlled-term base template (older InterLex/KnowledgeSpace properties).
code/internal/+openminds/+abstract/ControlledTermBase.m Introduces shared controlled-term initialization/deserialization behavior.
code/internal/+openminds/+abstract/ControlledTerm.m Refactors ControlledTerm to inherit shared behavior from ControlledTermBase.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +36 to +43
if startsWith(instanceSpec, openminds.constant.BaseURI)
obj.deserializeFromName(instanceSpec);
elseif isfile( instanceSpec )
obj.load( instanceSpec ) % todo: Not implemented??
else
% Deserialize from name of controlled instance
obj.deserializeFromName(instanceSpec);
end
Copy link

Copilot AI Apr 28, 2026

Choose a reason for hiding this comment

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

initializeControlledTerm calls obj.load(instanceSpec) when instanceSpec is a local file, but there is no load method defined on openminds.abstract.Schema (or elsewhere for controlled terms). Passing a filename will therefore throw a runtime error despite the API implying it is supported. Either implement a controlled-term file loading path here (e.g., deserialize from JSON-LD) or remove the isfile branch and update the accepted-input logic accordingly.

Copilot uses AI. Check for mistakes.
Comment thread code/internal/+openminds/+abstract/ControlledTermBase.m Outdated
Comment thread code/internal/+openminds/selectOpenMindsVersion.m Outdated
Comment on lines +1 to +9
function controlledTermVersion = activateControlledTermBase(modelVersion)
%activateControlledTermBase Activate the controlled-term base for a model version.

arguments
modelVersion (1,1) openminds.internal.utility.VersionNumber ...
{openminds.mustBeValidVersion(modelVersion)} = "latest"
end

controlledTermVersion = getControlledTermVersion(modelVersion);
Copy link

Copilot AI Apr 28, 2026

Choose a reason for hiding this comment

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

There’s no unit test asserting that switching the openMINDS model version in the same MATLAB session actually swaps the active openminds.abstract.ControlledTerm definition (e.g., openminds.version(4) exposes interlexIdentifier/knowledgeSpaceLink, then switching back to latest exposes otherCrossReference/preferredCrossReference). Adding such a test would protect the version-switching + clear classes behavior from regressions.

Copilot uses AI. Check for mistakes.
ehennestad and others added 2 commits April 28, 2026 21:03
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
@ehennestad ehennestad merged commit ca4adc3 into main Apr 28, 2026
1 of 3 checks passed

% Version selection can replace shared abstract class files.
% Clear cached class definitions so MATLAB sees the active files.
clear classes;
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.

3 participants