Skip to content

Enhance filter-expression evaluation and metaclass-kind classification#35

Merged
Malcolmnixon merged 8 commits into
mainfrom
feature/filter-istype-hastype
Jul 13, 2026
Merged

Enhance filter-expression evaluation and metaclass-kind classification#35
Malcolmnixon merged 8 commits into
mainfrom
feature/filter-istype-hastype

Conversation

@Malcolmnixon

Copy link
Copy Markdown
Member

This pull request delivers Phase 2d of the SysML v2 filter expression evaluation, expanding support for metaclass/kind classification-test matching and usage-level filter candidates. It updates the documentation to describe these new behaviors, clarifies the grammar limitations around certain constructs, and adds new test coverage. The changes ensure that filters like @SysML::PartUsage correctly match usages based on both applied domain metadata and the candidate node's AST kind, and that usage-level candidates are included and deduplicated in filter results.

Filter expression evaluation enhancements:

  • Added support for metaclass/kind classification-test matching in FilterExpressionEvaluator, so a filter like @Type matches if either the candidate's applied annotation or its AST node kind (via a new MetaclassNames table and specialization walk) corresponds to the requested metaclass. This is documented in detail, including known gaps and rationale for the matching logic. [1] [2]
  • Widened the filter candidate set in both GeneralViewLayoutStrategy.CollectDefinitions and ExposeScopeResolver to include named SysmlFeatureNode usages (not just SysmlDefinitionNode definitions), enabling correct filtering of usage-level elements. The deduplication logic for nested usages was improved to avoid rendering duplicates or dropping deeply nested usages. [1] [2] [3]

Documentation updates:

  • Updated design docs to describe the new metaclass/kind classification-test matching path, the candidate set widening, and the specialization-conformance walk. Added explicit references to new tests and clarified known limitations and rationale. [1] [2] [3] [4] [5] [6] [7]

Grammar and roadmap clarification:

  • Clarified in ROADMAP.md that certain constructs (bare istype/hastype) are not applicable in filter expressions under the actual SysML v2 grammar, and documented the rationale and evidence for deferring other constructs.

Other:

  • Added "metaclass" and "metaclasses" to the spell-check word list.

Malcolm Nixon and others added 2 commits July 13, 2026 09:45
… candidates

- FilterExpressionEvaluator now matches classification tests (@Type/@pkg::Type)
  against a candidate's own built-in SysML/KerML metaclass kind (e.g. part ->
  SysML::PartUsage, part def -> SysML::PartDefinition), verified against the
  real embedded stdlib metadata definitions, in addition to explicit applied
  metadata annotations.
- Honors stdlib metaclass specialization chains for conformance (e.g. @ConstraintUsage
  matches a RequirementUsage candidate), mirroring istype-style kind-of semantics.
- GeneralViewLayoutStrategy/ExposeScopeResolver widen filter candidates to include
  usage-level nodes (not just definitions), with depth-ordered dedup to avoid
  redundant nested-usage rendering.
- Fixes the confirmed corpus bug: filter @sysml::PartUsage; (OMG's own
  42.Views/ViewsExample.sysml pattern) previously rendered a silently empty
  diagram; now renders only the matching elements.
- ROADMAP.md Phase 2d marked delivered; istype/hastype confirmed out of scope
  (no bare grammar form, zero corpus evidence in filter position).

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

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.

Pull request overview

This PR advances SysML v2 view filter evaluation (Phase 2d) by (1) enabling classification tests like @SysML::PartUsage to match candidates by AST kind/metaclass (with stdlib specialization conformance), and (2) widening view/expose filter candidate sets to include named usage-level declarations, with post-filter deduplication to prevent nested-usage box duplication. It also updates roadmap/design/verification/ReqStream artifacts and adds regression-focused test coverage.

Changes:

  • Extend FilterExpressionEvaluator classification tests to match by node-kind → metaclass mapping plus stdlib specializes conformance.
  • Admit named SysmlFeatureNode usages as filter/render candidates in General View and expose bracket-filter evaluation, with nested-usage dedup after narrowing.
  • Add targeted unit/regression tests and update roadmap/design/verification/ReqStream docs accordingly.

Reviewed changes

Copilot reviewed 19 out of 19 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
test/DemaConsulting.SysML2Tools.Tests/Layout/GeneralViewLayoutStrategyTests.cs Adds regression tests for usage-level candidates, metaclass-kind filters, nested-usage dedup, and a gallery-model box-count guard.
test/DemaConsulting.SysML2Tools.Tests/Layout/ExposeScopeResolverTests.cs Adds bracket-filter test proving usage-level candidates are considered for metaclass-kind filtering.
test/DemaConsulting.SysML2Tools.Tests/Filtering/FilterExpressionEvaluatorTests.cs Adds unit tests for metaclass-kind classification matching and specialization-conformance behavior.
src/DemaConsulting.SysML2Tools.Core/Layout/Internal/GeneralViewLayoutStrategy.cs Widens candidate collection to include usages and adds RemoveRedundantNestedUsages dedup stage.
src/DemaConsulting.SysML2Tools.Core/Layout/Internal/ExposeScopeResolver.cs Expands bracket-filter candidate query to include usage declarations.
src/DemaConsulting.SysML2Tools.Core/Filtering/FilterExpressionEvaluator.cs Implements metaclass/kind classification matching (keyword table + stdlib specialization walk).
ROADMAP.md Documents Phase 2d delivery details and clarifies grammar constraints around istype/hastype.
docs/verification/sysml2-tools-core/layout/internal/general-view-layout-strategy.md Updates verification claims and test scenario mapping for usage-level candidates and dedup behavior.
docs/verification/sysml2-tools-core/layout/internal/expose-scope-resolver.md Documents bracket-filter candidate widening to include usages.
docs/verification/sysml2-tools-core/filtering/filter-expression-evaluator.md Documents metaclass-kind classification behavior and related tests.
docs/reqstream/sysml2-tools-core/layout/internal/general-view-layout-strategy.yaml Adds ReqStream requirement/test mapping for usage-level candidate admission + dedup semantics.
docs/reqstream/sysml2-tools-core/layout/internal/expose-scope-resolver.yaml Adds ReqStream requirement/test mapping for bracket-filter usage-level candidates.
docs/reqstream/sysml2-tools-core/filtering/filter-expression-evaluator.yaml Adds ReqStream requirement/test mapping for metaclass-kind classification tests.
docs/reqstream/sysml2-tools-core/filtering.yaml Includes new evaluator requirement and new tests in the filtering module rollup.
docs/design/sysml2-tools-core/layout/internal/general-view-layout-strategy.md Updates design description for usage-level candidate admission and post-narrowing dedup stage.
docs/design/sysml2-tools-core/layout/internal/expose-scope-resolver.md Updates design notes for ExplicitMembers including usages and widened bracket-filter candidate set.
docs/design/sysml2-tools-core/filtering/filter-expression-evaluator.md Adds design explanation for metaclass/kind mapping and stdlib specialization walk.
docs/design/sysml2-tools-core/filtering.md Updates high-level filtering design overview to reflect metaclass-kind matching and usage candidates.
.cspell.yaml Adds “metaclass/metaclasses” to spelling dictionary.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread src/DemaConsulting.SysML2Tools.Core/Filtering/FilterExpressionEvaluator.cs Outdated
Comment thread src/DemaConsulting.SysML2Tools.Core/Layout/Internal/GeneralViewLayoutStrategy.cs Outdated
…etaclass; complete DefBox XML doc params

- ConformsToMetaclass now searches the small workspace.StdlibNames set
  and looks up the match directly in Declarations, instead of scanning
  every entry in Declarations (which includes all user-model nodes).
- DefBox's XML doc previously had empty <param> tags for every member
  except IsUsage; filled in brief descriptions for all params for
  consistency.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot AI review requested due to automatic review settings July 13, 2026 17:34

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.

Pull request overview

Copilot reviewed 19 out of 19 changed files in this pull request and generated 2 comments.

Comment thread src/DemaConsulting.SysML2Tools.Core/Layout/Internal/GeneralViewLayoutStrategy.cs Outdated
Comment thread src/DemaConsulting.SysML2Tools.Core/Layout/Internal/GeneralViewLayoutStrategy.cs Outdated
- Only exclude unnamed SysmlFeatureNode usages (no stable qualified
  name to key a box on). An unnamed SysmlDefinitionNode is still
  admitted, keying its box on the declaration's own qualified name,
  restoring behavior that regressed when usage-level candidates were
  introduced.
- DefBox's specialization SupertypeNames are now sourced only from
  SysmlDefinitionNode declarations. SysmlFeatureNode.SupertypeNames is
  populated exclusively by usage-level subsets/:> clauses (subsetting,
  not specialization), so surfacing it here previously caused
  usage-level boxes to incorrectly emit specialization edges when they
  subset another feature.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot AI review requested due to automatic review settings July 13, 2026 17:54

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.

Pull request overview

Copilot reviewed 19 out of 19 changed files in this pull request and generated 1 comment.

Comment thread docs/design/sysml2-tools-core/layout/internal/general-view-layout-strategy.md Outdated
…rategy design doc

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot AI review requested due to automatic review settings July 13, 2026 18:01

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.

Pull request overview

Copilot reviewed 19 out of 19 changed files in this pull request and generated 2 comments.

Comment thread src/DemaConsulting.SysML2Tools.Core/Filtering/FilterExpressionEvaluator.cs Outdated
Comment thread src/DemaConsulting.SysML2Tools.Core/Filtering/FilterExpressionEvaluator.cs Outdated
- Merge two consecutive XML <remarks> blocks on FilterExpressionEvaluator
  into a single well-formed block.
- Expand MetaclassNameMatches to accept stdlib-qualified names under the
  SysML:: namespace at any depth (e.g. SysML::Systems::PartUsage), not
  just the exact two-segment SysML::PartUsage spelling, so a filter
  written against the stdlib's real declaring package path also matches.

Verified via a code-review sub-agent pass (no issues found: no false-
positive risk from the broadened suffix match, correct interaction with
ConformsToMetaclass's specialization walk, well-formed XML doc).

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot AI review requested due to automatic review settings July 13, 2026 18:15

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.

Pull request overview

Copilot reviewed 19 out of 19 changed files in this pull request and generated 3 comments.

Comment thread src/DemaConsulting.SysML2Tools.Core/Layout/Internal/GeneralViewLayoutStrategy.cs Outdated
Comment thread ROADMAP.md Outdated
…evel candidates

- ExposeScopeResolver.cs: update XML docs (type summary, ExplicitMembers
  param, IsInSubjectScope) to say 'definition and/or named usage'
  instead of 'definition only', matching the earlier candidate-set
  widening to include SysmlFeatureNode usages.
- GeneralViewLayoutStrategy.cs: update DefBox's summary to reflect that
  it now represents usage-level boxes too, not just definitions.
- ROADMAP.md: correct a misleading claim that the bare 'allocation'
  keyword is entirely absent from MetaclassNames (the table does
  contain 'allocation def' -> AllocationDefinition; it's specifically
  the bare 'allocation' feature/connection-usage keyword, captured by
  SysmlConnectionNode, that is out of scope). Also updated a stale
  description of MetaclassNameMatches to reflect the already-shipped
  suffix-match broadening (StartsWith/EndsWith under SysML::) rather
  than the earlier exact two-segment spelling.

Verified via a code-review sub-agent pass (no issues found).

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot AI review requested due to automatic review settings July 13, 2026 18:29

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.

Pull request overview

Copilot reviewed 19 out of 19 changed files in this pull request and generated 2 comments.

Comment thread src/DemaConsulting.SysML2Tools.Core/Filtering/FilterExpressionEvaluator.cs Outdated
…cket-filter candidates to named usages

- FilterExpressionEvaluator.cs: ConformsToMetaclass's per-step
  FirstOrDefault linear scan over workspace.StdlibNames is replaced
  with a per-workspace cached bare-name -> qualified-name dictionary
  (GetStdlibBareNameLookup), stored in a ConditionalWeakTable keyed by
  workspace reference identity so the cache doesn't prevent workspace
  GC and is naturally scoped per workspace instance. First-match-wins
  semantics are preserved via Dictionary.TryAdd.
- ExposeScopeResolver.cs: the bracket-filter candidate query now
  restricts SysmlFeatureNode candidates to those with a non-null Name,
  matching GeneralViewLayoutStrategy.CollectDefinitions's existing
  exclusion of unnamed usages (which have no stable qualified name to
  key a rendered box on) -- previously an unnamed usage could end up
  in ExplicitMembers even though it could never be rendered/collected
  downstream.

Verified via a code-review sub-agent pass (no issues found: caching
approach confirmed correct and race-free, first-match-wins semantics
confirmed preserved, candidate-filter fix confirmed to exactly mirror
CollectDefinitions's exclusion logic).

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot AI review requested due to automatic review settings July 13, 2026 18:42

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.

Pull request overview

Copilot reviewed 19 out of 19 changed files in this pull request and generated 1 comment.

@Malcolmnixon
Malcolmnixon merged commit cc3acc0 into main Jul 13, 2026
10 checks passed
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