Skip to content

Sensitivity's dimensional formula matches neither V/Pa nor A/Pa, and the .NET generator emits the operator the C++ projection refuses #216

Description

@matt-edmondson

The metadata

Semantics.SourceGenerators/Metadata/dimensions.json:

"name": "Sensitivity",
"symbol": "M⁻¹ L⁻¹ T² I",
"dimensionalFormula": { "mass": -1, "length": -1, "time": 2, "electricCurrent": 1 },
"availableUnits": ["VoltPerPascal"],
"integrals": [ { "other": "Pressure", "result": "ElectricPotential" } ]

Its only unit is VoltPerPascal, symbol V/Pa (units.json:890-893). Working the exponents out:

M L T I
declared −1 −1 2 1
V/Pa — what the unit says 0 3 −1 −1
A/Pa — what CLAUDE.md says is declared −1 +1 2 1

The declared vector is neither. CLAUDE.md's own account ("declared as A/Pa, M⁻¹L⁻¹T²I") is itself inconsistent — A/Pa has length +1, not −1.

The relationship then computes Sensitivity × Pressure = L⁻² I, against ElectricPotential = M L² T⁻³ I⁻¹.

Checking every integrals / derivatives / dotProducts / crossProducts entry in the file: exactly four are dimensionally false, matching the set CLAUDE.md documents. Three are the rotational/angle cluster, which is structurally unfixable and correctly explained. This is the fourth, and it is not.

What ships

The C++ projection refuses it — Semantics.Cpp/QuantityVocabulary.cs:216-222, asserted by Semantics.Cpp.Test/CppQuantityGeneratorTests.cs:190-203.

The .NET generator has no dimensional check at all. SEM001 verifies only that names resolve; there is no exponent arithmetic anywhere in Semantics.SourceGenerators. So the operator is emitted into committed generated source:

// Semantics.Quantities/Generated/…/QuantitiesGenerator/Sensitivity.g.cs:123
public static VoltageMagnitude<T> operator *(Sensitivity<T> left, Pressure<T> right) =>
    VoltageMagnitude<T>.Create(left.Quantity * right.Quantity);

A caller writing sensitivity * pressure gets a VoltageMagnitude back — type-checked, and silently wrong by a factor carrying units of m⁻⁵·kg⁻¹·s⁴·A².

Why it matters

The point of the type system is that a dimensionally wrong product does not compile. Here it does, and yields a named quantity.

It also means the two projections of one metadata file disagree about what the vocabulary contains — at exactly the place the library promises they do not.

Suggested fix

Two separable pieces:

(a) Fix the metadata. This is a physics call between:

  • V/Pa{"length": 3, "time": -1, "electricCurrent": -1}, matching the declared unit and making the relationship true; or
  • A/Pa{"mass": -1, "length": 1, "time": 2, "electricCurrent": 1}, which requires both the unit and the relationship to change.

The symbol string needs updating either way, and CLAUDE.md's description of the bug needs its sign corrected.

(b) Port the exponent check to the .NET generator as a new SEM00x, so the two sides cannot diverge again. The arithmetic already exists in Semantics.Cpp/DimensionVector.cs; today a false relationship is caught only if it happens to reach the C++ projection.

Part (b) is the more durable half — (a) fixes one entry, (b) makes the next one impossible to miss.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions