Skip to content

Build AST nodes for nested bodies, directed usages, timeslices, multi-redefinition (#137): corpus strict errors 48 → 8 - #138

Merged
Malcolmnixon merged 3 commits into
mainfrom
ast-coverage-gaps
Nov 20, 2026
Merged

Malcolmnixon merged 3 commits into
mainfrom
ast-coverage-gaps

Conversation

@Malcolmnixon

Copy link
Copy Markdown
Member

Pull Request

Description

Closes the AST coverage gaps that blocked strict-by-default lint (#137). Each construct below previously built no AST node, so references into it could never resolve:

  • Action, calc, constraint and case bodies (definitions and usages) and transition effects: nested usages, nested actions and parameters.
  • Bare directed usages (in x : T;), with direction, typing and multiplicity. These are designed so [Feature]: Action Flow View: parameters, swimlanes, flows, nested actions, control structures #103 can render action parameters later.
  • Timeslice and snapshot usages.
  • perform, exhibit, include and assert constraint usages.
  • Multiple redefinitions (:>> a :>> b): all targets are recorded and resolved.
  • Anonymous owner scopes.

The new nodes are kept out of diagrams through IsExcludedFromDiagrams, so gallery images are byte-identical.

Results:

Metric Before After
OMG corpus strict errors (ratchet cap) 48 8
OMG corpus files failing strict 18 4
OMG corpus default-mode errors 0 0
Stdlib warnings 13 12 (0 errors)
stdlib.json.gz 729,610 B 881,745 B

The remaining 8 are all explained:

  • 3, in training/17.Control/Camera.sysml: a genuine collision in the corpus, where a root-level package Camera sits alongside examples/CameraExample/Camera.sysml's root-level part def Camera. Each file resolves cleanly on its own, and a test covers this.
  • 5, #service def, #cloud and #cause: semantic-metadata keyword usages, not modeled yet. A follow-up issue will track them.

Since #129 began, strict errors on the OMG corpus have gone 161 → 8 and failing files 60 → 4.

Type of Change

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • Documentation update
  • Code quality improvement

Related Issues

Closes #137

Pre-Submission Checklist

Before submitting this pull request, ensure you have completed the following:

Build and Test

  • Code builds successfully and all tests pass: pwsh ./build.ps1. Passed: 6357 tests.
  • Code produces zero warnings

Code Quality

  • New code has appropriate XML documentation comments
  • Static analyzer warnings have been addressed

Quality Checks

  • All linters pass: pwsh ./lint.ps1. Passed.

Testing

  • Added unit tests for new functionality: one per construct, the Camera single-file test, and the ratchet cap lowered to 8.
  • Updated existing tests if behavior changed
  • All tests follow the AAA (Arrange, Act, Assert) pattern
  • Test coverage is maintained or improved

Documentation

  • Updated README.md (if applicable). N/A.
  • Updated docs/ documentation (if applicable): AstBuilder and SysmlNode design and verification docs, and the export format notes in the user guide.
  • Added code examples for new features (if applicable). N/A.
  • Updated requirements.yaml (if applicable): the reqstream files.

Additional Notes

  • Export and query: output now includes the new declaration kinds, two new fields, and $anon<n>/$perform<n> name segments. No golden files changed.
  • OMG corpus renders (not committed): 12 of 275 differ because references now resolve. New = binding connectors and :>/:>> labels appear.
  • Performance: lint on the spec's Annex A SimpleVehicleModel takes 9s on both main and this branch, with peak memory 209 MB on main and 222 MB here.
    • Separately, render --auto on that model does not finish within 15 minutes, on main as well as this branch. Profiling puts the time in the Rendering library's orthogonal edge router. This is unrelated to this PR and is being investigated separately.

…tions and anonymous owners (closes #137)

Build the AST members the OMG corpus references but the AST lacked, so that corpus strict unresolved-reference errors drop from 48 (18 files) to 8 (4 files), each explained (3 from a genuine name collision between two corpus files, 5 from user-defined keyword/semantic-metadata members left unmodeled).

- AstBuilder: bare/default reference usages (ref, with direction/typing/multiplicity; return = out), timeslice/snapshot/individual usages, bodies of action/calc/constraint/state/case usages and definitions, perform/exhibit/include/assert constraint usages, a named transition effect, all redefinition targets (AdditionalRedefinedFeatureNames) and redefinition/subsetting capture for every usage kind, a synthetic $anon scope for an anonymous usage with a body.

- NameResolver/ReferenceResolver: implicit-specialization rows (perform, exhibit, include, assert constraint, timeslice, snapshot, transition), reference subsetting as a lookup general type, self-exclusion for general-type references, every redefinition target resolved and inherited, anonymous owner scope.

- SysmlNode.IsExcludedFromDiagrams/DiagramChildren: the new members stay out of every diagram strategy, the auto-view target and the dynamic-view pre-check; gallery images are byte-identical.

- stdlib.json.gz regenerated (0.73 MB to 0.88 MB; stdlib warnings 13 to 12), corpus ratchet lowered to 8 with an expected-errors table, tests, requirements, design, verification and user guide updated.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot AI lite review requested due to automatic review settings November 20, 2026 04:13

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔵 Needs a closer look

The broad cross-component changes affect parsing, resolution, serialization, and all layout strategies, while the full test/build matrix and rendering regressions remain unverified.

No open issues 🎉

What changed in this PR

This pull request expands SysML AST coverage for nested behavior bodies, directed usages, semantic usages, multiple redefinitions, and anonymous scopes, improving name resolution and reducing strict OMG corpus diagnostics from 48 to 8 while preserving diagram output.

Changes:

  • Builds and resolves previously unmodeled AST members, usages, effects, and redefinition targets.
  • Excludes resolution-only nodes from diagram rendering and layout strategies.
  • Adds semantic, layout, serialization, corpus, documentation, and requirements coverage for the new behavior.
File Description
test/​DemaConsulting.SysML2Tools.Tests/​Semantic/​WorkspaceLoaderTests.cs Updates bare-parameter expectations to validate generated reference nodes.
test/​DemaConsulting.SysML2Tools.Tests/​Semantic/​StdlibProviderTests.cs Lowers the standard-library warning threshold.
test/​DemaConsulting.SysML2Tools.Tests/​Semantic/​SemanticOmgModelsTests.cs Adds strict OMG corpus coverage and assertions for the remaining documented diagnostics.
test/​DemaConsulting.SysML2Tools.Tests/​Semantic/​NameResolverTests.cs Updates implicit-specialization expectations for case and verification definitions.
test/​DemaConsulting.SysML2Tools.Tests/​Semantic/​KermlLibraryIndexingTests.cs Adjusts unnamed KerML member coverage for bare usages.
test/​DemaConsulting.SysML2Tools.Tests/​Semantic/​AstSerializerTests.cs Verifies serialization of additional redefinitions and diagram-exclusion metadata.
test/​DemaConsulting.SysML2Tools.Tests/​Semantic/​AstBodyCoverageTests.cs Adds broad AST, resolution, body, scope, and redefinition coverage.
test/​DemaConsulting.SysML2Tools.Tests/​Layout/​ExcludedMembersLayoutTests.cs Verifies that excluded members do not alter rendered diagrams.
src/​DemaConsulting.SysML2Tools.Language/​Semantic/​Model/​SysmlNode.cs Adds diagram-exclusion metadata and storage for multiple redefinition targets.
src/​DemaConsulting.SysML2Tools.Language/​Semantic/​Model/​ReferenceResolver.cs Resolves all redefinition targets and anonymous owner scopes.
src/​DemaConsulting.SysML2Tools.Language/​Semantic/​Model/​NameResolver.cs Adds lookup support for reference subsetting, new usage kinds, transitions, and multiple redefinitions.
src/​DemaConsulting.SysML2Tools.Language/​Semantic/​Model/​AstBuilder.cs Builds new AST nodes for body members, usages, effects, scopes, and redefinition metadata.
src/​DemaConsulting.SysML2Tools.Core/​Rendering/​Internal/​DynamicViewSynthesizer.cs Excludes resolution-only children from dynamic-view compatibility checks.
src/​DemaConsulting.SysML2Tools.Core/​Rendering/​DiagramRenderer.cs Ignores excluded definitions and children during automatic-view selection.
src/​DemaConsulting.SysML2Tools.Core/​Layout/​Internal/​StateTransitionViewLayoutStrategy.cs Filters excluded states and transitions from state-transition layouts.
src/​DemaConsulting.SysML2Tools.Core/​Layout/​Internal/​SequenceViewLayoutStrategy.cs Filters excluded lifelines and messages from sequence layouts.
src/​DemaConsulting.SysML2Tools.Core/​Layout/​Internal/​InterconnectionViewLayoutStrategy.cs Filters excluded parts, ports, connectors, and roots from interconnection layouts.
src/​DemaConsulting.SysML2Tools.Core/​Layout/​Internal/​GridViewLayoutStrategy.cs Omits excluded definitions from relationship grids.
src/​DemaConsulting.SysML2Tools.Core/​Layout/​Internal/​GeneralViewLayoutStrategy.cs Filters excluded members from general-view boxes and compartments.
src/​DemaConsulting.SysML2Tools.Core/​Layout/​Internal/​BrowserViewLayoutStrategy.cs Omits excluded declarations from browser trees.
src/​DemaConsulting.SysML2Tools.Core/​Layout/​Internal/​ActionFlowViewLayoutStrategy.cs Filters excluded actions and successions from action-flow layouts.
docs/​verification/​sysml2-tools-language/​semantic/​model/​sysml-node.md Documents verification scenarios for node properties and diagram exclusion.
docs/​verification/​sysml2-tools-language/​semantic/​model/​reference-resolver.md Documents multiple-redefinition and anonymous-scope verification.
docs/​verification/​sysml2-tools-language/​semantic/​model/​name-resolver.md Documents new lookup and implicit-specialization scenarios.
docs/​verification/​sysml2-tools-language/​semantic/​model/​ast-builder.md Documents AST-builder coverage for new body and usage constructs.
docs/​verification/​sysml2-tools-language/​semantic/​ast-serializer.md Records serializer verification coverage for the new members.
docs/​verification/​sysml2-tools-core/​rendering/​internal/​dynamic-view-synthesizer.md Records dynamic-view exclusion verification.
docs/​verification/​sysml2-tools-core/​rendering/​diagram-renderer.md Records automatic-view exclusion verification.
docs/​verification/​sysml2-tools-core/​layout/​internal/​state-transition-view-layout-strategy.md Records state-transition exclusion verification.
docs/​verification/​sysml2-tools-core/​layout/​internal/​sequence-view-layout-strategy.md Records sequence-member exclusion verification.
docs/​verification/​sysml2-tools-core/​layout/​internal/​interconnection-view-layout-strategy.md Records interconnection-member exclusion verification.
docs/​verification/​sysml2-tools-core/​layout/​internal/​grid-view-layout-strategy.md Records grid-definition exclusion verification.
docs/​verification/​sysml2-tools-core/​layout/​internal/​general-view-layout-strategy.md Records general-view exclusion verification.
docs/​verification/​sysml2-tools-core/​layout/​internal/​browser-view-layout-strategy.md Records browser-declaration exclusion verification.
docs/​verification/​sysml2-tools-core/​layout/​internal/​action-flow-view-layout-strategy.md Records action-flow exclusion verification.
docs/​user_guide/​introduction.md Updates strict-lint behavior and exported AST-member documentation.
docs/​reqstream/​sysml2-tools-language/​semantic/​model/​sysml-node.yaml Adds requirements for node properties and diagram exclusion.
docs/​reqstream/​sysml2-tools-language/​semantic/​model/​reference-resolver.yaml Adds requirements for multiple redefinitions and corpus resolution.
docs/​reqstream/​sysml2-tools-language/​semantic/​model/​name-resolver.yaml Adds requirements for reference subsetting and implicit specialization.
docs/​reqstream/​sysml2-tools-language/​semantic/​model/​ast-builder.yaml Adds requirements for the expanded AST-building behavior.
docs/​reqstream/​sysml2-tools-language/​semantic/​model.yaml Links the new semantic-model requirements.
docs/​reqstream/​sysml2-tools-language/​semantic/​ast-serializer.yaml Links serializer coverage requirements.
docs/​reqstream/​sysml2-tools-core/​rendering/​internal/​dynamic-view-synthesizer.yaml Adds dynamic-view exclusion requirements.
docs/​reqstream/​sysml2-tools-core/​rendering/​internal.yaml Registers dynamic-view requirements.
docs/​reqstream/​sysml2-tools-core/​rendering/​diagram-renderer.yaml Adds automatic-view exclusion requirements.
docs/​reqstream/​sysml2-tools-core/​rendering.yaml Registers the automatic-view requirement.
docs/​reqstream/​sysml2-tools-core/​layout/​internal/​state-transition-view-layout-strategy.yaml Adds state-transition exclusion requirements.
docs/​reqstream/​sysml2-tools-core/​layout/​internal/​sequence-view-layout-strategy.yaml Adds sequence exclusion requirements.
docs/​reqstream/​sysml2-tools-core/​layout/​internal/​interconnection-view-layout-strategy.yaml Adds interconnection exclusion requirements.
docs/​reqstream/​sysml2-tools-core/​layout/​internal/​grid-view-layout-strategy.yaml Adds grid exclusion requirements.
docs/​reqstream/​sysml2-tools-core/​layout/​internal/​general-view-layout-strategy.yaml Adds general-view exclusion requirements.
docs/​reqstream/​sysml2-tools-core/​layout/​internal/​browser-view-layout-strategy.yaml Adds browser exclusion requirements.
docs/​reqstream/​sysml2-tools-core/​layout/​internal/​action-flow-view-layout-strategy.yaml Adds action-flow exclusion requirements.
docs/​reqstream/​sysml2-tools-core/​layout/​internal.yaml Registers layout exclusion requirements.
docs/​design/​sysml2-tools-stdlib/​stdlib-provider.md Documents the expanded serialized standard library.
docs/​design/​sysml2-tools-language/​semantic/​model/​sysml-node.md Documents node exclusion and multiple-redefinition design.
docs/​design/​sysml2-tools-language/​semantic/​model/​reference-resolver.md Documents multi-target resolution and anonymous scopes.
docs/​design/​sysml2-tools-language/​semantic/​model/​name-resolver.md Documents new general-type lookup behavior.
docs/​design/​sysml2-tools-language/​semantic/​model/​ast-builder.md Documents expanded AST construction and exclusion behavior.
docs/​design/​sysml2-tools-core/​rendering/​internal/​dynamic-view-synthesizer.md Documents excluded-member compatibility handling.
docs/​design/​sysml2-tools-core/​rendering/​diagram-renderer.md Documents automatic-view filtering.
docs/​design/​sysml2-tools-core/​layout/​internal/​state-transition-view-layout-strategy.md Documents excluded state-transition handling.
docs/​design/​sysml2-tools-core/​layout/​internal/​sequence-view-layout-strategy.md Documents excluded sequence handling.
docs/​design/​sysml2-tools-core/​layout/​internal/​interconnection-view-layout-strategy.md Documents excluded interconnection handling.
docs/​design/​sysml2-tools-core/​layout/​internal/​grid-view-layout-strategy.md Documents excluded grid handling.
docs/​design/​sysml2-tools-core/​layout/​internal/​general-view-layout-strategy.md Documents excluded general-view handling.
docs/​design/​sysml2-tools-core/​layout/​internal/​browser-view-layout-strategy.md Documents excluded browser handling.
docs/​design/​sysml2-tools-core/​layout/​internal/​action-flow-view-layout-strategy.md Documents excluded action-flow handling.
.textlint.yaml Adds terminology for timeslice constructs.
.reviewmark.yaml Registers the new semantic and layout test coverage.

Review effort: Lite

…es resolve deterministically (refs #137)

The symbol table keeps the first registration of a qualified name, so which of two
same-named root declarations won depended on the caller's file order (directory
enumeration differs between Windows and Linux): the corpus Camera collision gave 8
strict errors on Windows and 5 on Linux. WorkspaceLoader now orders files by the
ordinal, '/'-normalized full path before registration and resolution.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

Unresolved moderate and critical issues remain in anonymous constraint scoping and general-type resolution, including incorrect member ownership and leakage of lookup-only references into the public type calculation.

1 open issue
1 previously missed issue

In code that hasn't changed since last review

Medium severity Give anonymous constraint bodies a synthetic scope

src/​DemaConsulting.SysML2Tools.Language/​Semantic/​Model/​AstBuilder.cs:2030

For an anonymous constraint { ... } usage, name is null, so the body members collected here are built while _namespaceStack is still the enclosing scope. A parameter such as in x : T; is therefore registered as an enclosing member (or can collide with one) instead of under a private synthetic owner. Please use the same synthetic-scope treatment as BuildUsageNode for nameless bodies.

Review effort: Lite

…) (refs #137)

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot AI lite review requested due to automatic review settings November 20, 2026 05:12

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔵 Needs a closer look

A moderate issue remains because anonymous constraint-body members are built without a local scope, causing them to be registered in the enclosing namespace where they can incorrectly shadow or resolve as siblings.

No open issues 🎉

1 previously missed issue

In code that hasn't changed since last review

Medium severity Give anonymous constraint bodies a synthetic scope

src/​DemaConsulting.SysML2Tools.Language/​Semantic/​Model/​AstBuilder.cs:2035

When an anonymous constraint usage has a body, this path now builds its local parameters and usages without creating a scope: name is null, so _namespaceStack is never extended and those children receive qualified names in the enclosing namespace (for example P::p::x). They are then registered and can shadow or resolve as siblings of the constraint even though they belong to the anonymous body's local scope. Please either give anonymous constraint bodies the same synthetic owner scope as other anonymous usages or avoid registering their body members.

1 resolved since last review

Review effort: Lite

@Malcolmnixon
Malcolmnixon merged commit 9db0113 into main Nov 20, 2026
10 checks passed
@Malcolmnixon
Malcolmnixon deleted the ast-coverage-gaps branch November 20, 2026 05:34
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.

[Feature]: AST coverage gaps blocking strict-by-default lint

2 participants