Enhance filter-expression evaluation and metaclass-kind classification#35
Merged
Conversation
…etaclass-kind gap
… 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>
Contributor
There was a problem hiding this comment.
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
FilterExpressionEvaluatorclassification tests to match by node-kind → metaclass mapping plus stdlibspecializesconformance. - Admit named
SysmlFeatureNodeusages 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.
…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>
- 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>
…rategy design doc Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
- 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>
…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>
…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>
This was referenced Jul 20, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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::PartUsagecorrectly 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:
FilterExpressionEvaluator, so a filter like@Typematches if either the candidate's applied annotation or its AST node kind (via a newMetaclassNamestable and specialization walk) corresponds to the requested metaclass. This is documented in detail, including known gaps and rationale for the matching logic. [1] [2]GeneralViewLayoutStrategy.CollectDefinitionsandExposeScopeResolverto include namedSysmlFeatureNodeusages (not justSysmlDefinitionNodedefinitions), 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:
Grammar and roadmap clarification:
ROADMAP.mdthat certain constructs (bareistype/hastype) are not applicable in filter expressions under the actual SysML v2 grammar, and documented the rationale and evidence for deferring other constructs.Other: