Skip to content

Commit 17d17e8

Browse files
192 feature implement typeextensions (#231)
* Fix #192: Implementation of TypeExtensions.cs * Rebase & unit test improve * Fix unit tests * fix SQ issues * SQ issues * bump versions and rebase * Command include parallelism * try to fix PR * fix indentation * package deps * revert package deps * try with fix dotnet version
1 parent 56a1909 commit 17d17e8

23 files changed

Lines changed: 1551 additions & 193 deletions

File tree

Lines changed: 227 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,227 @@
1+
---
2+
description: Spawn researcher/implementer/tester/reviewer team to fill in stub Compute* methods in a SysML2.NET Extend file
3+
argument-hint: <absolute-path-to-Extensions-file.cs>
4+
---
5+
6+
# /implement-extensions
7+
8+
Spawn the 4-role agent team (researcher → implementer → tester → reviewer, all
9+
Opus) for **$ARGUMENTS** — a `*Extensions.cs` file under `SysML2.NET/Extend/`
10+
whose `Compute*` methods are still stubs throwing `NotSupportedException`.
11+
12+
The team template is at `C:\Users\atheate\.claude\team-templates\extension-impl.md`
13+
(v2). Read it first — its role prompts are the source of truth; this command body
14+
is the orchestration glue.
15+
16+
## Hard scope rule
17+
18+
**Only modify**:
19+
- The named production file `$ARGUMENTS`
20+
- Its corresponding test fixture (auto-derived in step 2)
21+
- The researcher's notes file (auto-derived in step 2)
22+
- Sibling test fixtures whose `Throws.TypeOf<NotSupportedException>()` assertions
23+
now fail because of regressions caused by the new implementations (regression
24+
sweep in step 8)
25+
26+
**MUST NOT modify**:
27+
- Any other production file in `SysML2.NET/Extend/`, `SysML2.NET/Core/`, etc.
28+
- Auto-generated POCOs and interfaces.
29+
- Code-generator templates.
30+
31+
This is the user-memory `feedback_scope_discipline.md` rule. Even when an adjacent
32+
stub blocks dependent test coverage, surface the blocker; do not silently expand
33+
scope. Use the stub-blocker test pattern (see template).
34+
35+
## Workflow
36+
37+
### 1. Validate input
38+
39+
Confirm `$ARGUMENTS` is:
40+
- An absolute Windows path with backslashes.
41+
- A file matching `C:\CODE\SysML2.NET\SysML2.NET\Extend\*Extensions.cs`.
42+
- The file exists.
43+
44+
If validation fails, stop and ask the user to re-invoke with a corrected path.
45+
46+
### 2. Auto-derive paths
47+
48+
From `$ARGUMENTS = C:\CODE\SysML2.NET\SysML2.NET\Extend\<FOO>Extensions.cs`:
49+
50+
- **Production file**: `$ARGUMENTS` itself.
51+
- **Test fixture**: `C:\CODE\SysML2.NET\SysML2.NET.Tests\Extend\<FOO>ExtensionsTestFixture.cs`.
52+
If it does not exist, surface that to the user — likely scope mismatch.
53+
- **Reference production file**: `C:\CODE\SysML2.NET\SysML2.NET\Extend\NamespaceExtensions.cs`.
54+
- **Reference test file**: `C:\CODE\SysML2.NET\SysML2.NET.Tests\Extend\NamespaceExtensionsTestFixture.cs`.
55+
- **Target interface**: `I<FOO>` — find via Glob `SysML2.NET\Core\AutoGenPoco\**\I<FOO>.cs`.
56+
- **Target metaclass name**: `<FOO>`.
57+
- **Subject param name**: lowercase first char of `<FOO>` + `<FOO>[1..]` + `Subject` (e.g. `Type``typeSubject`, `Feature``featureSubject`).
58+
- **Notes file**: `C:\CODE\SysML2.NET\.team-notes\<foo>-extensions-spec.md` (kebab-case `<foo>`). Create the `.team-notes\` directory if it doesn't exist (`mkdir -p`).
59+
- **Team name**: `<foo>-extensions-impl`.
60+
61+
Print the derived paths back to the user as a sanity check.
62+
63+
### 3. Enumerate stub methods
64+
65+
Grep the production file for `throw new NotSupportedException`. List the enclosing
66+
methods. These are the stubs to implement.
67+
68+
If the count is 0, stop — the file has no stubs left.
69+
70+
### 4. Sanity check with the user
71+
72+
Use `AskUserQuestion` to present:
73+
- The auto-derived paths (test fixture, interface, reference template, notes file).
74+
- The list of stub methods (or a count if there are many).
75+
- Two options: "Implement all" or "Implement a subset" (let the user paste a method
76+
list as a custom answer).
77+
78+
If they pick subset, narrow the method list. Otherwise proceed with all.
79+
80+
### 5. Spawn the researcher (FIRST role — produces the notes file the others read)
81+
82+
Read the v2 team template at `C:\Users\atheate\.claude\team-templates\extension-impl.md`
83+
to refresh the role prompts. Substitute the placeholders from step 2 + the method
84+
list from step 4.
85+
86+
Spawn the **researcher** as `Agent({subagent_type: "general-purpose", model: "opus"})`
87+
with the v2 researcher prompt. Foreground (not `run_in_background`) — the next
88+
roles depend on the notes file.
89+
90+
The researcher MUST:
91+
- Treat the OCL `<defaultValue>`/`<ownedRule>` body in the XMI as the canonical
92+
source of truth.
93+
- Fall back to the OCL block in the production file's `<remarks>` (mirrored from
94+
XMI by codegen).
95+
- For methods with NO OCL body (e.g. `Type::isConjugated`), record a short prose
96+
derivation rule + spec citation, and EXPLICITLY FLAG the spec-text-only origin
97+
in the notes.
98+
- Flag any method whose OCL transitively reads a still-stubbed sibling
99+
`Compute*` so the tester knows to use the stub-blocker pattern.
100+
101+
After the researcher finishes, read `{{NOTES_FILE}}` yourself to verify it
102+
covers all methods + flags spec-text-only and stub-blocker cases.
103+
104+
### 6. Spawn the implementer and tester in parallel
105+
106+
**Spawn both roles in a single orchestrator message** containing TWO `Agent(...)`
107+
tool calls — one for the implementer, one for the targeted-fixture tester. Both
108+
foreground (do not set `run_in_background`). Parallel `Agent` tool calls in the
109+
same assistant message execute concurrently; each agent runs in its own
110+
isolated context. The only thing they share is the researcher's notes file on
111+
disk.
112+
113+
Spawn 1 — **implementer**:
114+
`Agent({subagent_type: "general-purpose", model: "opus"})` with the v2
115+
implementer prompt. The prompt MUST instruct the implementer to read
116+
`{{NOTES_FILE}}` first.
117+
118+
Spawn 2 — **tester**:
119+
`Agent({subagent_type: "general-purpose", model: "opus"})` with the v2 tester
120+
prompt. The prompt MUST instruct the tester to read `{{NOTES_FILE}}` first
121+
(each method has a "Test plan" section there).
122+
123+
**Parallel-mode caveat for the tester**: when spawned in parallel with the
124+
implementer, the tester runs ONLY `dotnet build` on the test project (confirms
125+
the fixture compiles against the pre-existing interfaces in `Core/AutoGenPoco/`).
126+
It MUST NOT run `dotnet test` — production does not yet contain the
127+
implementer's parallel-turn edits, so every populated-case test would fail with
128+
`NotSupportedException` (useless signal). The orchestrator runs targeted
129+
`dotnet test` in step 7. State this explicitly in the tester's spawn prompt.
130+
131+
### 7. Orchestrator verification (post-parallel)
132+
133+
After both step-6 agents return, run sequentially in the orchestrator's own
134+
turn:
135+
136+
1. Build production:
137+
```bash
138+
dotnet build C:\CODE\SysML2.NET\SysML2.NET\SysML2.NET.csproj --nologo --verbosity quiet
139+
```
140+
On failure, dispatch the implementer back to fix its own bugs (do not
141+
delegate to a fresh agent unless the original is non-responsive).
142+
143+
2. Run targeted fixture:
144+
```bash
145+
dotnet test C:\CODE\SysML2.NET\SysML2.NET.Tests\SysML2.NET.Tests.csproj --filter "FullyQualifiedName~<FOO>ExtensionsTestFixture" --nologo --verbosity quiet
146+
```
147+
Analyze each failure and route the fix:
148+
- **OCL mistranslation in production** → re-dispatch the implementer.
149+
- **Wrong test assertion** (e.g. assertion built against the original
150+
contract that the implementer's deviation report invalidated) →
151+
re-dispatch the tester.
152+
153+
Iterate until the targeted fixture has 0 failures.
154+
155+
### 8. Regression sweep (mandatory)
156+
157+
Run the full solution test suite:
158+
159+
```bash
160+
dotnet test C:\CODE\SysML2.NET\SysML2.NET.sln --no-build --nologo --verbosity quiet
161+
```
162+
163+
If failures exist, identify those of the form:
164+
165+
> Expected: `<NotSupportedException>` But was: `no exception thrown`
166+
167+
These are pre-existing tests in sibling fixtures that asserted the stubs throw —
168+
they now fail because our new implementations make those paths succeed. Dispatch
169+
the tester back (via `SendMessage` to the still-running tester if available, else
170+
a fresh `Agent` call) with the failing-test list and instructions to update those
171+
assertions to assert real behavior. The regression sweep is in-scope per the
172+
template.
173+
174+
**Parallel-spawn opportunity**: if step 7's verification surfaced targeted-fixture
175+
test-assertion fixes that were deferred to this step (i.e. there is BOTH (a)
176+
work for the targeted-fixture tester re-dispatch on `{{TEST_FILE}}` AND (b)
177+
work for the regression-sweep tester on sibling `*ExtensionsTestFixture.cs`
178+
files), spawn the two roles in a single orchestrator message with TWO
179+
`Agent(...)` tool calls, both foreground. They edit disjoint files so this is
180+
safe. If only one of (a) or (b) has work, spawn only that one.
181+
182+
Iterate until 100% green or the user opts out.
183+
184+
### 9. Spawn the reviewer (LAST role — verdict only)
185+
186+
`Agent({subagent_type: "general-purpose", model: "opus"})` with the v2 reviewer
187+
prompt. Foreground. The reviewer cross-checks `{{PRODUCTION_FILE}}` and
188+
`{{TEST_FILE}}` against `{{NOTES_FILE}}` and produces an "OK / NEEDS FIX" verdict.
189+
190+
If the verdict is "NEEDS FIX", dispatch the implementer or tester back to
191+
action the findings (the reviewer never edits).
192+
193+
### 10. Final summary
194+
195+
Report to the user:
196+
- Modified files (production + test fixture + notes + any regression-sweep test fixtures).
197+
- Test counts (X/Y green for the targeted fixture; A/B green for the full solution).
198+
- Reviewer verdict + any unresolved findings.
199+
- Out-of-scope blockers surfaced (e.g. "5 populated cases use the stub-blocker
200+
pattern because `<UpstreamMethod>` in `<UpstreamFile>.cs` is still a stub —
201+
consider a follow-up issue").
202+
- Spec-text-only methods (e.g. `IsConjugated`) — flag separately so the user
203+
knows the implementation is grounded in spec prose rather than OCL.
204+
205+
Do NOT auto-commit. The user reviews and commits.
206+
207+
## Notes for the orchestrator (you, the main agent)
208+
209+
- Use the **Opus** model for all four roles — they handle OCL→C# translation
210+
best and the user has explicitly preferred Opus for this workflow.
211+
- Spawn each role **foreground** (not `run_in_background`). The implementer and
212+
tester in step 6 are spawned in parallel by issuing TWO `Agent(...)` tool
213+
calls in a single orchestrator message — both still foreground, just
214+
concurrent. The same single-message-two-Agent-calls pattern applies to the
215+
Level-2 parallel spawn in step 8 (targeted-fixture re-dispatch ∥
216+
regression-sweep tester) when both have work. All other roles run
217+
sequentially because they depend on the previous step's output.
218+
- The researcher runs **FIRST and is mandatory** — even when the production file's
219+
`<remarks>` already carries OCL, the researcher's notes file gives the
220+
implementer/tester/reviewer a single shared contract document, AND it's the only
221+
role that handles spec-text-only methods cleanly.
222+
- The reviewer is **mandatory** even when in past runs it caught no bugs the
223+
tester missed — the user explicitly wants it as cheap insurance against subtle
224+
OCL mistranslation.
225+
- If a build error involves an explicit-interface-impl loop (e.g. `(INamespace)x`
226+
cast not bypassing virtual dispatch), call the static extension method directly
227+
rather than via interface dispatch — pattern from the TypeExtensions task fix.

.github/workflows/CodeQuality.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,10 @@ on:
55
pull_request:
66
types: [opened, synchronize, reopened]
77

8+
concurrency:
9+
group: ${{ github.workflow }}-${{ github.ref }}
10+
cancel-in-progress: true
11+
812
jobs:
913
build:
1014
name: Build

.github/workflows/nuget-reference-check.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ jobs:
2020
- name: Setup .NET Environment
2121
uses: actions/setup-dotnet@v5.1.0
2222
with:
23-
dotnet-version: '10.0.x'
23+
dotnet-version: '10.0.107'
2424

2525
- name: Check for outdated packages
2626
id: outdated

SySML2.NET.REST.Tests/SySML2.NET.REST.Tests.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
</PropertyGroup>
1919

2020
<ItemGroup>
21-
<PackageReference Include="Microsoft.Extensions.Logging.Console" Version="10.0.7" />
21+
<PackageReference Include="Microsoft.Extensions.Logging.Console" Version="10.0.8" />
2222
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="18.5.1" />
2323
<PackageReference Include="NUnit" Version="4.6.0" />
2424
<PackageReference Include="NUnit.Console" Version="3.22.0" />

SysML2.NET.CodeGenerator.Tests/SysML2.NET.CodeGenerator.Tests.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1144,7 +1144,7 @@
11441144
</None>
11451145
</ItemGroup>
11461146
<ItemGroup>
1147-
<PackageReference Include="Microsoft.Extensions.Logging.Console" Version="10.0.7" />
1147+
<PackageReference Include="Microsoft.Extensions.Logging.Console" Version="10.0.8" />
11481148
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="18.5.1" />
11491149
<PackageReference Include="NUnit" Version="4.6.0" />
11501150
<PackageReference Include="NUnit.Console" Version="3.22.0" />

SysML2.NET.Dal.Tests/SysML2.NET.Dal.Tests.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
</PropertyGroup>
1919

2020
<ItemGroup>
21-
<PackageReference Include="Microsoft.Extensions.Logging.Console" Version="10.0.7" />
21+
<PackageReference Include="Microsoft.Extensions.Logging.Console" Version="10.0.8" />
2222
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="18.5.1" />
2323
<PackageReference Include="NUnit" Version="4.6.0" />
2424
<PackageReference Include="NUnit.Console" Version="3.22.0" />

SysML2.NET.Extensions.Tests/SysML2.NET.Extensions.Tests.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
</PropertyGroup>
1919

2020
<ItemGroup>
21-
<PackageReference Include="Microsoft.Extensions.Logging.Console" Version="10.0.7" />
21+
<PackageReference Include="Microsoft.Extensions.Logging.Console" Version="10.0.8" />
2222
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="18.5.1" />
2323
<PackageReference Include="NUnit" Version="4.6.0" />
2424
<PackageReference Include="NUnit.Console" Version="3.22.0" />

SysML2.NET.Kpar.Tests/SysML2.NET.Kpar.Tests.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@
5555
</ItemGroup>
5656

5757
<ItemGroup>
58-
<PackageReference Include="Microsoft.Extensions.Logging.Console" Version="10.0.7" />
58+
<PackageReference Include="Microsoft.Extensions.Logging.Console" Version="10.0.8" />
5959
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="18.5.1" />
6060
<PackageReference Include="NUnit" Version="4.6.0" />
6161
<PackageReference Include="NUnit.Console" Version="3.22.0" />

SysML2.NET.Serializer.Json.Tests/SysML2.NET.Serializer.Json.Tests.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
</PropertyGroup>
1919

2020
<ItemGroup>
21-
<PackageReference Include="Microsoft.Extensions.Logging.Console" Version="10.0.7" />
21+
<PackageReference Include="Microsoft.Extensions.Logging.Console" Version="10.0.8" />
2222
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="18.5.1" />
2323
<PackageReference Include="NUnit" Version="4.6.0" />
2424
<PackageReference Include="NUnit.Console" Version="3.22.0" />

SysML2.NET.Serializer.Json/SysML2.NET.Serializer.Json.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
</PropertyGroup>
2525

2626
<ItemGroup>
27-
<PackageReference Include="System.Text.Json" Version="10.0.7" />
27+
<PackageReference Include="System.Text.Json" Version="10.0.8" />
2828
<PackageReference Include="Microsoft.Sbom.Targets" Version="4.1.5" PrivateAssets="all" />
2929
</ItemGroup>
3030

0 commit comments

Comments
 (0)