Skip to content

Implement CLI enhancements, grammar fixes, and performance refactor - #8

Merged
Malcolmnixon merged 10 commits into
mainfrom
feature/phase5-polish
Jun 27, 2026
Merged

Implement CLI enhancements, grammar fixes, and performance refactor#8
Malcolmnixon merged 10 commits into
mainfrom
feature/phase5-polish

Conversation

@Malcolmnixon

Copy link
Copy Markdown
Member

This pull request introduces a major reorganization and clarification of the project structure, documentation, and review configuration to better separate concerns between the Language, Stdlib, and Core libraries. The changes update the .reviewmark.yaml review definitions, solution/project structure, and design documentation to reflect the new modular architecture.

Key changes include:

Review configuration and architecture alignment

  • Added new review definitions in .reviewmark.yaml for DemaConsulting.SysML2Tools.Language and DemaConsulting.SysML2Tools.Stdlib, covering architecture, design, verification, and implementation, and updated existing reviews to reference the correct projects, paths, and documentation. [1] [2] [3]

Solution and project structure

  • Updated DemaConsulting.SysML2Tools.slnx to include separate projects for DemaConsulting.SysML2Tools.Language, DemaConsulting.SysML2Tools.Stdlib, DemaConsulting.SysML2Tools.Core, and the new Tools/StdlibGen tool, reflecting the new modular structure.

Design documentation updates

  • Revised docs/design/introduction.md to document the new breakdown of system, subsystem, and unit levels, clearly distinguishing the roles of the Language, Stdlib, and Core libraries, and describing new units such as AstSerializer, AstDeserializer, and StdlibProvider. [1] [2]
  • Updated the folder structure and NuGet package mapping in the design documentation to match the new organization, including the addition of sysml2-tools-language.md and sysml2-tools-stdlib.md design docs. [1] [2]

Core library documentation

  • Updated docs/design/sysml2-tools-core.md to clarify that the Core library now focuses on layout and rendering, and depends on the Language and Stdlib libraries for parsing and semantic analysis, with an updated architecture diagram.

Malcolm Nixon and others added 10 commits June 26, 2026 09:12
…on, NuGet attribution

- Add validate CLI command with inline self-test model (lint + SVG + PNG)
- Add --depth N flag to render command with ellipsis truncation beyond limit
- Add view name enumeration to multiple-view error diagnostic
- Add NuGet attribution for Noto Sans (SIL OFL 1.1) and SkiaSharp (MIT)
- Include OFL.txt in NuGet package content
- 600 tests passing

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
- Add view def GeneralView to general-view-test.sysml to enable rendering tests
- Add DiagramRenderer_RenderWorkspace_GeneralViewModel_SvgContainsElementNames:
  proves the full pipeline produces SVG containing ComponentA and ComponentB text
- Add DiagramRenderer_RenderWorkspace_GeneralViewModel_PngProducesValidOutput:
  proves PNG output is non-trivially sized with valid PNG header signature bytes
- Add DiagramRenderer_RenderWorkspace_GeneralViewModel_NoUnresolvedWarnings:
  confirms no false unresolved-reference warnings on same-package specialization
- Use inline SysML constant + temp file pattern (consistent with WorkspaceLoaderTests)
  to avoid dependency on test output directory layout

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

The daltskin/sysml-v2-grammar source omitted KerML classifier types
(datatype, class, struct, assoc, assoc struct) from the definitionElement
rule, causing the SysML v2 grammar to fail parsing the OMG standard
library .kerml files. These constructs are valid SysML v2 / KerML
textual notation and the grammar rules for them already existed -- they
were simply unreachable as package-level members.

Changes:
- SysMLv2Parser.g4: add dataType, class, structure, association,
  associationStructure to definitionElement
- Regenerated Parser/Antlr/ from updated grammar using JDK 25 + ANTLR 4.13.1
- AstBuilder: add VisitDataType, VisitClass, VisitStructure,
  VisitAssociation, VisitAssociationStructure visitors with shared
  BuildClassifierNode helper and GetSuperclassingSupertypes
- WorkspaceLoader: parallelize stdlib parsing across thread pool
- Grammar/README.md: document local patch and correct regeneration
  instructions (must run from Grammar/ directory)
- Parser/Antlr/README.md: reference local patches section

Result: stdlib warnings reduced from 10,000+ to ~111 (10 unique types),
all of which are downstream of remaining KerML expression-syntax gaps
(->reduce, ??, inv{}, return keywords in feature bodies).

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Patch 2: Add function and predicate to definitionElement
- These KerML behavioral classifiers appear at the top level of KerML
  function libraries (BaseFunctions.kerml, DataFunctions.kerml, etc.)
  but were missing from definitionElement, causing parse failures on
  every function declaration in the KerML stdlib

Patch 3: Allow bare qualifiedName as arrow expression argument
- KerML reduce/collect operations pass a function reference inline
  without parentheses: dimensions->reduce '*' ?? 1
- The upstream grammar required bodyExpression ({...}) or argumentList
  ((...)) after ->, leaving bare name arguments unrecognized
- Made the suffix optional and added qualifiedName as a third option

Both rule changes are documented in Grammar/README.md Local Patches.
AstBuilder updated with VisitFunction and VisitPredicate visitors.
206/206 tests passing.

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

- Extract Language project: ANTLR parser, AstBuilder, SymbolTable, ReferenceResolver,
  WorkspaceParser, WorkspaceLoader, AstSerializer/AstDeserializer
- Add Stdlib project: embeds pre-compiled stdlib.bin as managed resource via StdlibProvider
- Add StdlibGen tool: build-time codegen that parses all 94 stdlib files, resolves
  cross-references, and serializes the symbol table to stdlib.bin
- Rename DemaConsulting.SysML2Tools -> DemaConsulting.SysML2Tools.Core (workspace,
  rendering, layout, diagram model)
- Fix SkiaSharp native asset PrivateAssets='All' suppressing libSkiaSharp.dll from publish
- Add stdlib.json to .gitignore (StdlibGen debug output artifact)
- Add view def to software-structure.sysml for rendering tests
- Cold startup time: 25s -> 0.35s (70x speedup)
- Tests: 645 passing

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
- .editorconfig: broaden ANTLR generated_code glob to src/**/Parser/Antlr/*.cs
  (was hardcoded to old project path, dotnet format now correctly skips generated files)
- fix.ps1: add dotnet restore before dotnet format (mirrors lint.ps1 behavior;
  fixes 'Required references did not load' warnings on Core/Png projects)
- .cspell.yaml: add Superclassing/superclassing (KerML technical term from grammar)
  and NETSDK (MSBuild error code referenced in design doc)
- StdlibProviderTests.cs: behaviour -> behavior (US English)
- docs/verification/sysml2-tools-core/parser.md: wrap long line to stay under 120 chars

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

- Stdlib.csproj: run GenerateStdlibBin in outer (cross-targeting) build via
  BeforeTargets=DispatchToInnerBuilds to prevent parallel TFM builds racing
  to write StdlibGen.dll (CS2012 file-locked error in CI)
- Stdlib.csproj: write stdlib.bin to BaseIntermediateOutputPath (shared obj/Release/)
  instead of per-TFM IntermediateOutputPath
- StdlibGen: switch from net9.0 (STS) to net10.0 (LTS)
- StdlibGen/Program.cs: extract ParseArguments() to reduce cognitive complexity (S3776)
- PngRenderer.cs: introduce parameter object to reduce method parameter count (S107)
- SvgRenderer.cs: extract constants for repeated string literals (S1192)
- SvgRenderer.cs: extract helper method to reduce cognitive complexity (S3776)
- Validation.cs: add timeout to Regex construction (S6444)
- Build: 0 warnings, 0 errors across all three TFMs

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Two root causes were causing the CI build to fail:

1. StdlibGen in .slnx: solution built StdlibGen in parallel with the
   GenerateStdlibBin target's <MSBuild> task, causing file-lock (CS2012)
   and node-pool deadlocks (10+ min hang). Fixed by removing StdlibGen
   from .slnx — it is a private build tool, not a deliverable.

2. <MSBuild> task re-entrancy: calling <MSBuild> from inside a solution
   build requests a worker node that may already be fully occupied,
   deadlocking. Fixed by replacing with <Exec Command='dotnet build ...'>
   which spawns an independent child process outside the node pool.

Also switch StdlibGen from net9.0 (STS) to net10.0 (LTS).

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Removed --no-restore from the dotnet build <Exec> call for StdlibGen.
Because StdlibGen is no longer in the .slnx, the solution-level
dotnet restore does not restore it. The child process dotnet build
must restore it itself. This is safe because the child process is
independent and does not interfere with the parent build.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Parse_StdlibOnly_NoErrors was removed during the Language/Stdlib refactor
(stdlib is now pre-compiled; not parsed at test time). The three remaining
ParseSource_* tests still fully exercise the ANTLR4 runtime.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@Malcolmnixon
Malcolmnixon merged commit 56b0cf6 into main Jun 27, 2026
15 checks passed
@Malcolmnixon
Malcolmnixon deleted the feature/phase5-polish branch June 27, 2026 02:21
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.

1 participant