Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions .claude/agents/textual-notation-reviewer.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
---
name: textual-notation-reviewer
description: Expert reviewer for SysML2 TextualNotationBuilder code — generated AND hand-coded, across SysML2.NET/TextualNotation/, SysML2.NET/LexicalRules/, and the textual-notation-adjacent parts of the code generator. Verifies that each Build{RuleName}/Build{Rule}HandCoded method and each IsValidFor guard correctly implements its KEBNF grammar rule. Pass one or more file paths and optionally specific method names.
description: Expert reviewer for SysML2 TextualNotationBuilder code — generated AND hand-coded, across SysML2.NET.Serializer.TextualNotation/Writers/, SysML2.NET/LexicalRules/, and the textual-notation-adjacent parts of the code generator. Verifies that each Build{RuleName}/Build{Rule}HandCoded method and each IsValidFor guard correctly implements its KEBNF grammar rule. Pass one or more file paths and optionally specific method names.
tools: Read, Grep, Glob, Bash
model: sonnet
---
Expand All @@ -11,12 +11,12 @@ You are a master of the SysML2.NET textual notation pipeline. Your job is to rev

Any code change touching any of these paths is in your remit:

- **`SysML2.NET/TextualNotation/`** — every `.cs` file, both hand-coded partial classes (`*.cs` at the folder root) and auto-generated (`AutoGenTextualNotationBuilder/*.cs`). This includes `TextualNotationValidationExtensions.cs`, `MembershipValidationExtensions.cs`, and the per-class hand-coded partials that provide `Build{Rule}HandCoded` bodies.
- **`SysML2.NET.Serializer.TextualNotation/Writers/`** — every `.cs` file under `Writers/`, both hand-coded partial classes (`*.cs` at the folder root) and auto-generated (`AutoGenTextualNotationBuilder/*.cs`). This includes `TextualNotationValidationExtensions.cs`, `MembershipValidationExtensions.cs`, and the per-class hand-coded partials that provide `Build{Rule}HandCoded` bodies. The namespace for all of these is `SysML2.NET.Serializer.TextualNotation.Writers`.
- **`SysML2.NET/LexicalRules/`** — hand-coded members and auto-generated (`AutoGenLexicalRules/Keywords.cs`, `SymbolicKeywordKind.cs`, `SymbolicKeywordKindExtensions.cs`).
- **`SysML2.NET.CodeGenerator/HandleBarHelpers/RulesHelper.cs`** — the central code-gen logic.
- **`SysML2.NET.CodeGenerator/Templates/Uml/*.hbs`** — any Handlebars template that emits textual-notation or lexical-rules code (e.g. `core-textual-notation-builder-template.hbs`, `core-textual-notation-shared-builder-template.hbs`, `core-lexical-*.hbs`).

The grammar context applies to EVERY file in the folders above — not only to the generator. When reviewing a hand-coded method in `SysML2.NET/TextualNotation/`, re-ground yourself in the grammar before judging the implementation.
The grammar context applies to EVERY file in the folders above — not only to the generator. When reviewing a hand-coded method in `SysML2.NET.Serializer.TextualNotation/Writers/`, re-ground yourself in the grammar before judging the implementation.

## Your Knowledge Base

Expand Down
7 changes: 4 additions & 3 deletions CLAUDE.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,11 +43,11 @@ Test framework: **NUnit**. Test classes use `[TestFixture]` and `[Test]` attribu

**Every code change touching any of the following paths MUST be verified by the `textual-notation-reviewer` agent before reporting the change as complete or committing:**

- Every file under `SysML2.NET/TextualNotation/` — both hand-coded partials (`*.cs`), the generated `AutoGenTextualNotationBuilder/*.cs`, `IsValidFor` guard extensions (`TextualNotationValidationExtensions.cs`), and any membership / string / cursor helpers that sit beside them.
- Every file under `SysML2.NET.Serializer.TextualNotation/Writers/` — both hand-coded partials (`*.cs`), the generated `AutoGenTextualNotationBuilder/*.cs`, `IsValidFor` guard extensions (`TextualNotationValidationExtensions.cs`), and any membership / string / cursor helpers that sit beside them.
- Every file under `SysML2.NET/LexicalRules/` — both hand-coded members and the generated `AutoGenLexicalRules/*.cs` (`Keywords`, `SymbolicKeywordKind`, `SymbolicKeywordKindExtensions`).
- `SysML2.NET.CodeGenerator/HandleBarHelpers/RulesHelper.cs` and any Handlebars template under `SysML2.NET.CodeGenerator/Templates/Uml/` that emits textual-notation or lexical-rules code.

**The KEBNF grammar context applies to ALL of these locations** — not just the generator. When implementing or reviewing hand-coded methods in `SysML2.NET/TextualNotation/`, the author and the reviewer must re-ground in:
**The KEBNF grammar context applies to ALL of these locations** — not just the generator. When implementing or reviewing hand-coded methods in `SysML2.NET.Serializer.TextualNotation/Writers/`, the author and the reviewer must re-ground in:
- `SysML2.NET.CodeGenerator/GRAMMAR.md` — the cursor / builder conventions and patterns
- `Resources/SysML-textual-bnf.kebnf` and `Resources/KerML-textual-bnf.kebnf` — the grammar source of truth
- The rule's `<para>{…}</para>` XML doc on the generated sibling method (if the method is a HandCoded companion)
Expand Down Expand Up @@ -86,7 +86,7 @@ The XMI files (`Resources/KerML_only_xmi.uml`, `Resources/SysML_only_xmi.uml`) d
- `Resources/specification/1-Kernel_Modeling_Language.pdf.txt` — *Kernel Modeling Language (KerML) Version 1.0* (OMG formal/2026-03-01). Consult when working with metaclasses in the `Root.*`, `Core.*`, and `Kernel.*` namespaces (under `SysML2.NET/Core/AutoGenDto/` and `AutoGenPoco/`), when an OCL constraint is unclear, or when reasoning about element/relationship/feature/classification semantics that the XMI does not spell out.
- `Resources/specification/2a-OMG_Systems_Modeling_Language.pdf.txt` — *OMG Systems Modeling Language (SysML) Version 2.0, Part 1: Language Specification* (OMG formal/2026-03-02). Consult when working with the systems-engineering-specific metaclasses in `Systems.*` namespaces — Parts, Ports, Connections, Interfaces, Actions, States, Interactions, Requirements, Constraints, Use Cases, Analysis/Verification Cases, Views, Metadata — and to ground the Definition/Usage pattern.
- `Resources/specification/3-Systems_Modeling_API_and_Services.pdf.txt` — *Systems Modeling API and Services Version 1.0* (OMG formal/2026-03-04). Consult when working in `SysML2.NET.REST/`, `SysML2.NET/PIM/`, `SysML2.NET.Serializer.Dictionary/`, or `SysML2.NET/ModelInterchange/`. Defines the Platform-Independent Model (ProjectService, ElementNavigationService, ProjectDataVersioningService, QueryService, ExternalRelationshipService, ProjectUsageService) and the REST/HTTP and OSLC PSMs.
- `Resources/specification/Intro to the SysML v2 Language-Textual Notation.pdf.txt` — SST tutorial, Release 2026-03. Informative companion to the KEBNF grammar; consult for canonical examples and idioms when implementing or reviewing rules under `SysML2.NET/TextualNotation/` and `SysML2.NET/LexicalRules/`.
- `Resources/specification/Intro to the SysML v2 Language-Textual Notation.pdf.txt` — SST tutorial, Release 2026-03. Informative companion to the KEBNF grammar; consult for canonical examples and idioms when implementing or reviewing rules under `SysML2.NET.Serializer.TextualNotation/Writers/` and `SysML2.NET/LexicalRules/`.
- `Resources/specification/Intro to the SysML v2 Language-Graphical Notation.pdf.txt` — SST tutorial, Release 2026-03. Consult when working on `SysML2.NET.Viewer/` (Blazor) for the visual-rendering conventions of each metaclass family.

These text files are large (PDF-converted, up to 1.3 MB) and the conversion is not always clean. Read them with `Read` `offset`/`limit` and use `Grep` to jump to chapter/section anchors (e.g. `^7\.\d+`, `Clause 8\.`, or a metaclass name) rather than loading whole files into context.
Expand All @@ -111,6 +111,7 @@ SysML2.NET.Serializer.Json - JSON (de)serialization via System.Text.Json
SysML2.NET.Serializer.Xmi - XMI (de)serialization
SysML2.NET.Serializer.MessagePack - MessagePack binary serialization
SysML2.NET.Serializer.Dictionary - Dictionary-based serialization (PIM)
SysML2.NET.Serializer.TextualNotation - Writers/, Writers/AutoGenTextualNotationBuilder/, validation extensions, cursor helpers
SysML2.NET.Dal - Data Access Layer (Assembler, ElementFactory)
SysML2.NET.REST - REST client + Session for SysML2 API servers
SysML2.NET.Kpar - Reader/Writer for .kpar archive format
Expand Down
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ project
[SysML2.NET.Serializer.Json](https://www.nuget.org/packages/SysML2.NET.Serializer.Json) | ![NuGet Version](https://img.shields.io/nuget/v/SysML2.NET.Serializer.Json)
[SysML2.NET.Serializer.Xmi](https://www.nuget.org/packages/SysML2.NET.Serializer.Xmi) | ![NuGet Version](https://img.shields.io/nuget/v/SysML2.NET.Serializer.Xmi)
[SysML2.NET.Serializer.MessagePack](https://www.nuget.org/packages/SysML2.NET.Serializer.MessagePack) | ![NuGet Version](https://img.shields.io/nuget/v/SysML2.NET.Serializer.MessagePack)
[SysML2.NET.Serializer.TextualNotation](https://www.nuget.org/packages/SysML2.NET.Serializer.TextualNotation) | ![NuGet Version](https://img.shields.io/nuget/v/SysML2.NET.Serializer.TextualNotation)
[SysML2.NET.Kpar](https://www.nuget.org/packages/SysML2.NET.Kpar) | ![NuGet Version](https://img.shields.io/nuget/v/SysML2.NET.Kpar)
[SysML2.NET.REST](https://www.nuget.org/packages/SysML2.NET.REST) | ![NuGet Version](https://img.shields.io/nuget/v/SysML2.NET.REST)
[SysML2.NET.DAL](https://www.nuget.org/packages/SysML2.NET.DAL) | ![NuGet Version](https://img.shields.io/nuget/v/SysML2.NET.DAL)
Expand Down
14 changes: 8 additions & 6 deletions SysML2.NET.CodeGenerator/GRAMMAR.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,9 @@

This file provides essential context for working on the SysML2 textual notation code generator (`RulesHelper.cs` and related files). Read this when modifying grammar processing or the `TextualNotationBuilder` generation pipeline.

> **⚠ Reviewer agent is mandatory for every change.** Before committing any modification to `SysML2.NET/TextualNotation/*.cs` or to `SysML2.NET.CodeGenerator/HandleBarHelpers/RulesHelper.cs`, invoke the `textual-notation-reviewer` agent (`.claude/agents/textual-notation-reviewer.md`) to verify grammar correctness. See CLAUDE.md "Textual notation reviewer is MANDATORY" for details.
> **For the end-to-end pipeline narrative** (parser → grammar model → `RuleProcessor` dispatch → patterns A/B/C/D → three-tier guard resolution → no-target lifting), see the longer companion document `TEXTUAL_NOTATION_CODEGEN.md` in this same folder.

> **⚠ Reviewer agent is mandatory for every change.** Before committing any modification to `SysML2.NET.Serializer.TextualNotation/Writers/*.cs` or to `SysML2.NET.CodeGenerator/HandleBarHelpers/RulesHelper.cs`, invoke the `textual-notation-reviewer` agent (`.claude/agents/textual-notation-reviewer.md`) to verify grammar correctness. See CLAUDE.md "Textual notation reviewer is MANDATORY" for details.

## EBNF / KEBNF Notation Legend

Expand Down Expand Up @@ -40,10 +42,10 @@ KEBNF grammar files (Grammar/Resources/*.kebnf)
into Grammar/Model/* (RuleElement hierarchy)
processed by HandleBarHelpers/RulesHelper.cs
via Handlebars template (Templates/Uml/textualNotationBuilder.hbs)
emits SysML2.NET/TextualNotation/AutoGenTextualNotationBuilder/*.cs
emits SysML2.NET.Serializer.TextualNotation/Writers/AutoGenTextualNotationBuilder/*.cs
```

**Hand-coded counterparts** live in `SysML2.NET/TextualNotation/*.cs` (parent folder) as `partial` classes. When code-gen can't handle a rule, it emits `Build{RuleName}HandCoded(poco, cursorCache, stringBuilder)` which must be implemented in the hand-coded partial.
**Hand-coded counterparts** live in `SysML2.NET.Serializer.TextualNotation/Writers/*.cs` (parent folder) as `partial` classes. When code-gen can't handle a rule, it emits `Build{RuleName}HandCoded(poco, cursorCache, stringBuilder)` which must be implemented in the hand-coded partial.

## Grammar Element Types (`Grammar/Model/`)

Expand Down Expand Up @@ -138,7 +140,7 @@ Build{RuleName}HandCoded(poco, cursorCache, stringBuilder);
```

The hand-coded partial class file must:
1. Live in `SysML2.NET/TextualNotation/{ClassName}TextualNotationBuilder.cs`
1. Live in `SysML2.NET.Serializer.TextualNotation/Writers/{ClassName}TextualNotationBuilder.cs`
2. Declare `public static partial class {ClassName}TextualNotationBuilder`
3. Implement the method as `private static void Build{RuleName}HandCoded(...)`
4. Use `NotSupportedException` (not `NotImplementedException`) for unimplemented stubs
Expand All @@ -157,12 +159,12 @@ After modifying `RulesHelper.cs`:
dotnet build SysML2.NET.CodeGenerator/SysML2.NET.CodeGenerator.csproj
dotnet test SysML2.NET.CodeGenerator.Tests/SysML2.NET.CodeGenerator.Tests.csproj --filter UmlCoreTextualNotationBuilderGeneratorTestFixture
# Generated files land in SysML2.NET.CodeGenerator.Tests/bin/Debug/net10.0/UML/_SysML2.NET.Core.UmlCoreTextualNotationBuilderGenerator/
cp SysML2.NET.CodeGenerator.Tests/bin/Debug/net10.0/UML/_SysML2.NET.Core.UmlCoreTextualNotationBuilderGenerator/*.cs SysML2.NET/TextualNotation/AutoGenTextualNotationBuilder/
cp SysML2.NET.CodeGenerator.Tests/bin/Debug/net10.0/UML/_SysML2.NET.Core.UmlCoreTextualNotationBuilderGenerator/*.cs SysML2.NET.Serializer.TextualNotation/Writers/AutoGenTextualNotationBuilder/
dotnet build SysML2.NET.sln
dotnet test SysML2.NET.sln
```

**Count remaining HandCoded calls** to track progress:
```bash
grep -r "HandCoded" SysML2.NET/TextualNotation/AutoGenTextualNotationBuilder/*.cs | wc -l
grep -r "HandCoded" SysML2.NET.Serializer.TextualNotation/Writers/AutoGenTextualNotationBuilder/*.cs | wc -l
```
Loading
Loading