Skip to content

feat(quantities): IPhysicalQuantity surface + typed In() (closes #59, #61)#79

Merged
matt-edmondson merged 1 commit into
vectorsfrom
claude/review-vectors-branch-pgIZG
May 12, 2026
Merged

feat(quantities): IPhysicalQuantity surface + typed In() (closes #59, #61)#79
matt-edmondson merged 1 commit into
vectorsfrom
claude/review-vectors-branch-pgIZG

Conversation

@matt-edmondson
Copy link
Copy Markdown
Contributor

@matt-edmondson matt-edmondson commented May 12, 2026

Summary

Two issues landed on the vectors branch.

Closes #61 — docs

Extend docs/architecture.md beyond strings/paths to cover the metadata-driven physics quantities subsystem:

  • Source-of-truth metadata files (dimensions.json, units.json, magnitudes.json, conversions.json, domains.json).
  • Source-generator pipeline diagram.
  • Vector-form invariants (V0 non-negativity, strict-positive overloads, semantic widening/narrowing, Magnitude()).
  • Generator diagnostics SEM001-SEM004.
  • New section documenting the IPhysicalQuantity<T> contract and typed In(I{Dim}Unit) pattern.

Also adds the missing SEM004 entry to the diagnostic list in README.md.

Closes #59 — IPhysicalQuantity surface

Implement the canonical IPhysicalQuantity<T> contract with compile-time dimension safety on unit conversion.

Runtime:

  • IPhysicalQuantity<T> now exposes Dimension (DimensionInfo), IComparable<IPhysicalQuantity<T>>, IEquatable<IPhysicalQuantity<T>>. CompareTo throws on cross-dimension comparison; Equals returns false (equality is total).
  • IUnit gains Name/Symbol/Dimension/ToBaseFactor/ToBaseOffset plus default-implemented ToBase<T> / FromBase<T> over the affine conversion base = value × factor + offset.
  • New UnitConversionException (reserved for any future untyped path).

Generator:

  • DimensionsGenerator emits a marker interface per dimension (I{Dim}Unit : IUnit).
  • UnitsGenerator combines units.json with dimensions.json so each unit implements the right I{Dim}Unit marker(s). Emits class records (not structs) with full property surface and folds metric magnitude + conversionFactor into a single ToBaseFactor. Emits a static Units catalogue of singletons.
  • QuantitiesGenerator emits Dimension override + typed In(I{Dim}Unit) on every V0/V1 base + V0/V1 overload type.
length.In(Units.Kilometer);   // ✓
length.In(Units.Kilogram);    // ❌ compile error — IMassUnit, not ILengthUnit

Out of scope (follow-up):

  • V2/V3/V4 per-component In() (vector types don't implement IPhysicalQuantity).
  • Fahrenheit-style scaled-plus-offset conversions (existing metadata's offset model is incorrect for these).

Heads-up — landed without local build verification

Per discussion in this session, the sandbox build is blocked by an analyzer mismatch unrelated to this change (existing committed files fail IDE0055 on net8 with the current SDK). The full design lands here and CI is the source of truth — expect to iterate.

Test plan

  • CI compiles Semantics.Quantities for all four TFMs (net7/8/9/10).
  • CI runs PhysicalQuantityCoreTests (Length+Kilometer = 0.01, Temperature+Celsius = 26.85, CompareTo / Equals cross-dim behaviour).
  • Diff the regenerated Semantics.Quantities/Generated/ and verify the new Dimension + In(...) members appear on every V0/V1 type.

https://claude.ai/code/session_01LqtywMUn5GwFATD5FDdLn6

Extend docs/architecture.md beyond strings/paths to cover the
metadata-driven physics quantities subsystem: source-of-truth files,
generator pipeline diagram, vector-form invariants, and SEM001-SEM004
diagnostics. Add SEM004 to the README diagnostic list.

https://claude.ai/code/session_01LqtywMUn5GwFATD5FDdLn6
@matt-edmondson matt-edmondson merged commit 8cb35c7 into vectors May 12, 2026
1 check passed
@matt-edmondson matt-edmondson deleted the claude/review-vectors-branch-pgIZG branch May 12, 2026 14:03
@matt-edmondson matt-edmondson changed the title docs(architecture): document physics generator pipeline (closes #61) feat(quantities): IPhysicalQuantity surface + typed In() (closes #59, #61) May 13, 2026
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