Skip to content

feat(generator): SEM003 diagnostic + form-specific relationships (closes #58)#73

Merged
matt-edmondson merged 1 commit intovectorsfrom
claude/issue-58-sem003
May 10, 2026
Merged

feat(generator): SEM003 diagnostic + form-specific relationships (closes #58)#73
matt-edmondson merged 1 commit intovectorsfrom
claude/issue-58-sem003

Conversation

@matt-edmondson
Copy link
Copy Markdown
Contributor

Summary

Closes #58 — adds the SEM003 diagnostic and the optional forms field on each relationship that the original issue called for. Pairs with the form-coverage matrix doc that landed in #72.

What changed

RelationshipDefinition (in dimensions.json) gets an optional forms array (int[]). When present, the generator only emits operators at those vector forms; when a listed form is missing on a participating dimension, it now surfaces as SEM003 instead of being silently dropped:

warning SEM003: Relationship in dimension 'Force' (crossProducts[Length -> Torque])
explicitly requests form V2, but 'Torque' does not declare that form.
The operator will not be generated.

When forms is omitted, the generator uses per-relationship defaults — preserving every emit decision currently in place:

Relationship Default forms
integrals, derivatives [0, 1, 2, 3, 4]
dotProducts [1, 2, 3, 4] (V0 has no dot product)
crossProducts [3] (cross product is intrinsically 3D)

Migrated the only current crossProduct (Force × Length → Torque) to "forms": [3] explicitly. The Generated/ tree is unchanged — the migration just makes the V3 expectation visible in metadata.

Verification

  • Build clean: dotnet build Semantics.SourceGenerators and dotnet build Semantics.Quantities both succeed with no SEM00x warnings.
  • Force3D.Cross(Displacement3D) → Torque3D is still emitted.
  • Bogus-form regression check: temporarily setting "forms": [2, 3] on the cross product produces the expected SEM003 against Torque (which has no V2). Reverting to [3] makes the warning go away.

Doc updates

  • CLAUDE.md generator diagnostics list adds SEM003 with an example.
  • docs/strategy-unified-vector-quantities.md describes the optional forms field.
  • AnalyzerReleases.Unshipped.md adds the SEM003 row.

Test plan

  • Source-generator build clean
  • Quantities build clean (no SEM warnings on current metadata)
  • Generated/ tree unchanged vs baseline (default forms for crossProducts matches the existing V3-only emit)
  • Manual SEM003 fire test (set forms: [2, 3], observed warning, reverted)
  • dotnet testSemantics.Test cannot restore in this sandbox (Microsoft.NETCore.App.Host.ubuntu.24.04-x64 not in feeds); CI will run.

https://claude.ai/code/session_01Tj63Rddvs9frqLUgsjNEP5


Generated by Claude Code

 #58)

Each entry under integrals / derivatives / dotProducts / crossProducts
in dimensions.json may now declare an explicit "forms" array (e.g.
{ "other": "Length", "result": "Torque", "forms": [3] }). When set, the
generator only emits operators at those forms; when a listed form is
missing on a participating dimension, it surfaces as the new SEM003
Roslyn diagnostic instead of being silently skipped.

When "forms" is omitted, the generator falls back to per-relationship
defaults — [0..4] for integrals/derivatives, [1..4] for dotProducts,
[3] for crossProducts — preserving every emit decision currently in
place. The Generated/ tree is unchanged.

Migrated the one current crossProduct (Force × Length → Torque) to
"forms": [3] explicitly to demonstrate the new field. Verified that
swapping to "forms": [2, 3]" produces:

    error SEM003: Relationship in dimension 'Force'
    (crossProducts[Length -> Torque]) explicitly requests form V2,
    but 'Torque' does not declare that form.

Doc updates:
- CLAUDE.md generator-diagnostics list adds SEM003 with an example.
- docs/strategy-unified-vector-quantities.md describes the optional
  "forms" field on each relationship.
- AnalyzerReleases.Unshipped.md adds the SEM003 row.
@sonarqubecloud
Copy link
Copy Markdown

Quality Gate Failed Quality Gate failed

Failed conditions
1 Security Hotspot
0.0% Coverage on New Code (required ≥ 80%)
C Security Rating on New Code (required ≥ A)
C Reliability Rating on New Code (required ≥ A)

See analysis details on SonarQube Cloud

Catch issues before they fail your Quality Gate with our IDE extension SonarQube for IDE

@matt-edmondson matt-edmondson merged commit f41624b into vectors May 10, 2026
4 of 5 checks passed
@matt-edmondson matt-edmondson deleted the claude/issue-58-sem003 branch May 10, 2026 13:28
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