Skip to content

fix(collection): write references to controlled instances as library instances, or keep them as links - #200

Draft
ehennestad wants to merge 2 commits into
fix-serialize-mixed-type-reference-as-linkfrom
collection-expands-controlled-instance-references
Draft

ehennestad wants to merge 2 commits into
fix-serialize-mixed-type-reference-as-linkfrom
collection-expands-controlled-instance-references

Conversation

@ehennestad

@ehennestad ehennestad commented Sep 19, 2026 •

Copy link
Copy Markdown
Collaborator

Mechanism

Collection.addNode decides whether a linked instance becomes a node. A controlled instance (an IRI under openminds.om-i.org/instances/ or openminds.ebrains.eu/instances/) is in the bundled instance library; the preference AddControlledInstanceToCollection says whether such instances become nodes. A link with only an identifier is a reference: typed ("IsReference", true) or untyped (MixedTypeReference, which kgpull leaves for links it cannot take from the library).

Problem

addNode tested for a controlled-instance IRI before testing for a reference, so an untyped reference to a controlled instance became a node, and save failed because the serializer has no type for it. A dataset version pulled from the Knowledge Graph could not be saved. Separately, a typed, ID-only controlled instance was written as a node with only @id and @type, while an untyped reference to the same instance stayed a link.

Changes

  • With the preference on, a reference to a controlled instance, typed or untyped, is replaced by the instance from the library (openminds.instanceFromIRI), so the node has its properties. A reference the library does not have stays a link. A controlled term with an unknown name is created with the warning openMINDS:ControlledTerm:UnknownInstanceName rather than an error, so that warning is raised as an error during the lookup, and the warning state is restored.
  • With the preference off, references stay links.
  • Saving, loading and saving again gives the same document, because both saves write the library instance.
  • Tests: six in CollectionTest (an unresolved untyped reference stays a link; typed and untyped references are expanded; a reference not in the library stays a link; preference off; round trip).

🤖 Generated with Claude Code

ehennestad and others added 2 commits September 19, 2026 08:01
… the nodes

A link to a controlled instance that could not be taken from the
instance library stays a MixedTypeReference. Collection.addNode tested
for a controlled-instance identifier before it tested for a reference,
so with AddControlledInstanceToCollection on, the untyped reference
became a node, and saving the collection failed: the serializer has no
type for it. kgpull leaves such links, for example to single colors of
atlas annotations, so a pulled dataset version could not be saved.

An untyped reference is now handled as any other reference: it stays a
link in the linking document. A typed controlled instance with only an
identifier is still a node when the preference is on.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
…brary instance

With AddControlledInstanceToCollection on, a typed reference to a
controlled instance became a node with only @id and @type: nothing for
a reader without the instance library, and only a link for a reader
with it. An untyped reference was a link instead, so the two kinds of
reference to one instance were saved differently.

addNode now replaces a reference to a controlled instance, typed or
not, with the instance from the library, so the node has the
instance's properties. A reference to an instance the library does
not have stays a link, including a controlled term with a name the
library does not know, which is created with a warning rather than an
error. With the preference off, references stay links as before.

Saving, loading and saving again gives the same document, because
both saves write the library instance.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
@ehennestad
ehennestad added this pull request to stack #201 September 19, 2026 16:29
@ehennestad ehennestad changed the title collection expands controlled instance references fix(collection): write references to controlled instances as library instances, or keep them as links Sep 19, 2026
@github-actions

Copy link
Copy Markdown
Contributor

Test Results (R2022a)

867 tests  +6   863 ✅ +6   5m 10s ⏱️ +7s
 27 suites ±0     4 💤 ±0 
  1 files   ±0     0 ❌ ±0 

Results for commit b27337d. ± Comparison against base commit b5bc40f.

@github-actions

Copy link
Copy Markdown
Contributor

Test Results (R2026a)

867 tests  +6   865 ✅ +6   5m 57s ⏱️ + 1m 27s
 27 suites ±0     2 💤 ±0 
  1 files   ±0     0 ❌ ±0 

Results for commit b27337d. ± Comparison against base commit b5bc40f.

@codecov

codecov Bot commented Sep 19, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 80.35%. Comparing base (b5bc40f) to head (b27337d).

Additional details and impacted files
@@                              Coverage Diff                               @@
##           fix-serialize-mixed-type-reference-as-link     #200      +/-   ##
==============================================================================
+ Coverage                                       80.25%   80.35%   +0.09%     
==============================================================================
  Files                                             424      424              
  Lines                                            4436     4448      +12     
==============================================================================
+ Hits                                             3560     3574      +14     
+ Misses                                            876      874       -2     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

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.

1 participant