Repository navigation
Resolve layout references by KerML name resolution (same-named definitions) - #84
Conversation
The General View re-resolved raw type/supertype reference text through a workspace-wide simple-name dictionary (first-seen wins), so when several packages each define a same-named part def (e.g. ApiMark's three DocumentationCoverageChecker defs) every usage was wired to the first one, leaving the others as unconnected duplicates. The Interconnection View's ResolveByTyping had the same flaw when expanding nested containers. ReferenceResolver itself resolves these correctly. - General View: membership/typing/ref edges use each feature's resolved Typing edge; specialization uses the definition's resolved Supertype edges; the raw-text fallback now tries the enclosing namespaces (innermost first) before the simple-name last resort. - Interconnection View: ResolveByTyping takes the feature, prefers its resolved Typing edge, then lexical scoping, then simple name. - Regression tests, requirements, design and verification docs. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
There was a problem hiding this comment.
🟡 Changes recommended
Several moderate layout-resolution issues remain, allowing imported or non-rendered types and same-named definitions to produce incorrect cross-wired edges instead of honoring authoritative semantic targets and lexical scope.
4 open issues
What changed in this PR
This pull request updates General and Interconnection layout strategies to honor semantic type resolution and lexical namespace scoping when multiple packages contain definitions with the same simple name. It adds regression tests and updates the related design, verification, and requirements documentation.
Changes:
- Prefer resolved typing and supertype targets before namespace-aware and simple-name fallbacks.
- Resolve interconnection containers and General View relationships within the owning namespace.
- Add same-named-definition regression tests and traceability updates.
| File | Description |
|---|---|
| test/DemaConsulting.SysML2Tools.Tests/Semantic/WorkspaceLoaderTests.cs | Verifies that same-named usages resolve to definitions in their owning packages. |
| test/DemaConsulting.SysML2Tools.Tests/Layout/InterconnectionViewLayoutStrategyTests.cs | Verifies that nested containers expand the correct same-named definition. |
| test/DemaConsulting.SysML2Tools.Tests/Layout/GeneralViewLayoutStrategyTests.cs | Verifies that General View composition edges connect each package to its own same-named definition. |
| src/DemaConsulting.SysML2Tools.Core/Layout/Internal/InterconnectionViewLayoutStrategy.cs | Uses semantic typing targets and namespace-aware lookup for container expansion and root selection. |
| src/DemaConsulting.SysML2Tools.Core/Layout/Internal/GeneralViewLayoutStrategy.cs | Uses semantic targets and namespace-aware resolution for General View relationship edges. |
| docs/verification/sysml2-tools-language/semantic/model/reference-resolver.md | Documents verification coverage for semantic same-name resolution. |
| docs/verification/sysml2-tools-core/layout/internal/interconnection-view-layout-strategy.md | Documents verification coverage for same-named container expansion in the Interconnection View. |
| docs/verification/sysml2-tools-core/layout/internal/general-view-layout-strategy.md | Documents verification coverage for same-named definition wiring in the General View. |
| docs/reqstream/sysml2-tools-language/semantic/model/reference-resolver.yaml | Adds the owning-namespace reference resolution requirement. |
| docs/reqstream/sysml2-tools-language/semantic/model.yaml | Links the new reference resolution requirement into the semantic model requirements. |
| docs/reqstream/sysml2-tools-core/layout/internal/interconnection-view-layout-strategy.yaml | Adds the same-named container expansion requirement. |
| docs/reqstream/sysml2-tools-core/layout/internal/general-view-layout-strategy.yaml | Adds the same-named definition wiring requirement. |
| docs/reqstream/sysml2-tools-core/layout/internal.yaml | Includes the new layout requirements in the internal layout requirements hierarchy. |
| docs/design/sysml2-tools-core/layout/internal/interconnection-view-layout-strategy.md | Documents semantic-target-first and namespace-aware container resolution behavior. |
| docs/design/sysml2-tools-core/layout/internal/general-view-layout-strategy.md | Documents semantic-target-first and lexical-scope resolution for General View relationships. |
Review effort: Lite
- New public Language unit NameResolver: local resolution (owned, imported incl. recursive/filtered imports, inherited memberships; names, short names, aliases), full resolution outward to the global namespace, visible (public-only) resolution for later qualified-name segments, redefined features against the owning type's general types, and a flagged simple-name fallback. - AstBuilder captures membership/import visibility, import all, short names, and alias members (SysmlVisibility, SysmlAliasNode). - ReferenceResolver looks a simple name up in the global namespace only after enclosing namespaces and imports (local Base no longer resolves to the stdlib Base package). - General, Interconnection and Grid views use the resolved edges first, then NameResolver; the bare simple-name fallback now emits a warning. ResolveOwningBox no longer maps qualified endpoints by simple name. - Requirements, design (with spec clauses), verification, tests. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
There was a problem hiding this comment.
🟡 Changes recommended
Active moderate and critical findings remain in fallback resolution, visibility application, recursive filtering, and inherited-type handling, including cases that can silently produce incorrect or missing semantic edges.
7 open issues
Local resolution ignores aliases and short names · New Redefinition resolution skips flagged fallback · New Subsetting resolution bypasses fallback · New Fallback warning skipped for unrendered declarations · New Alias members ignore private visibility · New Unresolved supertypes dropped when some edges resolve · New Filtered recursive lookup stops at first rejected match · New
4 resolved since last review
Review effort: Lite
# Conflicts: # docs/reqstream/sysml2-tools-core/filtering.yaml # docs/reqstream/sysml2-tools-core/filtering/filter-expression-evaluator.yaml # docs/reqstream/sysml2-tools-core/layout/internal.yaml # docs/reqstream/sysml2-tools-core/layout/internal/general-view-layout-strategy.yaml # docs/reqstream/sysml2-tools-core/layout/internal/interconnection-view-layout-strategy.yaml # docs/reqstream/sysml2-tools-language/semantic/model.yaml # docs/reqstream/sysml2-tools-language/semantic/model/ast-builder.yaml # docs/reqstream/sysml2-tools-language/semantic/model/reference-resolver.yaml # docs/verification/sysml2-tools-core/filtering/filter-expression-evaluator.md # docs/verification/sysml2-tools-core/layout/internal/general-view-layout-strategy.md # docs/verification/sysml2-tools-core/layout/internal/interconnection-view-layout-strategy.md # docs/verification/sysml2-tools-language/semantic/model/ast-builder.md # docs/verification/sysml2-tools-language/semantic/model/sysml-node.md # src/DemaConsulting.SysML2Tools.Core/Layout/Internal/InterconnectionViewLayoutStrategy.cs # test/DemaConsulting.SysML2Tools.Tests/Filtering/FilterExpressionEvaluatorTests.cs # test/DemaConsulting.SysML2Tools.Tests/Semantic/WorkspaceLoaderTests.cs
…isibility - ReferenceResolver resolves a simple name through a local member's short name or a local alias before outer or global names (KerML 8.2.3.5.2). - GeneralView redefinition and subsetting lookups use the flagged simple-name fallback, and the fallback warning is recorded even when the match is outside the rendered scope. - Aliases take their member visibility. - NameResolver.GeneralTypes merges resolved edges with raw resolution of unresolved supertypes; filtered recursive imports keep searching after a rejected candidate. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
There was a problem hiding this comment.
🟡 Changes recommended
Approval is blocked by multiple active critical issues where semantic edge resolution bypasses visibility, import filters, and lexical import scope, causing diagrams to wire or render inaccessible or incorrect targets.
8 open issues
Semantic edge resolution bypasses visibility checks · New Filtered imports can produce authoritative typing edges · New Filtered imports can produce incorrect supertype edges · New Filtered imports can expand excluded containers · New Specialized body collectors omit visibility and short-name metadata · New Qualified symbol lookup ignores visibility and access rules · New Semantic import lookup crosses namespace boundaries · New Imported aliases lose their short names · New
7 resolved since last review
Local resolution ignores aliases and short names Filtered recursive lookup stops at first rejected match Unresolved supertypes dropped when some edges resolve Alias members ignore private visibility Fallback warning skipped for unrendered declarations Subsetting resolution bypasses fallback Redefinition resolution skips flagged fallback
Review effort: Lite
…ody, layout re-check - A membership import of an alias brings in the alias's short name. - Visibility and short-name capture applies to KerML type, action, state, and requirement bodies, never taking a nested member's prefix. - Layouts re-check semantic typing/supertype targets with NameResolver; a different KerML resolution wins. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
There was a problem hiding this comment.
🔵 Needs a closer look
A critical active finding shows semantic resolution can still create Typing/Supertype edges to private or out-of-scope targets, allowing references to cross namespace visibility boundaries.
7 resolved since last review
Semantic import lookup crosses namespace boundaries Qualified symbol lookup ignores visibility and access rules Specialized body collectors omit visibility and short-name metadata Filtered imports can expand excluded containers Filtered imports can produce incorrect supertype edges Semantic edge resolution bypasses visibility checks Imported aliases lose their short names
Review effort: Lite


Problem
ApiMark has three distinct
DocumentationCoverageCheckerpart defs, one each inApiMarkCpp,ApiMarkDotNetandApiMarkVhdl. The General View drew one box wired to all three systems, plus two unconnected duplicates.The layout strategies re-resolved raw reference text through a first-seen simple-name dictionary that spans the whole workspace. That ignores SysML v2 name resolution:
GeneralViewLayoutStrategy.BuildModelEdges/TryResolveQualifiedInterconnectionViewLayoutStrategy.ResolveByTypingGridViewLayoutStrategy.ResolveSupertypeIndicesResolveOwningBoxendpoint mappingChange (spec basis: KerML 1.1 Beta 2 §8.2.3.5)
NameResolver:aliasmemberships all match.AstBuilder: captures membership visibility (public by default), import visibility (private by default) andimport all, short names, andaliasmembers (SysmlVisibility,SysmlAliasNode).ReferenceResolver: a simple name is looked up in the global namespace only after the enclosing namespaces and imports (§8.2.3.5.4). Previously, a localBaseresolved to the standard library's top-levelBasepackage.NameResolver. The bare simple-name fallback now emits a layout warning (Reference 'X' in 'P::Q' … matched 'A::X' by simple name only (ambiguous: …)) instead of silently picking a match.ResolveOwningBoxno longer maps already-qualified endpoints by simple name.Tests
Base; visibility, short name and alias are captured.Requirements, design (with spec clauses) and verification docs are updated, including a new
NameResolverunit.Validation
./build.ps1: all tests pass on net8/9/10/11../lint.ps1: clean.reqstream --lint --enforce: clean.DocumentationCoverageCheckerboxes with no fallback warnings.