fix(collection): write references to controlled instances as library instances, or keep them as links - #200
Draft
ehennestad wants to merge 2 commits into
Conversation
… 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
added this pull request to stack #201
September 19, 2026 16:29
Contributor
Contributor
Codecov Report✅ All modified and coverable lines are covered by tests. 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. 🚀 New features to boost your workflow:
|
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.
Mechanism
Collection.addNodedecides whether a linked instance becomes a node. A controlled instance (an IRI underopenminds.om-i.org/instances/oropenminds.ebrains.eu/instances/) is in the bundled instance library; the preferenceAddControlledInstanceToCollectionsays whether such instances become nodes. A link with only an identifier is a reference: typed ("IsReference", true) or untyped (MixedTypeReference, whichkgpullleaves for links it cannot take from the library).Problem
addNodetested for a controlled-instance IRI before testing for a reference, so an untyped reference to a controlled instance became a node, andsavefailed 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@idand@type, while an untyped reference to the same instance stayed a link.Changes
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 warningopenMINDS:ControlledTerm:UnknownInstanceNamerather than an error, so that warning is raised as an error during the lookup, and the warning state is restored.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