Skip to content

feat(export): name the standard library elements a converted model references (#731) - #746

Merged
HuiJun merged 3 commits into
Open-MBEE:developfrom
someshSandbox:feat/731-library-names
Sep 30, 2026
Merged

HuiJun merged 3 commits into
Open-MBEE:developfrom
someshSandbox:feat/731-library-names

Conversation

@someshSandbox

@someshSandbox someshSandbox commented Sep 30, 2026 •

Copy link
Copy Markdown
Contributor

Fixes #731.

package L {
    private import ScalarValues::Real;
    private import ISQ::*;
    part def Car {
        attribute speed : Real;
        attribute weight : MassValue;
        attribute count : ScalarValues::Integer;
    }
}

sysml l.sysml -convert api-json:

develop this PR
@ids referenced but not in the output 5 normative ids, e.g. 14c0aa22-5489-59b5-b438-ded26e83ba31 none
ScalarValues::Real only its id {"@type": "DataType", "@id": "14c0aa22-…", "elementId": "14c0aa22-…", "qualifiedName": "ScalarValues::Real", "declaredName": "Real", "isLibraryElement": true}
ISQ (imported namespace) only its id a LibraryPackage with the same properties
import ScalarValues::Real (importedMembership) only its id an OwningMembership with memberElement → Real, isLibraryElement: true

A referenced library element is stated under its normative id, and nothing more is written about it:

  • It carries its metaclass, elementId, qualifiedName and declaredName, and isLibraryElement: true (KerML Element::isLibraryElement, Element_isLibraryElement in the ontology).
  • Its owner, members and relationships stay in the library, and the library isn't exported.

Change:

  • Writer: claimLibrary records each library element a document links to. libraryNames then states the ones the output references, after the normative relationships are materialized. A library package is a LibraryPackage. An alias, or an element with no metaclass to state, isn't stated, and neither is its membership.
  • The API JSON root namespace takes only the document's own unowned elements, not the stated library elements (LibraryReference).
  • Reader: such an element is a reference into the bundled library, not a declaration, and isn't written back. It is refused when its qualified name isn't the one the library gives its id, or when the library has no such id. A library membership must own such an element.
  • Repository sync ignores them: a library element is never created, changed or deleted in a repository.
  • rdf-mapping.md describes them.

Tests:

  • tests/export/library_names_test.go:
    • every @id the output references is an element of it;
    • the metaclasses stated for Real, Integer, MassValue and ISQ;
    • no owner on a stated library element;
    • one membership for the membership import;
    • a graph-only round trip and an API JSON round trip give the same notation back;
    • a library element named otherwise than the library names it is refused.
  • 13 .golden.ttl files are regenerated. The diff only adds the stated library elements (29), no line removed.
  • TestFixtureElementIDsRoundTrip skips stated library elements, which keep the normative id the references to them carry. TestToolkitReExportTable counts model elements only.
  • internal/translate/..., tests/export/..., tests/corpus/..., tests/identity/..., tests/reposync/..., tests/grpc/..., internal/frontend/grpc/..., internal/workspace/... and internal/check/... pass.
  • The example is valid for sysml -validate.

🤖 Generated with Claude Code


Devin Review

…ferences (Open-MBEE#731)

A reference to a library element is its normative id, a hash no reader can
turn back into a name. Each referenced library element is now stated under
that id with its metaclass, elementId, qualifiedName and declaredName, marked
isLibraryElement; a referenced library membership with its memberElement.
The library itself is not exported. Reading back, such an element is a
reference into the bundled library, checked against it, and not written;
repository sync leaves it alone.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
devin-ai-integration[bot]

This comment was marked as resolved.

someshSandbox and others added 2 commits September 30, 2026 07:17
…ames

# Conflicts:
#	internal/translate/export/behavior.go
#	internal/translate/export/rdf_in.go
…her true

Review:
- a library membership is refused unless the library gives its id to the
  owning membership of the element its memberElement names, so an import
  of it cannot silently name another element;
- isLibraryElement is read as an xsd:boolean, so "1" marks a library
  element as "true" does, in the reader, the root namespace and sync.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@HuiJun
HuiJun merged commit b77decc into Open-MBEE:develop Sep 30, 2026
23 checks passed
@HuiJun

HuiJun commented Sep 30, 2026

Copy link
Copy Markdown
Collaborator

Accepted! Thank you!

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.

Convert: name the standard-library elements a converted model references

2 participants