Skip to content

feat(generator): SEM002 metadata validation + refresh stale generator output#70

Merged
matt-edmondson merged 1 commit intovectorsfrom
claude/fix-vectors-issues-sHLUx
May 9, 2026
Merged

feat(generator): SEM002 metadata validation + refresh stale generator output#70
matt-edmondson merged 1 commit intovectorsfrom
claude/fix-vectors-issues-sHLUx

Conversation

@matt-edmondson
Copy link
Copy Markdown
Contributor

Summary

Continues the vectors-branch cleanup. Pulls in three things:

  1. Closes DimensionsMetadata models lack schema validation; malformed dimensions.json fails late #60 — schema validation for dimensions.json. Adds DimensionsMetadata.Validate() and a new Roslyn diagnostic SEM002 so malformed metadata (missing name/symbol, empty availableUnits, duplicate type names, no vector forms declared) is reported in the build log instead of crashing mid-emit or silently dropping output. Pairs with the existing SEM001 from feat(generator): emit SEM001 diagnostic for unknown dimension references #65.
  2. Fixes a pre-existing build failure. Adds AnalyzerReleases.Shipped.md / AnalyzerReleases.Unshipped.md so SEM001/SEM002 satisfy RS2008 analyzer release tracking. The source-generator project now builds clean.
  3. Refreshes stale committed generator output. The 132 *.g.cs files under Semantics.Quantities/Generated/ were not re-emitted after the V0 non-negativity / absolute V0–V0 subtraction work landed in test: cover IVector*/Magnitude/Dot/Cross and semantic overload conversions #66/feat(quantities): enforce V0 non-negativity and absolute V0-V0 subtraction (closes #50, #52) #68. Re-running the generator updates each Vector0 type's From{Unit} factory to call Vector0Guards.EnsureNonNegative and replaces the V1-typed subtraction operator with the documented same-type T.Abs(a − b). Per CLAUDE.md generator output is committed source, so this needed to be in-tree.
  4. Doc tidying for Update CLAUDE.md / README to reflect .NET 10 target and new generator-driven architecture #61. CLAUDE.md's V0 invariant section now describes what's actually enforced (structural, via Vector0Guards) and the PhysicalConstants example matches the real generated surface (no Conversion sub-class). Adds a SEM00x diagnostics list to the generator workflow section.

Status of the rest of the open issues on the branch is summarised in follow-up comments on each issue.

Test plan

https://claude.ai/code/session_01Tj63Rddvs9frqLUgsjNEP5


Generated by Claude Code

…tor output

- Adds DimensionsMetadata.Validate() and a SEM002 Roslyn diagnostic so
  malformed entries in dimensions.json (missing name/symbol, empty
  availableUnits, duplicate type names, no vector forms declared)
  surface in the build log instead of crashing the emit pass or dropping
  output silently. Pairs with the existing SEM001 (closes #60).
- Adds AnalyzerReleases.Shipped/Unshipped.md so SEM001/SEM002 satisfy
  RS2008 analyzer release tracking; the generator project now builds
  clean.
- Re-runs QuantitiesGenerator to refresh 132 committed .g.cs files that
  were stale relative to the V0 non-negativity / absolute V0-V0
  subtraction work merged in #66/#68. Diff is purely the documented
  #50/#52 changes (Vector0Guards.EnsureNonNegative in factories;
  same-type T.Abs subtraction replacing the old V1-typed result).
- CLAUDE.md: corrects the V0 invariant entry (constraints are enforced
  structurally, not yet declared in metadata), fixes the
  PhysicalConstants surface to match what's actually emitted (no
  Conversion sub-class), and lists the SEM00x diagnostics.
@sonarqubecloud
Copy link
Copy Markdown

sonarqubecloud Bot commented May 9, 2026

Quality Gate Failed Quality Gate failed

Failed conditions
1 Security Hotspot
0.0% Coverage on New Code (required ≥ 80%)
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 6eaf12f into vectors May 9, 2026
4 of 5 checks passed
@matt-edmondson matt-edmondson deleted the claude/fix-vectors-issues-sHLUx branch May 9, 2026 12:21
matt-edmondson pushed a commit that referenced this pull request May 9, 2026
…tories with SEM002 + AnalyzerReleases

#70 merged into vectors while this branch was up, so re-merging brought in:
- The SEM002 dimensions.json schema validation diagnostic and its
  invocation at the top of QuantitiesGenerator.Generate / GenerateInner.
- AnalyzerReleases.Shipped.md / Unshipped.md tracking files (RS2008).
- The CLAUDE.md tweaks for the V0 invariant and PhysicalConstants
  surface.
- A regenerated Generated/ tree.

Conflicts and resolutions:

1. QuantitiesGenerator.cs: SEM002 metadata.Validate() + ReportDiagnostic
   loop runs first, then BuildUnitMap(units) builds the unit lookup that
   AddUnitFactories needs for #48. Both belong; combined.

2. AnalyzerReleases.Unshipped.md: kept both SEM001 (this branch) and
   SEM002 (from #70) entries.

3. Semantics.Quantities/Generated/*.g.cs (~130 files): both branches
   regenerated. Discarded the merge attempt and re-ran the generator
   from scratch. Spot-checked Length: multi-unit factories
   (FromMeter/FromKilometer/FromCentimeter/FromFoot/FromInch/FromMile)
   each wrap their conversion in Vector0Guards.EnsureNonNegative, and
   the V0-V0 absolute subtraction operator
   (Length<T> operator -(Length<T>, Length<T>) => Create(T.Abs(...)))
   is intact.

Source generator builds clean (0 warnings, 0 errors); generator runs
clean against current dimensions.json (no SEM001 / SEM002 diagnostics).
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.

DimensionsMetadata models lack schema validation; malformed dimensions.json fails late

2 participants