Skip to content

A feature's type leaves out the types it gets through subsetting and redefinition, and reference subsetting (::>) is not reported at all #2007

Closed

Description

@hideo67

This issue was written with AI help. The model and the reproduction were run against the version below.

What happened

A Symbol's type_info gives only the feature's own : T typing. A feature that gets its type by subsetting, reference subsetting or redefinition reports no type. A feature that has its own typing and also subsets another feature reports only its own type. Reference subsetting (::>) is not in specializations either, so nothing in the Symbol says where pRef gets its type.

package P {
    part def T;
    part def V;
    part def Owner {
        part q : T;
        part pSub :> q;             // subsetting
        ref part pRef ::> q;        // reference subsetting
        part pBoth : V :> q;        // typing and subsetting
        attribute a : ScalarValues::Real;
    }
    part def SubOwner :> Owner {
        part :>> q;                 // redefinition
    }
    part tuned : Owner {
        attribute :>> a = 3.5;      // redefinition with a value
    }
}
import opensysml
m = opensysml.loads(SRC)            # m.ok is True, no diagnostics
for qn in ["P::Owner::q", "P::Owner::pSub", "P::Owner::pRef",
           "P::Owner::pBoth", "P::SubOwner::q", "P::tuned::a"]:
    s = m.get(qn)
    print(qn, repr(s.type_facts.resolved_id), repr(s.type_facts.primitive),
          [(sp.kind, sp.target_id) for sp in s.specializations])
P::Owner::q     'P::T' ''     [('typing', 'P::T')]
P::Owner::pSub  ''     ''     [('subsets', 'P::Owner::q')]
P::Owner::pRef  ''     ''     []
P::Owner::pBoth 'P::V' ''     [('typing', 'P::V'), ('subsets', 'P::Owner::q')]
P::SubOwner::q  ''     ''     [('redefines', 'P::Owner::q')]
P::tuned::a     ''     'Real' [('redefines', 'P::Owner::a')]

The last line is the most common case in practice: attribute :>> mass = 1500; in a usage. The service does follow the redefinition for primitive ('Real') but leaves resolved_id empty, so the type is known but not reported.

The Python client's own code generator already works around this. _with_inherited_facts in client/python/opensysml/generate.py walks subsets/redefines to fill in a feature's type. A user reading Symbols has no such fallback, and the workaround cannot help pRef, whose reference subsetting is not reported at all.

Expected

  • type_info (or a new field) reports the feature's types as KerML derives them. Feature::type covers the feature's own typings and the types of every feature it subsets. Redefinition and reference subsetting are kinds of subsetting, so their targets count too:

    feature expected types
    pSub :> q T
    pRef ::> q T
    pBoth : V :> q V, T
    SubOwner::q :>> q T
    tuned::a :>> a = 3.5 ScalarValues::Real

    pBoth has two types, and TypeInfo.resolved_id holds one. A list is probably needed. Alternatively, a separate field could hold the derived types and leave type_info as the declared typing.

  • pRef ::> q lists a specialization for q, with its own kind (the spec metaclass is ReferenceSubsetting). The comment on Specialization.kind in api/proto/sysml.proto lists only specializes, subsets, redefines and typing. Reporting ::> as subsets would also do, since a reference subsetting is a subsetting. Losing the relationship entirely is the bug.

For comparison, the SysML v2 Pilot Implementation (0.64.0-SNAPSHOT, commit 378a8700c) and sysml-toolkit (v0.11.3) give the types and specializations above for every case.

Version

OpenSysML develop at 1a8e4927dc (2026-11-05), built locally: sysml-grpc nightly-153-g1a8e4927dc, Python client from client/python. The Go API (client/opensysml) gives the same results.

Related

#1961 is about features not being listed through a typing usage or a specialization. This issue is about features read directly in their owner, which are found but report the wrong type.

Found by

The test suite at https://github.com/hideo67/sysmlv2-tests, matrices A20 (attribute usages) and A40 (feature typing, subsetting and redefinition). Models: test-suite/data/models/A20.sysml and A40.sysml. Failing cases:

  • A20-037..039: the type of :>> plain = 3.5, :>> bound and :>> dflt = 5.5 in a usage.
  • A40-007, A40-022: the specializations and subsetted features of pRef ::> q.
  • A40-034, A40-037, A40-040, A40-043: the types of pSub, pRef, pBoth and SubOwner::q.

The other A40 failures (read through owner, subOwner, subSub) are #1961.

Activity

  1. devin-ai-integration commented on Nov 6, 2026

    @devin-ai-integration
    Contributor

    Confirmed as a bug in the Symbol surface; the semantic model already derives the right answer. Reproduced on develop at 1f0aef8 with output identical to yours. Reflective Feature::type on the same model gives exactly your table: pSub → T, pRef → T, pBoth → V, T, SubOwner::q → T, tuned::a → ScalarValues::Real, and the pilot (2026-09 pin) agrees, listing ReferenceSubsetting to q as pRef's ownedSpecialization.

    KerML v1.1 Beta 2 §8.3.3.3 deriveFeatureType: the types of a Feature are the union of the types of its typings and the types of the Features it subsets, redundant supertypes removed. ReferenceSubsetting (§8.3.3.3.9) and Redefinition are kinds of Subsetting, so their targets count.

    Root cause, both in internal/frontend/symbolfacts/facts.go:

    • usageTypeInfo reads only the first RelTyping relationship written on the declaration. PrimTypeOf walks the generalization graph (which is why primitive is Real for tuned::a), but resolved_id is never filled from the derived type.
    • relationshipKindName maps specializes, subsets, redefines and typing and returns the empty string for everything else, so specializationsOf silently drops ::> (RelReferences) — and the other KerML relationship kinds with it.

    Generalised: every feature typed only through subsetting, redefinition or reference subsetting — attributes, parts, ports, items, parameters, and the common attribute :>> mass = 1500; in a usage — on Symbol, gRPC, Python and Go clients; _with_inherited_facts in the Python generator is a client-side workaround for part of it.

    Planned fix: add a derived type list to TypeInfo (SymbolInfo, Python TypeFacts) filled from the semantic Feature::type, keeping declared/resolved_id as the written typing so existing readers do not change meaning; report reference subsetting as its own Specialization.kind (references) and update the proto comment and clients; tests at the symbolfacts, gRPC and Python layers over your six cases.

  2. added
    bug
    on Nov 6, 2026
  3. devin-ai-integration commented on Nov 6, 2026

    @devin-ai-integration
    Contributor

    Update on the plan: the Symbol-surface half (a derived type list on TypeInfo, reference subsetting in specializations) will not be added as more SymbolInfo fields. #2012 proposes one generic per-element read, GetElementProperties, that answers metamodel properties by their specification names (Feature::type, Feature::ownedSubsetting, Feature::ownedReferenceSubsetting, Feature::ownedRedefinition, …) from the same evaluator that already derives them, so these six cases are covered there. This issue stays open as the acceptance case for that work.

  4. devin-ai-integration commented on Nov 7, 2026

    @devin-ai-integration
    Contributor

    Fixed in #2040.

    What changed. TypeInfo gains types (repeated TypeRef {id, kind}, a new field — declared/resolved_id/resolved_kind keep their meaning, the typing as written). It is KerML §8.3.3.3 Feature::type as the metamodel evaluator derives it (internal/frontend/symbolfacts/facts.go Context.derivedTypes → semantics.Model.ReflectiveFeatureTypes, the derivation the metamodel evaluator answers Feature::type from), so the six cases now answer q -> T, pSub -> T, pRef -> T, pBoth -> V, T, SubOwner::q -> T, tuned::a -> ScalarValues::Real. relationshipKindName maps ast.RelReferences (and include) to "references", so pRef's edge is in specializations as ('references', 'P::Owner::q'). Every client that mirrors the field (Python TypeFacts.types/TypeRef, Go TypeInfo.Types, TypeScript, Java, Rust, Julia) carries it, and the generators take a feature's type from it instead of walking specializations.

    How to verify. Your script, with [t.id for t in s.type_facts.types] added to the print:

    P::Owner::q     'P::T' ''     ['P::T']         [('typing', 'P::T')]
    P::Owner::pSub  ''     ''     ['P::T']         [('subsets', 'P::Owner::q')]
    P::Owner::pRef  ''     ''     ['P::T']         [('references', 'P::Owner::q')]
    P::Owner::pBoth 'P::V' ''     ['P::V', 'P::T'] [('typing', 'P::V'), ('subsets', 'P::Owner::q')]
    P::SubOwner::q  ''     ''     ['P::T']         [('redefines', 'P::Owner::q')]
    P::tuned::a     ''     'Real' ['ScalarValues::Real'] [('redefines', 'P::Owner::a')]
    

    Pinned by internal/frontend/symbolfacts/typeinfo_test.go, internal/frontend/grpc/derivedtypes_test.go, the tests/grpc conformance cases symbol_type_* and client/python/tests/test_symbol.py::TestSymbolTypeFacts.

    One thing the verification turned up, left for its own PR: GetElementProperties type answers pBoth -> V only — the element form keeps the graph's stated written typing and runs deriveFeatureType only when nothing is written (export/api_json_derived.go completeDerived). The Symbol surface answers V, T as the specification and the pilot do.

  5. added 2 commits that reference this issue on Nov 9, 2026
    9fefc12
    0eca4a4
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bug

    Type

    No type

    Fields

    Priority

    None yet

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions