A `subject` is reported as an ordinary part with no direction (and no type in a requirement def), and inherited `result`/`verdict` parameters are not listed

未关闭
#2,009 3 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

维护者通常 1 天内回复

还没有人认领这个 Issue。

评估

难度
4/5
预计耗时
3-5 天
新手友好度
48/100
Issue 类型
缺陷
描述清晰度
描述清楚
活跃度
活跃
技术栈
go, python
领域
api, backend

调研方向

Start with internal/semantic/symbols/builder.go, especially the *ast.SubjectMember case, and trace how parameter direction, subject typing, and inherited return parameters reach attributes(). Reproduce with the supplied Python example or the C01 cases C01-055..064 in sysmlv2-tests; inspect the Go API path too, since the issue reports the same behavior there. Done means the listed parameters and metadata match the expected table for definitions and specializations.

由索引模型根据 Issue 内容生成。

描述

bug enhancement spec compliance

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

What happened
package P {
    private import ScalarValues::*;
    part def Thing;
    constraint def Cons     { in x : Real; x > 0 }
    requirement def Req     { subject s : Thing; in x : Real; }
    use case def UC         { subject s : Thing; }
    analysis def An         { subject s : Thing; return r : Real; }
    verification def Ver    { subject s : Thing; }
}
import opensysml
m = opensysml.loads(SRC)            # m.ok is True, no diagnostics
for qn in ["P::Cons", "P::Req", "P::UC", "P::An", "P::Ver"]:
    d = m.get(qn)
    for c in d.children():
        print(qn, c.name, c.kind, dict(c.metadata),
              c.type_facts.resolved_id if c.type_facts else None)
    print(qn, "attributes:", [(a.name, a.metadata.get("direction")) for a in d.attributes()],
          "withheld:", d.withheld_library_attributes)
P::Cons x referenceUsage {'type': 'Real', 'visibility': 'default', 'direction': 'in'} ScalarValues::Real
P::Cons attributes: [('x', 'in')] withheld: 58
P::Req s partUsage {'visibility': 'default'} None
P::Req x referenceUsage {'type': 'Real', 'visibility': 'default', 'direction': 'in'} ScalarValues::Real
P::Req attributes: [('x', 'in')] withheld: 58
P::UC s partUsage {'type': 'Thing', 'visibility': 'default'} P::Thing
P::UC attributes: [] withheld: 55
P::An s partUsage {'type': 'Thing', 'visibility': 'default'} P::Thing
P::An r referenceUsage {'type': 'Real', 'visibility': 'default', 'direction': 'out'} ScalarValues::Real
P::An attributes: [('r', 'out')] withheld: 55
P::Ver s partUsage {'type': 'Thing', 'visibility': 'default'} P::Thing
P::Ver attributes: [] withheld: 56

Three things are wrong with the subject, and one with the result parameters:

  1. The subject is a partUsage. The symbol builder makes it one on purpose (internal/semantic/symbols/builder.go, case *ast.SubjectMember: "Create a part usage symbol (subject is structural usage like part)"). In SysML a subject is a ReferenceUsage (SubjectUsage : ReferenceUsage). It is owned through a SubjectMembership, which is a ParameterMembership, so it is a parameter of the case or requirement.
  2. The subject has no direction. Every other parameter carries direction in its metadata. A parameter with no written direction is in: KerML ParameterMembership::parameterDirection() gives in, and Feature::direction takes it from there. Nothing in the Symbol marks s as the subject either, so a client cannot tell subject s : Thing; from part s : Thing;.
  3. In a requirement def the subject has no type. subject s : Thing; in Req reports no type metadata and an empty type_facts.resolved_id. The same declaration in UC, An and Ver reports P::Thing. This happens whether or not the subject is the first member.
  4. Inherited result and verdict parameters are not listed. A constraint def and a requirement def inherit the result : Boolean return parameter, a use case def its result, and a verification def its verdict (which redefines result). They come from the standard library, so attributes() withholds them along with the rest of the library members (withheld_library_attributes). A declared return r is listed, as An shows. Leaving out library noise such as self or subparts is reasonable. The return parameter is part of the definition's signature, though, and should be listed like r.
Expected

The parameters, with their directions:

definition parameters
Cons in x, out result
Req in s (subject, typed Thing), in x, out result
UC in s (subject), out result
An in s (subject), out r
Ver in s (subject), out verdict

The subject is a referenceUsage with direction: in and something that marks it as the subject. A metadata key such as subject: true would do. The same applies to the specializing definitions (requirement def SubReq :> Req; and so on), which inherit these parameters.

For comparison, the SysML v2 Pilot Implementation (0.64.0-SNAPSHOT, commit 378a8700c) and sysml-toolkit (v0.11.3, ResolvedModel compatibility reader) list exactly these parameters, in both the definitions and their specializations.

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) fails the same cases.

Related

#1961 is about members not being listed through a typing usage or a specialization. Here the definitions are read directly.

Found by

The test suite at https://github.com/hideo67/sysmlv2-tests, matrix C01 (behavioral definitions), model test-suite/data/models/C01.sysml. Failing cases C01-055..064: the parameters of Cons, Req, UC, An and Ver and of their specializations SubCons ... SubVer.

主要语言
Go
星标
56
派生
17
平均合并
12 小时 31 分钟
30 天内合并 PR
909

环境准备

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

Open-MBEE/OpenSysML 的其他 Issue

查看 Open-MBEE/OpenSysML 的全部 Issue

相似的 Issue

更多 Go Issue

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。