Skip to content

Feature-chain resolution (#129 stage 3): corpus strict errors 94 → 48 - #136

Merged
Malcolmnixon merged 1 commit into
mainfrom
resolver-feature-chains
Nov 19, 2026
Merged

Malcolmnixon merged 1 commit into
mainfrom
resolver-feature-chains

Conversation

@Malcolmnixon

Copy link
Copy Markdown
Member

Pull Request

Description

This is stage 3 of #129, which fixes false "Unresolved reference" diagnostics on valid models. It adds feature-chain resolution per KerML 1.0 §8.2.3.5: the first segment resolves from the local namespace, and each later segment uses visible resolution in the previous segment's types. It builds on the stage 2 inherited lookup (explicit and implicit general types).

Chain kinds handled:

  • Usage specialization chains: p1 :> p; then p1.x.
  • Aliases. Private aliases stay hidden.
  • Conjugated port types (~Port members).
  • Quoted segments.
  • Inline owned members.
  • Multi-level chains.
  • Qualified first segments: P::p.x.

Where chains are used: subsetting and redefinition targets, allocate, satisfy and verify targets, and connect, bind, message and transition endpoints.

Also fixed:

  • Anonymous $fork0-style endpoints no longer raise a diagnostic.
  • satisfy r : R by s now satisfies R, not r.

Legacy code retired: about 150 lines of ad-hoc chain logic in ReferenceResolver (TryResolveFeatureChain, FindFeatureMember). Chains now go through NameResolver. The visibility rules from #94 still hold: private members are not visible through a chain from outside, and a first segment can still see local private members.

Results (all of #129 so far):

Metric Start of #129 Stage 1 Stage 2 Stage 3
OMG corpus, strict errors (ratchet cap) 161 139 94 48
OMG corpus, files failing strict 60 53 36 18
Stdlib warnings 1964 65 45 13

Default mode still reports 0 errors.

The remaining 48 are not name-resolver bugs. They come from model data the AST does not capture yet:

  • 26: nested action, calc and constraint bodies, for example producer_2.producerBehavior.publish.sentMessage.
  • 7: bare directed usages, for example shoot.picture.
  • 5: timeslices and snapshots, for example vehicle1_t0.
  • 3: only the first of several redefinitions (:>> a :>> b) is recorded.
  • 3: a name collision in the corpus itself (part def Camera and package Camera).
  • 2: an anonymous owner.
  • 2: #service def, which is not modeled.

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

Refs #129

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: 6149 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: 26 new tests covering each chain kind, visibility through chains and multi-level chains; the ratchet cap is lowered to 48.
  • 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): NameResolver and ReferenceResolver design and verification docs.
  • Added code examples for new features (if applicable). N/A.
  • Updated requirements.yaml (if applicable): the reqstream files.

Additional Notes

  • Gallery: all 24 SVGs are byte-identical, with 0 diagnostics in both default and strict modes.
  • Performance: corpus lint CPU time rose by about 2.5% (67.4s → 69.1s, on a noisy machine).
  • stdlib.json.gz: regenerated.
  • Next: making strict mode the default needs the AST gaps listed above to be closed first. A follow-up issue tracks them.

…): corpus strict errors 94 -> 48

Feature chains (a.b.c) now resolve per KerML 8.2.3.5: first segment by full
resolution, every later segment by visible resolution in the previous
feature through its own and inherited members (explicit and implicit general
types, subsetting/redefinition, aliases, conjugated port types, inline
members), public members only. Chains are accepted by every reference kind
(supertype, redefinition, allocate, satisfy, verify, connect/bind/transition
ends) and recorded at the instance path for relationship ends.

- NameResolver: chain-aware Resolve/ResolveRedefinedFeature, ResolveFeatureChain
  (instance path), quote-aware dot splitting, quoted/unquoted name equivalence,
  re-entry guard for self-referential chains
- ReferenceResolver: retire TryResolveFeatureChain/FindFeatureMember, accept
  anonymous $fork0-style succession ends
- AstBuilder: satisfy requirement usage satisfies its typing, not its own name
- OMG corpus strict errors 94 -> 48 (36 -> 18 files); stdlib warnings 45 -> 13;
  gallery output unchanged; remaining errors are members the AST does not model

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

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 PR rewrites recursive name resolution and edge-path semantics across multiple reference kinds, while the review environment cannot run the claimed .NET test or corpus validation, so human confirmation of corpus and layout/query regressions is needed.

No open issues 🎉

What changed in this PR

This pull request implements stage 3 of feature-chain resolution for SysML/KerML references, centralizing chained lookup in NameResolver, extending semantic relationship resolution, and reducing false strict-mode OMG corpus diagnostics from 94 to 48.

Changes:

  • Added segment-by-segment resolution for inherited, subsetted, aliased, conjugated, quoted, inline, qualified, and cyclic feature chains.
  • Updated ReferenceResolver for chain-aware relationship endpoints, instance paths, anonymous action nodes, and satisfy requirement typing.
  • Added regression coverage and updated design, verification, requirements, and diagnostic-threshold documentation.
File Description
test/​DemaConsulting.SysML2Tools.Tests/​Semantic/​WorkspaceLoaderTests.cs Adds workspace-level tests for feature-chain relationships, anonymous action nodes, and satisfy requirement typing.
test/​DemaConsulting.SysML2Tools.Tests/​Semantic/​StdlibProviderTests.cs Lowers the standard-library unresolved-warning ceiling to 13.
test/​DemaConsulting.SysML2Tools.Tests/​Semantic/​SemanticOmgModelsTests.cs Lowers the OMG strict-mode diagnostic baseline to 48 and verifies resolved corpus models.
test/​DemaConsulting.SysML2Tools.Tests/​Semantic/​NameResolverTests.cs Adds unit coverage for feature-chain traversal, visibility, aliases, conjugation, quoting, cycles, and qualified names.
src/​DemaConsulting.SysML2Tools.Language/​Semantic/​Model/​ReferenceResolver.cs Routes reference resolution through NameResolver, records instance-path relationship endpoints, and handles anonymous action nodes.
src/​DemaConsulting.SysML2Tools.Language/​Semantic/​Model/​NameResolver.cs Implements feature-chain parsing and lookup, quote equivalence, cycle handling, instance paths, and chain-aware redefinition resolution.
src/​DemaConsulting.SysML2Tools.Language/​Semantic/​Model/​AstBuilder.cs Records the requirement typing associated with declared satisfy usages.
docs/​verification/​sysml2-tools-language/​semantic/​model/​reference-resolver.md Updates resolver verification scenarios for chains, instance paths, anonymous nodes, and satisfy declarations.
docs/​verification/​sysml2-tools-language/​semantic/​model/​name-resolver.md Documents feature-chain and quoted-name verification coverage.
docs/​user_guide/​introduction.md Updates strict-mode guidance, limitations, and OMG corpus metrics.
docs/​reqstream/​sysml2-tools-language/​semantic/​model/​reference-resolver.yaml Adds traceability for instance-path and anonymous-action requirements.
docs/​reqstream/​sysml2-tools-language/​semantic/​model/​name-resolver.yaml Adds feature-chain and quote-equivalence requirements and tests.
docs/​reqstream/​sysml2-tools-language/​semantic/​model/​ast-builder.yaml Adds traceability for satisfy requirement-name typing.
docs/​reqstream/​sysml2-tools-language/​semantic/​model.yaml Registers the new semantic model requirements.
docs/​reqstream/​sysml2-tools-language.yaml Updates language-level feature-chain and satisfy verification traceability.
docs/​design/​sysml2-tools-stdlib.md Updates standard-library diagnostic metrics and remaining limitations.
docs/​design/​sysml2-tools-language/​semantic/​workspace-loader.md Updates strict-mode corpus status, diagnostic rationale, and remaining gaps.
docs/​design/​sysml2-tools-language/​semantic/​model/​reference-resolver.md Documents centralized chain-aware reference resolution, instance paths, anonymous nodes, and remaining scope boundaries.
docs/​design/​sysml2-tools-language/​semantic/​model/​name-resolver.md Documents feature-chain semantics, quote handling, caching, and cycle behavior.
docs/​design/​sysml2-tools-language/​semantic/​model/​ast-builder.md Documents satisfy declaration typing extraction.
docs/​design/​introduction.md Updates the architecture overview for centralized feature-chain resolution.

Review effort: Lite

@Malcolmnixon
Malcolmnixon merged commit ed60461 into main Nov 19, 2026
10 checks passed
@Malcolmnixon
Malcolmnixon deleted the resolver-feature-chains branch November 19, 2026 22:55
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.

2 participants