Skip to content

feat(grpc): read any metamodel property of an element by its specification name #2012

Closed

Description

@devin-ai-integration

Problem

OpenSysML has no per-element client API shaped like the KerML/SysML abstract syntax.
A client that wants inheritedFeature, connectorEnd, relatedFeature, directedFeature,
portDefinition, payloadType, subjectParameter, entryAction, isComposite, the
FeatureValue behind a feature, the operands of an expression, … has three routes and none
of them answers per element over gRPC:

The derivation itself already exists and is the most carefully measured part of the
metamodel in the tree:

  • internal/semantic/metamodel (Evaluator.Property(element, definingClass, name))
    serves 297 derived properties by specification clause and omits 58
    (Omitted(), each with the engine fact it would need). It covers every property named
    above, plus Connector::sourceFeature/targetFeature, Feature::isComposite/isReference,
    FeatureValue::value, OperatorExpression::operand/operator,
    InvocationExpression::argument, SendActionUsage::payloadArgument/senderArgument/
    receiverArgument, StateDefinition::entryAction/doAction/exitAction,
    ConjugatedPortTyping::portDefinition, ConjugatedPortDefinition::originalPortDefinition.
  • It is refereed against the pinned pilot's JSON export over 935 corpus files
    (docs/project/api-json-differential.md): 1,925,327 properties equal, 125,740 different,
    321,317 missing on our side, bucketed per (metaclass, property).
  • The in-model query executor (internal/doc/queryexec metaclassPropertyValues) and
    meta reflection already answer metaclass properties on a live model through
    semantics.ReflectiveElements / ReflectiveFeatureValues.

An external conformance suite (hideo67/sysmlv2-tests, 1,630 static reads of exactly these
properties, pilot EMF as oracle) scores the gRPC surface at 504 pass / 364 fail /
753 unsupported, against 1,527 / 53 / 50 for sysml-toolkit's ResolvedModel.derived(element, "<spec name>") and 1,580 / 0 / 50 for the pilot. The 753 are properties the surface has no
route to; 87 of the 364 are inherited members the suite's adapter does not yet read from
members. The gap is the surface, not the derivation.

Proposal

1. One RPC: element properties by specification name

rpc GetElementProperties(GetElementPropertiesRequest) returns (GetElementPropertiesResponse);

message GetElementPropertiesRequest {
  string model_id   = 1;
  string element_id = 2;           // qualified name, or a positional id for an unnamed member (#1978)
  repeated string properties = 3;  // spec names; empty = every property the metaclass declares
  bool include_library = 4;        // library-inherited members etc., as `members` does
}

message GetElementPropertiesResponse {
  string metaclass = 1;            // "ConnectionUsage"
  repeated ElementProperty properties = 2;
}

message ElementProperty {
  string name = 1;                 // "connectorEnd"
  string defining_class = 2;       // "Connector"
  bool many = 3;                   // ordered list vs single
  repeated PropertyValue values = 4;
  string unsupported_reason = 5;   // set when OpenSysML does not derive it; from Evaluator.Explain / Omitted
}

message PropertyValue {
  oneof value {
    string element_id = 1;         // qualified or positional id
    string literal = 2;            // string / integer / real / boolean spelled as the API JSON spells it
    string enumeration = 3;        // "in", "public", …
  }
}

Backing: metamodel.Evaluator over the model, resolving the metaclass and the declared
property set from internal/translate/rdf/ontology (so an unknown name is an error, a
declared-but-underived name is unsupported_reason, and a derived one is a value). Element
values are returned as the ids GetSymbol accepts, positional ids included, so a client can
walk the graph (feature → ownedRelationship → FeatureValue::value → operand) without a
second vocabulary.

2. Structure for a live model

Evaluator reads containment and owned attributes through a metamodel.Structure. Two
routes, in order:

  1. Reuse the API-JSON graph structure (internal/translate/export newAPIJSONEvaluation):
    build the model's graph once per model revision and cache it on the service's model
    entry. This is the path the differential measures today, so its fidelity is known.
  2. If the per-model graph is too expensive for editor-sized models, implement
    metamodel.Structure directly over symbols/semantics side tables and run the
    differential over both to prove they agree.

3. Clients

client/opensysml (Go), Python, Rust, TypeScript and WASM each gain
ElementProperties(id, names...) returning name → values | reason, mirroring the Go
Query row shape. The Python Symbol gets .property("connectorEnd").

4. What stays as it is

  • SymbolInfo remains the curated editor/client surface and stops growing metamodel fields.
  • Query keeps the API & Services projection. A later step may admit metaclass property
    names in select through the same evaluator; not part of this issue.
  • Convert api-json is unchanged; the RPC and the export must agree per property, and the
    differential baseline is the gate for both.

Effect on open pull requests

PR What it changes Under this proposal
#1978 unnamed members get positional ids identity of Owner::@3 on child_ids, GetSymbol, Python Keep. Any surface needs addressable unnamed elements; the RPC returns these ids.
#1980 conjugated port typed by P::'~P' semantics, export, views Keep. Engine fix; ConjugatedPortTyping::portDefinition reads it.
#1992 send action is a SendActionUsage semantics, runtime, query, export Keep. Engine fix; metaclass and payloadArgument/senderArgument/receiverArgument read it.
#1994 positional parameter redefinition semantics, migrate Keep. Engine fix.
#1983 connector related features from the ends' reference subsettings semantics derivation + SymbolInfo/query fields Keep the derivation, drop the new fields. Connector::relatedFeature/sourceFeature/targetFeature/connectorEnd are served by the evaluator once the derivation is right.
#1993 isComposite/isReference on symbols and in queries surface only Supersede. Feature::isComposite/isReference are served.
#1981 Symbol.valuation with expression text/structure bespoke valuation shape on symbol, gRPC, query Supersede. FeatureValue::value → OperatorExpression::operand/operator, InvocationExpression::argument, LiteralExpression::value give the structure in the specification's own shape.
#1979 instance owner and paths runtime objects, not metamodel Independent. Unaffected either way.

Acceptance

  • GetElementProperties answers every property in metamodel.servedRules for a declared
    element and reports the recorded reason for every Omitted() one; tests/grpc
    conformance cases per metaclass family (Type, Feature, Connector, Flow, SendActionUsage,
    StateDefinition, FeatureValue/Expression, Membership/Import).
  • The RPC's answer and the api-json export agree on every (element, property) pair over
    examples/ (a hygiene test, not a new baseline).
  • All five clients expose it; the Python and Go clients have the same differential test
    they have for Query.
  • docs/project/spec-compliance/08-grpc-service-layer.md and the gRPC guide document the
    RPC and the capability flag.

Activity

  1. added 2 commits that reference this issue on Nov 6, 2026
  2. hideo67 commented on Nov 7, 2026

    @hideo67

    This comment was written with AI help. The reproduction was run against the version below.

    Thanks for #2013. We added a suite that reads every case through Model.element_properties (test-opensysml-py/test_props.py) and walks the abstract syntax the same way as our sysml-toolkit adapter. On 19bc16d1df it scores 1236 pass / 323 fail / 62 unsupported / 9 error on the 1630 cases. The Symbol API gets 652 / 222 / 747 / 9. 470 reads that had no route now pass. Of the 62 unsupported, 39 need a KerML operation (allSupertypes(), directionOf()), and 20 need an expression's source text.

    Most of the remaining failures come from the problems below. All were reproduced with the Python client (OPENSYSML_BINARY = bin/sysml-grpc of 19bc16d1df).

    Reproduction

    package P {
        private import ScalarValues::*;
        port def PP { out item v : Real; }
        part def Unit { port p : PP; }
        part def Tank { out item fuelOut : Real; }
        part def Engine { in item fuelIn : Real; }
        connection def Link { end a : Unit; end b : Unit; }
        item def Sig;
        calc def Calc { in x : Real; return r : Real; }
        part def V {
            part x : Unit; part y : Unit;
            part tank : Tank; part engine : Engine;
            connection c1 : Link connect x.p to y.p;
            flow f1 of Real from tank.fuelOut to engine.fuelIn;
            message msg of Sig from tank to engine;
            port sp : PP;
            action sendIt send new Sig() via sp;
            attribute s : Sig = new Sig();
            attribute chain = x.p;
            part comp : Unit;
            ref part r : Unit;
        }
        part a : V;
    }
    
    m = opensysml.loads(SRC)
    def show(el, *props):
        for p in m.element_properties(el, *props):
            print(f"{el} {p.name}: {p.unsupported or [str(v) for v in p.values]}")
    def value_expr(el):
        fv = [x for x in m.element_properties(el, "ownedMembership")["ownedMembership"].elements
              if x.metaclass == "FeatureValue"][0]
        return m.element_properties(fv.id, "value")["value"].elements[0]

    1. Ids in an answer that the call cannot read back

    for ms in m.element_properties("P::a", "inheritedMembership")["inheritedMembership"].elements:
        m.element_properties(ms.id, "memberElement")

    28 of the 101 entries raise ConversionError: library document Systems Library/Parts.sysml writes no element bd909aa8-dcdb-59fb-a116-8670f6db05b1. They are 18 FeatureMemberships of Occurrences.kerml and 10 OwningMemberships of Parts.sysml, Items.sysml, Objects.kerml, Base.kerml and Occurrences.kerml. The members of the 18 FeatureMemberships are the unnamed library features. They are listed in inheritedFeature, and reading them fails the same way, so a client cannot tell an unnamed library feature from a model one, or count them (the Pilot lists 18).

    2. Chained connector ends have no related features

    P::V::c1 connectorEnd: ['P::V::c1::a', 'P::V::c1::b']
    P::V::c1 relatedFeature: []
    P::V::c1 sourceFeature: []
    P::V::c1 targetFeature: []
    

    With unchained ends (connect q to r) all three are answered. Expected: relatedFeature = the chains x.p and y.p, sourceFeature = x.p, targetFeature = y.p. This is 114 cases (B10, B11, B12), with connection, interface and binding usages at end depths 1 and 2.

    3. A connection def's endFeature is empty

    P::Link ownedFeature: ['P::Link::a', 'P::Link::b']
    P::Link endFeature: []
    

    Expected: a, b (both declared end).

    4. Flows and messages

    P::V::f1 connectorEnd: ['P::V::f1::source', 'P::V::f1::target']
    P::V::f1 sourceOutputFeature: []
    P::V::f1 targetInputFeature: []
    P::V::msg ownedFeature: ['P__V__msg_pend0', 'P__V__msg_pend1', 'P::V::msg::payload']
    P::V::msg connectorEnd: []
    

    Expected for f1: sourceOutputFeature and targetInputFeature are the flow ends' owned features that redefine Tank::fuelOut and Engine::fuelIn. A message's two ends are owned features but not connectorEnd.

    5. A send action has no owned features

    P::V::sendIt ownedFeature: []
    P::V::sendIt payloadArgument: []
    P::V::sendIt receiverArgument: []
    

    Expected: the payload, sender and receiver parameters as owned features, with payloadArgument the new Sig() expression. The same happens for send alarm via alarmPort and send alarm to display.

    6. Expressions

    ConstructorExpression instantiatedType: []        (s = new Sig())
    FeatureChainExpression operator: []               (chain = x.p)
    

    Expected: instantiatedType = P::Sig. operator = ".", which the Pilot reports. The constructor's result and argument are answered.

    7. isReference is answered only when written

    P::V::comp isComposite: ['True']
    P::V::comp isReference: []
    P::V::r isComposite: ['False']
    P::V::r isReference: ['True']
    

    isReference is derived as not isComposite. Expected: false for comp, and true for a part usage owned by a package.

    8. Function::result is empty

    P::Calc result: []
    P::Calc directedFeature: ['P::Calc::x', 'P::Calc::r', 'Performances::Evaluation::result']
    

    Expected: result = P::Calc::r. For a constraint, requirement or case def, expected: the inherited result. directedFeature lists the library result beside the parameter r that redefines it, which is item 4 of #2009.

    Already filed and seen here as well: if/while/for reported as ActionUsage (#1985), a succession flow as FlowUsage (#2008), the type of a ~PP port (#1962), an inherited type missing from type (#2007).

    Version

    • OpenSysML develop at 19bc16d1df (nightly-199-g19bc16d1df), bin/sysml-grpc built with make build-grpc
    • Python client from client/python of the same commit
    • Suite: https://github.com/hideo67/sysmlv2-tests, test-suite/test-opensysml-py/test_props.py (suite opensysml-py-props)
  3. added a commit that references this issue on Nov 8, 2026
  4. devin-ai-integration commented on Nov 8, 2026

    @devin-ai-integration
    ContributorAuthor

    Thanks for the suite — it is the most useful measurement we have of this API, and we ran your model through all eight parts against current develop (bfebfa9, with #2050 merged) and against the branch of #2042, which moves GetElementProperties off the api-json element form onto the symbol-backed SymbolStructure (#2014) so that the RPC, the Symbol surface and the exporter read one representation. Status per item:

    # Item develop bfebfa9 #2042 branch Where it is fixed
    1 ids in inheritedMembership that cannot be read back fixed — 113/113 of P::a's memberships read back (was 85/113). Root cause: unnamed members of catalogued library elements were minted under AnonymousMemberOf ids by the model form but under positional ids by the per-document library form regressed (100 of 113 come back with no id); sent to the PR #2050 (merged); #2042 must keep it
    2 chained connector ends: no relatedFeature/sourceFeature/targetFeature reproduced fixed: relatedFeature → the two chain features, sourceFeature/targetFeature split #2051 (engine derivation + export, #1956/#1957/#1958) and #2042 (surface)
    3 connection def endFeature empty reproduced fixed: P::Link::a, P::Link::b #2042
    4 flows/messages: no sourceOutputFeature/targetInputFeature, message connectorEnd empty reproduced not fixed — flow/message ends are not yet symbols, so connectorEnd is reported as not derived rather than empty, and Flow::sourceOutputFeature/targetInputFeature have no rule end representation: #2042 follow-up; the two rules: #2028 stage 2
    5 send action: no owned features, payloadArgument/receiverArgument reproduced (the node is still a plain ActionUsage) same #1992 (SendActionUsage classification + arguments), then #2053 for accept/assign/if/while/for
    6a ConstructorExpression::instantiatedType empty reproduced fixed: P::Sig #2042
    6b FeatureChainExpression::operator empty reproduced not fixed (no rule; the answer is .) #2028 stage 2
    7 isReference only answered when written reproduced fixed: derived as ¬isComposite — comp → False, ref part r → True, and the package-owned a → True #2042 (via #2040's shared derivation)
    8 Function::result empty reproduced fixed: P::Calc::r #2042; the census gate that would have caught the served-but-empty rule is #2049

    One more thing you will see when #2042 lands: anonymous ids change spelling (the connector ends are P::V::c1.r1.e0 rather than P::V::c1::a, membership ids P::V.r0 rather than P__V__x_om). Every id an answer carries will read back, which is the contract #2050 added a test for (TestElementPropertiesReadsBackEveryIdAnAnswerCarries) and which #2042 has to keep.

    Also noted from your run and ours: Type::directedFeature on P::Calc lists both P::Calc::r and the Performances::Evaluation::result it redefines; inherited members redefined by an owned member must be excluded (KerML §8.3.3.1), same defect as #2009 item 4 — added to #2028's scope.

    If you re-run the suite after #2050 the item-1 failures should be gone; the rest will move with the PRs above, and we would welcome the suite itself as a fixture once the count is stable.

  5. added a commit that references this issue on Nov 10, 2026
  6. devin-ai-integration commented on Nov 13, 2026

    @devin-ai-integration
    ContributorAuthor

    Closing this tracking issue. #2073 (merged) satisfies the acceptance text as written: GetElementProperties answers any metamodel property by its specification name, cached on the model hash, over the full KerML/SysML metamodel. The symbol-backed structure and hideo67's follow-ups (1–4, 6a, 7, 8) are owned by #2042 and #2052, which stay open and now carry Closes #2012 so the cross-reference survives; anything that is not covered there should be opened as its own issue against the specific property.

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

    enhancement

    Type

    No type

    Fields

    Priority

    None yet

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions